6 — Connectivity and Load Balancing (AZ-305)
A. Vocabulaire load balancing
A.1 L4 vs L7
| L4 (TCP/UDP) | L7 (HTTP/HTTPS) | |
|---|---|---|
| Voit | IP src→dest:port, aveugle au contenu | Headers, URL, body |
| Capacités | Ultra rapide, tout protocole | Path-based routing, SSL termination, WAF, header rewrite |
| Service | Azure LB | App Gateway, Front Door |
LB (L4) ne sait pas que
/api/ordersdoit aller au backend orders. App Gateway (L7) sait.
A.2 Proxy vs DNS-based
| Proxy (LB, AGW, Front Door) | DNS-based (Traffic Manager) | |
|---|---|---|
| Trafic | Passe par le service | Service répond DNS, client va direct au backend |
| Failover | Instant | Lent (TTL DNS, client cache l'IP) |
| Visibilité trafic | ✅ logs, transformations, WAF | ❌ juste DNS queries |
A.3 TTL DNS
Time To Live = durée pendant laquelle un resolver cache une réponse DNS. Traffic Manager : TTL bas (30s) = failover + rapide mais + de queries DNS = + cher. Default 60s.
A.4 Anycast IP
Une seule IP publique répliquée sur N POPs MS mondial. BGP route vers le POP le plus proche. → Front Door = anycast (Paris → POP Paris ~5ms, Tokyo → POP Tokyo).
A.5 Health probe
LB envoie périodiquement requête au backend (HTTP GET /health ou TCP ping). N échecs → backend marqué unhealthy, exclu du pool. → Best practice : exposer endpoint /health qui check les dépendances (DB, KV).
A.6 Session affinity (sticky)
Garantit qu'une session client revient au même backend (cookie ajouté par LB). Use case : app stateful avec panier en mémoire. → Best practice moderne : app stateless (Redis/DB), pas besoin d'affinity.
A.7 WAF + DRS
Web Application Firewall filtre requêtes malveillantes (SQL injection, XSS) avant backend.
- DRS (Default Rule Set) = règles MS-managed basées sur OWASP Top 10.
- Custom rules : whitelist/blacklist IP, geo-block, rate limit.
- Bot Manager : block scrapers/scanners.
- 2 modes : Detection (log only, tuning 1-2 semaines) → Prevention (block, prod).
B. Azure Load Balancer ⭐ (étoffé)
B.1 C'est quoi
Load balancer L4 (TCP/UDP) Azure natif, régional ou global. Pour balancer le trafic non-HTTP ou très haut débit.
B.2 SKUs
| SKU | Quand |
|---|---|
| Basic | Dev/test (legacy, retraite annoncée — sans SLA, pas de zone-redundancy) |
| Standard ⭐ | Prod (SLA 99.99%, zone-redundant, outbound rules, Cross-region tier possible) |
| Gateway | NVAs tiers (Palo Alto, F5) → chainage de Network Virtual Appliances en HA |
B.3 Public vs Internal
| Public LB | Internal LB (ILB) ⭐ | |
|---|---|---|
| Frontend | IP publique (internet) | IP privée dans VNet |
| Use case | Exposer apps web vers internet | Tier interne (SQL AG listener, AKS internal, microservices) |
B.4 Cross-Region Load Balancer ⭐
Global tier du Standard LB : L4 global avec anycast IP statique, route vers des LBs régionaux en backend.
- Préserve l'IP client.
- Failover instant (proxy, pas DNS).
- Le pendant L4 de Front Door (qui est L7).
- Use case : "TCP/UDP multi-région avec failover instant" (Traffic Manager DNS est trop lent).
B.5 Quand l'utiliser
- L4 régional simple (TCP/UDP, DB cluster, gaming, IoT) → Standard LB Public ou Internal.
- Chainage NVA (Palo Alto, F5) → Gateway LB.
- L4 global non-HTTP avec failover instant → Cross-Region LB.
- Pour L7 HTTP/S → préférer App Gateway (régional) ou Front Door (global).
B.6 Pièges 305
- 🚨 Basic SKU sunset → toujours Standard en prod.
- 🚨 Azure LB = L4 only : pas de SSL termination, pas de WAF, pas de path routing.
- 🚨 Cross-Region LB = L4 global anycast (différent de Traffic Manager qui est DNS).
- 🚨 Public vs Internal : 1 LB = 1 type, choisir selon scope.
C. Application Gateway (SHARED AZ-104 mais critique design)
🎯 Présentation
Load balancer L7 régional avec WAF intégré, path-based routing, SSL termination. Façade HTTPS pour apps déployées dans une région.
🏗️ Architecture
[Public/Private IP] → [Listener] → [Routing rule (priority v2)] → [Backend pool] + [Backend HTTP settings]
- Frontend IP : jusqu'à 4 (IPv4 public+privé, IPv6 public+privé) — dual-stack v2
- Listener : Basic (1 domaine) ou Multi-site ⭐ (N domaines, wildcards
*.contoso.commax 5/listener v2) - Routing rule v2 : priority numérique (1-20000), Basic ou Path-based
- Backend pool : IP/FQDN/VM/VMSS/App Service/AKS via AGIC — pas multi-region
- Backend HTTP settings : port, protocole, cookie affinity, override hostname, custom probe, timeout, connection draining
- Health probe : default
/30s, custom/healthrecommandé - TLS : termination + re-encryption optional. Cert depuis Key Vault ⭐ (rotation auto via MI)
- Subnet dédié
/27min (recommandé/24pour autoscale) - Ports v2 : 1-64999 (sauf 22 si PE, 53)
🎚️ Tiers / SKU (v2)
| SKU | Use case |
|---|---|
| Standard_v2 | L7 sans WAF |
| WAF_v2 ⭐ | L7 + WAF intégré (OWASP CRS 3.2 ou 4.0) |
AGW v1 deprecated, retire avril 2026 → toujours v2 design nouveau.
✅ Quand l'utiliser
- Load balancing L7 régional (1 région) avec WAF
- Path-based routing (
/api/*→ backend A,/static/*→ backend B) - Multi-site (N domaines même IP/port)
- SSL termination + cert via Key Vault
- Pour multi-region L7 → Front Door (AGW est régional uniquement)
D. Azure Traffic Manager
🎯 Présentation
Load balancer global DNS-based : pas un proxy, le client résout un FQDN et tape direct le backend. Idéal pour failover global non-HTTP et backends hors Azure.
🏗️ Architecture
- Profile Traffic Manager → FQDN
*.trafficmanager.net - DNS resolver retourne IP d'un endpoint selon la routing method
- Health probes : HTTP/HTTPS/TCP, intervalle 30s default
- Endpoints supportés : Azure (App Service, Public IP, Cloud Service), External FQDN (autres clouds, on-prem), Nested endpoints
🎚️ Routing methods
| Méthode | Quoi | Cas concret |
|---|---|---|
| Priority ⭐ | Failover Active-Passive | App primaire eastus + standby weu |
| Weighted | Distribution % | Blue/Green : 90% v1, 10% v2 |
| Performance | Latence min (region la + proche) | App SaaS globale |
| Geographic | Routing strict pays/région | Compliance GDPR : users UE → weu (data residency) |
| MultiValue | Renvoie N IPs (client choisit) | App avec retry client-side |
| Subnet | Mapping subnets → endpoints | HQ → backend interne, internet → public |
✅ Quand l'utiliser
- Trafic non-HTTP (TCP/UDP, gaming, IoT custom)
- Backends hors Azure (on-prem, autres clouds)
- Geographic routing strict (compliance data residency)
- Active-Passive cross-region simple
- Pour L7 HTTP + WAF + CDN global → préférer Front Door
🚨 Pièges
- Failover lent : limité par TTL DNS (default 60s) + cache resolver client
- Pas de proxy → pas de SSL termination, WAF, CDN, session affinity
- TTL trop bas (30s) = + de queries DNS = + cher
- Geographic routing utilise IP du DNS resolver (pas du client) → imprécis avec Google DNS 8.8.8.8
- Toujours définir endpoint Default sinon NXDOMAIN
- Probes externes payantes (External endpoints facturés différemment)
E. Azure Front Door
🎯 Présentation
Load balancer L7 global anycast (100+ POPs MS) avec CDN + WAF + SSL offload + Private Link backend. Solution pour exposer des apps multi-region avec latence optimale et sécurité avancée.
🏗️ Architecture
[Clients globaux] → DNS → Front Door anycast IP (POP edge)
↓
[Endpoint = <name>.azurefd.net OR custom]
↓
[Routes (pattern)] → [Origin Group] → [Origins]
(cache hit possible au POP)
| Élément | Quoi | Exemple |
|---|---|---|
| Endpoint | URL globale Front Door | shop-prod.azurefd.net ou www.shop.com |
| Origin group | Pool backends par rôle | og-app-frontend (App Service x3 régions) |
| Origin | Backend individuel + health probe + priority + weight | app-eastus.azurewebsites.net priority=1 |
| Route | Match pattern URL → origin group + caching | /api/* (no cache), /static/* (cache 1h) |
| Rule set | Transformations in-flight | Add header, redirect HTTP→HTTPS, URL rewrite |
| WAF policy | Sécurité Premium | OWASP DRS + custom rules (geo-block, rate limit) |
Routing methods : Latency ⭐ (default, POP le + rapide), Priority (active-passive), Weighted (A/B), Session affinity (sticky cookie). Caching : POP edge, TTL par route, compression Brotli/gzip, purge URL/wildcard.
🎚️ Tiers / SKU (2026)
| Tier | Description |
|---|---|
| Standard | LB global + CDN + custom domain + SSL |
| Premium ⭐ | Standard + WAF Premium + Private Link to backend + Bot Manager + MS-managed rules |
| Legacy, sunset |
✅ Quand l'utiliser
- App multi-region avec routage latence + failover instant (anycast)
- Besoin de CDN global + cache edge
- WAF + Bot Manager + Private Link backend → Premium
- Backends jamais exposés publiquement (zero-trust) → Premium + PE
- Pour single-region L7 sans CDN → préférer App Gateway
Front Door + Private Link (Premium) — zero-trust backend
- Backend privé (App Service+PE, Storage+PE, Internal LB)
- Approval workflow pour accepter la connexion Private Link
- Use case : backend jamais exposé publiquement
F. WAF Policy — ressource indépendante ⭐
F.1 C'est quoi
Ressource Azure indépendante qui contient les règles WAF (managed + custom + bot manager). Attachée à un App Gateway OU à un Front Door (pas les 2).
F.2 Les 2 types de WAF policy + SKUs
| App Gateway WAF policy | Front Door WAF policy | |
|---|---|---|
| Scope | Régional (1 region) | Global (anycast edge) |
| Attaché à | App Gateway tier WAF_v2 | Front Door tier Standard ou Premium |
| Managed rules | OWASP CRS 3.2 / 4.0 | Premium only : Microsoft DRS + Bot Manager. Standard = custom rules only |
| Body inspection | 2 MB | 128 KB |
| Granularité | Listener / path | Endpoint / route |
🚨 1 WAF policy = 1 type de service (AGW ou FD, jamais réutilisable). Defense-in-depth = 2 policies.
F.3 Modes WAF (les 2 plateformes)
- Detection : log seulement → tuning 1-2 semaines
- Prevention : bloque → prod
F.4 Décision WAF
| Besoin | Choix |
|---|---|
| Single-region, backend VNet | App Gateway WAF_v2 + WAF policy |
| Multi-région + managed rules + Bot Manager + CDN | Front Door Premium + WAF policy |
| Standard tier Front Door (custom rules only) | Insuffisant pour OWASP managé → Premium |
| Defense-in-depth bancaire/gov | FD edge + AGW régional = 2 WAF policies |
G. Comparaison Front Door vs Traffic Manager vs App Gateway vs LB
| Azure LB | App Gateway | Front Door | Traffic Manager | |
|---|---|---|---|---|
| Layer | L4 | L7 | L7 | DNS |
| Scope | Régional (+ Cross-region tier global L4) | Régional | Global | Global |
| Proxy | ✅ | ✅ | ✅ | ❌ DNS only |
| WAF | ❌ | ✅ v2 | ✅ Premium | ❌ |
| SSL termination | ❌ | ✅ | ✅ | ❌ |
| URL path routing | ❌ | ✅ | ✅ | ❌ |
| CDN / caching | ❌ | ❌ | ✅ | ❌ |
| Failover speed | Instant | Instant | Instant (anycast) | Lent (TTL DNS) |
| Backend hors Azure | Limité | ✅ FQDN | ✅ | ✅ |
| Non-HTTP support | ✅ | ❌ | ❌ | ✅ |
H. Decision tree consolidé AZ-305
Tu as quoi à load-balancer ?
├─ TCP/UDP non-HTTP (DB, gaming, custom protocol)
│ ├─ Intra-region → Azure LB Standard (L4)
│ ├─ Cross-region failover instant → Cross-Region Load Balancer (L4 global)
│ └─ Cross-region failover OK lent (DNS) → Traffic Manager
│
├─ HTTP/S régional (1 région, SSL, path routing)
│ ├─ Sans WAF → Application Gateway Standard_v2
│ └─ Avec WAF → Application Gateway WAF_v2 + WAF policy
│
├─ HTTP/S global (multi-région, edge, CDN)
│ ├─ Sans WAF avancé → Front Door Standard
│ ├─ Avec WAF managed + Bot Manager → Front Door Premium + WAF policy
│ └─ Backend privé zero-trust (Private Endpoint) → Front Door Premium + Private Link
│
├─ NVA chainage (Palo Alto / F5) → Gateway Load Balancer
│
├─ Failover DNS (Azure + autre cloud / on-prem) → Traffic Manager
│
└─ Defense-in-depth bancaire/gov → Front Door + App Gateway + Firewall
DEMO
Demo Portail — Regional Load Balancer (L4) pour 2 VMs
Load balancers > + Create— Basics : SKU Standard, Tier Regional, Type Public- Frontend IP :
fe-public+ new Public IPpip-lb(zone-redundant) - Backend pools :
bp-vms, config NIC (ou IP), ajoutervm1+vm2 - Inbound rules > Load balancing rule :
- Name
lbr-http, Frontendfe-public, Backendbp-vms - Protocol TCP, Port (listen) 80, Backend port (send-to) 80
- Health probe :
+ Create→ Protocol HTTP, Port 80, Path/health(ou TCP) - Session persistence None, Idle timeout 4 min, TCP reset Enabled
- Floating IP : Disabled (cas standard — voir ci-dessous)
- Name
- Review + Create → test sur IP publique LB
Floating IP (Direct Server Return, DSR) — c'est quoi ?
Par défaut, le LB réécrit l'IP destination vers l'IP privée du backend. Avec Floating IP enabled, l'IP frontend est préservée comme destination → la VM doit avoir une loopback interface configurée avec l'IP frontend. Cas AZ-305 : SQL Server Always On AG Listener, NVAs en cluster, réutiliser même port backend pour plusieurs LB rules. Sinon → Disabled.
Demo Portail — App Gateway v2 + Path-based routing (scénario 2 ACI)
Scénario : 2 ACI
aci-appetaci-web(FQDN public)./app/*→aci-app,/web/*→aci-web,/*(default) →aci-app.
Étape 1 — App Gateway
Application Gateways > + Create→ Basics :- Name
agw-shop, Tier Standard V2 (ou WAF V2), Autoscale min 2 max 10, AZ 1+2+3 - VNet
vnet-agw, Subnetagw-subnetdédié/27min (recommandé/24)
- Name
- Frontends : Type Both (Public+Private possible v2) →
pip-agw-shopzone-redundant - Backends :
+ Add a backend pool:bp-aci-app→ Target type IP address or FQDN =aci-app.eastus.azurecontainer.iobp-aci-web→ FQDNaci-web.eastus.azurecontainer.io
Étape 2 — Routing rule (Listener + Backend targets)
Configuration > Routing rules > + Add a routing rule : Name rr-shop, Priority 100 (v2 : 1-20000, bas = prioritaire)
Sous-onglet Listener :
- Listener name
listener-https, Frontend Public, Frontend port443, Protocol HTTPS - Choose a certificate from Key Vault ⭐ → KV
kv-certs, certcert-shop-contoso-com, MImi-agw(RBAC "Key Vault Certificate User" + "Secrets User") - Listener type : Basic (1 domaine) OU Multi site (N domaines via Host header, jusqu'à 100+ sites, wildcards
*.shop.commax 5/listener) - (Multi-site) Host name :
shop.contoso.com
Sous-onglet Backend targets > Path-based :
- Default backend pool (obligatoire) :
bp-aci-app+ new HTTP settinghs-aci-app + Add multiple targets:- Path
/app/*, Target namepath-app, Backendbp-aci-app, settingshs-aci-app - Path
/web/*, Target namepath-web, Backendbp-aci-web, settingshs-aci-web
- Path
Backend settings (HTTP settings) :
- Backend protocol HTTP (ou HTTPS pour re-encryption), Backend port 80
- Cookie-based affinity : Disable (stateless) ou Enable (sticky)
- Connection draining 30-60s en prod
- Pick host name from backend target : Yes (sinon backend reçoit
Host: shop.contoso.com→ 404) - Use custom probe : Yes → probe
/health, match 200-399 (pas 200 strict pour gérer 302)
Étape 3 — Test
DNS : shop.contoso.com → pip-agw-shop → https://shop.contoso.com/app/... (ACI app), /web/... (ACI web), /... (default = ACI app).
Demo Portail — Traffic Manager Priority (2 VMs)
Traffic Manager profiles > + Create→ Namemyapp-prod(FQDNmyapp-prod.trafficmanager.net), Routing Priority, RGrg-tm→ Review + Createmyapp-prod > Configuration: TTL 30s, Protocol HTTPS, Port 443, Path/health, Interval 30s, Failures tolerated 3 → Savemyapp-prod > Endpoints > + Add(primary) : Type Azure endpoint, Target type Public IP, Targetpip-vm1-eastus, Priority 1+ Add(secondary) : Targetpip-vm2-weu, Priority 2- DNS public :
app.contoso.com CNAME myapp-prod.trafficmanager.net - Test :
nslookup myapp-prod.trafficmanager.net→ IPvm1. Coupervm1→ après ≈ 3×30s probe failures → re-nslookup→ IPvm2
Geographic routing : si method = Geographic, onglet Geographic mapping apparaît sur chaque endpoint pour associer les pays (EU → FR/DE/ES, etc). Traffic Manager utilise l'IP du DNS resolver (pas du client direct) → imprécis avec Google DNS 8.8.8.8. Toujours définir un endpoint Default sinon NXDOMAIN.
Demo Portail — Front Door (profile + endpoint + origin group)
Scénario : 2 App Services
webapp-eastus+webapp-weu(peuvent être dans n'importe quelle région, contrairement à AGW qui est régional). Routing Latency.
Front Door and CDN profiles > + Create > Custom create- Basics : Profile name
afd-shop, Tier Standard (LB+CDN+SSL+custom domain) ou Premium (Standard + Microsoft DRS + Bot Manager + Private Link backend) - Endpoints :
+ Add an endpoint→ nameshop-prod→ URLshop-prod-<hash>.z01.azurefd.net(on peut créer plusieurs endpoints, ex shop/admin/api) - Origin groups :
+ Add→ Nameog-webapp, Health probe/healthHTTPS 30s, Session affinity Disabled - Dans le groupe,
+ Add an origin(1er) :- Origin type : App Services (auto-discover Azure ; types possibles : App Service, Storage, Cloud Service, API Management, App Gateway, Public IP, Static Web App, Container Apps, Container Instances, Spring Apps, Custom pour non-Azure)
- Host name :
webapp-eastus.azurewebsites.net - Origin host header : auto-populé (override possible si backend attend autre host)
- Priority 1, Weight 1000
- Private link : (Premium only)
+ Add an origin(2e) :webapp-weu.azurewebsites.net, Priority 1, Weight 1000- Routes :
+ Add a route→ Nameroute-default, Patterns/*, Accepted protocols HTTPS only (redirect HTTP→HTTPS), Origin groupog-webapp, Caching Disabled pour/api/*, Enabled pour/static/* - Custom domain :
+ Add→www.shop.com→ validate TXT_dnsauth.www.shop.com→ cert FD managed (free) ou KV → DNSwww.shop.com CNAME shop-prod-xxx.azurefd.net
Origin type vs Origin host name : Origin type = catégorie de ressource (App Service, Storage, Custom...). Origin host name = FQDN réel joint par FD. Plusieurs origins dans un origin group = HA + LB. Routing method (Latency/Priority/Weighted) défini au niveau Route, pas origin group.
Demo Portail — Front Door Premium + Private Link backend (zero public)
App Service > webapp-eastus > Networking > Public access: DisabledFront Door Premium > Origin groups > + Add an origin: type App Services, hostwebapp-eastus.azurewebsites.net, Private link Enable, Region East US, sub-resourcesitesApp Service > Networking > Private endpoint connections→ connexion Front Door Pending → Approve- Flux : Client → Front Door (anycast public) → Private Link → App Service privé (aucune Public IP)
Demo Portail — Front Door Premium WAF (depuis fiche 7 retiré)
Front Door and CDN profiles > Create > Custom create→ Tier Premium → Namemyafd→ Review + CreateWAF policies > + Create:- Policy for : Global WAF (Front Door), Tier Premium
- Policy name :
mywaf - Policy mode : Detection (audit avant Prevention)
- Onglet Managed rules :
- + Assign :
Microsoft_DefaultRuleSet 2.1 - + Assign :
Microsoft_BotManagerRuleSet 1.0
- + Assign :
- Onglet Custom rules :
+ Add: NameBlockNorthKorea, Priority 100, MatchRemoteAddrGeoMatchKP, Action Block+ Add: NameRateLimitGlobal, Rate limit rule, Priority 200, threshold 1000/min,RequestUri contains /api/, Action Block
- Onglet Association : associer au profile
myafd(endpoint cible) - Review + Create
- Après 1-2 semaines de tuning →
mywaf > Policy settings > Mode = Prevention > Save
Managed vs Custom rules : Managed (DRS / CRS / Bot Manager) = règles MS auto-updated, désactivables individuellement. Custom = TES règles (match RemoteAddr/RequestUri + action Allow/Block/Log) priority 1-100 évaluées AVANT managed.
Demo Portail — App Gateway WAF v2 (depuis fiche 7 retiré)
Application Gateways > Web Application Firewall > + Create policy- Basics : Policy for Regional WAF (Application Gateway), Name
agwaf, Mode Detection (puis Prevention) - Onglet Managed rules : Rule set OWASP 3.2
- Onglet Custom rules :
+ Add→ NameBlockEU, Priority 100, MatchRemoteAddrGeoMatchFR, DE, ES, Action Block - Onglet Association : associer au App Gateway
myagw - Review + Create
WAF AGW vs FD : 1 policy = AGW OU FD (pas les 2). Defense-in-depth FD+AGW = 2 policies. AGW peut scope la WAF policy listener/path (granularité fine). FD = global au niveau profile/endpoint.