Restarting a Specific Azure Web App Instance
The Azure Portal allows you to restart a specific instance in your App Service, but how do you know which one is which? Read on for a helpful tip!
While experiencing issues with a load-balanced Azure web app running three instances, it became apparent that one particular instance of the app was causing issues and needed to be restarted.
Azure does provide an interface to do exactly that, which, at least at the time of this writing (Azure is always changing!), is accessible in the Web App menu under Diagnose and Solve Problems. The resulting page has a search bar, and entering “advanced” reveals the “Advanced Application Restart” tool:
This is also accessible on that same page by navigating underneath that search box through the button labeled “Diagnostic Tools”, then selecting Advanced Application Restart on the following page.
This will reveal a list of all the instances currently running for your Web App, and you can restart each instance using the menu on the right:
However, although this is useful, there appears to be no indication of exactly which instance is which!
ARRAFFINITY
When an Azure web site is opened in a browser, it is assigned to a specific instance, and the identity of that instance is saved in a cookie named “ARRAFINITY”. You can open up the browser tools (F12 if using Chrome or Edge) and view this cookie in the Application Tab:
Each instance will have a different ID, allowing you to differentiate between them. Unfortunately, this is a different value than the one shown in the Advanced Application Restart.
It turns out the value shown there is the Computer Name running the instance, and this name is accessible from the KUDU console, which you can reach from the Web App menu under Advanced Tools:
FYI you can also easily navigate directly to this console if you know your Azure web app URL; if your site’s URL is https://myawesomesite.azurewebsites.net then the console URL would be https://myawesomesite.scm.azurewebsites.net
At the top right of this console is a dropdown menu containing a list of each instance, using the first four characters of the ID:
Simply match up the ID to the instance value in your cookie for the offending site, then click the “Environment” menu item. This will reveal a ton of useful information, not the least of which is the COMPUTERNAME. Scroll down or search for that text and you’ll find the value that corresponds to the instance name, allowing you to restart the appropriate one!
It would be nice if this value was surfaced up to the Azure portal, and if anyone knows a way to do this (or a better way than this), I’d sure love to know about it. Either way, I hope this was helpful, and as always, thanks for reading!
Enjoyed this post and/or found it useful?