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.

npx skills add https://github.com/microsoft/azure-skills --skill azure-aigateway

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

CategoryTriggers
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

PolicyPurposeDetails
azure-openai-token-limitCost controlModel Policies
azure-openai-semantic-cache-lookup/store60-80% cost savingsModel Policies
azure-openai-emit-token-metricObservabilityModel Policies
llm-content-safetySafety & complianceAgent Policies
rate-limit-by-keyMCP/tool protectionTool 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

IssueSolution
Token limit 429Increase tokens-per-minute or add load balancing
No cache hitsLower score-threshold to 0.7
Content false positivesIncrease category thresholds (5-6)
Backend auth 401Grant APIM "Cognitive Services User" role

See references/troubleshooting.md for details.


References

SDK Quick References

Más skills de microsoft

oss-growth
microsoft
Persona de growth hacker de OSS
official
microsoft-foundry
microsoft
Implementar, evaluar y gestionar agentes de Foundry de extremo a extremo: compilación de Docker, envío a ACR, creación de agente alojado/de prompt, inicio de contenedor, evaluación por lotes, evaluación continua, flujos de trabajo del optimizador de prompts, agent.yaml, curación de conjuntos de datos a partir de trazas. USAR PARA: implementar agente en Foundry, agente alojado, crear agente, invocar agente, evaluar agente, ejecutar evaluación por lotes, evaluación continua, monitoreo continuo, estado de evaluación continua, optimizar prompt, mejorar prompt, optimizador de prompts, optimizar instrucciones del agente, mejorar agente...
officialdevelopmentdevops
azure-ai
microsoft
Útil para Azure AI: Search, Speech, OpenAI, Document Intelligence. Ayuda con búsqueda, búsqueda vectorial/híbrida, voz a texto, texto a voz, transcripción, OCR. CUANDO: AI Search, búsqueda de consultas, búsqueda vectorial, búsqueda híbrida, búsqueda semántica, voz a texto, texto a voz, transcribir, OCR, convertir texto a voz.
officialdevelopmentapi
azure-deploy
microsoft
Ejecuta despliegues en Azure para aplicaciones YA PREPARADAS que tengan archivos .azure/deployment-plan.md e infraestructura existentes. NO uses esta habilidad cuando el usuario solicite CREAR una nueva aplicación — usa azure-prepare en su lugar. Esta habilidad ejecuta comandos azd up, azd deploy, terraform apply y az deployment con recuperación de errores integrada. Requiere .azure/deployment-plan.md de azure-prepare y estado validado de azure-validate. CUANDO: "ejecutar azd up", "ejecutar azd deploy", "ejecutar despliegue",...
officialdevopsaws
azure-storage
microsoft
Servicios de Azure Storage que incluyen Blob Storage, File Shares, Queue Storage, Table Storage y Data Lake. Responde preguntas sobre niveles de acceso de almacenamiento (hot, cool, cold, archive), cuándo usar cada nivel y comparación entre niveles. Proporciona almacenamiento de objetos, recursos compartidos de archivos SMB, mensajería asíncrona, NoSQL clave-valor y análisis de big data. Incluye gestión del ciclo de vida. USAR PARA: blob storage, file shares, queue storage, table storage, data lake, subir archivos, descargar blobs, cuentas de almacenamiento, niveles de acceso,...
officialdevelopmentdatabase
azure-diagnostics
microsoft
Depura problemas de producción en Azure usando AppLens, Azure Monitor, estado de recursos y triaje seguro. CUANDO: depurar problemas de producción, solucionar problemas de App Service, CPU alta en App Service, fallo de implementación de App Service, solucionar problemas de Container Apps, solucionar problemas de Functions, solucionar problemas de AKS, kubectl no puede conectar, fallos de kube-system/CoreDNS, pod pendiente, crashloop, nodo no listo, fallos de actualización, analizar registros, KQL, información, fallos de extracción de imágenes, problemas de arranque en frío, fallos de sondeo de estado,...
officialdevopsdevelopment
azure-prepare
microsoft
Prepara aplicaciones de Azure para el despliegue (infra Bicep/Terraform, azure.yaml, Dockerfiles). Úselo para crear/modernizar o crear+desplegar; no para migración entre nubes (use azure-cloud-migrate). NO USAR PARA: aplicaciones copilot-sdk (use azure-hosted-copilot-sdk). CUANDO: "crear aplicación", "construir aplicación web", "crear API", "crear API HTTP sin servidor", "crear frontend", "crear backend", "construir un servicio", "modernizar aplicación", "actualizar aplicación", "agregar autenticación", "agregar almacenamiento en caché", "alojar en Azure", "crear y...
officialdevelopmentdevops
azure-validate
microsoft
Validación previa al despliegue para la preparación en Azure. Realiza verificaciones exhaustivas de configuración, infraestructura (Bicep o Terraform), asignaciones de roles RBAC, permisos de identidad administrada y requisitos previos antes de desplegar. CUÁNDO: validar mi aplicación, verificar preparación para el despliegue, ejecutar comprobaciones previas, verificar configuración, comprobar si está listo para desplegar, validar azure.yaml, validar Bicep, probar antes de desplegar, solucionar errores de despliegue, validar Azure Functions, validar aplicación de funciones, validar serverless...
officialdevopstesting