Application Gateway + Azure App Service Session Management

LCS 25 Reputation points
2023-09-04T05:31:25.9733333+00:00

My application is an Azure App Service behind an Application Gateway. As the session information is stored in-memory, I need to have the same session request being routed to the same instance in the App Service. I noted that in Application Gateway, there is this cookie-based-affinity setting and in Azure App Service, there is this ARRAffinity setting. Do I need to set both setting to true ?

Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
1,088 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,019 questions
{count} vote

Accepted answer
  1. Ben Gimblett 4,535 Reputation points Microsoft Employee
    2023-09-04T13:22:19.9866667+00:00

    Hi LCS thanks for the question

    Lets map out an example quickly

    I have a website for contoso partners called "https://partner.contoso.com", using public DNS I point "partner.contoso.com" to my Application Gateway running in Azure.

    Lets assume I want the App Gateway for the WAF feature (It might also be I want to request route too)

    Behind the App Gateway I have an App Service actually hosting the website for "partner.contoso.com" - it's default name is "partnercontoso.azurewebsites.net". Probably this is via a private endpoint (but it doesn't matter for this example)

    My partner website is not stateless so i need to ensure that once the client lands on the site they always go back to the same instance.

    In this scenario enabling session affinity at App Service is enough. Why?

    Because App Service is a two tier architecture all requests to "partnercontoso.azurewebsites.net" are going to hit the app service "front end" - this will decide which instance (worker VM) to relay the client request and the session cookie is required here. And it's for this reason the session setting on App Gateway doesnt make sense. The "app service front end" abstracts the backend pool, app service backend configured in the App gateway is in effect another load balancer.

    This question has been blogged here https://techcommunity.microsoft.com/t5/apps-on-azure-blog/configure-arraffinity-cookie-when-accessing-azure-app-service/ba-p/3842511


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.