Skip to main content

Application Gateway

Azure Application Gateway is a regional Layer 7 load balancer that routes HTTP and HTTPS traffic by URL path or host name and terminates TLS. Its optional Web Application Firewall blocks common attacks such as SQL injection and cross-site scripting.

Application Gateway

Application Gateway reads the HTTP request itself, so it can send /api/* to one backend pool and /static/* to another, terminate TLS in one place, and inspect traffic with a built-in Web Application Firewall (WAF). It works inside a single region and is the Azure counterpart to an AWS Application Load Balancer. For raw TCP or UDP traffic, use Azure Load Balancer instead.

How Does Application Gateway Route a Request?

A request passes through four building blocks in order: a listener accepts the connection, a routing rule picks the target, a backend pool holds the servers, and a health probe keeps unhealthy servers out of rotation.

flowchart LR U(["Client"]):::person -->|HTTPS| G["Application Gateway
WAF v2"]:::tool G -->|"/api/*"| A["API pool"]:::cloud G -->|"/static/*"| S["Static pool"]:::cloud classDef person fill:#EDE9FE,color:#1E293B classDef tool fill:#326CE5,color:#FFFFFF classDef cloud fill:#D1FAE5,color:#1E293B

How Do You Create a WAF-Enabled Gateway?

Bash
az network application-gateway create \
--name mumbai-appgw --resource-group mumbai-prod-rg \
--sku WAF_v2 --capacity 2 --priority 100 \
--vnet-name mumbai-prod-vnet --subnet appgw-subnet \
--public-ip-address appgw-pip

The gateway needs its own dedicated subnet, and the v2 SKU supports autoscaling and zone redundancy. The older v1 SKU is retired, so new deployments should always use v2.

Why It Matters in Production

A payments company like PhonePe would put the gateway in front of its web tier with the WAF in Prevention mode, so SQL injection and cross-site scripting payloads are rejected at the edge before they reach application code. Central TLS termination also means certificates are rotated in one place.

Security

Run the WAF in Prevention mode in production. Detection mode only logs attacks and blocks nothing, which gives a false sense of safety.

Tip

Roll out new WAF rule sets in Detection mode on staging first, then tune exclusions for false positives before enforcing.

Frequently Asked Questions

When should I use Application Gateway instead of Azure Load Balancer?

Use Application Gateway for HTTP and HTTPS workloads that need URL or host routing, TLS termination, or a WAF. Use Azure Load Balancer for protocol-agnostic Layer 4 traffic such as databases or custom TCP services.

Is Application Gateway global like Azure Front Door?

No. Application Gateway lives in one region and balances across backends in that region. Front Door is the global option that routes users to the nearest healthy region, and the two are often combined.

Why does my gateway report backend servers as unhealthy?

The health probe is usually the cause: a wrong path, a host header the app rejects, or an NSG blocking the gateway subnet. Check Backend health in the portal to see the exact probe error.

Found a mistake, an outdated step or a broken link?