0
votes

We're enforcing HTTPS on our app that runs on Azure App Service using the rewrite rule in the web.config as explained in this article: https://docs.microsoft.com/en-us/azure/app-service-web/web-sites-configure-ssl-certificate#enforce-https-on-your-app

The problem is when we do a swap from a deployment slot to the main production site, the web.config seems to get recreated and the rewrite rule in the web.config disappears.

Any suggestions how we can ensure that this rule will stay in tact after a swap?

1
We use rewrite rules in our web.config and it doesn't get erased. Are you sure you are not using anything extra?albattran
Basically, right after I do a swap, I go into the web.config through the Kudu debug console and all the rewrite is gone. The only explanation I have is that when we publish the app to deployment slot, it's coming from our dev environment and we don't have the rewrite rules locally because that gives us an error locally. So, may be the local version of web.config is overwriting the one on App Service.Sam

1 Answers

1
votes

As I known, the Swap operation for Azure Web Apps is not about copying the content of your web app but more about swapping DNS pointers. For more details, you could refer to this blog for a better understanding about the process of deployment slots.

Based on your scenario for enforcing HTTPS on your app, for a simple way, I assume that you could leverage site extensions to enforce HTTPS both on your production and deployment slot. You could achieve it as follows:

Using KUDU, choose "Site extensions > Gallery":

Also, you could log into Azure portal, choose your web app and click "DEVELOPMENT TOOLS > Extensions", add the "Redirect HTTP to HTTPS" extension as follows:

Additionally, for more details about Azure Site Extensions, you could follow this tutorial.