Web App Instance Name and ARR affinity Mapping using Function App – Part-1

**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.

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.

image

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 :

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 :

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

           https://blogs.msdn.microsoft.com/kaushal/2016/11/21/azure-app-service-how-to-connect-to-the-kudu-site-of-a-specific-instance/

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

  • Using a Powershell  script located here , you can get the list of Instance name with their ARRAffinity  value , but this has the limitation that :
    • you must run this script every time you want to find the information
    • login with your account 
    • you must be on a machine capable to run PowerShell script and of course
    • you need that powershell script handy

           …………….phew………

Connect to that specific instance.

          If above 3 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.

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

Web App Instance Name and ARR affinity Mapping using Function App – Part-2