Use az cli to Query Multiple Fields of Resource Information
Use az cli to query multiple fields of VM information. Here we need to use JMESPath language to implement it.
Typically, we will use az vm show to get the detailed VM information:
However, this table doesn’t contains the VM size. If we remove the -o table argument, the VM size will be shown like this:
Then we can get VM information with queries :
Can we get the powerState and the vmSize at the same time? az vm show -g Linux -n alpha -d --query 'hardwareProfile.vmSize' --query 'powerState' doesn’t work. So how to query multiple fields of the json?
The answer is using
JMESPath language
, putting all the required fields in the []:
References: