Skip to content
Latchkey

How to Deploy to App Service Slots and Swap in Azure Pipelines

Deploy to a staging slot, verify it, then use AzureAppServiceManage@0 to swap slots for a near-zero-downtime release.

Set deployToSlotOrASE: true and a slotName on AzureWebApp@1 to deploy to staging, then run AzureAppServiceManage@0 with action: Swap Slots.

Steps

  • Create a staging deployment slot on the App Service.
  • Deploy to the slot with AzureWebApp@1 and deployToSlotOrASE: true.
  • Run smoke checks against the slot URL.
  • Swap with AzureAppServiceManage@0 and action: Swap Slots.

azure-pipelines.yml

azure-pipelines.yml
pool:
  vmImage: ubuntu-latest
steps:
  - task: AzureWebApp@1
    inputs:
      azureSubscription: 'my-azure-rm'
      appName: 'my-web-app'
      deployToSlotOrASE: true
      resourceGroupName: 'prod-rg'
      slotName: 'staging'
      package: '$(Pipeline.Workspace)/drop/app.zip'
  - task: AzureAppServiceManage@0
    inputs:
      azureSubscription: 'my-azure-rm'
      action: 'Swap Slots'
      WebAppName: 'my-web-app'
      ResourceGroupName: 'prod-rg'
      SourceSlot: 'staging'

Gotchas

  • Slot settings marked as deployment slot settings stay with the slot and do not swap.
  • Warm the staging slot before swapping or the first production requests hit a cold start.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →