Some links in this article are affiliate links. We earn a commission at no extra cost to you when you purchase through them. Full disclosure.
Click any command to expand the explanation and examples. Using multiple clouds? See our AWS CLI cheat sheet and AWS vs GCP vs Azure comparison.
🔧 Setup & Auth
az login / configure setup
# Login (opens browser) az loginLogin 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 tableEverything in Azure lives in a resource group. Delete the group = delete everything inside.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
🖥️ Virtual Machines
az vm compute
# List VMs az vm list --output table az vm list -g my-rg --output tableCreate VM
az vm create
—resource-group my-rg
—name my-vm
—image Ubuntu2204
—size Standard_B2s
—admin-username azureuser
—generate-ssh-keysSSH 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_LRSGet 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-linuxCreate 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 mainSet 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 20Deploy
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 tsvList 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
Quick access: Raycast lets you search commands, snippets, and cheat sheets instantly from your keyboard. Free for Mac.
Related: aws cli cheat sheet · gcloud cli cheat sheet · aws vs gcp vs azure