Why is app service production slot being updated to staging before the slot swap completes?

Jon Bell 0 Reputation points
2024-06-27T16:22:44.24+00:00

I am using Azure App Service deployment pipeline linked to GIT, along with auto swap deployment.

I notice recently that our deployments are creating small blips of downtime in our production slot.

After further investigation, I am seeing that the live production URL app is being restart, with the staging slot settings, before the swap happens. This does not align with the documented behavior of how slot swaps are supposed to happen: https://learn.microsoft.com/en-us/azure/app-service/deploy-staging-slots?tabs=portal#what-happens-during-a-swap

During the deployment, first the new code starts in the staging slot (with prod slot settings), which is expected. But the production slot experiences a recycle (with brief downtime) and is reloaded with the staging slot settings. THEN the swap of URLs happen. That swap SHOULD be happening BEFORE the old instance is restarted with the staging settings, so that is a zero-downtime deploy, but it is happening out of order.

Is anyone else experiencing this? Can I get assistance?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,977 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Andriy Bilous 11,821 Reputation points MVP Volunteer Moderator
    2024-06-30T20:31:43.1233333+00:00

    Hello Jon Bell

    During a swap, the first step is to apply production settings to the staging slot and warm it up. This means that there is a period of time during which both the production slot and the staging slot run the app with production settings - which could be problem

    In order to detect whether my app is running in the staging slot with production settings you can check the WEBSITE_HOSTNAME environment variable. Before the swap this has the value of xxxx.azurewebsites.net on the production slot and xxxx-staging1.azurewebsites.net on the staging slot.

    After the swap is complete, WEBSITE_HOSTNAME will have the value of xxxx-staging1.azurewebsite.net in both slots - so it is impossible to detect when the swap is done using this variable.

    Setting the value of WEBSITE_HOSTNAME is important because it is used for application insights telemetry to derive the cloud_RoleName property.

    https://stackoverflow.com/questions/75684758/azure-deployment-slot-swap-both-slots-use-production-settings
    https://github.com/microsoft/azure-pipelines-tasks/issues/19273

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.