Logo
CloudWithSingh
Back to all field notes
Cheatsheet
Azure
Intermediate

Azure CLI Cheatsheet

Every Azure CLI command you'll actually use, organized by resource type. A practical reference for cloud engineers, administrators, and anyone working in Azure daily.

Parveen Singh
January 28, 2026
12 min read
65 commands
Prerequisites:An Azure account (free tier works)Azure CLI installed (az --version to check)Basic terminal/command line comfort
TLDR

The Azure CLI (az) is the command-line tool for managing Azure resources. This cheatsheet covers 65+ commands organized by resource type — from logging in and managing resource groups to deploying VMs, configuring networking, and monitoring costs. If you're still doing everything in the Azure portal, this is your sign to level up.

⚙️ The Azure CLI Workflow

Every Azure task follows a similar pattern:

logincreate resource groupcreate resourcesmanagemonitorclean up

The portal is great for exploring. The CLI is how you get fast, repeatable, and scriptable. Once you learn these commands, you'll wonder why you ever clicked through the portal for routine tasks.

🚀 Getting Started

Install the CLI, sign in, and make sure you're pointed at the right subscription.

CommandWhat It Does
az --versionShows your installed Azure CLI version
az upgradeUpdates Azure CLI to the latest version
az loginOpens a browser to sign in to your Azure account
az login --tenant <tenant-id>Sign in to a specific Azure AD/Entra ID tenant
az account show --output tableShows your current subscription and tenant
az account list --output tableLists all subscriptions you have access to
az account set --subscription <name-or-id>Switches to a different subscription
az configure --defaults location=canadacentralSets default values so you don't have to repeat them
az interactiveLaunches interactive mode with autocomplete and docs
Pro Tip

First thing after install: run az account show to confirm you're targeting the right subscription. Deploying resources to the wrong subscription is a mistake you only make once. 😅

Cloudlearn - Hands-On AWS &amp; Azure Training
Hands-on LabCloudlearn - Hands-On AWS &amp; Azure Training

Cloudlearn - Hands-On AWS &amp; Azure Training

Hands-on AWS &amp; Azure labs with real-time skill verification. Close skill gaps, track progress, and prove training ROI to leadership.

cloudlearn.ioTry Hands-On Labs

📦 Resource Groups

Every resource in Azure lives in a resource group. Think of it as a folder for related resources.

CommandWhat It Does
az group create --name myRG --location canadacentralCreates a new resource group
az group list --output tableLists all resource groups in the current subscription
az group show --name myRGShows details of a specific resource group
az group exists --name myRGReturns true/false — useful in scripts
az group delete --name myRG --yes --no-waitDeletes a resource group and everything in it
Warning

az group delete deletes EVERYTHING inside the resource group — VMs, databases, storage, all of it. The --yes flag skips the confirmation prompt. Use it carefully. 🔥

🖥️ Virtual Machines

VMs are the bread and butter of Azure infrastructure. These commands cover the full lifecycle.

CommandWhat It Does
az vm create --name myVM -g myRG --image Ubuntu2204 --size Standard_B1s --admin-username azureuser --generate-ssh-keysCreates an Ubuntu VM with SSH keys
az vm list -g myRG --output tableLists all VMs in a resource group
az vm show --name myVM -g myRGShows full details of a VM
az vm start --name myVM -g myRGStarts a stopped VM
az vm stop --name myVM -g myRGStops a VM (OS shuts down but you're still billed 💸)
az vm deallocate --name myVM -g myRGDeallocates the VM — this is what stops billing
az vm restart --name myVM -g myRGRestarts a running VM
az vm delete --name myVM -g myRG --yesDeletes a VM (doesn't delete disks or NICs by default)
az vm resize --name myVM -g myRG --size Standard_B2sChanges the VM size (requires a restart)
az vm list-sizes --location canadacentral --output tableLists all available VM sizes in a region
az vm list-ip-addresses --name myVM -g myRG --output tableShows public and private IPs for a VM
az vm open-port --name myVM -g myRG --port 80 --priority 900Opens a port in the VM's NSG
az vm run-command invoke --name myVM -g myRG --command-id RunShellScript --scripts "apt update"Runs a command inside the VM remotely
Gotcha

az vm stop is NOT the same as az vm deallocate. If you just stop a VM, Azure keeps the compute allocated and you keep paying 💸. Always deallocate to stop charges. This catches people every month.

🌐 Networking

VNets, subnets, NSGs, and public IPs — the foundation of Azure networking.

CommandWhat It Does
az network vnet create --name myVNet -g myRG --address-prefixes 10.0.0.0/16 --subnet-name default --subnet-prefixes 10.0.0.0/24Creates a VNet with one subnet
az network vnet list -g myRG --output tableLists VNets in a resource group
az network vnet subnet create --vnet-name myVNet -g myRG --name backend --address-prefixes 10.0.1.0/24Adds a subnet to an existing VNet
az network vnet subnet list --vnet-name myVNet -g myRG --output tableLists all subnets in a VNet
az network nsg create --name myNSG -g myRGCreates a Network Security Group
az network nsg rule create --nsg-name myNSG -g myRG --name AllowHTTP --priority 100 --destination-port-ranges 80 --access Allow --protocol TcpAdds an inbound rule to allow HTTP traffic
az network public-ip create --name myPublicIP -g myRG --sku StandardCreates a static public IP address
az network nic create --name myNIC -g myRG --vnet-name myVNet --subnet default --network-security-group myNSG --public-ip-address myPublicIPCreates a NIC with all the networking attached
When to Use

When you're setting up a new environment or troubleshooting connectivity. In production, use Terraform or Bicep for networking — but know these commands for quick debugging. 🔍

💾 Storage

Azure Storage Accounts handle blobs, files, tables, and queues.

CommandWhat It Does
az storage account create --name mystorageacct -g myRG --sku Standard_LRSCreates a storage account (name must be globally unique)
az storage account list -g myRG --output tableLists storage accounts
az storage account show-connection-string --name mystorageacct -g myRGGets the connection string (you'll need this for apps) 🔑
az storage container create --name mycontainer --account-name mystorageacctCreates a blob container
az storage blob upload --container-name mycontainer --account-name mystorageacct --file ./myfile.txt --name myfile.txtUploads a file to blob storage
az storage blob list --container-name mycontainer --account-name mystorageacct --output tableLists blobs in a container
az storage blob download --container-name mycontainer --account-name mystorageacct --name myfile.txt --file ./downloaded.txtDownloads a blob to your local machine
Pro Tip

Storage account names must be globally unique, 3-24 characters, and lowercase letters/numbers only. Save yourself the frustration — use a naming convention like st<project><env><region> (e.g., stappdev01cc). 📝

🌍 Web Apps and App Service

Deploy and manage web applications on Azure App Service.

CommandWhat It Does
az appservice plan create --name myPlan -g myRG --sku F1Creates a free-tier App Service Plan
az webapp create --name myapp -g myRG --plan myPlan --runtime "NODE:20-lts"Creates a web app with Node.js runtime
az webapp list -g myRG --output tableLists all web apps
az webapp show --name myapp -g myRGShows web app details
az webapp deploy --name myapp -g myRG --src-path ./app.zip --type zipDeploys a zip package to the web app
az webapp log tail --name myapp -g myRGStreams live application logs to your terminal 📡
az webapp restart --name myapp -g myRGRestarts the web app
az webapp config appsettings set --name myapp -g myRG --settings DB_HOST=mydb.database.azure.comSets an environment variable (app setting)
When to Use

App Service is your go-to for web apps, APIs, and backends that don't need container orchestration. Use the F1 (free) or B1 (basic) SKU for dev/test — scale up when you go to production.

🐳 Azure Container Apps

The modern way to run containers on Azure without managing Kubernetes yourself.

CommandWhat It Does
az containerapp env create --name myEnv -g myRG --location canadacentralCreates a Container Apps environment
az containerapp create --name myapp -g myRG --environment myEnv --image mcr.microsoft.com/k8se/quickstart:latest --target-port 80 --ingress externalDeploys a container with public access
az containerapp list -g myRG --output tableLists all container apps
az containerapp update --name myapp -g myRG --min-replicas 1 --max-replicas 5Configures auto-scaling
az containerapp logs show --name myapp -g myRGShows application logs
Pro Tip

Azure Container Apps has a generous free tier — 180,000 vCPU-seconds and 360,000 GiB-seconds per month. That's enough to run a small app 24/7 at no cost. 🆓

🔐 Identity and Access (Entra ID and RBAC)

Manage users, groups, and role assignments.

CommandWhat It Does
az ad user list --output tableLists all users in your Entra ID (Azure AD) tenant
az ad user create --display-name "Jane Doe" --user-principal-name jane@contoso.com --password "TempP@ss123"Creates a new user
az ad group list --output tableLists all groups
az ad group member add --group "Cloud Admins" --member-id <user-object-id>Adds a user to a group
az role assignment create --assignee jane@contoso.com --role "Contributor" --scope /subscriptions/<sub-id>/resourceGroups/myRGAssigns an RBAC role to a user at the resource group level
az role assignment list -g myRG --output tableLists all role assignments for a resource group
az role definition list --output tableLists all available built-in RBAC roles
Warning

Follow the principle of least privilege. Give Reader or a custom role instead of Contributor unless they genuinely need write access. And never give Owner at the subscription level unless absolutely necessary. 🚨

📊 Monitoring and Logs

Keep an eye on what's happening in your environment.

CommandWhat It Does
az monitor activity-log list -g myRG --output tableShows recent activity (who did what, when)
az monitor metrics list --resource <resource-id> --metric "Percentage CPU" --output tableGets CPU metrics for a resource
az monitor log-analytics workspace create --workspace-name myWorkspace -g myRGCreates a Log Analytics workspace
az monitor diagnostic-settings create --resource <resource-id> --workspace <workspace-id> --name "send-logs" --logs '[{"enabled":true,"category":"allLogs"}]'Sends resource logs to Log Analytics
az advisor recommendation list --output tableGets Azure Advisor recommendations (performance, cost, security)

💰 Cost and Billing

Keep your Azure bill under control.

CommandWhat It Does
az consumption usage list --start-date 2026-01-01 --end-date 2026-01-31 --output tableShows usage details for a date range
az vm deallocate --name myVM -g myRGStop paying for a VM you're not using 💤
az group delete --name testRG --yes --no-waitDelete an entire test environment to stop charges
az advisor recommendation list --category cost --output tableShows cost-saving recommendations from Azure Advisor 💡
Pro Tip

Set a monthly budget alert in the Azure portal (or with az consumption budget create). I've seen students rack up $200+ in a weekend because they forgot to deallocate a VM. A $10 budget alert would have saved them. ⚠️

⚡ Power User Tips

Make the CLI faster and more readable.

🎨 Output Formatting

FlagWhat It Does
--output tableClean, readable table format — my default for everything ✅
--output jsonFull JSON — useful for piping into scripts
--output tsvTab-separated — great for shell scripting
--output yamlYAML format

🔎 JMESPath Queries

Filter and format output without external tools:

CommandWhat It Does
az vm list --query "[].{Name:name, Size:hardwareProfile.vmSize}" --output tableShows only name and size of all VMs
az group list --query "[?location=='canadacentral'].name" --output tsvLists resource groups in a specific region
az vm list -g myRG --query "[?powerState=='VM running'].name" --output tsvLists only running VMs

🛠️ Handy Shortcuts

CommandWhat It Does
az find "create vm"Searches CLI commands — when you know what you want to do but not the command
az extension list-available --output tableLists all available CLI extensions
az extension add --name <extension-name>Installs a CLI extension
az config set core.collect_telemetry=falseDisables telemetry collection
Pro Tip

Add --output table to basically everything when you're working interactively. The default JSON output is useful for scripts but painful to read in a terminal. You can also set it as default: az configure --defaults output=table. 🎯

🧹 Quick Reference: Resource Cleanup

When you're done with a lab or test, clean up to avoid surprise charges:

CommandWhat It Does
az group delete --name myRG --yes --no-waitNukes everything in a resource group 💥
az vm deallocate --ids $(az vm list -g myRG --query "[].id" -o tsv)Deallocates all VMs in a resource group
az resource list -g myRG --output tableLists everything in a resource group (review before deleting) 👀
Warning

Always run az resource list -g myRG before deleting a resource group. Make sure it only contains what you expect. Deleting is permanent — there's no undo. ⛔

What's Next

Bookmark this page

Save it for your next project sprint

Start a project

Apply what you just learned hands-on

Follow on Instagram

Daily cloud tips & behind-the-scenes

Try hands-on labs

Practice in a real cloud environment

Parveen Singh

Parveen Singh

Microsoft Certified Trainer & Cloud Solutions Consultant

Related Field Notes

Found this useful?

Stay in the loop

Weekly cloud insights, no spam

Subscribe

Explore CloudLearn

Hands-on labs & projects

Start Learning

Book Training

Custom cloud training for your team

Get in Touch

On this page