I need to list azure VMs with associated IP addresses.
When I run
az vm list-ip-addresses --resource-group RG --query "[[].virtualMachine.name, [].virtualMachine.network.publicIpAddresses[0].ipAddress]"
the output is
[
[
"Server1",
"Server2"
],
[
"20.25.36.153",
"20.84.93.126"
]
]
but I need it to be better formated, e.g.
Server1 20.25.36.153
Server2 20.84.93.126
Is there a better az cli way to achieve what I want? Or do I need to somehow flatten this nested array? I tried to do that as well but need some assistance. I use bash.
CodePudding user response:
Here is the command to get the Ip addresses in table format
az vm list-ip-addresses -o table
which will give you the list of VM's in your subscription and you can use -g
to get the list of the particular resource group