Disable ARR (Application Request Routing) on Microsoft Azure Websites

One feature that was highly demanded on Microsoft Azure platform was the possibility of having affinty with the web server, due to the large number of legacy applications that were developed in this way. For those who don’t know this process is basically allowing a user to keep all requests to the same server in a web farm, which breaks the whole concept of scalability in cloud. However, Microsoft Azure Websites uses Application Request Routing, which is an IIS module that attaches a cookie (ARRAffinity) to your browser, which will enable the affinity with the server that is included encrypted in that cookie:

IE Cookies ARRAffinity

However, there are situations where you don’t want this behavior for your website. To disable it, the easiest way is to modify the web.config file and add the following custom header:

<system.webServer>
  <httpProtocol>
    <customHeaders>
      <add name="Arr-Disable-Session-Affinity" value="true"/>
    </customHeaders>
  </httpProtocol>
</system.webServer>

To verify that the configuration is working properly, just close the browser and come back again to the site. The cookie ARRAffinity and Arr-Disable-Session-Affinity header will disappear of the requests, using the load balancing from now.

Hope this helps.

Happy weekend!