Azure CLI 列出具有关联 public IP 的虚拟机

Azure CLI list VMs with associated public IP

我需要列出具有关联 IP 地址的 Azure VM。

当我运行 az vm list-ip-addresses --resource-group RG --query "[[].virtualMachine.name, [].virtualMachine.network.publicIpAddresses[0].ipAddress]" 输出是

[
  [
    "Server1",
    "Server2"
  ],
  [
    "20.25.36.153",
    "20.84.93.126"
  ]
]

但我需要它的格式更好,例如

Server1 20.25.36.153
Server2 20.84.93.126

是否有更好的 az cli 方法来实现我想要的? 或者我是否需要以某种方式展平这个嵌套数组?我也尝试这样做,但需要一些帮助。我用 bash.

这是获取 table 格式的 IP 地址的命令

az vm list-ip-addresses -o table

这将为您提供订阅中的 VM 列表,您可以使用 -g 获取特定资源组的列表