Azure CLI Tips & Tricks is a collection of small, yet powerful things, that will boost your productivity when working with Microsoft Azure CLI.

Azure CLI provides a bunch of different output formats. By default, it generates output using the json format. Although the default output format is both human-readable and descriptive, it is not the optimal format for every situation. Sometimes you need more focused responses, or you just want a good old ASCII-style table.

As a user, you can choose from the following formats json, jsonc, none, table, tsv, yaml and yamlc.

Use different output formats

You can specify the desired output format for every command using the --output argument, or you use one of the shorter variations like --out and -o.

Azure CLI - Specify the output format explicitly

As an alternative, you can use jsonc or yamlc to get corresponding output with basic colorization, which is helpful when talking about Azure stuff during conference talks, or while explaining things to customers or co-workers.

Azure CLI - Colored YAML output

Another great and typical scenario for overwriting the default output format is when you have a query a unique cloud-resource identifier, which you want to use in constitutive commands. In situations like this, you should consider using the tsv format.

# store the unique Id of an ACR instance for later usage
ACR_ID=$(az acr show -n myacrinstance --query id -o tsv)

echo $ACR_ID
# /subscriptions/111111111111-1111-1111-1111-111111111111/resourceGroups/...

Set the default output format

I use table as my default output format. The default output format can be set by either using the interactivce configuration command az configure, or by editing the Azure CLI configuration file (on unix based systems located at ~/.azure/config) manually, as shown in this quick animation:

Azure CLI - Overwrite the default output format

No matter which format you prefer, make sure to set it as default output format and add the configuration file (~/.azure/config ) to your dotfiles repository.