Share via


Azure App Service: How to connect to the Kudu site of a specific instance

Every Azure Web App has an associated 'scm' service site, which runs Kudu and other Site Extensions.

OVERVIEW:

  • Kudu site can be accessed using either of these credentials
    • Single Sign-on
    • User-level credentials (aka Deployment Credentials)
    • Site-level credentials (aka Publish Profile Credentials)
  • Kudu site always connect to a single instance. E.g. If the site is hosted in an App Service plan which is scaled out to 3 instances, then at any time the KUDU will always connect to one instance only.

Here is a simple request flow of an Azure Web App

image

The front-end uses ARRAffinity cookie to affinitize the request to specific instances. This cookie can be disabled if needed. Refer this on how disable ARR Affinity.

The ARRAffinity cookie is unique and corresponds to an instance. If there are multiple instances, then there will be ARRAffinity cookie corresponding to those many instances. So we can modify the ARRAffinity cookie in the HTTP response and force KUDU to connect to a specific instance.

 

PRE-REQUISITES:

DETERMINE THE ARRAFFINITY COOKIE OF AN INSTANCE

  • Browse to https://resources.azure.com/ (Azure Resource Explorer)
  • In the search window enter the name of the web app. See the following screenshot for reference:

image

  • If there are other Azure resources with similar names, select the resource of type “Microsoft.Web/sites
  • In the left side panel, expand “instances” and this would load all the instances on which the web app is hosted. The instance name displayed is also the value of the ARRAffinity cookie.

image

In the above image the site kaushalp is scaled out to 2 instances. So we have 2 instance id’s which are beginning with:

  1. bac64d
  2. c2a879

CONNECT TO THE KUDU CONSOLE OF A SPECIFIC INSTANCE

  • For this we need to have a tool which allows us to modify the cookies
  • There are multiple ways to do this.
  • I am using EditThisCookie extension in chrome browser. Here is the link to install this: Install EditThisCookie
  • Now, browse to the KUDU site of your web app: https://<sitename>.scm.azurewebsites.net (replace <sitename> with name of the web app)
  • Click on Environment.
  • Under System info, the “instance id” value determines the instance to which the KUDU is connected. In the screenshot below, the kudu site is connected to the instance whose short instance id is bac64d.

image

  • We can use one of the instances value we obtained via ARM explorer to force KUDU to connect to a specific site.
    (Here we are connecting to the instance with the id beginning with “bac64d” )
  • In the browser window click on EditThisCookie clip_image005 icon (next to the Address bar) .

clip_image006

  • In the pop-up, click on ARRAffinity

clip_image007

  • Replace the value with the instance id that you need to connect to

image

  • Click on the tick mark to save the cookie and then refresh the page.

It should have connected to other instance. To confirm, browse to Environment and under System Info the value of Instance id should match the value that was entered earlier.