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

Azure云服务(扩展支持):Get-AzCloudServicePublicIPAddress无返回值

获取Azure Cloud Service (Extended Support)公网IP的PowerShell方法

针对你遇到的Get-AzCloudServicePublicIPAddress无返回结果的问题,是因为该命令主要适配经典云服务,而Cloud Service (Extended Support)采用ARM架构,公网IP关联在负载均衡器的前端配置中,可通过以下两种方法获取:

方法一:从云服务的网络配置中提取IP

  1. 先获取云服务对象:
$cloudService = Get-AzCloudService -ResourceGroupName $resourceGroup -CloudServiceName $serviceName
  1. 提取关联的公网IP资源ID并查询详情:
# 读取负载均衡器前端配置中的公网IP资源ID
$publicIpIds = $cloudService.Properties.NetworkProfile.LoadBalancerConfiguration.FrontendIpConfiguration.PublicIpAddress.Id

# 遍历获取每个公网IP的地址
foreach ($ipId in $publicIpIds) {
    Get-AzPublicIpAddress -ResourceId $ipId | Select-Object Name, IpAddress
}

方法二:直接筛选资源组内关联云服务的公网IP

如果你的公网IP资源带有对应云服务的标签,可直接筛选:

Get-AzPublicIpAddress -ResourceGroupName $resourceGroup | 
    Where-Object { $_.Tags['cloudservice'] -eq $serviceName } |
    Select-Object Name, IpAddress

注:如果标签不存在,可先给关联的公网IP添加cloudservice标签,值设为云服务名称,方便后续筛选。

内容的提问来源于stack exchange,提问作者Patrick

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.03 09:41:31