📋 Cheat Sheets

Azure CLI Cheat Sheet — Commands You'll Actually Use


Click any command to expand the explanation and examples.

🔧 Setup & Auth

az login / configure setup
# Login (opens browser)
az login

Login with service principal

az login —service-principal -u APP_ID -p SECRET —tenant TENANT_ID

Check current account

az account show

List subscriptions

az account list —output table

Set active subscription

az account set —subscription “My Subscription”

Set defaults

az configure —defaults location=westeurope group=my-rg

📁 Resource Groups

az group — manage resource groups basics
# List resource groups
az group list --output table

Create

az group create —name my-rg —location westeurope

Delete (and everything in it!)

az group delete —name my-rg —yes —no-wait

List all resources in a group

az resource list —resource-group my-rg —output table

Everything in Azure lives in a resource group. Delete the group = delete everything inside.

🖥️ Virtual Machines

az vm compute
# List VMs
az vm list --output table
az vm list -g my-rg --output table

Create VM

az vm create
—resource-group my-rg
—name my-vm
—image Ubuntu2204
—size Standard_B2s
—admin-username azureuser
—generate-ssh-keys

SSH into VM

ssh azureuser@$(az vm show -g my-rg -n my-vm —show-details —query publicIps -o tsv)

Start / stop / deallocate / delete

az vm start -g my-rg -n my-vm az vm stop -g my-rg -n my-vm az vm deallocate -g my-rg -n my-vm # Stop billing az vm delete -g my-rg -n my-vm —yes

Get public IP

az vm show -g my-rg -n my-vm —show-details —query publicIps -o tsv

Open port

az vm open-port -g my-rg -n my-vm —port 80

stop keeps the VM allocated (still billed). deallocate stops billing.

📦 Storage

az storage storage
# Create storage account
az storage account create -n mystorageacct -g my-rg -l westeurope --sku Standard_LRS

Get connection string

az storage account show-connection-string -n mystorageacct -g my-rg -o tsv

Create container (like an S3 bucket)

az storage container create -n mycontainer —account-name mystorageacct

Upload file

az storage blob upload -f file.txt -c mycontainer -n file.txt —account-name mystorageacct

List blobs

az storage blob list -c mycontainer —account-name mystorageacct —output table

Download

az storage blob download -c mycontainer -n file.txt -f ./downloaded.txt —account-name mystorageacct

Delete

az storage blob delete -c mycontainer -n file.txt —account-name mystorageacct

Upload directory

az storage blob upload-batch -d mycontainer -s ./dist —account-name mystorageacct

🌐 App Service — Web Apps

az webapp webapp
# Create App Service plan
az appservice plan create -n my-plan -g my-rg --sku B1 --is-linux

Create web app

az webapp create -n my-app -g my-rg —plan my-plan —runtime “NODE:20-lts”

Deploy from local folder

az webapp up -n my-app -g my-rg —runtime “NODE:20-lts”

Deploy from GitHub

az webapp deployment source config -n my-app -g my-rg
—repo-url https://github.com/user/repo —branch main

Set environment variables

az webapp config appsettings set -n my-app -g my-rg —settings KEY=value DB_HOST=prod.db.com

View logs

az webapp log tail -n my-app -g my-rg

Restart

az webapp restart -n my-app -g my-rg

List web apps

az webapp list —output table

Get URL

az webapp show -n my-app -g my-rg —query defaultHostName -o tsv

⚡ Azure Functions

az functionapp functions
# Create function app
az functionapp create -n my-func -g my-rg --storage-account mystorageacct \
  --consumption-plan-location westeurope --runtime node --runtime-version 20

Deploy

func azure functionapp publish my-func

List functions

az functionapp function list -n my-func -g my-rg

Set app settings

az functionapp config appsettings set -n my-func -g my-rg —settings KEY=value

View logs

az functionapp log tail -n my-func -g my-rg

🔍 Useful Patterns

Common one-liners tips
# Who am I?
az account show --query user.name -o tsv

List all resources (everything)

az resource list —output table

Find resources by tag

az resource list —tag env=production —output table

List available VM sizes in a region

az vm list-sizes —location westeurope —output table

List available regions

az account list-locations —query ’[].name’ -o tsv

Cost estimate (requires Cost Management)

az costmanagement query —type Usage —timeframe MonthToDate —dataset-filter ’{}’ —scope “/subscriptions/SUB_ID”

Interactive mode (autocomplete!)

az interactive