Bird
Raised Fist0
Azurecloud~10 mins

Output formats (json, table, tsv) in Azure - Step-by-Step Execution

Choose your learning style10 modes available
Process Flow - Output formats (json, table, tsv)
Start Command
↓
Select Output Format
↓
Format Data
↓
Display Output
↓
End
The command starts, you choose an output format (json, table, or tsv), data is formatted accordingly, then displayed.
Execution Sample
Azure
az vm list --output json
az vm list --output table
az vm list --output tsv
These commands list virtual machines in Azure with output in JSON, table, or TSV formats.
Process Table
StepCommandOutput Format SelectedData FormattingOutput Example
1az vm list --output jsonjsonData structured as JSON objects{"name": "vm1", "location": "eastus"}
2az vm list --output tabletableData formatted into columns and rowsName Location vm1 eastus
3az vm list --output tsvtsvData formatted as tab-separated valuesvm1 eastus
4EndN/AOutput displayed to userOutput shown in chosen format
💡 All commands complete after displaying output in the selected format.
Status Tracker
VariableStartAfter jsonAfter tableAfter tsvFinal
output_formatnonejsontabletsvtsv
formatted_datanoneJSON objectTable stringTSV stringTSV string
Key Moments - 2 Insights
Why does the output look different when I change the format?
Because each format structures data differently: JSON uses nested objects, table uses columns and rows, and TSV uses tabs to separate values, as shown in execution_table rows 1-3.
Can I use these formats for automation?
Yes, JSON and TSV are easier for scripts to parse, while table is better for human reading, as seen in the output examples in execution_table.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what output format is used in step 2?
Ajson
Btable
Ctsv
Dxml
💡 Hint
Check the 'Output Format Selected' column in execution_table row 2.
At which step is data formatted as tab-separated values?
AStep 1
BStep 2
CStep 3
DStep 4
💡 Hint
Look at the 'Data Formatting' column in execution_table.
If you want output easy for scripts to read, which format should you choose?
Ajson
Bplain text
Ctable
Dnone
💡 Hint
Refer to key_moments about automation and execution_table output examples.
Concept Snapshot
Azure CLI output formats:
- json: structured data, good for automation
- table: human-readable columns
- tsv: tab-separated, easy for scripts
Use --output or -o flag to select format
Example: az vm list --output json
Full Transcript
This lesson shows how Azure CLI commands can output data in different formats: JSON, table, or TSV. The command starts, you pick a format, the data is formatted accordingly, then shown. JSON outputs structured data good for automation. Table outputs columns and rows for easy reading. TSV outputs tab-separated values for scripts. Examples include 'az vm list --output json' and others. Understanding these helps you choose the best format for your needs.

Practice

(1/5)
1. What is the main reason to use --output json when running Azure CLI commands?
easy
A. To shorten the output for quick reading
B. To display results in a colorful table format
C. To export data as a tab-separated file
D. To get output that machines and scripts can easily read

Solution

  1. Step 1: Understand output formats purpose

    JSON format is structured and easy for programs to parse and use.
  2. Step 2: Compare with other formats

    Table and TSV are better for humans to read or export, not for machines.
  3. Final Answer:

    To get output that machines and scripts can easily read -> Option D
  4. Quick Check:

    JSON = machine-friendly output [OK]
Hint: JSON output is for scripts; table/TSV is for people [OK]
Common Mistakes:
  • Confusing JSON with table format
  • Thinking TSV is for machine parsing only
  • Assuming JSON output is shorter
2. Which Azure CLI command correctly sets the output format to table?
easy
A. az vm list --output table
B. az vm list --format table
C. az vm list -o json
D. az vm list --output tsv

Solution

  1. Step 1: Identify correct syntax for output option

    The correct flag to set output format is --output or -o.
  2. Step 2: Match the format value

    To get table format, use --output table. Other options are either wrong flag or different formats.
  3. Final Answer:

    az vm list --output table -> Option A
  4. Quick Check:

    Use --output table for table format [OK]
Hint: Use --output or -o followed by format name [OK]
Common Mistakes:
  • Using --format instead of --output
  • Mixing output format names
  • Using -o json when table is needed
3. What will be the output format of this command?
az storage account list -o tsv
medium
A. Tab-separated values without headers
B. A human-friendly table with headers
C. A JSON array of storage accounts
D. An error because tsv is invalid

Solution

  1. Step 1: Understand the -o tsv flag

    The tsv output format produces tab-separated values, useful for scripts or exporting.
  2. Step 2: Check if headers are included

    TSV output usually does not include headers, just raw data separated by tabs.
  3. Final Answer:

    Tab-separated values without headers -> Option A
  4. Quick Check:

    TSV = tab-separated, no headers [OK]
Hint: TSV outputs raw tab-separated data, no headers [OK]
Common Mistakes:
  • Thinking TSV includes headers like table
  • Confusing TSV with JSON format
  • Assuming TSV causes errors
4. You run az group list --output tsv but get an error. What is the most likely cause?
medium
A. You forgot to install Azure CLI
B. The Azure subscription is not set
C. You used the wrong flag; it should be --output table
D. The command does not support TSV output format

Solution

  1. Step 1: Check common prerequisites

    az group list requires an active Azure subscription (via az login and az account set-subscription).
  2. Step 2: Eliminate other causes

    TSV is fully supported, CLI issues prevent az from running at all, wrong flag like table would output table instead of error.
  3. Final Answer:

    The Azure subscription is not set -> Option B
  4. Quick Check:

    No subscription -> auth error on list [OK]
Hint: Run az login & az account set-subscription first [OK]
Common Mistakes:
  • Assuming TSV unsupported (all standard formats work)
  • CLI install confusion (command runs but auth fails)
  • Wrong flag mixup (tsv is valid)
5. You want to export a list of Azure VMs with their names and locations in a format easy to import into Excel. Which command and output format should you use?
hard
A. az vm list --query '[].{Name:name, Location:location}' -o table
B. az vm list --query '[].{Name:name, Location:location}' -o json
C. az vm list --query '[].{Name:name, Location:location}' -o tsv
D. az vm list --output yaml

Solution

  1. Step 1: Choose output format for Excel import

    TSV (tab-separated values) is easy to import into Excel as columns.
  2. Step 2: Use query to select needed fields

    The query selects only VM name and location, simplifying the output.
  3. Final Answer:

    az vm list --query '[].{Name:name, Location:location}' -o tsv -> Option C
  4. Quick Check:

    TSV + query = Excel-friendly export [OK]
Hint: Use -o tsv with query for Excel import [OK]
Common Mistakes:
  • Using JSON which Excel needs extra steps to import
  • Using table which is for human reading only
  • Using unsupported YAML format
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard