Ian Obermiller

Part time hacker, full time dad.

Require HTTPS on Azure


Once you have configured an Azure web role with an SSL certificate and setup the port configuration in the Azure project, you may want to redirect anyone who comes to the http:// version of your page to the secured https:// version. To do so in production, add the following to your Web.Release.config:

    <rewrite xdt:Transform="Insert">
            <rule name="RedirectToHTTPS" stopProcessing="true">
                <match url="(.*)" />
                    <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                <action type="Redirect" url="https://{SERVER_NAME}/{R:1}" redirectType="Permanent" />

Some important things to note:

  • The rewrite node has the attribute xdt:Transform="Insert", because Web.config does not contain that node, so the transform needs to know to insert it.
  • The name attribute of rule must not have spaces; the rule won't work correctly in IIS on Azure with spaces in the name.


  • http://blog.smarx.com/posts/redirecting-to-https-in-windows-azure-two-methods
  • http://forums.asp.net/p/1704544/4527302.aspx/1?Azure+Url+Rewrite+not+working