mediumIntermediateSymptom-first#app-service#slots#swap#deployment#lock

App Service slot swap failing — lock conflict or traffic swap error

az webapp deployment slot swap returns a conflict error

Likely source:deploymentconfiguration

Focused incident mode — strips away everything but this runbook.

Symptoms

  • az webapp deployment slot swap returns a conflict error
  • Slot swap shows provisioningState = Failed in the activity log
  • Portal slot swap button fails with a deployment slot error

Evidence to grab

Collect these artifacts before you change anything — they prove (or rule out) each cause.

  • Slot provisioning state

    az webapp deployment slot list --name <APP> --resource-group <RG> --query "[].{name:name,state:state}" -o table
  • Locks on the app

    az lock list --resource-group <RG> --resource-type Microsoft.Web/sites --resource <APP> --output table

Diagnostic flow

Run the steps in order, marking each claim confirmed or refuted. The evidence you gather feeds the ranked causes below.

Guided decision tree is ready.

Steps with commands, expected output, and pass/fail branches.

Ranked root causes

Evidence checklist

  • az lock list shows CanNotDelete on the slot
  • Swap error references a lock conflict

Confirm before fixing

az lock list --resource-group <RG> --resource-type Microsoft.Web/sites --resource <APP> --output table
READ

Check locks on the app and slots

Fix

az lock delete --name <LOCK-NAME> --resource-group <RG> --resource-type Microsoft.Web/sites --resource <APP>
DESTRUCTIVE

Remove the lock before swapping

Resolution runbook

Apply from top to bottom after the cause is confirmed. Review every command before running it — risk tags are shown on each.

1
az webapp deployment slot list --name <APP> --resource-group <RG> --query "[].{name:name,state:state}" -o table
READ

Check all slot states

2
az lock list --resource-group <RG> --resource-type Microsoft.Web/sites --resource <APP> --output table
READ

Check for locks on the app

3
az webapp deployment slot swap --name <APP> --resource-group <RG> --slot <SOURCE-SLOT>
CHANGE

Retry the swap after fixing the blocking issue

Prevention

  • Never place resource locks on individual deployment slots.
  • Validate slot-specific settings before swapping.
  • Use deployment slots in a CI/CD pipeline with automated pre-swap tests.
  • Monitor slot swap operations in the activity log.

Commands marked READ CHANGE DESTRUCTIVE — never run DESTRUCTIVE commands against production data you cannot restore. Copy → verify → execute.