How to change applicationHost.config in an Azure web app? I try:
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: Cannot write configuration file due to insufficient permissions
The way to do this is to use XML Document Transforms (XDT) which is referenced here.
For your scenario, create a file called applicationhost.xdt that contains the following:
Then, using an FTP client (I used FileZilla), copy it to the site folder (not wwwroot) for your web app.
Finally, restart your web app which you can do from the Azure portal.
You can verify the changes are applied using the Kudu site extension. After signing into Kudu, go to the Debug Console (CMD) window and drill down into the Logfiles folder and then the Transform folder.
In the Transform folder you will see a "*scm.log" file that will show the transformations. It should look something like this.