Where should <allowedServerVariables> tag live in Azure Website applicationHost.config? Where should <allowedServerVariables> tag live in Azure Website applicationHost.config? azure azure

Where should <allowedServerVariables> tag live in Azure Website applicationHost.config?


You have to create a applicationHost.xdt file under the site folder d:\home\site\applicationHost.xdt with this content:

<?xml version="1.0"?> <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">   <system.webServer>     <rewrite>      <allowedServerVariables>        <add name="HTTP_X_USE_HTTPS" xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)" />      </allowedServerVariables>    </rewrite>  </system.webServer></configuration>

Now you can use the new variable in your web.config file

<?xml version="1.0" encoding="UTF-8"?><configuration>    <system.webServer>        <rewrite>                       <rules>                <rule name="Proxy">                    <serverVariables>                        <set name="HTTP_X_USE_HTTPS" value="{HTTPS}"/>                    </serverVariables>                </rule>            </rules>        </rewrite>    </system.webServer></configuration>

See also https://azure.microsoft.com/en-us/documentation/articles/web-sites-transform-extend/ or https://github.com/projectkudu/kudu/wiki/Xdt-transform-samples