Sam
Sam

Reputation: 30388

Keeping web.config after a swap on Azure App Service

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://learn.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?

Upvotes: 0

Views: 622

Answers (1)

Bruce Chen
Bruce Chen

Reputation: 18465

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.

Upvotes: 1

Related Questions