Azure Cheatsheet
az CLI
Use this Azure reference while you build software engineering projects, review code for technical interview prep, or polish examples for a software engineer resume.
Installation & Auth
# Install (macOS) brew install azure-cli # Install (Ubuntu/Debian) curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash # Install (Windows — winget) winget install Microsoft.AzureCLI # Log in (browser pop-up) az login # Log in — service principal (CI/CD) az login --service-principal \ --username $APP_ID \ --password $CLIENT_SECRET \ --tenant $TENANT_ID # Log in — managed identity (from an Azure resource) az login --identity # Device-code flow (headless) az login --use-device-code
Account & Subscription Management
| Command | What it does |
|---|---|
az account list -o table | List all subscriptions |
az account show | Show active subscription |
az account set --subscription <id|name> | Switch subscription |
az account list-locations -o table | List all regions |
az account get-access-token | Print bearer token (debug) |
az account set --subscription "My Production Sub"Output Formats
# --output / -o controls format az vm list -o table # human-readable table az vm list -o json # full JSON (default when piped) az vm list -o jsonc # JSON with color az vm list -o tsv # tab-separated (script-friendly) az vm list -o yaml # YAML az vm list -o none # suppress output # --query: JMESPath filter az vm list --query "[].{Name:name, RG:resourceGroup, State:powerState}" -o table az storage account list --query "[?location=='eastus'].name" -o tsv
Global Flags
| Flag | Purpose |
|---|---|
--resource-group / -g | Target resource group |
--location / -l | Azure region |
--name / -n | Resource name |
--output / -o | Output format |
--query | JMESPath expression |
--verbose | Show HTTP requests |
--debug | Full debug output |
--only-show-errors | Suppress warnings |
--no-wait | Return immediately, don't block |
--yes / -y | Skip confirmation prompts |
Configuration & Defaults
# Set persistent defaults (avoid repeating -g / -l) az configure --defaults group=myRG location=eastus # View current config az configure --list-defaults # Enable/disable telemetry az configure --collect-telemetry false # Use a specific subscription in a shell session export AZURE_SUBSCRIPTION_ID="<guid>" # az config (newer approach) az config set defaults.group=myRG az config set defaults.location=eastus az config get
Extensions
az extension list # installed extensions az extension list-available -o table # available extensions az extension add --name aks-preview # install extension az extension update --name aks-preview # update az extension remove --name aks-preview # uninstall
Useful Patterns
# Wait for an async operation az vm create ... --no-wait az vm wait --name myVM -g myRG --created # blocks until provisioned # Delete with confirmation suppressed (CI) az group delete --name myRG --yes --no-wait # List all resources in a group az resource list -g myRG -o table # Show a resource by ID az resource show --ids /subscriptions/<sub>/resourceGroups/myRG/providers/... # Tag a resource az resource tag --ids <resource-id> --tags env=prod team=platform # Move resources to another group az resource move --destination-group newRG --ids <resource-id> # Bulk delete by tag (query + pipe) az resource list --tag env=dev --query "[].id" -o tsv | \ xargs az resource delete --ids
Interactive Mode & Autocomplete
# Interactive REPL with autocompletion az interactive # Enable tab-completion (bash) source <(az completion bash) # add to ~/.bashrc # Enable tab-completion (zsh) source <(az completion zsh) # add to ~/.zshrc
Useful Aliases (az alias extension)
az extension add --name alias # ~/.azure/alias [alias] ls = account list -o table rg-ls = group list -o table