azure-aigateway by microsoft/azure-skills
npx skills add https://github.com/microsoft/azure-skills --skill azure-aigateway配置 Azure API 管理 (APIM) 作为 AI 网关,用于治理 AI 模型、MCP 工具和智能体。
要部署 APIM,请使用 azure-prepare 技能。请参阅 APIM 部署指南。
| 类别 | 触发词 |
|---|---|
| 模型治理 | "语义缓存", "令牌限制", "负载均衡 AI", "跟踪令牌使用量" |
| 工具治理 | "限制 MCP 速率", "保护我的工具", "配置我的工具", "将 API 转换为 MCP" |
| 智能体治理 | "内容安全", "越狱检测", "过滤有害内容" |
| 配置 | "添加 Azure OpenAI 后端", "配置我的模型", "添加 AI Foundry 模型" |
| 测试 | "测试 AI 网关", "通过网关调用 OpenAI" |
| 策略 | 目的 |
|---|
Configure Azure API Management (APIM) as an AI Gateway for governing AI models, MCP tools, and agents.
To deploy APIM , use the azure-prepare skill. See APIM deployment guide.
| Category | Triggers |
|---|---|
| Model Governance | "semantic caching", "token limits", "load balance AI", "track token usage" |
| Tool Governance | "rate limit MCP", "protect my tools", "configure my tool", "convert API to MCP" |
| Agent Governance | "content safety", "jailbreak detection", "filter harmful content" |
| Configuration | "add Azure OpenAI backend", "configure my model", "add AI Foundry model" |
| Testing | "test AI gateway", "call OpenAI through gateway" |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
暂无相关 Skills
| 详情 |
|---|
azure-openai-token-limit | 成本控制 | 模型策略 |
azure-openai-semantic-cache-lookup/store | 节省 60-80% 成本 | 模型策略 |
azure-openai-emit-token-metric | 可观测性 | 模型策略 |
llm-content-safety | 安全与合规 | 智能体策略 |
rate-limit-by-key | MCP/工具保护 | 工具策略 |
# 获取网关 URL
az apim show --name <apim-name> --resource-group <rg> --query "gatewayUrl" -o tsv
# 列出后端(AI 模型)
az apim backend list --service-name <apim-name> --resource-group <rg> \
--query "[].{id:name, url:url}" -o table
# 获取订阅密钥
az apim subscription keys list \
--service-name <apim-name> --resource-group <rg> --subscription-id <sub-id>
GATEWAY_URL=$(az apim show --name <apim-name> --resource-group <rg> --query "gatewayUrl" -o tsv)
curl -X POST "${GATEWAY_URL}/openai/deployments/<deployment>/chat/completions?api-version=2024-02-01" \
-H "Content-Type: application/json" \
-H "Ocp-Apim-Subscription-Key: <key>" \
-d '{"messages": [{"role": "user", "content": "Hello"}], "max_tokens": 100}'
完整步骤请参阅 references/patterns.md。
# 发现 AI 资源
az cognitiveservices account list --query "[?kind=='OpenAI']" -o table
# 创建后端
az apim backend create --service-name <apim> --resource-group <rg> \
--backend-id openai-backend --protocol http --url "https://<aoai>.openai.azure.com/openai"
# 授予访问权限(托管标识)
az role assignment create --assignee <apim-principal-id> \
--role "Cognitive Services User" --scope <aoai-resource-id>
<inbound> 中推荐的策略顺序:
完整示例请参阅 references/policies.md。
| 问题 | 解决方案 |
|---|---|
| 令牌限制 429 | 增加 tokens-per-minute 或添加负载均衡 |
| 无缓存命中 | 将 score-threshold 降低至 0.7 |
| 内容误报 | 增加类别阈值 (5-6) |
| 后端身份验证 401 | 授予 APIM "Cognitive Services User" 角色 |
每周安装量
13.0K
代码仓库
GitHub 星标数
2
首次出现
5 天前
安全审计
安装于
github-copilot13.0K
opencode14
gemini-cli14
codex14
amp13
cline13
| Policy | Purpose | Details |
|---|---|---|
azure-openai-token-limit | Cost control | Model Policies |
azure-openai-semantic-cache-lookup/store | 60-80% cost savings | Model Policies |
azure-openai-emit-token-metric | Observability | Model Policies |
llm-content-safety | Safety & compliance | Agent Policies |
rate-limit-by-key | MCP/tool protection | Tool Policies |
# Get gateway URL
az apim show --name <apim-name> --resource-group <rg> --query "gatewayUrl" -o tsv
# List backends (AI models)
az apim backend list --service-name <apim-name> --resource-group <rg> \
--query "[].{id:name, url:url}" -o table
# Get subscription key
az apim subscription keys list \
--service-name <apim-name> --resource-group <rg> --subscription-id <sub-id>
GATEWAY_URL=$(az apim show --name <apim-name> --resource-group <rg> --query "gatewayUrl" -o tsv)
curl -X POST "${GATEWAY_URL}/openai/deployments/<deployment>/chat/completions?api-version=2024-02-01" \
-H "Content-Type: application/json" \
-H "Ocp-Apim-Subscription-Key: <key>" \
-d '{"messages": [{"role": "user", "content": "Hello"}], "max_tokens": 100}'
See references/patterns.md for full steps.
# Discover AI resources
az cognitiveservices account list --query "[?kind=='OpenAI']" -o table
# Create backend
az apim backend create --service-name <apim> --resource-group <rg> \
--backend-id openai-backend --protocol http --url "https://<aoai>.openai.azure.com/openai"
# Grant access (managed identity)
az role assignment create --assignee <apim-principal-id> \
--role "Cognitive Services User" --scope <aoai-resource-id>
Recommended policy order in <inbound>:
See references/policies.md for complete example.
| Issue | Solution |
|---|---|
| Token limit 429 | Increase tokens-per-minute or add load balancing |
| No cache hits | Lower score-threshold to 0.7 |
| Content false positives | Increase category thresholds (5-6) |
| Backend auth 401 | Grant APIM "Cognitive Services User" role |
See references/troubleshooting.md for details.
Weekly Installs
13.0K
Repository
GitHub Stars
2
First Seen
5 days ago
Security Audits
Installed on
github-copilot13.0K
opencode14
gemini-cli14
codex14
amp13
cline13