For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
Azure
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.
| Setting | Description |
|---|---|
name | The model name to match in incoming requests. Use * to match any model name. |
provider | The LLM provider, set to azure for Azure AI. |
params.model | The deployment name to send upstream. |
params.azureResourceName | The Azure resource name. |
params.azureResourceType | The endpoint type, either openAI for Azure OpenAI Service or foundry for an Azure AI Foundry project. |
auth.azure | Entra 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-identityNote the following details.
- Port 4000 carries LLM traffic. When your configuration file defines no gateway, the implied
defaultgateway serves LLM traffic on port4000and MCP traffic on port3000. Set--target-portto the port that carries the traffic you route. For more information, see Configuration modes. - The identity is the credential. Because
auth.azureuses the identity attached to the container,--user-assignedis 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
-fflag, 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 internalkeeps 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.implicitpicks 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-vaultAzure services
| Service | How it is used |
|---|---|
| Azure OpenAI | GPT and other models, reached with the managed identity |
| Azure Content Safety | Prompt and response moderation |
| Azure Key Vault | Storage for the API keys of non-Azure providers |
| Azure Application Gateway | Load balancing, TLS termination, and WAF in front of the gateway port |
| Azure Monitor | Metrics and log collection |
| Application Insights | Trace collection, through an OpenTelemetry collector |
Next steps
- Azure for the full provider reference, including Azure AI Foundry.
- Set up the UI to serve the web interface on a gateway.
- Choose where configuration is stored before you mount a read-only file.