sammy34
sammy34

Reputation: 5467

How to prevent Azure App Service from restarting Production slot on the first step of Swap With Preview

We have a .net core app hosted on Azure App Service. It's running on the 64 bit platform, "Always On" is enabled and the Local Cache feature is also enabled.

In addition to the production slot we have a QA slot. The configuration of the QA slot is identical to the production slot. Currently our deployment process involves manually publishing to the QA slot, then manually doing a couple of "sanity" tests and then invoking the first step of the "Swap with Preview" (source QA, destination Production) option from the portal. We then finally invoke the "Complete Swap" option.

Often, but not always (perhaps every second time), the production slot restarts immediately after we invoke the first step of the "Swap with Preview" option. The QA slot never restarts. We know this based on looking at the start time of the relevant processes in Process Explorer in the Kudu Console.

Based on my understanding, the first step of "Swap with Preview" should never affect the production slot. If anything it should only touch the QA slot, so our observations seem backwards to what we'd expect. The restart of the production slot causes around a 15 seconds of unresponsiveness in our live app (at least no 'Service Unavailable' errors are returned though).

This unpredictable behavior makes us hesitant to do deployments during "busy" times because we're "scared" that the production slot will restart and cause delays for our users.

We've tried to use the nice new "Diagnose and Solve Problems" tool to figure out why the production slot is restarting, but this tool doesn't even report the restart (even though it's clear that the app restarted from the Process Explorer in Kudu).

I've tried to reproduce this behavior in an isolated account with a simple web app, to no avail.

My question: can anybody perhaps shed some light on why the production slot might be restarting and/or how one could proceed to diagnose this problem?

Upvotes: 4

Views: 1436

Answers (2)

Erik Steinebach
Erik Steinebach

Reputation: 401

The thing to check are the configuration. If there are differences between the configurations (appsettings/connectionstring, but also other settings), the might restart on swap. At least I have seen weird behavior in those situations.

Try this, export the ARM template of the app service (and the staging slot) and compare all configuration values. Make sure that everything is the same. And see if the problem persists.

Upvotes: 0

Joey Cai
Joey Cai

Reputation: 20097

can anybody perhaps shed some light on why the production slot might be restarting

As you have said, you manually publish deployment process to the QA slot. To utilize the staging slot, update the Git deployment location in Jenkins (your CI) to point to the staging slot’s Git URL. Don’t do this manually, set up Jenkins jobs to do this.

Pressing swap twice does one swap and then another swap, putting the original application code back out. This causes a restart on the production slot and will take down your production application for 1–5 minutes.

For more details, you could refer to this article.

Upvotes: -1

Related Questions