azure-aigateway
Configure Azure API Management as an AI Gateway for AI models, MCP tools, and agents. WHEN: semantic caching, token limit, content safety, load balancing, AI model governance, MCP rate limiting, jailbreak detection, add Azure OpenAI backend, add AI Foundry model, test AI gateway, LLM policies, configure AI backend, token metrics, AI cost control, convert API to MCP, import OpenAPI to gateway.
- License 许可
- MIT
- 所属仓库
- microsoft/skills
- 最近更新
- 2026-11-14
- Stars
- ★ 3.2k
- Forks
- 368
01 前言 Front Matter
- name
- azure-aigateway
- license
- MIT
- metadata
- { "author": "Microsoft", "version": "3.2.1" }
- description
- Configure Azure API Management as an AI Gateway for AI models, MCP tools, and agents. WHEN: semantic caching, token limit, content safety, load balancing, AI model governance, MCP rate limiting, jailbreak detection, add Azure OpenAI backend, add AI Foundry model, test AI gateway, LLM policies, configure AI backend, token metrics, AI cost control, convert API to MCP, import OpenAPI to gateway.
- compatibility
- Requires Azure CLI (az) for configuration and testing
02 资源文件 100
- 参考文档copilot-studio/agent.sync.yaml174 B
- 参考文档copilot-studio/behaviors/aibast_guided-fix.mcs.yml1.2 KB
- 参考文档copilot-studio/behaviors/aibast_local-work-check.mcs.yml1.2 KB
- 参考文档copilot-studio/behaviors/aibast_technician-booking.mcs.yml1.2 KB
- 参考文档copilot-studio/behaviors/aibast_visit-history.mcs.yml1.1 KB
- 参考文档copilot-studio/capabilities/knowledge/files/aibast_first-time-fix-rules-and-guardrails.md2.7 KB
- 参考文档copilot-studio/capabilities/knowledge/files/aibast_first-time-fix-rules-and-guardrails.md.mcs.yml194 B
- 参考文档copilot-studio/capabilities/knowledge/files/aibast_first-time-fix-synthetic-records.md10.7 KB
- 参考文档copilot-studio/capabilities/knowledge/files/aibast_first-time-fix-synthetic-records.md.mcs.yml188 B
- 参考文档copilot-studio/settings.mcs.yml3.9 KB
- 参考文档deployment.json3.9 KB
- 参考文档EASY-MODE-COPILOT-CHAT.md219 B
- 参考文档EASY-MODE-PERSONLESS.md219 B
- 参考文档EASY-MODE.md2.6 KB
- 参考文档evals/copilot-studio-preview-evidence.json1.6 KB
- 参考文档evals/dataverse-draft-evidence.json1.6 KB
- 参考文档evals/manual-build-evidence.json3.0 KB
- 参考文档evals/onepager-map.json1.7 KB
- 参考文档evals/source-audit.json1.5 KB
- 参考文档evals/transcripts.json7.5 KB
- 参考文档evals/visual-checkpoints.json21.8 KB
- 参考文档evidence-report.html28.1 KB
- 参考文档export-manifest.json44.9 KB
- 资产文件exports/first-time-fix-copilot-studio-solution.zip40.3 KB
- 参考文档exports/first-time-fix-deployment-settings.json208 B
- 参考文档exports/first-time-fix-solution-export.json1.0 KB
- 参考文档exports/README.md1.5 KB
- 参考文档field-guide.html37.8 KB
- 参考文档FIELD-GUIDE.md13.9 KB
- 参考文档manual-tutorial.html79.0 KB
- 参考文档manual/GLOBAL-INSTRUCTIONS.md3.0 KB
- 参考文档manual/knowledge/aibast_first-time-fix-rules-and-guardrails.md2.7 KB
- 参考文档manual/knowledge/aibast_first-time-fix-synthetic-records.md10.7 KB
- 参考文档quest.html128.3 KB
- 参考文档README.md3.6 KB
- 参考文档references/auth-best-practices.md6.1 KB
- 参考文档references/patterns.md6.6 KB
- 参考文档references/policies.md9.2 KB
- 参考文档references/sdk/azure-ai-contentsafety-py.md1.3 KB
- 参考文档references/sdk/azure-ai-contentsafety-ts.md1.4 KB
- 参考文档references/sdk/azure-mgmt-apimanagement-dotnet.md1.3 KB
- 参考文档references/sdk/azure-mgmt-apimanagement-py.md1.0 KB
- 参考文档references/troubleshooting.md7.7 KB
- 资产文件screenshots/assisted/01-review-build.jpg166.2 KB
- 资产文件screenshots/assisted/02-ftf-01.jpg154.7 KB
- 资产文件screenshots/assisted/03-ftf-02.jpg179.4 KB
- 资产文件screenshots/assisted/04-ftf-03.jpg144.3 KB
- 资产文件screenshots/assisted/05-ftf-04.jpg192.1 KB
- 资产文件screenshots/assisted/06-confirm-draft.jpg50.2 KB
- 资产文件screenshots/assisted/annotated/01-review-build.png112.7 KB
- 资产文件screenshots/assisted/annotated/02-ftf-01.png97.2 KB
- 资产文件screenshots/assisted/annotated/03-ftf-02.png110.2 KB
- 资产文件screenshots/assisted/annotated/04-ftf-03.png90.8 KB
- 资产文件screenshots/assisted/annotated/05-ftf-04.png118.6 KB
- 资产文件screenshots/assisted/annotated/06-confirm-draft.png29.0 KB
- 参考文档screenshots/assisted/browserfilm.json1.3 KB
- 资产文件screenshots/assisted/copilot-assisted-contact-sheet.jpg149.9 KB
- 资产文件screenshots/assisted/copilot-assisted-walkthrough.gif839.4 KB
- 参考文档screenshots/assisted/README.md467 B
- 资产文件screenshots/manual/01-create-blank-agent.jpg89.3 KB
- 资产文件screenshots/manual/02-name-agent.jpg88.1 KB
- 资产文件screenshots/manual/03-enter-instructions.jpg182.7 KB
- 资产文件screenshots/manual/04-save-instructions.jpg173.8 KB
- 资产文件screenshots/manual/05-remove-web-search.jpg181.7 KB
- 资产文件screenshots/manual/06-add-aibast-first-time-fix-rules-and-guardrails.jpg186.1 KB
- 资产文件screenshots/manual/07-add-aibast-first-time-fix-synthetic-records.jpg189.8 KB
- 资产文件screenshots/manual/08-add-aibast-guided-fix-01.jpg190.6 KB
- 资产文件screenshots/manual/09-add-aibast-local-work-check-02.jpg192.6 KB
- 资产文件screenshots/manual/10-add-aibast-technician-booking-04.jpg194.9 KB
- 资产文件screenshots/manual/11-add-aibast-visit-history-03.jpg196.4 KB
- 资产文件screenshots/manual/12-review-inventory.jpg196.4 KB
- 资产文件screenshots/manual/13-open-preview.jpg59.3 KB
- 资产文件screenshots/manual/14-ftf-01.jpg152.6 KB
- 资产文件screenshots/manual/15-ftf-02.jpg163.2 KB
- 资产文件screenshots/manual/16-ftf-03.jpg145.0 KB
- 资产文件screenshots/manual/17-ftf-04.jpg164.8 KB
- 资产文件screenshots/manual/18-confirm-draft.jpg50.7 KB
- 资产文件screenshots/manual/annotated/01-create-blank-agent.png60.3 KB
- 资产文件screenshots/manual/annotated/02-name-agent.png59.5 KB
- 资产文件screenshots/manual/annotated/03-enter-instructions.png116.0 KB
- 资产文件screenshots/manual/annotated/04-save-instructions.png110.1 KB
- 资产文件screenshots/manual/annotated/05-remove-web-search.png115.1 KB
- 资产文件screenshots/manual/annotated/06-add-aibast-first-time-fix-rules-and-guardrails.png119.1 KB
- 资产文件screenshots/manual/annotated/07-add-aibast-first-time-fix-synthetic-records.png120.8 KB
- 资产文件screenshots/manual/annotated/08-add-aibast-guided-fix-01.png119.8 KB
- 资产文件screenshots/manual/annotated/09-add-aibast-local-work-check-02.png121.4 KB
- 资产文件screenshots/manual/annotated/10-add-aibast-technician-booking-04.png122.9 KB
- 资产文件screenshots/manual/annotated/11-add-aibast-visit-history-03.png123.6 KB
- 资产文件screenshots/manual/annotated/12-review-inventory.png131.4 KB
- 资产文件screenshots/manual/annotated/13-open-preview.png35.7 KB
- 资产文件screenshots/manual/annotated/14-ftf-01.png102.0 KB
- 资产文件screenshots/manual/annotated/15-ftf-02.png105.1 KB
- 资产文件screenshots/manual/annotated/16-ftf-03.png91.8 KB
- 资产文件screenshots/manual/annotated/17-ftf-04.png108.3 KB
- 资产文件screenshots/manual/annotated/18-confirm-draft.png29.2 KB
- 参考文档screenshots/manual/browserfilm.json3.2 KB
- 资产文件screenshots/manual/manual-build-contact-sheet.jpg593.2 KB
- 资产文件screenshots/manual/manual-build-walkthrough.gif3.6 MB
- 参考文档screenshots/manual/README.md461 B
- 参考文档screenshots/README.md521 B
03 SKILL.md 正文
Azure AI Gateway
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.
When to Use This Skill
| 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" |
Quick Reference
| 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 Details
# 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>
Test AI Endpoint
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}'
Common Tasks
Add AI Backend
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>
Apply AI Governance Policy
Recommended policy order in <inbound>:
- Authentication - Managed identity to backend
- Semantic Cache Lookup - Check cache before calling AI
- Token Limits - Cost control
- Content Safety - Filter harmful content
- Backend Selection - Load balancing
- Metrics - Token usage tracking
See references/policies.md for complete example.
Troubleshooting
| 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.
References
- Detailed Policies - Full policy examples
- Configuration Patterns - Step-by-step patterns
- Troubleshooting - Common issues
- AI-Gateway Samples
- GenAI Gateway Docs
SDK Quick References
- Content Safety: Python | TypeScript
- API Management: Python | .NET
04 同仓库更多 Skills
azure-advisor-cost-optimization
Analyze Azure Advisor Cost/IdleResources findings and prevalidate deletion safety, including Service Groups. WHEN: "find unused Azure resources", "what resources am I paying for but no longer using", "idle-resource savings", "historical idle-resource savings", "are these idle resources safe to delete". Generic Cost, other subcategories, and cross-category requests use azure-advisor.
skill-creator
Guide for creating effective skills for AI coding agents working with Azure SDKs and Microsoft Foundry services. Use when creating new skills or updating existing skills.
podcast-generation
Generate AI-powered podcast-style audio narratives using Azure OpenAI's GPT Realtime Mini model via WebSocket. Use when building text-to-speech features, audio narrative generation, podcast creation from content, or integrating with Azure OpenAI Realtime API for real audio output. Covers full-stack implementation from React frontend to Python FastAPI backend with WebSocket streaming.
microsoft-docs
Understand Microsoft technologies by querying official documentation. Use whenever the user asks how something works, wants tutorials, needs configuration options, limits, quotas, or best practices for any Microsoft technology (Azure, .NET, M365, Windows, Power Platform, etc.)—even if they don't mention "docs." If the question is about understanding a concept rather than writing code, this is the right skill.
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP), Node/TypeScript (MCP SDK), or C#/.NET (Microsoft MCP SDK).
kql
KQL language expertise for writing correct, efficient Kusto Query Language queries. Covers syntax gotchas, join patterns, dynamic types, datetime pitfalls, regex patterns, serialization, memory management, result-size discipline, and advanced functions (geo, vector, graph). USE THIS SKILL whenever writing, debugging, or reviewing KQL queries — even simple ones — because the gotchas section prevents the most common errors that waste tool calls and cause expensive retry cascades. Trigger on: KQL, Kusto, ADX, Azure Data Explorer, Fabric Real-Time Intelligence, EventHouse, Log Analytics, log analysis, data exploration, time series, anomaly detection, summarize, where clause, join, extend, project, let statement, parse operator, extract function, any mention of pipe-forward query syntax.