Azure-cli: az vm list-ip-addresses --output tsv displays no output

Created on 11 Oct 2016  路  9Comments  路  Source: Azure/azure-cli

The tsv output for list-ip-addresses displays empty lines of text. It should minimally display the name of the VM and private & public IPs.

Output

All 9 comments

The reason is this command outputs an array with complex object which is more than tsv can handle. the workaround is to be used with --query "[*].virtualMachine.network.publicIpAddresses[0].ipAddress" Regardless, we might need to customize the output, which i think we should, even it hurts a bit on the generality, but the command is hard to use w/o it.

Also we should throw when tsv can't handle the data, and we have done that for table format anyway

@derekbekoe: thoughts?

I would strongly recommend _against_ just generating errors. While we do do that for table, it has also caused problems - especially when combined with the ability to set default output (which essentially made some commands unusable by default if they were not supported by the output format).

Our output formatters should handle all commands that return data in our recommended formats. This specific command does not follow those guidelines (which is not surprising since it predates this particular recommendation :))

The alternative is to effectively require the user to specify which columns to show (in other word, you have to specify --query to project the exact columns that you want to see). There are other products that have solved this problem in this exact way.

My thought on the original issue is this...
tsv format does not have headers so I'd always suggest using --query for this.
e.g.:

$ az vm list-ip-addresses --out tsv
MyVMName    10.8.0.4    123.111.222.333

I get the data but no info on what each column means. I should use query so I can specify the exact rows I want.

Should tsv throw an error if it can't handle the data?
I'd side with @johanste though not a strong opinion here.

Cleaning u old issues, reopen if this is still active.

For anyone else here: az vm list-ip-addresses -n nixos-29606 -g nixos-29606 -o tsv --query '[0].virtualMachine.network.publicIpAddresses[0].ipAddress'

This is a more complete answer using jmesquery, that will work regardless of the number of machines. (shows only the first private, and public address assigned to each vm)

az vm list-ip-addresses --query "[*].virtualMachine.{name: name, nat: network.privateIpAddresses[0], ip: network.publicIpAddresses[0].ipAddress}" -g myresourcegroup -o tsv
Machine-0   10.1.64.6   38.102.175.105
Machine-1   10.1.64.4   38.102.175.104
Machine-2   10.1.64.5   38.102.175.103
WorkNode-0  10.1.64.9   38.102.176.141
WorkNode-1  10.1.64.7   38.102.176.142
WorkNode-2  10.1.64.8   38.102.176.143
WorkNode-3  10.1.64.10  38.102.176.144

Still an issue in 2020. ( azure-cli 2.13.0 )

@qwordy

Was this page helpful?
0 / 5 - 0 ratings