Jérôme S.
Jérôme S.

Reputation: 451

Why Azure app service restarts when swapping slots?

After having this issue in production for a long time, and having read anything i can find about (such as this or this or that), i made a simple test.

  1. Create an empty asp.net website
  2. in Application_Start, send an email or message (i've used PushBullet) to you so you know when the app starts
  3. Create a new app service plan and resource group
  4. Create the website on Azure and publish it
  5. Create a staging deployment slot
  6. Swap staging/production
  7. Publish the website again so both slots have the same version of the website

So i have an empty website, no connectionstring, no slot setting : no change in both slots

When i click swap, I will get notifications that slots restart (at least once each).

Why is this happening ?

UPDATE:

After studying Mohit's answer, i need some more clarifications.

Upvotes: 8

Views: 3847

Answers (1)

Stelios Giakoumidis
Stelios Giakoumidis

Reputation: 2273

I have very similar problem, app is restarted after swapping to production slot and that causes unwanted downtime. After a lot of searching I found the following:

In some cases after the swap the web app in the production slot may restart later without any action taken by the app owner. This usually happens when the underlying storage infrastructure of Azure App Service undergoes some changes. When that happens the application will restart on all VMs at the same time which may result in a cold start and a high latency of the HTTP requests. While you cannot control the underlying storage events you can minimize the effect they have on your app in the production slot. Set this app setting on every slot of the app:

WEBSITE_ADD_SITENAME_BINDINGS_IN_APPHOST_CONFIG: setting this to “1” will prevent web app’s worker process and app domain from recycling when the App Service’s storage infrastructure gets reconfigured.

You can find the whole Ruslany post, that I found very helpful here

Upvotes: 4

Related Questions