Azure CLI 2 cheatsheet

Azure CLI 2: Output and queries

4 common Azure CLI 2 tasks.

Choose the output format

Print results as a table. Other formats are json, yaml, tsv and none.

az vm list --output table

Filter results with JMESPath

Select only the fields you need.

az vm list --query "[].{name:name, size:hardwareProfile.vmSize}" --output table

Capture a value in a script

Use tsv output for a plain value without quotes.

ID=$(az vm show -g my-rg -n my-vm --query id --output tsv)

See the underlying requests

Print detailed logs of requests, useful for permission errors.

az vm list --debug

Was this page helpful?