如何使用PowerShell/CLI删除处于断开连接状态的专用终结点?
删除断开连接状态的Azure专用终结点(PowerShell/CLI方法)
PowerShell 操作步骤
确认专用终结点状态
先验证目标专用终结点的当前状态:Get-AzPrivateEndpoint -Name MyPrivateEndpoint1 -ResourceGroupName TestResourceGroup强制删除断开状态的专用终结点
添加-Force参数跳过状态检查,直接执行删除:Remove-AzPrivateEndpoint -Name MyPrivateEndpoint1 -ResourceGroupName TestResourceGroup -Force关联连接残留时的处理
如果因关联的Private Link Connection残留导致删除失败,先清理连接再删除终结点:# 获取专用终结点对象 $pe = Get-AzPrivateEndpoint -Name MyPrivateEndpoint1 -ResourceGroupName TestResourceGroup # 遍历删除所有关联的连接 foreach ($connection in $pe.PrivateLinkServiceConnections) { Remove-AzPrivateEndpointConnection -ResourceId $connection.Id -Force } # 最终删除专用终结点 Remove-AzPrivateEndpoint -Name MyPrivateEndpoint1 -ResourceGroupName TestResourceGroup -Force
Azure CLI 操作步骤
确认专用终结点状态
查看目标终结点的详细信息及状态:az network private-endpoint show --name MyPrivateEndpoint1 --resource-group TestResourceGroup直接删除断开状态的专用终结点
使用--yes参数跳过确认,执行删除:az network private-endpoint delete --name MyPrivateEndpoint1 --resource-group TestResourceGroup --yes关联连接残留时的处理
若存在残留连接导致删除失败,先清理连接再删除终结点:# 获取关联连接的资源ID connection_id=$(az network private-endpoint show --name MyPrivateEndpoint1 --resource-group TestResourceGroup --query "privateLinkServiceConnections[0].id" -o tsv) # 删除关联连接 az network private-endpoint-connection delete --ids $connection_id --yes # 删除专用终结点 az network private-endpoint delete --name MyPrivateEndpoint1 --resource-group TestResourceGroup --yes
内容的提问来源于stack exchange,提问作者QuestingSoul
相关产品推荐
相关产品推荐

