How to do Path-Based Load Balancer Affinity with Azure Container Apps?

Philippe Höij
6 min readSep 30, 2023

Azure Container Apps currently (2023–09–30) only support cookie-based session affinity. This is an exploration, that kind of works but is not a 100% solution, some people get weird intermittent timeouts but it also seems to work mostly. Test it well before using!

I want users with a specific path to have a preference to be routed to the same container. This is an experimental workaround until Azure Container Apps releasesRoadmap: URL-based routing.”

This article is one of those “it works for me!”, but documented, hopefully in enough detail to make use of. Beware, there may be dragons to slay around here.

Photo by Marvin Meyer on Unsplash

I guess you also want URL-based routing before it’s released, like me. And make requests with a specific route path segment or similar, go to the same container replica in Azure Container Apps (ACA).

I present a possible solution, without mission-critical formal guarantees or anything, but with good enough stability to make it work for my needs. What I will use it for is not fully released yet, so I’m still hoping I don’t find any additional issues around it.

Routing based on the :instance key

My app keeps an in-memory cache for instance data, which is a relatively expensive…

--

--

Philippe Höij

Passion for the intersection between organisational development, digital infrastructure, computer code and sustainability. Inspiration based sharing.