Skip to content
agentgateway has joined the Agentic AI FoundationLearn more

For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.

Azure

Page as Markdown

Run agentgateway on Azure and reach Azure OpenAI with a managed identity instead of an API key.

Verified Code examples on this page have been automatically tested and verified.

Run agentgateway on Azure Container Apps or AKS, and reach Azure OpenAI with the managed identity that Azure already attaches to the workload. No API key goes into your configuration file.

Authenticate with a managed identity

Azure supplies credentials to the container through a managed identity on Container Apps and through workload identity on AKS. Agentgateway obtains an Entra ID token from whichever one is present.

Review the following example configuration.

Use auth.azure.implicit to detect the method from the environment. Agentgateway uses workload identity on Kubernetes, managed identity on Azure compute, and local developer tools on a workstation.

# yaml-language-server: $schema=https://agentgateway.dev/schema/config

llm:
  models:
  - name: "*"
    provider: azure
    params:
      model: gpt-4o
      azureResourceName: my-resource
      azureResourceType: openAI
    auth:
      azure:
        implicit: {}

Review the following table to understand this configuration.

SettingDescription
nameThe model name to match in incoming requests. Use * to match any model name.
providerThe LLM provider, set to azure for Azure AI.
params.modelThe deployment name to send upstream.
params.azureResourceNameThe Azure resource name.
params.azureResourceTypeThe endpoint type, either openAI for Azure OpenAI Service or foundry for an Azure AI Foundry project.
auth.azureEntra ID authentication. Use implicit to detect the method from the environment, or explicitConfig to name a client secret, a managed identity, or workload identity.

For client secret and workload identity configurations, and for the Azure AI Foundry endpoint type, see Azure.

Important

Azure CLI authentication is a developer convenience, not a deployment method. Agentgateway calls az or azd when it needs a token, and neither command is in the container image. In a container, use a managed identity, workload identity, or a client secret.

Run on Azure Container Apps

Run agentgateway as a serverless container with a user-assigned identity.

az containerapp create \
  --name agentgateway \
  --resource-group my-rg \
  --environment my-env \
  --image cr.agentgateway.dev/agentgateway:latest-dev \
  --target-port 4000 \
  --ingress internal \
  --user-assigned /subscriptions/<sub-id>/resourceGroups/my-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/agentgateway-identity

Note the following details.

  • Port 4000 carries LLM traffic. When your configuration file defines no gateway, the implied default gateway serves LLM traffic on port 4000 and MCP traffic on port 3000. Set --target-port to the port that carries the traffic you route. For more information, see Configuration modes.
  • The identity is the credential. Because auth.azure uses the identity attached to the container, --user-assigned is what lets agentgateway call Azure OpenAI. No API key is needed in the create command or in the configuration file.
  • The container still needs a configuration file. The command above starts the image with no -f flag, so agentgateway generates a default configuration that does not route to Azure. Mount your file with an Azure Files volume, or bake it into your own image, and pass it with -f. For more information, see Configuration storage.
  • --ingress internal keeps the gateway inside the environment. A gateway that holds Azure OpenAI access is a credential of its own, so anyone who can reach it can spend against your resource. Before you switch to --ingress external, put an authentication policy in front of it. For more information, see Authentication and identity.

Run on AKS

AKS is an ordinary Kubernetes distribution as far as agentgateway is concerned. Two options are available.

  • Run standalone agentgateway as a Deployment with the Helm chart. Enable the workload identity add-on and annotate the pod’s service account, and auth.azure.implicit picks up workload identity automatically.
  • Run the Kubernetes control plane, which manages agentgateway proxies from Kubernetes custom resources and the Kubernetes Gateway API.

Role assignments

Assign the roles that agentgateway needs to the managed identity.

# Get the managed identity principal ID
PRINCIPAL_ID=$(az identity show --name agentgateway-identity \
  --resource-group my-rg --query principalId -o tsv)

# Grant Azure OpenAI access
az role assignment create \
  --assignee $PRINCIPAL_ID \
  --role "Cognitive Services OpenAI User" \
  --scope /subscriptions/<sub-id>/resourceGroups/my-rg/providers/Microsoft.CognitiveServices/accounts/my-openai

# Grant Key Vault access, if you store the API keys of other providers there
az role assignment create \
  --assignee $PRINCIPAL_ID \
  --role "Key Vault Secrets User" \
  --scope /subscriptions/<sub-id>/resourceGroups/my-rg/providers/Microsoft.KeyVault/vaults/my-vault

Azure services

ServiceHow it is used
Azure OpenAIGPT and other models, reached with the managed identity
Azure Content SafetyPrompt and response moderation
Azure Key VaultStorage for the API keys of non-Azure providers
Azure Application GatewayLoad balancing, TLS termination, and WAF in front of the gateway port
Azure MonitorMetrics and log collection
Application InsightsTrace collection, through an OpenTelemetry collector

Next steps

Was this page helpful?
Agentgateway assistant

Ask me anything about agentgateway configuration, features, or usage.

Note: AI-generated content might contain errors; please verify and test all returned information.

Tip: one topic per conversation gives the best results. Use the + button in the chat header to start a new conversation.

Switching topics? Starting a new conversation improves accuracy.
↑↓ navigate select esc dismiss

What could be improved?

Your feedback helps us improve assistant answers and identify docs gaps we should fix.

Need more help? Join us on Discord: https://discord.gg/y9efgEmppm

Want to use your own agent? Add the Solo MCP server to query our docs directly. Get started here: https://search.solo.io/.