Agent Skillsmicrosoft/azure-skills › azure-aigateway

azure-aigateway

GitHub

配置 Azure API Management 作为 AI 网关,用于治理 AI 模型、MCP 工具和智能体。涵盖语义缓存、令牌限制、内容安全、负载均衡及后端配置等核心功能。

skills/azure-aigateway/SKILL.md microsoft/azure-skills

Trigger Scenarios

配置 AI 网关以治理模型和工具 设置语义缓存或令牌限制 添加 Azure OpenAI 或 AI Foundry 后端 实施内容安全或防越狱策略 测试 AI 网关端点

Install

npx skills add microsoft/azure-skills --skill azure-aigateway -g -y
More Options

Use without installing

npx skills use microsoft/azure-skills@azure-aigateway

指定 Agent (Claude Code)

npx skills add microsoft/azure-skills --skill azure-aigateway -a claude-code -g -y

安装 repo 全部 skill

npx skills add microsoft/azure-skills --all -g -y

预览 repo 内 skill

npx skills add microsoft/azure-skills --list

SKILL.md

Frontmatter
{
    "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"
}

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>:

  1. Authentication - Managed identity to backend
  2. Semantic Cache Lookup - Check cache before calling AI
  3. Token Limits - Cost control
  4. Content Safety - Filter harmful content
  5. Backend Selection - Load balancing
  6. 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

SDK Quick References

Version History

  • ea76537 Current 2026-08-20 03:57
  • 013b97d 2026-07-25 09:45

Same Skill Collection

.github/plugins/azure-kusto-graph-skills/skills/azure-kusto-irql/SKILL.md
.github/plugins/azure-skills/skills/airunway-aks-setup/SKILL.md
.github/plugins/azure-skills/skills/appinsights-instrumentation/SKILL.md
.github/plugins/azure-skills/skills/azure-ai/SKILL.md
.github/plugins/azure-skills/skills/azure-aigateway/SKILL.md
.github/plugins/azure-skills/skills/azure-cloud-migrate/SKILL.md
.github/plugins/azure-skills/skills/azure-compliance/SKILL.md
.github/plugins/azure-skills/skills/azure-cost/SKILL.md
.github/plugins/azure-skills/skills/azure-kusto/SKILL.md
.github/plugins/azure-skills/skills/azure-quotas/SKILL.md
.github/plugins/azure-skills/skills/azure-resource-visualizer/SKILL.md
.github/plugins/azure-skills/skills/azure-upgrade/SKILL.md
.github/plugins/azure-skills/skills/entra-app-registration/SKILL.md
.github/plugins/azure-skills/skills/python-appservice-deploy/SKILL.md
skills/airunway-aks-setup/SKILL.md
skills/appinsights-instrumentation/SKILL.md
skills/azure-ai/SKILL.md
skills/azure-cloud-migrate/SKILL.md
skills/azure-compliance/SKILL.md
skills/azure-cost/SKILL.md
skills/azure-kubernetes/azure-kubernetes-automatic-readiness/SKILL.md
skills/azure-kusto/SKILL.md
skills/azure-quotas/SKILL.md
skills/azure-resource-visualizer/SKILL.md
skills/azure-upgrade/SKILL.md
skills/entra-app-registration/SKILL.md
skills/python-appservice-deploy/SKILL.md
.github/plugins/azure-kusto-graph-skills/skills/azure-kusto-graph/SKILL.md
.github/plugins/azure-kusto-graph-skills/skills/azure-kusto-irql-graph/SKILL.md
.github/plugins/azure-skills/skills/azure-app-onboard-prereq/SKILL.md
.github/plugins/azure-skills/skills/azure-app-onboard/SKILL.md
.github/plugins/azure-skills/skills/azure-compute/SKILL.md
.github/plugins/azure-skills/skills/azure-deploy/SKILL.md
.github/plugins/azure-skills/skills/azure-diagnostics/SKILL.md
.github/plugins/azure-skills/skills/azure-enterprise-infra-planner/SKILL.md
.github/plugins/azure-skills/skills/azure-kubernetes/SKILL.md
.github/plugins/azure-skills/skills/azure-messaging/SKILL.md
.github/plugins/azure-skills/skills/azure-prepare/SKILL.md
.github/plugins/azure-skills/skills/azure-reliability/SKILL.md
.github/plugins/azure-skills/skills/azure-resource-lookup/SKILL.md
.github/plugins/azure-skills/skills/azure-storage/SKILL.md
.github/plugins/azure-skills/skills/azure-validate/SKILL.md
.github/plugins/azure-skills/skills/entra-agent-id/SKILL.md
.github/plugins/azure-skills/skills/microsoft-foundry/SKILL.md
skills/azure-app-onboard-prereq/SKILL.md
skills/azure-app-onboard/SKILL.md
skills/azure-compute/SKILL.md
skills/azure-deploy/SKILL.md
skills/azure-diagnostics/SKILL.md

Metadata

Files
0
Version
ea76537
Hash
05acd88e
Indexed
2026-07-25 09:45

inicio - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-22 03:16
浙ICP备14020137号-1 $mapa de visitantes$