ApplicationHost.xdt in Azure Web Apps

How do I change applicationHost.config in Azure Web Application? I'm trying to:

using (ServerManager serverManager = new ServerManager())
{
    Microsoft.Web.Administration.Configuration config = serverManager.GetApplicationHostConfiguration();
    Microsoft.Web.Administration.ConfigurationSection webLimitsSection = config.GetSection("system.applicationHost/webLimits");

    webLimitsSection["connectionTimeout"] = TimeSpan.Parse("00:00:10");
    webLimitsSection["dynamicIdleThreshold"] = 150;
    webLimitsSection["headerWaitTimeout"] = TimeSpan.Parse("00:00:10");
    webLimitsSection["minBytesPerSecond"] = 500;

    serverManager.CommitChanges();
}

      

But catch exception:

Filename: \? \ D: \ Windows \ system32 \ inetsrv \ config \ applicationHost.config Error: Unable to write config file due to insufficient permissions

+3


source to share


1 answer


The way to do this is to use the XML Document Transforms (XDT) referenced here .

For your scenario, create a file named applicationhost.xdt that contains the following:

<configuration  xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <system.applicationHost>
    <webLimits xdt:Transform="SetAttributes(connectionTimeout)"
               connectionTimeout="00:00:10" />
    <webLimits xdt:Transform="SetAttributes(dynamicIdleThreshold)"
           dynamicIdleThreshold="150" />
    <webLimits xdt:Transform="SetAttributes(headerWaitTimeout)"
               headerWaitTimeout="00:00:10" />
    <webLimits xdt:Transform="SetAttributes(minBytesPerSecond)"
               minBytesPerSecond="500" />
  </system.applicationHost>
</configuration>

      

Then, using an FTP client (I used FileZilla), copy it to the site (not wwwroot) folder for your web app.

enter image description here



Finally, reload the web app, which you can do from the Azure portal.

You can check that the changes are being applied using the Kudu site extension. After logging into Kudu, go to the Debug Console (CMD) window and expand to the Logfiles folder and then the Transform folder .

enter image description here

In the Transform folder, you will see the "* scm.log" file showing the transformations. It should look something like this.

enter image description here

+8


source







All Articles