如何从Azure App Service Plan移除不存在的Classic VNET连接?
移除App Service Plan中不存在的VNET连接方案
当Azure Portal里的断开按钮不显示时,只能通过命令行或API强制清理无效的VNET连接,以下是三种可行方案:
方案1:Azure CLI操作
- 打开Azure CLI终端,登录账号:
az login - 切换到目标订阅(替换为你的订阅ID或名称):
az account set --subscription <订阅ID/名称> - 执行移除命令,替换资源组和App Service Plan名称:
az appservice plan vnet integration remove --name <App Service Plan名称> --resource-group <资源组名称> - 如果CLI提示找不到目标VNET,添加
--force参数强制清理无效连接:az appservice plan vnet integration remove --name <App Service Plan名称> --resource-group <资源组名称> --force
方案2:Azure PowerShell操作
- 打开PowerShell,登录Azure账号:
Connect-AzAccount - 切换到目标订阅:
Set-AzContext -Subscription <订阅ID/名称> - 移除无效VNET集成,替换对应的资源组和计划名称:
Remove-AzAppServicePlanVnetIntegration -ResourceGroupName <资源组名称> -Name <App Service Plan名称> - 若遇到报错,添加
-Force参数执行强制移除:Remove-AzAppServicePlanVnetIntegration -ResourceGroupName <资源组名称> -Name <App Service Plan名称> -Force
方案3:Azure REST API操作
如果上述方法都无效,可直接调用REST API清理:
- 获取Azure AD授权令牌:
az account get-access-token --resource https://management.azure.com/ - 发送DELETE请求到以下端点(替换所有占位符):
DELETE https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{serverFarmName}/virtualNetworkConnections/{原经典VNET名称}?api-version=2022-03-01 - 请求头需包含授权信息:
Authorization: Bearer <步骤1获取的令牌> Content-Type: application/json
操作完成后,回到Azure Portal刷新页面,无效的VNET连接条目应该会消失。
内容的提问来源于stack exchange,提问作者Pure.Krome
相关产品推荐
相关产品推荐

