Lesson 18 — Load Balancing in Azure

Domain 4 — Networking AZ-104: 15–20% ~35 min Prereq: VNets, NSGs, DNS

Why Load Balancing Is Always in the Exam

Azure has four distinct load balancing products: Azure Load Balancer, Application Gateway, Azure Front Door, and Traffic Manager. They are not interchangeable — each solves a specific problem at a specific OSI layer, with different geographic scope. The AZ-104 exam consistently tests whether you can pick the right product for a given scenario, and whether you understand how they can be layered together.

Senior engineers in real Azure environments face this decision constantly. A mistake here — using a Basic Load Balancer instead of Standard, or an Application Gateway when Traffic Manager is needed — can mean production downtime, security exposure, or failed availability zone redundancy. This lesson gives you the complete decision model.

1. The Four Load Balancing Services

Each Azure load balancing service addresses a different combination of OSI layer, geographic scope, and protocol support:

ServiceOSI LayerScopeProtocolWAFSSL TerminationPrimary Use Case
Azure Load Balancer Layer 4 (TCP/UDP) Regional TCP, UDP No No VM / VMSS traffic distribution within a region
Application Gateway Layer 7 (HTTP/S) Regional HTTP, HTTPS, HTTP/2, WebSocket Yes (WAF_v2) Yes Web apps needing URL routing, WAF, SSL offload
Azure Front Door Layer 7 (HTTP/S) Global HTTP, HTTPS Yes (Premium) Yes Global web apps with CDN, anycast routing, WAF
Traffic Manager DNS-based (L3/4) Global Any (DNS only) No No Global HA and failover including non-HTTP services
The quick decision rule L4 regional → Azure Load Balancer. L7 regional with WAF → Application Gateway. L7 global with CDN → Azure Front Door. DNS-based global / non-HTTP global → Traffic Manager. When in doubt: can these services be layered? Yes — Traffic Manager → Application Gateway → Load Balancer is a common production pattern.

2. Azure Load Balancer

Azure Load Balancer operates at Layer 4. It distributes inbound TCP and UDP flows across backend pool members based on a configurable hash algorithm. It does not inspect, decrypt, or modify the packet payload — it only sees IP addresses and ports.

SKUs — Standard vs. Basic

FeatureStandard SKUBasic SKU
Availability ZonesZone-redundant and zonal frontends supportedNot supported
VMSS supportYesYes (limited)
Backend pool sizeUp to 1,000 instancesUp to 300 instances
Health probe protocolsTCP, HTTP, HTTPSTCP, HTTP only
Secure by default (NSG required)Yes — inbound blocked by defaultNo — open by default
SLA99.99%No SLA
StatusCurrent — use thisRetiring September 2025
Basic Load Balancer is retiring — know this for the exam Microsoft announced the retirement of Azure Basic Load Balancer in September 2025. The exam may still reference it as a wrong answer or comparison point. Always choose Standard SKU for new deployments. Standard LB requires NSG rules to allow traffic — traffic is denied by default, unlike Basic.

Core components

ComponentDescription
Frontend IP configuration Public IP (internet-facing) or private IP (internal load balancer). A Standard LB can have multiple frontends.
Backend pool Set of VMs or VMSS instances that receive distributed traffic. Can span Availability Zones (Standard SKU).
Health probes Periodic checks to determine if a backend is healthy. Unhealthy backends are removed from rotation. Probe source IP is always 168.63.129.16 — must be allowed in backend NSGs.
Load balancing rules Map a frontend IP:port to a backend pool:port using a distribution algorithm (5-tuple hash by default).
Inbound NAT rules Forward specific ports on the frontend IP to specific VMs — used for RDP/SSH access to individual backend VMs.
Outbound rules Configure SNAT for backend pool VMs to reach the internet through the Load Balancer's public IP. Controls SNAT port allocation.

Session persistence (sticky sessions)

By default, Azure Load Balancer uses a 5-tuple hash (source IP, source port, destination IP, destination port, protocol) to distribute traffic. For stateful applications that need a client to always hit the same backend:

ModeHash inputsUse case
None (default)5-tuple hashStateless workloads — best distribution
Client IPSource IP (2-tuple)Same client IP always hits same backend
Client IP and ProtocolSource IP + protocol (3-tuple)Client with multiple protocols still sticky per protocol

Internal Load Balancer (ILB)

When the frontend IP is a private IP within a VNet, the Load Balancer is an Internal Load Balancer. Use this to distribute traffic between tiers within a VNet — for example, from an application tier to a database tier, or in front of NVAs (Network Virtual Appliances) in a hub-spoke topology.

HA Ports rule

A special load balancing rule that balances all TCP/UDP ports simultaneously. Only available on Internal Load Balancers with Standard SKU. Used when NVAs must inspect traffic on all ports — configure an ILB with an HA Ports rule in front of a cluster of NVA VMs.

Health probe source IP Azure Load Balancer health probes always originate from 168.63.129.16. If your backend VMs have NSGs that do not allow inbound from this IP (or from the AzureLoadBalancer service tag), the health probe will fail and the backend will be marked unhealthy — it will receive no traffic even if the application is running perfectly. This is a very common misconfiguration.

3. Application Gateway

Application Gateway is a Layer 7 load balancer that understands HTTP and HTTPS. It can inspect the full HTTP request — URL path, host headers, query strings, cookies — and make routing decisions based on that content. This makes it dramatically more powerful than Azure Load Balancer for web application workloads.

Core components

ComponentDescription
Frontend IP Public or private IP. The entry point for all incoming requests.
Listeners Define port, protocol (HTTP/HTTPS), and optionally hostname (for multi-site hosting). A basic listener accepts all traffic on a port; a multi-site listener routes based on Host header.
Rules Basic rule: maps a listener to a single backend pool. Path-based rule: routes different URL paths (/api/*, /images/*) to different backend pools.
Backend pools VMs, VMSS, App Service instances, IP addresses, or FQDNs. Different pools for different URL paths or hostnames.
HTTP settings Protocol and port to use when forwarding to backends, cookie-based session affinity, connection draining, custom health probe configuration, request/response headers.
Health probes HTTP/HTTPS probes that check backend health. Default probe uses the HTTP settings protocol/port; custom probes allow specific URL paths, status codes, and intervals.

SSL/TLS handling modes

ModeDescriptionUse case
SSL termination HTTPS decrypted at the gateway; traffic forwarded to backends over HTTP (unencrypted inside VNet) Reduces CPU load on backends; certificate management centralised at gateway
End-to-end SSL HTTPS decrypted at gateway, re-encrypted for backend communication Compliance requirements that mandate encryption in transit throughout
SSL passthrough TLS connection passed directly to backend — gateway does not decrypt When the backend must see the original client certificate

WAF — Web Application Firewall

Application Gateway WAF_v2 SKU includes an integrated WAF that inspects HTTP/S requests against OWASP Core Rule Sets (CRS). The WAF protects against the OWASP Top 10 vulnerabilities including SQL injection, cross-site scripting (XSS), and remote code execution attacks.

  • Detection mode: logs violations but does not block traffic. Use for initial tuning.
  • Prevention mode: actively blocks requests that match WAF rules.
  • Custom rules: allow or deny based on IP ranges, geo-location, HTTP variables, or rate limits.
  • Bot protection: built-in ruleset for known malicious bots.

SKUs

SKUWAFAutoscalingZone redundancy
Standard_v2NoYesYes
WAF_v2Yes (OWASP CRS + custom rules)YesYes
Standard_v1 / WAF_v1Limited (v1 only)NoNo
v1 is deprecated Application Gateway v1 SKUs (Standard and WAF) are deprecated. All new deployments must use v2. The v2 SKU is autoscaling and zone-redundant — no manual scaling or availability set configuration needed.

Path-based routing example

Listener: HTTPS on port 443 for "app.contoso.com"
  │
  ├─ /api/*         → backend-pool-api     (API VMs, port 8080)
  ├─ /images/*      → backend-pool-storage (Azure Blob / CDN)
  ├─ /admin/*       → backend-pool-admin   (Admin VMs, with WAF custom rule)
  └─ /* (default)   → backend-pool-web     (Web frontend VMs, port 80)

4. Azure Front Door

Azure Front Door is Microsoft's global Layer 7 load balancing service. It operates on Microsoft's global anycast network — users worldwide are routed to the nearest Microsoft PoP (Point of Presence), which then proxies the request to the origin. This dramatically reduces latency for geographically distributed users.

Key capabilities

  • Global anycast routing: users connect to the nearest of Microsoft's 200+ edge PoPs globally
  • L7 load balancing: HTTP/S routing to multiple regional backend origins
  • SSL offload: TLS termination at the edge PoP, reducing latency
  • WAF: OWASP CRS-based protection at global scale (Standard and Premium SKUs)
  • Caching (CDN): static content cached at PoPs, reducing origin load
  • Health probes to origins: detects unhealthy origins and routes around them
  • URL rewrite and redirect: HTTP → HTTPS redirect, path manipulation

SKUs

SKUCDNWAFPrivate Link to OriginsSecurity Analytics
StandardYesYes (OWASP)NoNo
PremiumYesYes (advanced + managed rulesets)YesYes
Front Door Premium: Private Link to origins With the Premium SKU, you can connect Azure Front Door to backend origins using Private Link — the origin (e.g. an App Service or Storage Account) does not need a public IP. Traffic flows from Microsoft's edge network to the origin over Microsoft's backbone, never over the public internet.

Front Door vs. Application Gateway

Both are L7 load balancers with WAF. The key difference is scope:

  • Application Gateway is regional — deploy one per region, routes traffic within that region.
  • Front Door is global — single deployment routes users worldwide to the nearest regional backend (which may itself be behind an Application Gateway).
Typical production combination Azure Front Door (global edge, WAF, CDN) → Application Gateway (regional L7 routing, per-app WAF rules) → Azure Load Balancer (internal L4, VM distribution) → VMs. Each layer handles what it is optimised for.

5. Traffic Manager

Traffic Manager is fundamentally different from the other three services. It does not proxy traffic — it only controls DNS resolution. When a client queries a Traffic Manager profile, Traffic Manager returns the IP of the "best" endpoint based on the configured routing method. The client then connects directly to that endpoint.

Traffic Manager does NOT inspect or proxy HTTP traffic Because Traffic Manager is DNS-based, it has no visibility into the HTTP request, cannot decrypt TLS, and cannot provide WAF functionality. It is purely a DNS routing mechanism. Failover detection is also limited by DNS TTL — if the TTL is 300 seconds, a failed endpoint may still receive traffic for up to 5 minutes after failure detection.

Routing methods

Routing MethodBehaviourUse Case
Priority Route all traffic to the primary endpoint; fail over to secondary only if primary is unhealthy Active/passive disaster recovery between regions
Weighted Distribute traffic proportionally by weight (e.g. 90/10 or 50/50) A/B testing, gradual migration, blue-green deployments
Performance Route to the endpoint with the lowest latency to the client (based on client IP geolocation) Global app — route each user to the nearest region for lowest latency
Geographic Route traffic from specific countries, regions, or continents to designated endpoints Data residency compliance — European users must be served from EU region
Multivalue Return multiple healthy endpoints in a single DNS response Client-side load balancing for IPv4/IPv6 endpoints
Subnet Map specific client IP address ranges to specific endpoints Serve different content to different network segments (e.g. corporate vs. consumer)

Health probes

Traffic Manager continuously probes endpoint health using HTTP, HTTPS, or TCP checks. When an endpoint fails its health probe, Traffic Manager stops returning its IP in DNS responses — clients are routed to a healthy endpoint instead.

Traffic Manager and HTTPS endpoints Traffic Manager health probes can check HTTPS endpoints, but Traffic Manager itself never terminates TLS — it is purely DNS. Endpoints must be publicly reachable for Traffic Manager health probes to work. This makes Traffic Manager unsuitable for purely internal (VNet-only) endpoints.

6. Decision Guide — Which Service to Use

The AZ-104 exam tests this decision tree repeatedly. Memorise the key differentiators:

Is the workload HTTP/HTTPS only, or does it include other protocols (TCP/UDP, non-HTTP)? ├─ Non-HTTP or mixed protocols → consider Traffic Manager (DNS) or Azure Load Balancer (L4) └─ HTTP/HTTPS ├─ Is the requirement GLOBAL (multiple regions)? │ YES → Azure Front Door (L7 + CDN + WAF at edge) │ or Traffic Manager (DNS-based, non-HTTP compatible, no proxy) └─ REGIONAL only? ├─ Need URL path routing or WAF? → Application Gateway (WAF_v2) └─ Pure L4 TCP/UDP distribution? → Azure Load Balancer (Standard)

Layering services — the enterprise pattern

These services are designed to be combined. A fully resilient global web application might use all four:

LayerServiceResponsibility
1 (outermost) Traffic Manager Global DNS failover: route all traffic to East US; if East US is down, redirect to West Europe
2 Application Gateway (per region) Regional L7 routing: URL-path routing to microservices, WAF protection, SSL offload
3 Azure Load Balancer (internal) Internal L4 distribution: spread HTTP traffic across a pool of backend VMs behind Application Gateway
4 (innermost) VMs / VMSS Application workload
When to combine Front Door with Application Gateway Azure Front Door handles global routing and edge WAF. Application Gateway handles regional URL routing and per-application WAF rule customisation. Use Front Door at the edge for global scale, and Application Gateway regionally when you need per-path routing or application-specific WAF tuning that is too granular for Front Door's global policies.

Check Your Understanding

Click any option to see immediate feedback. Answers reflect real Azure load balancing behaviour.

1. You are deploying a Virtual Machine Scale Set (VMSS) in a region with Availability Zones. You need the load balancer to distribute traffic across VMs in all three zones, with a 99.99% SLA and secure-by-default traffic rules. Which load balancer configuration is correct?

Standard SKU is the only choice here: it is zone-redundant, supports Availability Zones for backend pools, carries a 99.99% SLA, and requires NSG rules to allow inbound traffic (secure by default). Basic SKU does not support AZs and is being retired. Application Gateway is a Layer 7 load balancer — appropriate for HTTP routing, not for VM-level TCP/UDP distribution.

2. Your web application is deployed in a single Azure region. You need to route HTTP requests for /api/* to a pool of API VMs, and requests for /static/* to a storage-backed pool. You also need WAF protection. Which Azure service should you use?

Application Gateway (WAF_v2 SKU) is exactly the right tool: it operates at Layer 7, supports path-based routing rules to direct different URL paths to different backend pools, and includes integrated WAF (OWASP CRS + custom rules). Azure Load Balancer operates at Layer 4 only — it has no concept of URL paths. Traffic Manager is DNS-based and cannot inspect HTTP URLs. Front Door is global — not needed for a single-region scenario.

3. You deploy Traffic Manager with Priority routing. The primary endpoint is in East US and the secondary is in West Europe. An engineer asks whether clients will instantly fail over when East US goes down. What is the accurate answer?

Traffic Manager does not proxy traffic — it only controls DNS resolution. Once a client receives the East US IP via DNS, it connects directly there. Traffic Manager health probes will detect the failure and stop returning the East US IP in new DNS responses, but existing client connections and DNS caches will not be affected until TTL expires. This is the fundamental architectural limitation of DNS-based load balancing.

4. You deploy a Standard Azure Load Balancer with a backend pool of three VMs. One VM consistently appears unhealthy in the load balancer's backend health view, but you can verify that the application is running normally on that VM by connecting directly. The VM's NSG allows inbound on port 80 from the internet. What is the most likely cause?

Azure Load Balancer health probes always originate from the virtual IP 168.63.129.16. If the VM's NSG does not have an inbound rule allowing this source IP (or the AzureLoadBalancer service tag), the health probe packets are dropped. The VM never responds, the Load Balancer marks it unhealthy, and it receives no traffic. The NSG rule must explicitly permit inbound from AzureLoadBalancer service tag on the probe port.

5. Your company runs a global e-commerce platform with regional backends in East US, West Europe, and Southeast Asia. Users worldwide complain of high latency. You need to route each user to the nearest regional backend, provide DDoS + WAF protection at the edge, cache static assets globally, and avoid managing multiple CDN deployments. Which single Azure service best addresses all of these requirements?

Azure Front Door is purpose-built for this exact scenario: it operates on Microsoft's global anycast network for lowest latency, provides WAF protection at the edge, includes integrated CDN caching, and can route to multiple regional origins with health-probe-based failover — all in a single service. Traffic Manager alone cannot provide WAF, CDN, or SSL offload. The multi-service architecture in option C works but requires managing more resources — Front Door consolidates this.

6. Your company operates in the EU and is subject to GDPR data residency requirements: European users must have their requests processed only by EU-region backends, and North American users must only hit North American backends. Which Traffic Manager routing method satisfies this requirement?

Geographic routing is the only routing method that provides deterministic, compliance-grade routing guarantees. Performance routing routes to the lowest-latency endpoint, which is usually geographic but not guaranteed — a European user might route to a North American endpoint if it has lower measured latency. Geographic routing explicitly maps countries, regions, and continents to endpoints, satisfying GDPR and similar data residency requirements.
Primary source for this lesson Azure Load Balancer overview — Microsoft Learn

Also read: Application Gateway overview, Azure Front Door overview, and Traffic Manager routing methods. The load balancing decision guide at learn.microsoft.com/en-us/azure/architecture/guide/technology-choices/load-balancing-overview is the definitive reference for the decision tree.

Questions for your teacher (the AI agent)
This lesson covered the four Azure load balancing services. Explore the architecture further:
  • Walk me through configuring Application Gateway path-based routing with a WAF policy using Bicep.
  • How does Azure Front Door handle origin failover, and what are the health probe configuration options?
  • What is SNAT port exhaustion on Azure Load Balancer and how do outbound rules help prevent it?
  • How do you migrate from Azure Basic Load Balancer to Standard Load Balancer without downtime?
Coming up: Lesson 19 — Azure Monitor: Metrics, Logs & Alerts Having built out your network layer, the next domain shift covers observability. Azure Monitor is the unified monitoring platform for all Azure resources — covering metrics, logs, alerts, and the Azure Monitor Agent. You will learn how to route diagnostic data, configure alert rules, and understand the difference between platform metrics (free, automatic) and resource logs (requires configuration). This is a 10–15% exam domain.