Four doors, one decision
Picture a large venue on a busy night. Out on the motorway, long before you arrive, a road sign points you toward the nearest open site — it never sees your car, it only tells you where to go. At the site, a global entrance greets everyone, caches the cloakroom tickets so repeat visitors breeze through, and waves you to the nearest gate. Inside, an usher reads your ticket and sends you to the right section by what is printed on it. And at each section, a simple turnstile just counts bodies through whichever lane is free. Four different helpers, four different jobs — and Azure's traffic services map onto them almost exactly.
The four are Azure Load Balancer, Application Gateway, Front Door, and Traffic Manager. Newcomers memorise four separate product pages and stay confused. Professionals hold a single small grid, because every one of these answers the same two questions differently.
- The grid
- Two axes decide almost everything: scope — does it work globally, across regions, or only within one region — and layer — does it move packets blindly at Layer 4, or read the HTTP request at Layer 7.
Place the four on that grid and the confusion evaporates. Load Balancer is regional and Layer 4 — the turnstile. Application Gateway is regional and Layer 7 — the usher. Front Door is global and Layer 7 — the global entrance with the cloakroom cache. Traffic Manager is global but works at DNS, before any packet arrives — the motorway sign. Learn the grid, not the brochures, and picking the right one becomes a two-question decision rather than a memory test. This half of the class works the two regional cells; Part II opens the global two.
B. Scope and layer are the whole grid: does the service work globally or only within one region, and does it move packets blindly at Layer 4 or read the HTTP request at Layer 7. Every one of the four sits at one intersection of those two questions — memorising four brochures is optional once you hold the two axes.
B. DNS resolution happens before a single packet of the actual request is sent — Traffic Manager answers "which address does this name mean right now" and then steps aside. It never sees the request, so it cannot read HTTP (A), forward packets (C), or cache anything (D); those all require sitting in the path of the traffic, which the motorway sign never does.
Layer 4 and Layer 7, honestly
The layer axis is the one people fudge, so state it plainly. Layer 4 works at the level of TCP and UDP: it sees an incoming connection as an address and a port, and forwards it — fast, cheap, and utterly indifferent to what the traffic contains. Layer 7 works at the level of the HTTP request itself: it can read the URL path, the host header, the cookies, and decide where to send the request based on what it actually is.
- Layer 4 — the turnstile
- Distributes by connection, on IP and port. It cannot tell a request for /images from one for /checkout because it never looks. Blazingly fast, protocol-agnostic, no HTTP smarts.
- Layer 7 — the usher
- Reads the request. It can route /api to one pool and /images to another, terminate TLS, rewrite headers, and inspect content for attacks — at the cost of doing more work per request.
The consequence for design: if you need to route or protect traffic by what the request says — path-based routing, host-based routing, a web firewall — you need Layer 7, which means Application Gateway or Front Door. If you only need to spread raw connections across a set of machines and the content is irrelevant or not even HTTP, Layer 4 Load Balancer is the leaner tool. Reaching for Layer 7 when Layer 4 would do adds cost and latency for smarts you never use; reaching for Layer 4 when you needed to route by URL leaves you unable to do the one thing the job required.
Inside the turnstile: four parts, one path
Choosing Load Balancer is one decision; wiring one is four named parts, and the portal blades present them in exactly this order. A frontend IP configuration is the address the world dials — public for internet traffic, private for tier-to-tier work inside the VNet. A load-balancing rule ties that frontend, on a port, to a backend pool: the set of VM network interfaces the connections spread across. And a health probe decides, interval by interval, which pool members are actually eligible — an instance that fails the probe is not removed from the pool, merely skipped until it answers again. Frontend to rule to pool, with the probe as gatekeeper: every load balancer you will ever debug is these four parts, and the fault is usually in the last of them, which is why Part II's own health-probe section matters as much as it does.
One reality check before you build one. The Standard SKU — the only choice now that Basic retired in September 2025 — is secure by default: a VM behind a Standard load balancer receives nothing, probe traffic aside, until an NSG on its subnet or NIC explicitly allows the port. Wire the frontend, fill the pool, forget the NSG, and you have hung a door on a wall — the turnstile spins while the Class Ten fence behind it stays shut. A healthy fraction of "the load balancer isn't working" tickets are exactly this, and the fix is a rule, not a rebuild.
How the turnstile chooses a lane
Once the pool is healthy, one decision remains: how the load balancer maps an arriving connection to a specific member. By default it hashes a five-tuple — source IP, source port, destination IP, destination port, and protocol — and sends the connection to whichever member the hash lands on. Because the source port changes with every new connection, successive requests from the same client scatter across the pool. That is exactly what you want when the backends hold no per-user state: the load spreads as evenly as the arithmetic allows.
Some workloads cannot tolerate that scatter. A legacy app that keeps a shopping cart in local memory needs every request from one client to return to the same machine, or the cart vanishes mid-checkout. For those, you narrow the hash — session persistence, which Load Balancer offers in three settings.
- None — five-tuple
- The default. Each connection is placed independently, spreading load most evenly. Right for stateless backends, which is the design you should be aiming for anyway.
- Client IP — two-tuple
- Hashes on source and destination IP only, so every connection from one client address returns to the same member. The crutch for backends that keep session state locally.
- Client IP and protocol — three-tuple
- Adds the protocol to the two-tuple. A middle setting: sticky per client and protocol, still coarser than the default's even spread.
Persistence is a compromise, not a feature to reach for. The moment you pin a client to a member you trade even distribution for stickiness: one heavy client now loads a single node, and that node's failure drops that client's session outright rather than merely rebalancing it. The durable fix is the Class Eleven advice — push session state out to a shared store, keep the default five-tuple, and turn on affinity only when an application you cannot change forces your hand.1
Application Gateway and the firewall that reads
Application Gateway is the regional Layer 7 option: it lives inside your VNet, in one region, and distributes HTTP traffic to backends there by path or host. Its most valuable feature is the one worth a section of its own — the Web Application Firewall.
- WAF
- A Web Application Firewall — rules that inspect the content of each HTTP request and block common web attacks, such as SQL injection and cross-site scripting, before they ever reach your application.
This is a different kind of fence from the NSG of Class Ten. An NSG decides whether a connection is allowed by address and port; it cannot see that an allowed request carries a malicious payload in its body. A WAF reads the request and recognises the attack itself — the injection string, the script tag — and refuses it. The two layer together: the NSG controls who may knock, the WAF inspects what they are carrying. Neither replaces the other.
What Layer 7 actually buys: TLS termination and real routing
Reading the request is not one feature but a handful, and each earns the gateway its keep. Because Application Gateway terminates the connection, it can perform SSL/TLS termination — decrypting HTTPS at the gateway so the certificate lives in one managed place instead of on every backend, and the backends are spared the CPU cost of the handshake. Where a rule forbids plaintext on the wire even inside the VNet, the gateway can re-encrypt on the way to the pool — end-to-end TLS — and still inspect the request in the clear in between.
Routing itself is assembled from named parts, and their order is the model to hold. A listener catches traffic on a frontend IP, port, and protocol; a multi-site listener keys on the host header, which is how one gateway fronts several domains at once. A routing rule ties that listener to a backend, and a URL path map lets it split by path — /api/* to one pool, /images/* to another. An HTTP setting then governs how the gateway talks to that pool: port, protocol, cookie-based affinity, timeouts.
- Listener
- Where traffic is caught — frontend IP, port, protocol. A multi-site listener matches on the host header, so one gateway can serve many sites.
- Routing rule + path map
- Sends a listener's traffic to a backend pool, optionally splitting by URL path — the path-based routing Layer 4 cannot do, because it never reads the path.
- Backend pool
- The targets: VMs, scale sets, App Services, or bare IPs. Membership is judged by the gateway's own health probe, exactly as the turnstile judges its pool.
- HTTP setting
- How the gateway reaches the pool — port, protocol, session affinity, and whether traffic is re-encrypted for end-to-end TLS.
The firewall has two moods
The WAF does not have to block to be useful. In Detection mode it logs what its rules would have caught but lets everything through — the setting you run first, so you learn which legitimate requests the rules would wrongly reject before a false positive costs you a customer. In Prevention mode it actually blocks. The rules come from the OWASP Core Rule Set — a managed, versioned ruleset Microsoft maintains — plus any custom rules you add for your own patterns. Switching straight to Prevention without a spell in Detection is how a firewall becomes the outage it was meant to prevent: one false positive on the checkout path blocks real orders, and the graph looks exactly like the attack you were guarding against.2
Application Gateway with WAF is the right tool when the traffic is regional — and that includes being the public front door of an app serving a single geography, just as much as the internal cases: a line-of-business app served to staff, an admin console that never needs a global edge. It sits in the VNet, close to its backends, applying its rules in-region. For Campux that describes the internal admin application exactly, which is why the Gateway stays in the design even after the storefront moves to something bigger — the subject Part II opens with.
The deploy that stopped meaning downtime
A single instance is pegged at 100% while its twin sits idle, because nothing is spreading the traffic. You put a load balancer in front, health-probe the pool, and watch the graph flatten. Then you add a second instance and the app keeps serving straight through a node reboot — the first time a deploy stops meaning downtime for anyone.
Play it through
Four minutes, one sort and one decision. Match four kinds of traffic to their door — a wrong one bounces back and says why — then decide whether a payments microservice even needs a firewall watching it. It plays on its own and stops when it needs your hands.
Examination
Four drills, then two situations. Write your answer before you reveal the reasoning, or the exercise is worthless. Nothing is stored.
A. Raw TCP, one region, no HTTP smarts needed is Layer 4 — Azure Load Balancer, the turnstile. B and C are Layer 7 HTTP services; they would work for web traffic but are the wrong layer for arbitrary TCP and add cost and latency for inspection you do not need. D operates at DNS, not on connections at all. Choosing the leanest tool that does the job is the whole point of the grid: do not pay for Layer 7 when Layer 4 is what the traffic is.
B. Path-based routing, TLS termination, and a WAF are all Layer 7 jobs, and the audience is one region inside one VNet — the exact shape Application Gateway was built for. A is Layer 4 and cannot read a path at all. C reads the request too, but pays for a global edge nobody here needs. D never touches the traffic and could not route by path if it wanted to.
Detection mode, the OWASP Core Rule Set, and reading the request's content. Those are the WAF's real job. The two wrong answers describe other services wearing a disguise: answering at DNS before a packet arrives is Traffic Manager, and caching static content at the edge is Front Door's job, not a regional gateway's. A WAF inspects what is already in front of it; it does not resolve names or hold a cache.
Standard Load Balancer — frontend to pool
1. Frontend IP: 20.51.4.20 : 443 (public)
2. Load-balancing rule: 443 → 443, TCP
3. Backend pool: 3 VMs, all passing their probe
4. Health probe: GET /health, 15s interval
C. Every line shown is fine — the fault is a line that is not there. The Standard SKU is secure by default: it admits nothing to a backend beyond probe traffic until an NSG on the subnet or NIC explicitly allows the port. Wire the frontend, fill the pool, forget the NSG, and the turnstile spins in front of a door that is still locked. A, B and D are all correctly configured; nothing about them is the cause.
Name the mismatch first. The default five-tuple hash spreads connections evenly, including across requests from the same client, because the source port changes with every new connection. A cart kept in one VM's memory needs every request from that shopper to land back on the same VM — the default setting makes no such promise, so carts will vanish mid-checkout the moment a request lands on a different machine than the one holding the state.
The short-term fix is session persistence — Client IP, or Client IP and protocol — which narrows the hash so one client keeps returning to one member. It works, and it is worth turning on before this ships, because a broken cart today is worse than an uneven load tomorrow.
But say plainly that this is a patch, not a design. Pinning a client to a member trades even distribution for stickiness: one heavy shopper now loads a single VM, and that VM's failure drops the cart outright instead of the load simply rebalancing elsewhere. The durable fix is the one from Class Eleven — move the cart into a shared store the app reads from, whichever VM answers — and keep the default five-tuple doing what it does best, spreading load evenly with no client tied to any one machine.
Rule out the shared parts first. The listener catches every request on this gateway regardless of path, and it is plainly healthy — every other route answers. So the fault sits in something wired only to /reports/*, which points straight at the path map entry that was added last week and whatever it points to.
Follow that one path map entry to its own backend pool and HTTP setting — the two things a new rule brings with it that no other path shares. Check first whether the backend pool named for /reports/* actually contains members, and whether those members are passing the gateway's own health probe; a pool with no healthy members answers exactly this way, while paths pointed at a healthy pool keep working.
If the pool is healthy, look at the HTTP setting next — the port and protocol the gateway uses to reach that pool. A setting built for the wrong port, or expecting HTTPS from a backend that only serves HTTP, produces the same silent failure: the gateway forwards the request faithfully and the pool never answers it in a way the gateway can pass back. Whichever part turns up wrong, the diagnosis is finding the one piece a single new rule owns, not touching the listener that was never broken.
Five things worth carrying out of this class
- Two questions place every traffic service: what scope (global or regional) and what layer (L4 packets or L7 requests)?
- Layer 4 forwards connections blindly and fast; Layer 7 reads the HTTP request and can route, terminate TLS, and inspect it.
- A load balancer's four parts are frontend IP, rule, backend pool, and health probe — and the Standard SKU admits nothing until an NSG says so.
- Application Gateway is regional Layer 7 with a WAF — the right fit when traffic needs routing or inspection but never leaves one region.
- Session persistence trades even load for stickiness. Treat it as a bridge for software you cannot change, not a destination.
- Two-tuple and three-tuple affinity solve a real problem but flag a design smell — a backend that cannot survive its requests landing on different instances. Treat persistence as a bridge for software you cannot yet change, not a destination; the durable fix, every time, is to move session state into a shared store so the default distribution can do its job. The exact distribution-mode wording drifts in the portal; check the current Load Balancer docs before quoting the tuple names in a design review. ↩
- Run a WAF in Detection long enough to see a full traffic cycle — a weekly billing run, a marketing send — before switching to Prevention, or the first false positive you meet will be in production. Treat published rule-set version numbers and default-block behaviour as moving targets: Microsoft revises the managed OWASP ruleset periodically, so confirm the active version on the WAF policy rather than trusting a number you memorised. ↩