App Service slot swap failing — lock conflict or traffic swap error
az webapp deployment slot swap returns a conflict error
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 tableLocks 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 tableCheck locks on the app and slots
Fix
az lock delete --name <LOCK-NAME> --resource-group <RG> --resource-type Microsoft.Web/sites --resource <APP>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.
az webapp deployment slot list --name <APP> --resource-group <RG> --query "[].{name:name,state:state}" -o tableCheck all slot states
az lock list --resource-group <RG> --resource-type Microsoft.Web/sites --resource <APP> --output tableCheck for locks on the app
az webapp deployment slot swap --name <APP> --resource-group <RG> --slot <SOURCE-SLOT>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.
Related runbooks
Same stack, same failure family — worth a skim.
Commands marked READ CHANGE DESTRUCTIVE — never run DESTRUCTIVE commands against production data you cannot restore. Copy → verify → execute.