First CLI commands: find, filter and format output

Azure Portal, Hands On15 minutesFreeSteps checked 12 November 2026By Cloud Hands On

In this task you'll find out which Azure CLI command does a job.

Azure CLI commands follow one pattern: az, a group, sometimes a subgroup, then an action, such as az group list or az vm create. Once you know the pattern, you can guess most commands.

Three habits make the CLI much easier: --help on any command, --output table for readable results, and --query to pick out just the fields you want.

Example. Every Monday, Ironbridge Payments' platform team runs one CLI command that lists all VMs with their size and power state as a table, and pastes it into the weekly report.

Before you start

You need: Reader on the subscription. Time: 15 minutes.

Where to look

  1. Cloud Shell
  2. Bash

Steps

  1. Open Cloud Shell (Bash). List your resource groups: az group list --output table.
  2. Ask for help on any command: az group create --help.Help lists every option, and examples at the bottom.
  3. Not sure which command you need? Try az find "create storage account".
  4. Pick out just the names and regions: az group list --query "[].{name:name, region:location}" --output table.
  5. Get a single value for a script: az account show --query id --output tsv.tsv prints plain text with no quotes, which is ideal for putting into a variable.
  6. Save typing by setting a default: az config set defaults.location=uksouth.The CLI warns that the config commands are experimental: that's normal. az config unset defaults.location removes the default again.

Commands

# The pattern: az <group> <action> [options]
az group list --output table

# Help and search
az vm create --help
az find "create storage account"

# Pick fields with --query (JMESPath)
az vm list --query "[].{name:name, size:hardwareProfile.vmSize}" --output table

# One value, ready for a script variable
SUB_ID=$(az account show --query id --output tsv)

Watch out for

Cost
Commands that only list or show things are free. Commands that create things cost the same as creating them in the portal, so read before you press Enter.
Security
Commands with --yes skip the confirmation prompt. Use it in scripts with care, especially with delete.
Common mistakes
Running a command in the wrong subscription. Forgetting quotes around values with spaces. Using --output table in scripts, where tsv or json is more reliable.

Clean up

Nothing to clean up. To undo the default region, run az config unset defaults.location.

Words to know

Command group
The part after az that names a service, such as vm, group or storage.
--output
The format of the results: json (the default), table, tsv or yaml.
--query
A JMESPath expression that picks out and reshapes fields from the results.

Tick off each step and track your progress in the guide.

Open this task in Azure Portal, Hands On

Keep going