Authentication
- az loginInteractive login
- az login --service-principalSP login
- az account listList subscriptions
- az account set -sSet subscription
- az account showCurrent context
Resource Groups
- az group listList groups
- az group createCreate group
- az group deleteDelete group
- az group showGroup details
- az resource listList resources
Virtual Machines
- az vm listList VMs
- az vm createCreate VM
- az vm startStart VM
- az vm stopStop VM
- az vm deallocateDeallocate VM
- az vm deleteDelete VM
Storage
- az storage account listList accounts
- az storage account createCreate account
- az storage blob listList blobs
- az storage blob uploadUpload blob
- az storage blob downloadDownload blob
Create VM Example
# Create resource group
az group create \
--name myResourceGroup \
--location eastus
# Create Ubuntu VM
az vm create \
--resource-group myResourceGroup \
--name myVM \
--image Ubuntu2204 \
--size Standard_B2s \
--admin-username azureuser \
--generate-ssh-keys
# Open port 80
az vm open-port --port 80 --resource-group myResourceGroup --name myVM
AKS (Kubernetes)
# Create AKS cluster
az aks create \
--resource-group myResourceGroup \
--name myAKSCluster \
--node-count 3 \
--enable-addons monitoring \
--generate-ssh-keys
# Get credentials for kubectl
az aks get-credentials \
--resource-group myResourceGroup \
--name myAKSCluster
# Scale cluster
az aks scale --node-count 5 -g myResourceGroup -n myAKSCluster
Networking
- az network vnet listList VNets
- az network vnet createCreate VNet
- az network nsg listList NSGs
- az network public-ip listList IPs
- az network lb listList LBs
Service Principal
# Create service principal
az ad sp create-for-rbac \
--name myServicePrincipal \
--role contributor \
--scopes /subscriptions/{id}
# Login with SP
az login --service-principal \
-u {appId} \
-p {password} \
--tenant {tenant}
Storage Operations
# Create storage account
az storage account create \
--name mystorageaccount \
--resource-group myResourceGroup \
--location eastus \
--sku Standard_LRS
# Create container
az storage container create \
--name mycontainer \
--account-name mystorageaccount
# Upload file
az storage blob upload \
--account-name mystorageaccount \
--container-name mycontainer \
--name myblob --file ./localfile.txt
Output Formats
- -o jsonJSON output
- -o tableTable format
- -o tsvTab-separated
- -o yamlYAML format
- --queryJMESPath query
App Service
- az webapp listList web apps
- az webapp createCreate app
- az webapp deployDeploy code
- az webapp log tailStream logs
- az webapp restartRestart app