DevOps | Scripts | Automation

Azure CLI

Output Formats in Azure CLI

To retrieve the output in the AZ CLI console you need to use –output, –out, or -o argument. Azure CLI produces output in the following formats.

AZ CLI Output Format Table

Sr NoOutput FormatDescription
1jsonOutput in the Json format
2jsoncOutput in colored json format
3tableOutput in the ASCII table format with keys
4yamlYaml format, Machine readable format
5tsvOutput in Table separated values with no keys
6noneNo output other than errors and warnings

Different Output Format explained:

Please note below: You can use any of the arguments: –out, –output, or -o and they are case sensitive.

  • json – json is the default output format in the PowerShell. You can change the default output format by configuring AZ CLI settings.
az group list -o json
json format output
  • jsonc – It is the JSON format only but the output will be in the colored theme.
az group list --out jsonc
jsonc format output
  • yaml – We know the Yaml output and input format is popular in the azure pipeline and other scripting languages like Ansible. Azure CLI also supports the YAML as the output format and it is a better output display format than the json because of its rich structured output. It is also called machine-readable language.
az storage account list --output yaml
Yaml format output
  • table – Output will be in the table format. This is the most preferred output way if you have worked on PowerShell because it is easy to read and understand. This format of output doesn’t show the nested object and only a few header items are included.
az storage account list -o table
table format output
  • tsv – TSV is also known as Tab Separated Values. The output is in the values format and keys or table headers don’t show up and the output returns tab and new line separated values. The tsv format output doesn’t print the nested objects like the table output format and this format generally used when we need to retrieve multiple values or single values and store them into a variable or display as the output.
az vm list --output tsv

Please note: Due to the size constraint of the console, the above output displayed is not in a proper manner but whatever mentioned in the output are the values. Whenever we practice more about retrieving data that time we can use the tsv format to retrieve the single or multiple values.