# 错误：部署槽位 'staging' 因“粘性”配置设置而被锁定，无法交换

- **ID:** `cloud/azure-app-service-deployment-slot-sticky`
- **领域:** cloud
- **类别:** config_error
- **错误码:** `SlotSwapLocked`
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

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

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Azure App Service: Linux | active | — | — |
| Runtime: .NET 8 | active | — | — |
| Azure CLI: 2.60.0 | active | — | — |

## 解决方案

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

## 无效尝试

- **** — Recreating the slot does not resolve the underlying sticky settings conflict; the new slot inherits the same configuration unless manually changed. (70% 失败率)
- **** — The portal enforces the same sticky setting rules; manual swap will fail with the same error if sticky settings are misconfigured. (90% 失败率)
- **** — Restarting does not affect slot swap logic or configuration settings. (95% 失败率)
