You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用PowerShell/CLI删除处于断开连接状态的专用终结点?

删除断开连接状态的Azure专用终结点(PowerShell/CLI方法)

PowerShell 操作步骤

  1. 确认专用终结点状态
    先验证目标专用终结点的当前状态:

    Get-AzPrivateEndpoint -Name MyPrivateEndpoint1 -ResourceGroupName TestResourceGroup
    
  2. 强制删除断开状态的专用终结点
    添加-Force参数跳过状态检查,直接执行删除:

    Remove-AzPrivateEndpoint -Name MyPrivateEndpoint1 -ResourceGroupName TestResourceGroup -Force
    
  3. 关联连接残留时的处理
    如果因关联的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 操作步骤

  1. 确认专用终结点状态
    查看目标终结点的详细信息及状态:

    az network private-endpoint show --name MyPrivateEndpoint1 --resource-group TestResourceGroup
    
  2. 直接删除断开状态的专用终结点
    使用--yes参数跳过确认,执行删除:

    az network private-endpoint delete --name MyPrivateEndpoint1 --resource-group TestResourceGroup --yes
    
  3. 关联连接残留时的处理
    若存在残留连接导致删除失败,先清理连接再删除终结点:

    # 获取关联连接的资源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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.26 13:20:05