SlotSwapLocked cloud config_error ai_generated true

Error: Deployment slot 'staging' is locked and cannot be swapped due to 'sticky' configuration settings

ID: cloud/azure-app-service-deployment-slot-sticky

Also available as: JSON · Markdown · 中文
90%Fix Rate
82%Confidence
1Evidence
2025-01-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Azure App Service: Linux active
Runtime: .NET 8 active
Azure CLI: 2.60.0 active

Root Cause

The deployment slot has slot-specific (sticky) app settings or connection strings that are not marked as slot-specific, causing the swap to fail because the settings would move with the slot.

generic

中文

部署槽位具有未标记为槽位特定的粘性应用设置或连接字符串,导致交换失败,因为这些设置会随槽位移动。

Official Documentation

https://learn.microsoft.com/en-us/azure/app-service/deploy-staging-slots

Workarounds

  1. 95% success Mark all slot-specific settings as 'deployment slot settings' using Azure CLI: az webapp config appsettings set --resource-group myRG --name myApp --slot-settings KEY=VALUE
    Mark all slot-specific settings as 'deployment slot settings' using Azure CLI: az webapp config appsettings set --resource-group myRG --name myApp --slot-settings KEY=VALUE
  2. 85% success Temporarily remove all slot-specific settings from the source slot before swapping, then reapply them after swap.
    Temporarily remove all slot-specific settings from the source slot before swapping, then reapply them after swap.
  3. 90% success Use Azure DevOps 'Azure App Service Manage' task with 'Swap with preview' option to validate settings before full swap.
    Use Azure DevOps 'Azure App Service Manage' task with 'Swap with preview' option to validate settings before full swap.

中文步骤

  1. 使用 Azure CLI 将所有槽位特定设置标记为“部署槽位设置”:az webapp config appsettings set --resource-group myRG --name myApp --slot-settings KEY=VALUE
  2. 在交换前临时从源槽位中移除所有槽位特定设置,交换后重新应用。
  3. 使用 Azure DevOps 的“Azure App Service 管理”任务并选择“预览交换”选项,在完全交换前验证设置。

Dead Ends

Common approaches that don't work:

  1. 70% fail

    Recreating the slot does not resolve the underlying sticky settings conflict; the new slot inherits the same configuration unless manually changed.

  2. 90% fail

    The portal enforces the same sticky setting rules; manual swap will fail with the same error if sticky settings are misconfigured.

  3. 95% fail

    Restarting does not affect slot swap logic or configuration settings.