Making changes to the applicationHost.config on Azure App Service


There are a few other resources about this here and here, but as experiences and changes happen, documenting and sharing different perspectives help move projects and people forward.  Additionally, there is no better way to learn than by doing and no better way to remember than by documenting or writing it down. Here is an extension that will make this process eaiser.

As you likely know, not all IIS configuration elements can be modified on the Azure App Services platform.  Here is the most current list of the elements which you can modify that I am aware of.

An example is the weblimits element that can control connectTimeout, headerWaitTime, maxGlobalBandwidth, minBytesPerSecond, etc.. behavior.  As shown in Figure 1, using the IIS Management console on a stand-alone instance of IIS, changing these values is achieved via the Configuration Editor.

Figure 1, changing applicationHost variables, Azure Web App

There is no interface for doing this to an Azure App Service Web App, nor will there ever likely be one, because access to system configuration settings would cause some issues when automated scaling, or manual for that matter, happened.  I.e. system configurations are not replicated to other instances when scaled.  To get around this, the Azure Web App owner, can create an XDT file that includes these system configurations and publish them to the website.  Then, when the website is scaled, the settings can be propagated as required, because theses settings are part of the website configuration and not the system.

I did write a post about configuring the IIS Management Console for use with an App Service here, regardless of that you cannot change all the options, but at least you can look at them and see what the setting are.

For this example, want to decrease the connectionTimeout to 30 seconds.  To achieve this, I performed the following.

  1. Create an applicationHost.xdt file
  2. Create the content for the XDT file
  3. Publish the XDT file
  4. Confirm the change was applied

Create an applicationHost.xdt file

I created a file called applicationHost.xdt and placed it in my Azure App Service Web App project using Visual Studio 2013/15, similar to that show in Figure 2.

Figure 2, adding an applicationHost.xdt file to my project

Create the content for the XDT file

Once created I added the following content, shown in Listing 1, to the applicationHost.xdt file.

Listing 1, reducing the connectionTimeout limit on Azure App Service Web App

<?xml version="1.0"?>
<configuration  xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <system.applicationHost>
    <webLimits xdt:Transform="SetAttributes(connectionTimeout)" 
               connectionTimeout="00:00:30" />
  </system.applicationHost>
</configuration>

Publish the XDT file

I then published the XDT file to my Azure App Service Web App to the /site directory, similar to that shown in Figure 3 using FileZilla.

Figure 3, where to publish the XDT for an Azure Web App

Confirm the change was applied

Before the configuration is visible, a restart of the Azure Web App is required.  Additionally, make an initial request to the website to make sure the worker process is running.  There are certainly numerous options to get the Azure Web App configuration, I used the CMD Debug Console from KUDU, which I have discussed here, shown in Figure 4.  As you can see, after navigating to D:\home\site, I executed the following command: 

type c:\dwasfiles\sites\#1standard\config\applicationHost.config > myAppHostConfig.config

 

Figure 4, how to get the applicationHost.config for an Azure App Service Web App

Once created, the file can be downloaded using an FTP tool or by clicking the download link, illustrated by Figure 5, within KUDU. 

 

 

Figure 5, download the applicationHost.config for you Azure App Service Web App

When I clicked on the download link the configuration file was opened in my browser.  Searching for weblimits resulted in finding the desired element configuration, shown in Figure 6.

Figure 6, finding the XDT element in the extended Azure App Service Web App applicationHost.config file

NOTE:  Not all variables are extendable.  When I find a list of which ones are or are not, I will share.  For example, I do not think the sites\siteDefaults\limits element can be extended.  This was what I initially tried to get to work, without luck, so there is obviously some Azure App Service Web App logic preventing its change and likely protecting me from changing something that would cause problems with my website or for others.

Comments (3)

  1. Anonymous says:

    Hi,

    I can't seem to get this to work – does it work on an Azure free website?

  2. I was able to get this to work.  Are you getting an error or just no seeing the change reflected in the applicationHost.config file?  Are you trying to set the same variable or a different one, maybe the variable you are trying to change is not a supported one.  HTH

  3. Anon says:

    Hi, I’m having an issue of not being able to confirm the change, i cant seem to find my applicationhost.config file. The temp directory shows just to be the D: drive temp, not the actual DWASFiles location?

Skip to main content