Application Gateway
v2 SKUs · autoscale · infrastructure · listeners · routing rules · backend settings · probes · TLS · rewrite rule sets
By the tools4free.dev team · Last reviewed November 13, 2026
Practice questions for this topic →
Features, SKUs and use cases
Application Gateway is a layer 7 web traffic load balancer. It routes on HTTP request attributes such as URL path and host header, not just on IP address and port. It supports HTTP, HTTPS, HTTP/2 and WebSocket, and TLS and TCP through its layer 4 proxy.
| SKU | Use it for | Notes |
|---|---|---|
| Basic (preview) | Lower traffic and SLA requirements; no advanced traffic management | No manual or autoscale modes (scales automatically to an estimated 200 connections per second). No TCP/TLS proxy, mTLS, AKS ingress or Private Link |
| Standard_v2 | Production workloads and high traffic | Autoscaling or fixed capacity, zone redundancy, static VIP, Key Vault integration, header and URL rewrite, mTLS, Private Link, AKS ingress |
| WAF_v2 | Standard_v2 plus Web Application Firewall | WAF inspects the entire request to detect and block threats |
| v1 (Standard, WAF) | Retired | Retired on April 28, 2026 and no longer supported. Migrate to v2 |
- Pick the service by layer: Load Balancer for layer 4 (TCP, UDP); Application Gateway for regional layer 7 web traffic; Front Door for global web traffic and quick global failover; Traffic Manager for DNS-based global routing without TLS termination or per-request processing.
- Traffic routing features: URL path-based routing, multiple-site hosting, redirection, header and URL rewrite, cookie-based session affinity. Scale features: autoscaling, zone redundancy, a static VIP and connection draining.
- v2-only features: autoscaling, zone redundancy, static VIP, AKS Ingress Controller, Key Vault integration, header rewrite, mutual authentication (mTLS), Private Link, WAF custom rules. The v2 SKU offers up to 5X better TLS offload performance than Standard/WAF v1.
- The v2 SKU supports a static VIP exclusively: the VIP doesn't change for the lifecycle of the deployment, even after a restart.
- v2 differences: you can't mix Standard_v2 and Standard (v1) gateways on a subnet; v2 decodes paths before routing; FIPS mode isn't supported; for chunked file transfer on Standard_v2, turn off request buffering (not possible on WAF_v2).
- Standard_v2 and WAF_v2 aren't available in China East, China North, US DoD East and US DoD Central.
Subnet, frontend IP, backend pool and NSGs
- An application gateway needs a dedicated subnet. You can put several gateways in it, but no other resource type, and you can't mix v1 and v2 gateways. The virtual network and the public IP must be in the same location as the gateway.
- Each instance uses one private IP, plus one if a private frontend IP is configured; Azure reserves five addresses per subnet. v2 supports up to 125 instances, and Learn recommends at least a /24 (125 + 1 + 5). With 15 instances and no private frontend you need at least 20 addresses.
- Permissions on the virtual network or subnet:
Microsoft.Network/virtualNetworks/subnets/join/actionandMicrosoft.Network/virtualNetworks/subnets/read(the Network contributor built-in role includes them). - Changing the virtual network's DNS servers needs a stop and start of the gateway to take effect. Custom DNS servers must resolve public internet names.
- You can change the subnet of an existing gateway within the same virtual network, with PowerShell or the CLI.
- Frontend IP: v2 supports private + public, public only, or private only (a private-only deployment uses network isolation). Only one public and one private IP per IP protocol (up to four frontends with dual stack). With a private IP on v2 you must define a static address, and the static or dynamic choice can't be changed later.
- In regions with availability zones, the frontend public IP must be configured for all zones the gateway uses (the portal default is zones 1, 2 and 3).
- Backend pool members: a specific VM, a virtual machine scale set, an IP address or FQDN, or an App Service. Each pool must be associated with one or more routing rules, and you must configure health probes for each backend pool. Private IP backends outside the virtual network need peering or a VPN gateway.
NSG and route table rules for the gateway subnet
| Rule | Details |
|---|---|
| Inbound: client traffic | Allow clients to the subnet prefix on the listener ports (public and private frontend IPs as destination when both share a port) |
| Inbound: GatewayManager | Allow the GatewayManager tag on TCP 65200-65535 (v2) or 65503-65534 (v1) for the backend health communication |
| Inbound: AzureLoadBalancer | Allow the AzureLoadBalancer tag. Don't override it with a Deny rule |
| Also reserved | TCP 65502 and 54321, and UDP 12345, are used for platform health monitoring and operations |
| Outbound | Allow outbound to the internet. Don't create NSG rules that deny outbound connectivity |
| UDRs (v2) | Supported: disable BGP route propagation; 0.0.0.0/0 to the internet; AKS kubenet routes. Not supported: 0.0.0.0/0 through a virtual appliance, hub/spoke or on-premises (forced tunneling). A UDR might make backend health show Unknown and break logs and metrics |
Manual or autoscale, and zone redundancy
| Autoscaling | Manual | |
|---|---|---|
| Instances | You set a minimum (0 to 100) and optionally a maximum | You set a fixed count (1 to 125). The count is mandatory |
| Best for | Variable traffic. Avoids guessing the size and paying for peak capacity | Consistent, predictable workloads |
| Risk | A minimum of 0 means no reserved capacity: purely autoscaling | More traffic than the gateway can handle can mean traffic loss |
| SKUs | Standard_v2 and WAF_v2 | Standard_v2 and WAF_v2 (fixed capacity) |
- The Basic SKU doesn't use these modes: it scales automatically to an estimated 200 connections per second (RSA 2048-bit certificate).
- Each instance handles up to 10 capacity units. A new instance takes roughly three to five minutes to provision, so set a minimum that fits your normal traffic.
- On scale-in the gateway drains existing connections for 5 minutes on the instance being removed; new connections go to the remaining instances.
- If you lower the maximum below the current instance count, it takes effect only after a scale-in brings the count below it.
- The service is highly available even with a minimum of zero. Scaling up or down, or switching Standard to WAF, doesn't cause downtime.
- v2 deploys across a minimum of two availability zones by default, so you don't need a separate gateway per zone with Traffic Manager. Zone redundancy exists only where availability zones exist. Make sure the subnet can hold your maximum instance count.
- v2 pricing is consumption-based and isn't tied to instance counts or sizes.
Listeners and routing rules
| Listener | Behavior | Notes |
|---|---|---|
| Basic | Accepts all requests for any domain on that IP and port and sends them to one backend pool | Single-site hosting |
| Multi-site | Routes by host header or host names to different backend pools | Over 100 sites per gateway. Wildcard host names (*, ?) and up to 5 host names per listener on v2. No regular expressions. *.contoso.com doesn't match contoso.com |
| Rule type | Routes by | Notes |
|---|---|---|
| Basic | Every request on the listener goes to one backend pool with one HTTP setting | Can also redirect |
| Path-based | URL path (the pattern ignores query parameters) | Multiple pools and HTTP settings, plus a default pool and default setting for unmatched paths. Put least specific (wildcard) paths last. The full path is sent to the backend |
| Advanced (preview) | HTTP request attributes | Not supported for multi-site listeners or the layer 4 proxy |
- A rule binds a listener, a backend pool and a backend setting. One listener attaches to one rule.
- v2 processes rules by priority, an integer from 1 (highest) to 20000, unique per rule. Give wildcard and basic listeners a higher number than site-specific and multi-site listeners, so
shop.contoso.comis evaluated before*.contoso.com. v1 processed rules in listed order. - From API version 2021-08-01 priority is mandatory on new rules, and once used it must be set for all rules.
- Redirection targets another listener (for HTTP-to-HTTPS) or an external site; types 301 Permanent, 307 Temporary, 302 Found, 303 See other. A basic rule redirect is global; a path-based rule redirect covers one site area. You can't forward the original path to an external site.
- Protocol: HTTPS on the listener for TLS termination; choose HTTPS in the backend setting too for end-to-end TLS. HTTP/2 works with clients only (always HTTP/1.1 to the backend), over HTTPS listeners, and is off by default but on by default in the portal. WebSocket is on by default.
- Custom error pages are available for 400, 403, 405, 408, 500, 502, 503 and 504. Errors from the backend are passed on unchanged.
- On v2 a public and a private IPv4 listener can share a frontend port; a public and a private IPv6 listener can't. Check the NSG then: the destination becomes the frontend IPs.
Backend settings and health probes
| Backend setting | Details |
|---|---|
| Cookie-based affinity | Gateway-managed cookie, default name ApplicationGatewayAffinity, renameable. Gateways in line need unique names. Clients must support cookies. v2 can't append the domain to the cookie |
| Connection draining | Off: 30 seconds. On: 1 to 3,600 seconds (CLI --connection-draining-timeout; 0 disables). Gateway-managed session-affinity requests still go to deregistering instances |
| Protocol and port | HTTP or HTTPS (HTTPS plus an HTTPS listener gives end-to-end TLS); port 1 to 65535 |
| Trusted root certificate | Needed (.cer) for a private CA or self-signed backend certificate. Public CAs work by default |
| Request timeout | Default 20 seconds. Private backend: 1 to 86,400 seconds. External backend: 1 to 240 seconds |
| Override backend path | Optional custom forwarding path used when the request is forwarded to the backend |
| Host name | Pick host name from backend address (use the pool's name, for multitenant App Service) or host name override. Keep the same host name end to end where you can |
| Dedicated backend connection | 1:1 frontend to backend connections for NTLM and Kerberos pass-through. Not supported with HTTP/2. Costs more connections and SNAT ports |
| Probe | Default probe | Custom probe |
|---|---|---|
| Created | Automatically when you set no custom probe | Per backend setting; only one custom probe per setting |
| Target | <protocol>://127.0.0.1:<port>/, protocol and port from the backend setting | Your host (also SNI on v2), path starting with /, protocol (must match the setting), port (v2) |
| Timing | Interval 30 s, timeout 30 s, unhealthy threshold 3 | You set interval, timeout and threshold |
| Healthy | Status 200 to 399 | 200 to 399, or your status codes or body string match (not a regex, 4090 characters or less) |
| Extras | - | MinServers: minimum servers always marked healthy (PowerShell, CLI or ARM only). Use with caution |
- Probes come from the gateway's public frontend IP (public backends) or from the gateway subnet (private backends). Every instance probes independently, and each backend server and backend setting pair is probed.
- A backend is unhealthy until a probe succeeds. Health states: Healthy, Unhealthy, Unknown. Check with the portal Backend health page,
Get-AzApplicationGatewayBackendHealthor the CLI. - A custom probe doesn't monitor a pool unless its backend setting is associated with a listener through a rule. A wrong probe path commonly causes unhealthy servers and 502 errors.
- Use a custom probe to accept 403 from servers that need authentication, or to give a hostname for SNI when the backend has a wildcard certificate. With wildcard or multiple host names in a listener you can't associate several custom probes with one setting; probe one site or use
127.0.0.1.
TLS and rewrite rule sets
| Mode | How | Certificates |
|---|---|---|
| TLS termination | HTTPS listener decrypts; traffic to the backend can be unencrypted (HTTP setting) | PFX with private key and the full chain on the listener. Wildcard cert for wildcard hosts; SAN cert for multiple hosts |
| End-to-end TLS | HTTPS listener and HTTPS backend setting: gateway decrypts, applies rules, opens a new TLS connection and re-encrypts | v2: trusted root certificate for a self-signed or private CA backend. Public CA certs with a matching CN need nothing; App Service and similar Azure services are trusted |
- TLS 1.2 or higher is required for all clients and backends since August 31, 2025. SSL 2.0 and 3.0 are disabled and not configurable.
- TLS policy: predefined (named
AppGwSslPolicy<YYYYMMDD>) or custom, with a minimum version of TLS 1.0 to 1.3. Without a choice, API version 2023-02-01 or later defaults to minimum 1.2 (up to 1.3); older API versions default to minimum 1.0. TLS 1.3 policies (2022 predefined, CustomV2) are v2 only. - On v2 the TLS policy applies to the frontend only; backend connections negotiate TLS 1.3 and fall back to TLS 1.2.
- Application Gateway can't create certificates or send a request to a CA. The CN must match the host header and the date must be valid.
- Without an SNI header, v2 returns the certificate of the HTTPS listener whose rule has the highest priority (lowest number), not the basic listener's certificate.
- Key Vault certificates (v2): a user-assigned managed identity (only one per gateway) retrieves them; software-validated, exportable PFX only; instances poll every four hours; use a secret identifier without a version for rotation. The portal supports certificates, not secrets, and not cross-subscription vaults. A misconfigured vault disables the HTTPS listeners.
Rewrite rule sets
- Header and URL rewrite is v2 only. You can add, remove or set request and response headers (except
ConnectionandUpgrade) and rewrite host name, path and query string. You can't delete theHostheader. - A rewrite set holds a routing rule association, conditions and actions. Several conditions are joined with AND. A rule has at most one rewrite set; a set can serve many rules. A basic rule gives a global rewrite; with a path-based rule the set applies to the path map.
- Conditions test request or response headers and server variables. Patterns use RE2 regular expressions, without slashes around them. Reference values as
{http_req_<name>},{http_resp_<name>}and{var_<name>}; case must match between condition and capture. - Enable Re-evaluate path map to route on the rewritten path to a different pool (parameter-based path selection with a path-based rule). Without it, the original path is matched.
- Typical uses: remove the port from
X-Forwarded-For(add_x_forwarded_for_proxy), add HSTS and other security headers, remove headers that leak information, fix a redirectLocationthat exposes the backend host name.
CLI and PowerShell
| Task | Azure CLI | PowerShell |
|---|---|---|
| Create the public IP for the gateway | az network public-ip create --resource-group myResourceGroupAG --name myAGPublicIPAddress --allocation-method Static --sku Standard | - |
| Create a Standard_v2 application gateway | az network application-gateway create --name myAppGateway --location eastus --resource-group myResourceGroupAG --capacity 2 --sku Standard_v2 --public-ip-address myAGPublicIPAddress --vnet-name myVNet --subnet myAGSubnet --servers "$address1" "$address2" --priority 100 | - |
| Check backend health | - | Get-AzApplicationGatewayBackendHealth -Name "appgw1" -ResourceGroupName "rgOne" |
| Stop the gateway | az network application-gateway stop -g MyResourceGroup -n MyAppGateway | - |
| Start the gateway | az network application-gateway start -g MyResourceGroup -n MyAppGateway | - |
| Move the gateway to another subnet in the same virtual network (stop first) | az network application-gateway update -g <ResourceGroup> -n <ApplicationGatewayName> --set gatewayIpConfigurations[0].subnet.id=<subnetID> | - |
| Enable HTTP/2 on listeners (then Set-AzApplicationGateway -ApplicationGateway $gw) | - | $gw.EnableHttp2 = $true |
| Set connection draining (add --connection-draining-timeout; 0 disables, 1 to 3,600 enables) | az network application-gateway http-settings update | - |
| Set the TCP idle timeout of the gateway's public IP (4 to 30 minutes; then Set-AzPublicIpAddress) | - | $publicIP.IdleTimeoutInMinutes = "15" |
| Probe response match for a custom probe | - | $match = New-AzApplicationGatewayProbeHealthResponseMatch -StatusCode 200-399 |
Exam Tips
Tick each tip once you can answer it without looking.
“Route /images and /video on one site to different server pools, or host several sites on one IP” → Application Gateway: path-based rule or multi-site listeners (layer 7). Trap: Load Balancer works at layer 4 and can't read URLs or host headers. Traffic Manager only answers DNS.
“A v1 gateway is still deployed” → v1 was retired on April 28, 2026: migrate to v2 (Standard_v2 or WAF_v2). Trap: You can't mix v1 and v2 on a subnet. v2 features (autoscale, zones, static VIP, Key Vault, rewrite) don't exist on v1.
“Unpredictable traffic; avoid sizing for peak” → Autoscaling with a minimum (0 to 100) and optional maximum. Trap: Manual mode (1 to 125 instances) can lose traffic when load exceeds capacity. Minimum 0 reserves no capacity, and a new instance takes about three to five minutes.
“What goes in the Application Gateway subnet, and how big?” → Only application gateways. v2: at least a /24 (up to 125 instances + 1 private frontend + 5 reserved). Trap: No other resource type fits in it, and you can't mix v1 and v2 gateways.
“NSG on the gateway subnet; backend health is unhealthy or the gateway fails to deploy” → Allow GatewayManager on TCP 65200-65535 (v2), allow AzureLoadBalancer and outbound to the internet. Trap: Don't override the AzureLoadBalancer tag or deny outbound with NSG rules. Forced tunneling with a 0.0.0.0/0 UDR to an appliance isn't supported on v2.
“Internal line-of-business app, no public exposure, on v2” → A private frontend IP (static address required), or a private-only deployment. Trap: One public and one private IP per IP protocol at most. The static or dynamic choice can't be changed later.
“Which health probe is used if you configure none?” → The default probe: 127.0.0.1, port and protocol from the backend setting, 30 s interval, 30 s timeout, threshold 3, healthy on 200-399. Trap: A custom probe applies only through its backend setting, accepts one probe per setting, and the body match isn't a regex.
“Servers need login and return 403 to probes, or have a wildcard certificate” → A custom probe with a status code match (403), or a probe host name for SNI. Trap: The default probe treats only 200 to 399 as healthy and uses 127.0.0.1 as host unless a host name is set in the backend setting.
“Several sites on one listener port; shop.contoso.com must win over *.contoso.com” → Multi-site listeners, and a lower priority number (1 to 20000) on the more specific rule. Trap: On v2, order is by rule priority, not by list position. Basic and wildcard listeners need a higher number. *.contoso.com doesn't match contoso.com.
“Redirect HTTP to HTTPS” → A redirection setting on a rule, with listener as the target (301 or another type). Trap: An external site target can't carry the original path. A basic-rule redirect is global; path-based redirects only a site area.
“Encrypt traffic all the way to the backend, with private CA certificates” → HTTPS listener + HTTPS backend setting + upload the trusted root certificate (.cer). Trap: TLS termination alone leaves the backend leg unencrypted. Public CA certs with a matching CN need no upload; v2 doesn't use authentication certificates.
“Certificate renewal without touching the gateway” → Key Vault certificate with a versionless secret identifier and a user-assigned managed identity (polled every four hours). Trap: Only v2, only software-validated exportable PFX, one managed identity per gateway. The portal doesn't support secrets or cross-subscription vaults.
“Minimum TLS version” → TLS 1.2 or higher since Aug 31, 2025. Choose a predefined or custom TLS policy; default on API version 2023-02-01 or later is minimum 1.2. Trap: The v2 TLS policy applies to the frontend only. SSL 2.0 and 3.0 are disabled and can't be enabled.
“Remove the port from X-Forwarded-For, add HSTS, or strip a server header” → A rewrite rule set (v2 only), tied to a routing rule. Trap: You can't delete the Host header or rewrite Connection and Upgrade. Several conditions use AND. A rule can have only one rewrite set.
“Choose a pool by a query-string value” → Rewrite the URL path with Re-evaluate path map on, attached to a path-based rule. Trap: Without re-evaluation the original path is matched against the path map.
“502 errors during backend updates or scale-in” → Enable connection draining in the backend setting (1 to 3,600 s) and raise the timeout above the longest client transfer. Trap: Draining off means 30 seconds. Gateway-managed session affinity requests still reach deregistering instances.
Sources
- What is Azure Application Gateway
- What is Application Gateway v2
- Application Gateway components
- Configuration overview
- Infrastructure configuration
- Frontend IP configuration
- Listener configuration
- Request routing rules
- Backend settings
- Health probes
- Scaling and zone-redundant v2
- TLS termination and end-to-end TLS
- TLS policy overview
- Key Vault certificates
- Rewrite HTTP headers and URL
- Hosting multiple sites
- URL path-based routing
- Backend health troubleshooting
- Quickstart: create a gateway (CLI)
- Application Gateway FAQ
Checked against Microsoft Learn on November 13, 2026.