azure-pipelines-tasks: [Question]: Inconsistent duration swap slots using AzureAppServiceManage@0 for Web Apps on dedicated Linux App Service plan

Task name

AzureAppServiceManage@0

Task version

0.228.1

Environment type (Please select at least one enviroment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Windows 2019 datacenter-core-g2

Question

Recently we introduced a staging deployment slot for our Web Apps. So each Web App now has a staging and production slot. All Web Apps run on a dedicated Linux App Service plan (P1v3). Average CPU percentage is between 10 and 20, and average memory percentage around 80.

We now deploy our software to the staging slot and use Azure DevOps task AzureAppServiceManage@0 to swap the staging and production slots. The duration of a swap is not consistent between multiple deployments. Most of the times the duration is between 1m 30s and 2m 30s, but we also have occurrences where a swap takes more than 12 minutes. Especially when multiple Web Apps have a slow swap the pipeline takes a very long time, risking hitting the 60 minutes timeout.

The diagnostics show the swap starts by invoking:

[POST]https://management.azure.com/subscriptions/[redacted]/resourceGroups/Workload.WestEurope/providers/Microsoft.Web/sites/[redacted]/slots/staging/slotsswap?api-version=2016-08-01

Then we see the following call being invoked every 15 seconds, returning a HTTP response 202

[GET]https://management.azure.com/subscriptions/[redacted]/resourceGroups/Workload.WestEurope/providers/Microsoft.Web/sites/[redacted]/slots/staging/operationresults/08021b2d-33b1-4e10-bddb-8ac2b7ebd2cd?api-version=2016-08-01

And eventually after slightly more than 12 minutes this same call returns a HTTP response 200 and the swap is complete.

When we execute a swap in the Azure Portal we never seem to hit a slow swap. Looking at the developer tools in the browser while executing a swap in the portal shows a more current version for the swap API is used. The portal uses slotsswap?api-version=2018-11-01 while AzureAppServiceManage@0 uses api-version=2016-08-01. Could this perhaps explain the inconsistent durations?

I found this question from November 2021 which is almost identical to our situation: https://learn.microsoft.com/en-us/answers/questions/612601/optimizing-cd-pipeline-when-swapping-multiple-web Unfortunately I have not yet been able to verify if swap times are more consistent when using the AzureCLI@2 task as suggested in the answer to this question, because our self hosted build agent currently has no Azure CLI installed.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 27
  • Comments: 41 (3 by maintainers)

Most upvoted comments

Experiencing the same issue. It takes 4-5 minutes to swap slots for a single web app. Tried both AzureAppServiceManage@0 and AzureCLI@2 and although the latter seems to be slightly faster all the results are still in the same ball park.

Any update on this? Our team is having this issue as well. At the very least could the CLI be updated to not hang for 10+ minutes?

We’re having this too, but the bad thing is that sometimes, when the swap fails the staging slot is left corrupted: the envvars from the prod slot get poured into the staging slot. Such a swap should be a transaction, contacted the Azure team on this one but they were to unable or even acknowledge the issue.

I’m observing the exact same behavior as per the above post - my pipeline applies infrastructure as code changes that always contain differences (due to App Service changing the App Insights connection string, another story…) and this leads to swap being stuck approx. 50 % of the time.

Restarting the App Service swap source slot manually in Azure Portal helps. So I added stop + start the source slot in the pipeline and it gets stuck much less frequently.

I’m writing this because some people in this thread mentioned changing configuration properties helped while others state it did not. Changing the configuration causes a restart which may result in the swap working again so it may appear that a configuration change helped but it probably did not. I have all of the properties mentioned in this thread set up already.

Also, I do think this is not an issue with the pipelines task but with Linux App Service itself. The same behavior happens if I use Azure CLI directly.

I want to try some more things in the deployment pipeline like waiting for a bit or polling the URL and see what happens. Will report back if I find anything that helps.

I’m getting this on both P0v3 and P1v3.

@rvvincelli Could you share your sleep durations, please? Have you tried different values? Did you observe issues?

Same here. I have noticed that if I access the slot in a browser, the swap completes shortly after. Is there a bug in the code calling the slot, since it works when I do it manually ?

Same here. Our deployment swap takes up to 11 minutes, with no visible reason (activity logs/output logs).

still facing the same issue on March 2024 with AzureAppServiceManage@0. Switched to AzureCLI@2 and it works fine. My command: az webapp deployment slot swap -g {{your_rs_group}} -n {{app_name}} --slot {{source_slot}} --target-slot {{target_slot}}

Tried this solution but using AzureCLI@2 task takes just as long (20+ minutes) as does the AzureAppServiceManage one. The activity log has no useful data in it: image

We also tried this but with the same result as using AzureAppServiceManage@0. Is there no way of getting more information of what it is actually doing? Our deploy pipeline contains quite a few steps, including creating and deleting a database copy, and the two swaps are the steps that take by far the most time 😃

I think this is related to Azure slots itself. The task just waits until the slot is swapped and this is sometimes taking a ridicilously long time. Its all over the usual discussions like on SO.

I currently randomly get the following output after 20+ minutes:

Starting: Swap Slot api-dd-alerting
==============================================================================
Task         : Azure App Service manage
Description  : Start, stop, restart, slot swap, slot delete, install site extensions or enable continuous monitoring for an Azure App Service
Version      : 0.238.1
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-app-service-manage
==============================================================================
Warming-up slots
Swapping App Service '***' slots - 'deploy' and 'production'
Successfully updated deployment History at https://***-deploy.scm.azurewebsites.net/api/deployments/35831713538731739
Successfully updated deployment History at https://***.scm.azurewebsites.net/api/deployments/35831713538731739
##[error]Error: Failed to swap App Service '***' slots - 'deploy' and 'production'. Error: ExpectationFailed - Cannot swap site slots for site '***' because the 'deploy' slot did not respond to http ping. (CODE: 417)
Finishing: Swap Slot api-dd-alerting

I have experienced that if the Web App tier is low compute, that can be the obstruction in the swap flow. Fixed it by upgrading all the lower tiers… 💸💸

We have P2v3 which I would NOT consider a “low tier”

Hi, please update here if anyone is having any issues.

Hi All,

Please let us know if anyone faces this issue. Please share the logs with system.debug to true in case the issue persists otherwise we’ll proceed to close the issue

Thanks @zdenek-jelinek. I was trying before 2024 and I had to rollback everything, now it seems time to try again.

@FrancescoBonizzi I am consistently seeing swaps take 1:30 - 2 min for P0V3 and P1V3 Linux App Services right after deploying a new artifact into the source slot, whereas previously (i.e. before Nov 2024) they got stuck until the pipeline timed out more often than not.

Another thing helped us here… make sure you do not perform any az config operations right before launching the swap. Some of them (e.g. updating the SCM whitelist) do result in a soft restart of the instances: we noticed great improvements after we added some sleeps in between.

We are also running into this issue. 10+ minutes for a simple app service swap…

Same problem here. @michalkrzych, just a question. You said that you edited this value: WEBSITE_SWAP_WARMUP_PING_PATH, but the default is /. I didn’t understand how you changed it!

Thanks

Apologies for the confusion. I have only added this setting.

BTW. these settings haven’t made an impact on our slot swapping issue. It’s still happening and we are still troubleshooting with Microsoft. Next thing to check is the app start up in the slot, apparently when using vnets, kvs, managed identities, some of the settings aren’t being copied from the parent slot so have to be added manually to ensure the app can start up without errors in order for the slot swapping to succeed.

@DennisJensen95 @goodmanmd

I am having the same issue. We use Azure PowerShell via Octopus Deploy to Start / Stop / Swap slots.

#Start the Staging Slot Start-AzWebAppSlot -ResourceGroupName “#{ResourceGroup}” -Name "#{Website}" -Slot “Staging” #Swap the staging slot into production Switch-AzWebAppSlot -ResourceGroupName "#{ResourceGroup}" -Name “#{Website}” -SourceSlotName "Staging" -DestinationSlotName “Production” #Stop the Staging Slot Stop-AzWebAppSlot -ResourceGroupName "#{ResourceGroup}" -Name “#{Website}” -Slot "Staging"

The behavior is the same, sometimes the swap operation will just time out. Re-running works 99% of the time.

Where is @Microsoft or @Azure support?