Skip to content
Get Started for Free

Application Gateway for Containers

Application Gateway for Containers is an application layer (layer 7) load balancing and ingress service for Kubernetes workloads. It routes HTTP, HTTPS, and gRPC traffic to applications in Azure Kubernetes Service (AKS), and you configure it from Kubernetes with Gateway API and Ingress resources. An Application Gateway for Containers resource, of type Microsoft.ServiceNetworking/trafficControllers, holds its frontends, the entry points that clients connect to; its association with the subnet where Azure places its proxies; and its security policies, which attach a web application firewall (WAF) policy. For more information, see What is Application Gateway for Containers? and Application Gateway for Containers components.

LocalStack for Azure emulates the Application Gateway for Containers control plane. Application Gateway for Containers resources, frontends, associations, and security policies are Azure Resource Manager resources that you manage with the same Azure CLI commands, and the emulator validates them and returns them in the shape Azure returns them. No traffic passes through the service: the frontends’ FQDNs do not resolve, and no ALB Controller runs in AKS clusters. The supported APIs are listed in the API Coverage section.

This guide is designed for users new to Application Gateway for Containers and assumes basic knowledge of the Azure CLI and lstk az. The following example follows the bring-your-own deployment strategy: it creates an Application Gateway for Containers resource and a frontend, associates the resource with a delegated subnet, and attaches a WAF policy.

Launch LocalStack using your preferred method. For more information, see Introduction to LocalStack for Azure. Once the container is running, enable Azure CLI interception by running:

Terminal window
lstk az start-interception

This command points the az CLI away from the public Azure management REST API and toward the LocalStack for Azure emulator API. To revert this configuration, run:

Terminal window
lstk az stop-interception

This reconfigures the az CLI to send commands to the official Azure management REST API.

Create a resource group for the example:

Terminal window
az group create \
--name rg-agc-demo \
--location westeurope
Output
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-agc-demo",
"location": "westeurope",
"managedBy": null,
"name": "rg-agc-demo",
"properties": {
"provisioningState": "Succeeded"
},
"tags": null,
"type": "Microsoft.Resources/resourceGroups"
}

Create the Application Gateway for Containers resource:

Terminal window
az network alb create \
--resource-group rg-agc-demo \
--name alb-demo
Output
{
"associations": [],
"configurationEndpoints": [
"0cac247ff8724775ab47e565f7a496cf.alb.azure.com"
],
"frontends": [],
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-agc-demo/providers/Microsoft.ServiceNetworking/trafficControllers/alb-demo",
"location": "westeurope",
"name": "alb-demo",
"provisioningState": "Succeeded",
"resourceGroup": "rg-agc-demo",
"securityPolicies": [],
...
"type": "Microsoft.ServiceNetworking/TrafficControllers"
}

Create a frontend. Its FQDN is the host name that clients connect to:

Terminal window
az network alb frontend create \
--resource-group rg-agc-demo \
--alb-name alb-demo \
--frontend-name frontend-demo
Output
{
"fqdn": "0ok50ga837ba6oi2.fz25.alb.azure.com",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-agc-demo/providers/Microsoft.ServiceNetworking/trafficControllers/alb-demo/frontends/frontend-demo",
"location": "westeurope",
"name": "frontend-demo",
"provisioningState": "Succeeded",
"resourceGroup": "rg-agc-demo",
...
"type": "Microsoft.ServiceNetworking/TrafficControllers/Frontends"
}

Create a virtual network with a subnet of at least 256 addresses (a /24), and delegate the subnet to Application Gateway for Containers:

Terminal window
az network vnet create \
--resource-group rg-agc-demo \
--name vnet-agc-demo \
--location westeurope \
--address-prefixes 10.225.0.0/16 \
--subnet-name subnet-alb \
--subnet-prefixes 10.225.0.0/24 \
--output none
az network vnet subnet update \
--resource-group rg-agc-demo \
--vnet-name vnet-agc-demo \
--name subnet-alb \
--delegations Microsoft.ServiceNetworking/trafficControllers \
--query "delegations[0].serviceName" \
--output tsv
Output
Microsoft.ServiceNetworking/trafficControllers

Read the subnet’s ID, and associate the resource with the subnet:

Terminal window
SUBNET_ID=$(az network vnet subnet show \
--resource-group rg-agc-demo \
--vnet-name vnet-agc-demo \
--name subnet-alb \
--query id \
--output tsv)
az network alb association create \
--resource-group rg-agc-demo \
--alb-name alb-demo \
--association-name association-demo \
--subnet "$SUBNET_ID"
Output
{
"associationType": "subnets",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-agc-demo/providers/Microsoft.ServiceNetworking/trafficControllers/alb-demo/associations/association-demo",
"location": "westeurope",
"name": "association-demo",
"provisioningState": "Succeeded",
"resourceGroup": "rg-agc-demo",
"subnet": {
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-agc-demo/providers/Microsoft.Network/virtualNetworks/vnet-agc-demo/subnets/subnet-alb",
"resourceGroup": "rg-agc-demo"
},
...
"type": "Microsoft.ServiceNetworking/TrafficControllers/Associations"
}

The subnet now lists the IP configurations of the two instances that Azure places there:

Terminal window
az network vnet subnet show \
--resource-group rg-agc-demo \
--vnet-name vnet-agc-demo \
--name subnet-alb \
--query "length(ipConfigurations)" \
--output tsv
Output
2

Create a WAF policy with the Default Rule Set 2.1, which Application Gateway for Containers runs, and read its ID:

Terminal window
WAF_POLICY_ID=$(az network application-gateway waf-policy create \
--resource-group rg-agc-demo \
--name wafagcdemo \
--type Microsoft_DefaultRuleSet \
--version 2.1 \
--query id \
--output tsv)

Create a WAF security policy that uses the WAF policy:

Terminal window
az network alb security-policy waf create \
--resource-group rg-agc-demo \
--alb-name alb-demo \
--name waf-demo \
--waf-policy-id "$WAF_POLICY_ID"
Output
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-agc-demo/providers/Microsoft.ServiceNetworking/trafficControllers/alb-demo/securityPolicies/waf-demo",
"location": "westeurope",
"name": "waf-demo",
"policyType": "WAF",
"provisioningState": "Succeeded",
"resourceGroup": "rg-agc-demo",
...
"type": "Microsoft.ServiceNetworking/TrafficControllers/SecurityPolicies",
"wafPolicy": {
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-agc-demo/providers/Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies/wafagcdemo",
"resourceGroup": "rg-agc-demo"
}
}

Read the security policy’s ID, and make it the security policy of the whole resource:

Terminal window
SECURITY_POLICY_ID=$(az network alb security-policy show \
--resource-group rg-agc-demo \
--alb-name alb-demo \
--name waf-demo \
--query id \
--output tsv)
az network alb update \
--resource-group rg-agc-demo \
--name alb-demo \
--waf-policy-id "$SECURITY_POLICY_ID" \
--query "securityPolicyConfigurations.wafSecurityPolicy.id" \
--output tsv
Output
/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-agc-demo/providers/Microsoft.ServiceNetworking/trafficControllers/alb-demo/securityPolicies/waf-demo

List the frontends, associations, and security policies of the resource:

Terminal window
az network alb frontend list \
--resource-group rg-agc-demo \
--alb-name alb-demo \
--query "[].{name:name, state:provisioningState}" \
--output table
az network alb association list \
--resource-group rg-agc-demo \
--alb-name alb-demo \
--query "[].{name:name, state:provisioningState}" \
--output table
az network alb security-policy list \
--resource-group rg-agc-demo \
--alb-name alb-demo \
--query "[].{name:name, state:provisioningState}" \
--output table
Output
Name State
------------- ---------
frontend-demo Succeeded
Name State
---------------- ---------
association-demo Succeeded
Name State
-------- ---------
waf-demo Succeeded

Delete the frontend, then the Application Gateway for Containers resource, which deletes its association and its security policy:

Terminal window
az network alb frontend delete \
--resource-group rg-agc-demo \
--alb-name alb-demo \
--name frontend-demo \
--yes
az network alb delete \
--resource-group rg-agc-demo \
--name alb-demo \
--yes

Delete the resource group:

Terminal window
az group delete \
--name rg-agc-demo \
--yes

The Application Gateway for Containers emulator supports the following features:

  • Resource lifecycle: Create, get, update, list, and delete Application Gateway for Containers resources, by resource group and across a subscription, with their tags. A resource gets its configuration endpoint, and deleting it deletes its frontends, its association, and its security policies.
  • Frontends: Create, get, update, list, and delete frontends, each with an FQDN under alb.azure.com. A resource takes up to five public frontends and one private frontend.
  • Private frontends: With private ingress, a preview at API version 2026-03-01, a frontend can be private: it names its association, and its FQDN is under privatelink.alb.azure.com. Each private frontend is a private link resource, and a private endpoint that names it connects to the resource and is approved at once.
  • Associations: An association names a subnet delegated to Microsoft.ServiceNetworking/trafficControllers that has at least 250 free addresses, and the subnet lists the IP configurations of the two instances Azure places there. A resource takes one association, whose subnet cannot change, and the subnet cannot be deleted while the association holds it.
  • Security policies: A WAF security policy names an Application Gateway WAF policy in the same subscription and region, and the resource’s security policy configuration names the security policy it runs. The WAF policy lists the resources that run it, and cannot be deleted while one does.
  • WAF policy support: A WAF policy with a feature that Application Gateway for Containers does not run fails to attach, as on Azure: a managed rule set other than the Default Rule Set 2.1 and Bot Manager 1.0 and 1.1, the HTTP DDoS rule set, a custom block response, a rate limit grouped by the X-Forwarded-For header, or a JavaScript challenge.
  • Long-running operations: Writes and deletes answer with Azure’s status codes and operation headers, and complete at once.
  • Validation: The emulator refuses names, request bodies, regions, subnets, and references as Azure does, with Azure’s error codes.
  • Resource groups and Resource Graph: The resources and their children are listed in their resource group and in Resource Graph, and moving them to another resource group is refused, as on Azure.
  • No traffic passes through the service: The frontends’ FQDNs do not resolve, and the emulator runs no proxies, so no request reaches a backend and no WAF policy inspects one.
  • No ALB Controller: No ALB Controller runs in AKS clusters, so the Gateway API and Ingress resources that configure Application Gateway for Containers have no effect.
  • Changes complete at once: Creating and deleting an association complete before the command returns, where Azure takes about five minutes for each.
  • IP access rules security policies are refused: The emulator refuses them as Azure refuses them for a subscription without the preview feature, and keeps no feature registrations.

Explore end-to-end examples in the LocalStack for Azure Samples repository.

27 of 27 operations implemented

Operation ▲Implemented ▼
Page 1 of 0
Was this page helpful?