Disable Session affinity cookie (ARR cookie) for Azure web apps

2 minute read • By Sunitha Muthukrishna • May 16, 2016

Azure app service allows you to auto scale your web app by dynamically adding web server instances to handle the traffic to your web app. Azure app service uses Application Request Routing IIS Extension to distribute your connecting users between your active instances serving up the content. ARR cleverly identifies the user by assigning them a special cookie (known as an affinity cookie), which allows the service to choose the right instance the user was using to serve subsequent requests made by that user. This means, a client establishes a session with an instance and it will keep talking to the same instance until his session has expired. If you already have a web app on Azure app service , just browse the app and use browser debugger ( click on F12) to see the list of cookies. In the list of cookie you will see ARRAffinity Cookie.

View ARR cookie in browser debugging tools

There are situations where in keeping the affinity is not desired. For example, if you are getting way too many requests from a single user and the requests going to the same web server instance can overload it. If maintaining session affinity is not important and you want better load balancing , it is recommended to disable session affinity cookie. Follow the steps for either Azure portal or Azure resource Explorer to disable the session affinity cookie:

Disable using the Azure Portal

  1. Login to the Azure portal
  2. Browse App Services and select your web application.
  3. Click on Settings > Application Settings. You will find the ARR affinity setting under General Settings Disable ARR cookie in portal
  4. Select off

Disable using Azure Resource Explorer

  1. Go to Azure resource explorer.
  2. Click on subscriptions

    subscription expanded

  3. Click on your azure subscription in which your web app is located. Click on resourcegroups

    subname expanded

  4. Click on the resource group where the web app is located. Click on Microsoft.Web. Click on sites **and Select your web app . Click on **Edit to make your changes .

    edit schema

  5. Search for clientAffinityCookie and set it to false

    set affinitycookie

  6. Click on PUT to save your changes.

    put to save changes

That’s it! You have now disabled the session affinity cookie. You can browse your web app and click on F12 key to access the browser debugger and view the cookies. For an app without Session affinity cookie you will not see ARRAffinity in the list of cookies.

Confirm the cookie is removed

Without the cookie the requests for your web app, will be distributed evenly across all the instances serving your web app content. You can achieve better load balancing for your web app.