An Azure service that delivers high availability and network performance to applications.
Hello @ stephane clavel,
Thank you for reaching out to Microsoft Q&A.
You’re right that no single Azure “L4” load-balancer can do cookie-based affinity (that’s an L7 feature), so you have two main Azure options depending on whether your app is HTTP/HTTPS or truly raw TCP:
If your app speaks HTTP/HTTPS on ports 9000 and 9001
• Use Azure Application Gateway (v2)
- Create two HTTP listeners (one on port 9000, one on 9001)
- Point both listeners to the same backend pool (your VMs)
- In each HTTP setting, set the backend port (9000 or 9001) and enable cookie-based affinity
- App Gateway will insert its affinity cookie (
ApplicationGatewayAffinity) on the first response and stick subsequent requests to the same VM+port • Pros: full L7 termination, cookie-based “sticky sessions,” SSL offload, WAF, path-based routing, etc. • Docs: – https://docs.microsoft.com/azure/application-gateway/configuration-overview#cookie-based-affinity
If you need a global front-end or additional edge acceleration, still HTTP/HTTPS:
Use Azure Front Door Standard/Premium
Define an Origin Group with your VMs on ports 9000/9001
- Enable “Cookies-based session affinity” at the Origin Group level -Front Door will add
ASLBSAandASLBSACORScookies to keep traffic on the same origin+port.
Reference list
- Application Gateway cookie-based session affinity https://docs.microsoft.com/azure/application-gateway/configuration-overview#cookie-based-affinity
- Troubleshoot Application Gateway session affinity https://docs.microsoft.com/troubleshoot/azure/application-gateway/how-to-troubleshoot-application-gateway-session-affinity-issues
- Front Door session affinity (Standard/Premium) https://docs.microsoft.com/azure/frontdoor/routing-methods#affinity
- Configure cookie-based affinity in Front Door origins https://docs.microsoft.com/azure/frontdoor/how-to-configure-origin#create-a-new-origin-groupfigure-origin#create-a-new-origin-group
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".