0
0
Azurecloud~5 mins

Output formats (json, table, tsv) in Azure - Commands & Configuration

Choose your learning style9 modes available
Introduction
When you run commands in Azure CLI, you get results in different formats. These formats help you see the information in ways that are easy to read or use in other tools.
When you want to see detailed information in a structured way to use in scripts, use JSON format.
When you want a simple, easy-to-read list on the screen, use table format.
When you want to export data to a spreadsheet or text file, use TSV format.
Commands
This command lists all virtual machines in your subscription and shows the output in JSON format, which is easy to read by programs.
Terminal
az vm list --output json
Expected OutputExpected
[ { "name": "myVM1", "location": "eastus", "resourceGroup": "myResourceGroup", "vmId": "1234abcd-5678-efgh-9012-ijklmnopqrst" }, { "name": "myVM2", "location": "westus", "resourceGroup": "myResourceGroup", "vmId": "abcd1234-5678-efgh-9012-qrstuvwxzy" } ]
--output - Sets the output format of the command
This command lists all virtual machines but shows the output in a clean table format that is easy to read on the screen.
Terminal
az vm list --output table
Expected OutputExpected
Name Location ResourceGroup VMId ------ ---------- --------------- ------------------------------------ myVM1 eastus myResourceGroup 1234abcd-5678-efgh-9012-ijklmnopqrst myVM2 westus myResourceGroup abcd1234-5678-efgh-9012-qrstuvwxzy
--output - Sets the output format of the command
This command lists all virtual machines and shows the output in TSV format, which uses tabs to separate values. This is useful for exporting or processing data in scripts.
Terminal
az vm list --output tsv
Expected OutputExpected
myVM1 eastus myResourceGroup 1234abcd-5678-efgh-9012-ijklmnopqrst myVM2 westus myResourceGroup abcd1234-5678-efgh-9012-qrstuvwxzy
--output - Sets the output format of the command
Key Concept

If you remember nothing else, remember: use the --output flag to choose how Azure CLI shows your command results.

Common Mistakes
Not specifying the --output flag and getting default JSON output when a simpler format is needed
The output may be hard to read or use in scripts if the format is not what you want
Always add --output table or --output tsv when you want easier reading or exporting
Using TSV output but not handling tabs correctly in scripts
Tabs can cause parsing errors if scripts expect spaces or commas
Make sure your script or tool can handle tab-separated values when using TSV format
Summary
Use the --output flag in Azure CLI to control how command results are shown.
JSON format is best for detailed data and scripting.
Table format is easy to read on screen.
TSV format is good for exporting data to files or spreadsheets.