5.2 Azure Application Gateway Architecture & Routing

Key Takeaways

  • Azure Application Gateway is a dedicated Layer 7 Application Delivery Controller (ADC) reverse proxy supporting HTTP, HTTPS, HTTP/2, and WebSocket traffic.
  • Application Gateway v2 (Standard_v2 and WAF_v2) supports autoscaling (0 to 125 Capacity Units), multi-Availability Zone redundancy, faster provisioning (6-7 minutes), and Key Vault integration for TLS certificates.
  • Listeners can be Basic (single domain/IP) or Multi-site (multiple hostnames via SNI/Host headers, including wildcards like *.contoso.com).
  • Routing rules evaluate traffic using Basic Routing (direct to backend pool) or Path-Based Routing (URL Path Maps evaluated with longest prefix / exact match priority, e.g., /images/* or /api/*).
  • End-to-End TLS requires TLS termination at the frontend listener with a server certificate and re-encryption to the backend with trusted public CAs or uploaded enterprise Root/Intermediate CA certificates.
Last updated: August 2026

Azure Application Gateway Architecture & Routing

Azure Application Gateway is a dedicated, fully managed Layer 7 (Application Layer) Application Delivery Controller (ADC) and reverse proxy. Unlike Azure Load Balancer which routes packets at Layer 4 without inspecting application data, Application Gateway terminates incoming client TCP connections, evaluates HTTP/HTTPS request headers, hostnames, and URI paths, and makes intelligent routing decisions before proxying requests to backend targets.

Application Gateway delivers enterprise application delivery capabilities including SSL/TLS termination, cookie-based session affinity, URL path-based routing, multi-site hosting, URL and header rewrites, and integrated Web Application Firewall (WAF) protection.


1. Application Gateway v2 SKU Architecture & Sizing

The modern standard for Application Gateway is the v2 SKU (available as Standard_v2 and WAF_v2). The legacy v1 SKU (Standard and WAF) has been deprecated.

CapabilityApplication Gateway v2 (Standard_v2 / WAF_v2)Legacy v1 SKU (Deprecated)
AutoscalingSupported: Dynamic scaling from 0 to 125 Capacity Units based on trafficFixed instance count (1 to 32)
Zone RedundancyMulti-zone support: Instances span Zones 1, 2, and 3 automaticallyNot zone-redundant
Performance & ProvisioningFast provisioning (6–7 minutes); up to 5x higher TLS offload performanceSlow provisioning (20–25 minutes)
Frontend IP AllocationsStatic Public IP only (Standard SKU Public IP)Dynamic or Static IP
TLS Certificate StorageDirect integration with Azure Key Vault (auto-renewal via Managed Identity)Manual PFX upload only
Header & URL RewriteSupported natively in routing pipelineNot supported in v1
Mutual TLS (mTLS)Supported (Client Certificate Authentication)Not supported in v1

Subnet Requirements & Sizing Calculations

Application Gateway requires a dedicated subnet within your Virtual Network:

  • No other Azure compute resources (such as standard VMs, App Service environments, or Azure Bastion) can reside inside the Application Gateway subnet.
  • The subnet minimum size is /28 (16 total IP addresses, yielding 11 usable addresses).
  • Recommended Enterprise Sizing: Allocate a /26 (64 total IPs) or /24 (256 total IPs) subnet. When autoscaling is configured, Application Gateway provisions internal virtual machine instances to handle load surges. A /28 subnet restricts maximum autoscaling capacity units during peak traffic spikes.

Autoscaling Capacity Units (CU)

Application Gateway v2 scales automatically based on Capacity Units (CU). A single Capacity Unit represents:

  1. Compute Unit: Processing capability (CPU consumption per request/rule evaluation).
  2. Persistent Connections: Up to 2,500 persistent connections per CU.
  3. Throughput: Up to 2.22 Mbps of data transfer per CU.
  4. TLS Offload: Up to 50 new SSL/TLS connections per second per CU (using RSA 2048-bit keys).
Loading diagram...
Application Gateway v2 Request Flow: Listeners, URL Path Routing, and Backend Settings

2. Frontend IP Configurations & Listeners

Incoming traffic enters Application Gateway through a Frontend IP Configuration and is evaluated by one or more Listeners.

Frontend Configurations

Application Gateway v2 supports:

  • Public Frontend IP: Binds a static Standard Public IP address for Internet-facing web traffic.
  • Private Frontend IP: Binds a private IP address from the gateway subnet for internal Intranet traffic.
  • Dual Frontend: Concurrently binds both a Public IP and a Private IP to serve both external Internet users and internal corporate clients on distinct listeners.

Listener Types

A Listener checks for incoming connection requests matching a specific IP, port, protocol, and hostname:

+-----------------------------------------------------------------------------+
|                        LISTENER ARCHITECTURE TYPES                          |
|                                                                             |
|   1. BASIC LISTENER:                                                        |
|      Frontend IP (52.183.40.10) + Port 443                                  |
|      --> Accepts ALL incoming requests regardless of Host header            |
|                                                                             |
|   2. MULTI-SITE LISTENER (SNI & HOST HEADER ROUTING):                       |
|      Frontend IP (52.183.40.10) + Port 443                                  |
|      +---> Host: shop.contoso.com  --> Uses SSL Cert A --> Shop Rule        |
|      +---> Host: blog.contoso.com  --> Uses SSL Cert B --> Blog Rule        |
|      +---> Host: *.partner.com     --> Wildcard Cert C --> Partner Rule     |
+-----------------------------------------------------------------------------+
  1. Basic Listener: Listens on a single port and IP. It accepts all incoming requests regardless of the HTTP host header. Typically used when Application Gateway hosts a single application or behind a dedicated load balancing domain.
  2. Multi-Site Listener: Listens on a single public IP and port (e.g., 443) but routes traffic for multiple domain names (e.g., shop.contoso.com, finance.contoso.com, *.internal.contoso.com).
    • Uses Server Name Indication (SNI) during the TLS handshake to present the correct SSL certificate corresponding to the requested hostname.
    • Evaluates the HTTP Host: header to associate the request with the appropriate routing rule.
    • Supports exact hostnames and wildcard hostnames (e.g., *.contoso.com).

3. Routing Rules: Basic vs. Path-Based Routing

Routing rules bind a Listener to a Backend Pool and a set of Backend Settings (HTTP Settings).

Basic Routing Rules

A Basic Routing Rule forwards all traffic arriving at the associated listener directly to a single designated backend pool without inspecting URI paths.

Path-Based Routing Rules (URL Path Maps)

A Path-Based Routing Rule evaluates the URL path of the incoming request and routes to different backend pools and backend settings:

  • Path Pattern Matching:
    • /images/* or /media/* $\rightarrow$ Routes to Image Storage / CDN Backend Pool.
    • /api/* or /auth/* $\rightarrow$ Routes to Microservices Container / VMSS Backend Pool.
    • /* (Default Path) $\rightarrow$ Routes unmatched traffic to Default Web App Backend Pool.
  • Path Evaluation Precedence:
    1. Exact String Matches (e.g., /api/v1/health) are evaluated first.
    2. Longest Prefix Wildcard Matches (e.g., /api/v1/* takes precedence over /api/*).
    3. Default Backend Pool handles all requests that do not match any path rule.

4. Backend Pools & Backend Settings (HTTP Settings)

Supported Backend Pool Targets

A backend pool defines the collection of servers servicing incoming client requests. Application Gateway supports heterogeneous backend target types:

  • IPv4 / IPv6 IP Addresses: Virtual machines in the same VNet, peered VNets, or on-premises datacenters reachable via VPN or ExpressRoute.
  • Fully Qualified Domain Names (FQDN): Public or private domain endpoints.
  • Azure App Services: Multi-tenant Azure App Services and Azure Functions.
  • Virtual Machine Scale Sets (VMSS): Auto-registered VMSS network interfaces.

Backend Settings (HTTP Settings / Backend HTTP Configuration)

Backend settings control how Application Gateway proxies the connection from the gateway to the backend instances:

+-----------------------------------------------------------------------------+
|                        BACKEND SETTINGS MECHANICS                           |
|                                                                             |
|   Client ====== (HTTPS 443) ======> [ Application Gateway ]                 |
|                                            |                                |
|   Backend Settings Parameters:             | (Proxy Connection)             |
|   - Backend Protocol: HTTP or HTTPS        |                                |
|   - Cookie-Based Affinity: ARRAffinity     |                                |
|   - Connection Draining: 300 seconds       v                                |
|   - Request Timeout: 60 seconds      [ Backend Target ]                     |
|   - Pick Host Name from Backend Address (App Service FQDN matching)         |
+-----------------------------------------------------------------------------+
Setting ParameterFunction & Operational Rule
Backend Protocol & PortSpecifies the protocol (HTTP or HTTPS) and port (e.g., 80, 443, 8080) used to communicate with the backend servers.
Cookie-Based AffinityWhen enabled, Application Gateway injects a gateway-managed cookie (ARRAffinity or custom name) into the client response. Subsequent client requests containing this cookie are pinned to the same backend server instance.
Connection DrainingAllows backend instances undergoing maintenance or scale-in events to be gracefully deregistered. In-flight requests are allowed to complete until the draining timeout expires (Configurable from 1 to 3,600 seconds; Default: 0 / Disabled).
Request TimeoutThe maximum time Application Gateway waits for a response from the backend target before returning an HTTP 504 Gateway Timeout error (Default: 20 seconds; Range: 1 to 86,400 seconds).
Host Name OverrideModifies the HTTP Host: header sent to the backend. Crucial when routing to Azure App Service (Pick host name from backend address) to prevent 404 Site Not Found errors.
Custom Health Probe AssociationBinds an active custom health probe to validate backend reachability.

5. TLS Termination & End-to-End TLS Encryption

Application Gateway provides enterprise SSL/TLS offloading and full cryptographic compliance across its proxy architecture.

+-----------------------------------------------------------------------------+
|                   TLS TERMINATION vs. END-TO-END TLS ENCRYPTION             |
|                                                                             |
|   1. TLS TERMINATION (SSL Offloading):                                      |
|      Client === (HTTPS / Encrypted) ===> [ App Gateway ] === (HTTP / Plain) ===> [ Backend VMs ]
|      (Reduces CPU overhead on backend VMs; unencrypted inside VNet)         |
|                                                                             |
|   2. END-TO-END TLS ENCRYPTION:                                             |
|      Client === (HTTPS / Encrypted) ===> [ App Gateway ] === (HTTPS / Encrypted) ===> [ Backend VMs ]
|      (Gateway decrypts for WAF/routing inspection, then re-encrypts)        |
+-----------------------------------------------------------------------------+

1. TLS Termination (SSL Offload)

  • Client sends HTTPS traffic to Application Gateway.
  • Application Gateway decrypts the traffic using its frontend SSL certificate.
  • The gateway routes the decrypted plaintext HTTP traffic to backend servers over private VNet subnets.
  • Advantage: Eliminates cryptographic overhead on backend compute instances.

2. End-to-End TLS Encryption

  • Required for stringent regulatory standards (PCI-DSS, HIPAA, FedRAMP) where plaintext transmission inside the cloud perimeter is prohibited.
  • Application Gateway terminates the initial client TLS session, performs Layer 7 inspection and WAF rule processing, and then establishes a second, independent TLS session to the backend instance.

Certificate Management in Application Gateway v2

  • Frontend Certificates: Stored securely in Azure Key Vault. Application Gateway uses a User-Assigned Managed Identity to poll Key Vault for certificate updates, enabling automatic SSL certificate renewal without downtime.
  • Backend Authentication Certificates:
    • If the backend uses certificates signed by well-known public Certificate Authorities (CAs) (e.g., DigiCert, Let's Encrypt), no certificate upload to Application Gateway is required.
    • If the backend uses certificates signed by an internal Enterprise Private CA, the public Root CA or Intermediate CA certificate (.cer format) must be uploaded to the Backend Settings as a Trusted Root Certificate.
    • SNI / Host Header Validation: The Common Name (CN) or Subject Alternative Name (SAN) on the backend certificate must match the host name configured in the Backend Setting (or overridden via Pick host name from backend address).

6. URL Rewrite & HTTP Header Modifications

Application Gateway v2 can dynamically rewrite HTTP request and response headers, as well as rewrite URI paths and query strings, before packets reach the client or backend.

Common Rewrite Use Cases

  1. Security Header Injection: Automatically inject security response headers such as Strict-Transport-Security (HSTS), X-Content-Type-Options: nosniff, X-Frame-Options: DENY, and Content-Security-Policy.
  2. Sensitive Header Stripping: Remove backend information headers such as Server: Microsoft-IIS/10.0 or X-Powered-By: ASP.NET to prevent server fingerprinting.
  3. URL Path Manipulation: Transparently rewrite legacy client URLs (e.g., /v1/products?id=42) to modern microservice endpoints (e.g., /api/v2/catalog/42) without issuing an HTTP 301/302 redirect.
  4. Client IP Identification: Inject or preserve headers such as X-Forwarded-For, X-Forwarded-Proto, and X-Forwarded-Port so backend services identify the true client public IP.
Test Your Knowledge

A solutions architect is configuring Azure Application Gateway v2 to host two corporate web applications: 'sales.contoso.com' and 'hr.contoso.com'. Both applications must share a single static Public IP address on port 443, but each application requires its own distinct SSL certificate issued to its respective FQDN. Which listener configuration must be implemented?

A
B
C
D
Test Your Knowledge

An organization is migrating an on-premises web application to Azure App Service behind an Azure Application Gateway v2. During testing, browsing to the public URL returns an 'HTTP 404 Site Not Found' error generated by the App Service platform. The backend health probe also reports unhealthy status. What configuration setting in the Application Gateway Backend Settings resolves this issue?

A
B
C
D
Test Your Knowledge

A security policy mandates strict End-to-End TLS encryption for all web traffic passing through Application Gateway v2 to backend VMs. The backend VMs use TLS certificates signed by an internal corporate Active Directory Certificate Services (AD CS) Private Root CA. What certificate configuration is required on Application Gateway v2 to ensure backend health probes succeed and traffic is encrypted?

A
B
C
D
Test Your Knowledge

An e-commerce platform hosted behind Azure Application Gateway v2 experiences user session dropouts during flash sales, where users lose items in their shopping carts when browsing between web pages. The web servers store user session state in local memory rather than a shared Redis cache. Which feature must be enabled on the Application Gateway Backend Settings to ensure users remain connected to the same backend server instance?

A
B
C
D