我想在 Azure bash 命令行中获取特定虚拟机的公共 IP 地址,到目前为止我已经使用了这个命令,但它返回网络接口信息:
az vm list-ip-addresses -g dev-rg -n dev-vm
返回值:
[
{
"virtualMachine": {
"name": "dev-vm",
"network": {
"privateIpAddresses": [
"10.0.0.5"
],
"publicIpAddresses": [
{
"id": "/subscriptions/*********/resourceGroups/dev-rg/providers/Microsoft.Network/publicIPAddresses/dev-vmPublicIP",
"ipAddress": "52.142.***.***",
"ipAllocationMethod": "Dynamic",
"name": "dev-vmPublicIP",
"resourceGroup": "dev-rg"
}
]
},
"resourceGroup": "dev-rg"
}
}
]
我只需要 IP 地址值,应该是这样的:52.142.xxx.xxx