As we all know that Azure App Services uses sticky session by default in case of multiple instance (i.e. load balancing between multiple VM which are running your web application) ,  

those sticky session are maintained by a cookie key named ARRAffinity .

for all the running instances , there is is this unique value and based on this cookie value , browser’s request is redirected to specific instance.

While instances(VMs) has some standard name like : RD00XXXXXXX  , ARRAffinity  is some random alphanumeric .

You can delete these cookie key and try to connect to web app by refreshing url again , you will randomly get any of the ARRAffinity  key and your browser request will connect to the instance associated with that ARRAffinity.

arr affinity f12 developer option cookie

However In day to day app service maintenance and troubleshooting related issue , we may have requirement to connect to only any specific instance , for example manipulating anything on that instance only , Getting memory dump from that instance , killing any specific process on any particular instance  and lot many other requirements.

This requirement has two major challenges :

1. Identifying ARRAffinity cookie for any specific instance .

2. Once we know that ARRAffinity  , then using various available options , connect to that specific instance.

Lets discuss about both these challenges :

Challange 1:   Identifying ARRAffinity cookie for any specific instance  :

There is no out of the box UI  available to get the ARRAffinity of any specific instance  , but here are some options :

Method 1 :

Using steps mentioned in this blog post here, you can get all ARRAffinity  , but you would not get the instance name, so you may try connecting all those instances one by one to verify which one is of your interest.

    many hits & trials involved to reach to correct Instance …so lets move to next method.

Method 2 :

Using  a Powershell  script located here , you can get the      list of Instance name with their ARRAffinity    value , but this has the limitation that :

  1. you must run this script every time you want to find the information
  2. login with your account
  3. you must be on a machine capable to run PowerShell script and of course
  4. you need that powershell script handy

          …………….phew………

Challange 2:   Identifying ARRAffinity cookie for any specific instance  :

Method 1 :

Using Browser extension to edit the cookie , once we know the ARRAffinity   ,  we can connect to specific instance by using recommendation as in this post here.

Method 2 :

Using some Azure App Service extension like Instance Detective by Nazeef Mallick , which will help you to directly connect to any specific instance , but only issue is :

  1. you need to instance this extension to some site
  2. you should have KUDU access for that site
  3. you should have publish profile handy for the app service for which you want to connect to particular instance.

If above  challenges are not the concern , then I would recommend to use above extension ,

but if you are looking for some automated way where you don’t need to do anything manual to find ARRAffinity    & Instance name combination , then this Post is for you.

Goal of this Post :

In this post we shall discuss on some one time activity on your azure portal , which will finally create a Http trigger based Function app   with an URL.

once that is done , passing any web app name & resource group name to that URL will return all running instances of web application as well as their ARRAffinity  Id , so anyone can query this read-only data from any device which is capable of making normal HTTP call , thus any computing device limitation , any script limitation , any manual effort is gone.

So if are excited about this automation ,then continue further part in  my next Post here :