Azure CLI Cheatsheet
Quick reference for Azure CLI commands covering VMs, storage, identity, functions, AKS, networking, configuration, and SQL databases
61 commands
az vm createCreate a virtual machine
az vm create -g myRG -n myVM --image Ubuntu2204 --admin-username azureuser --generate-ssh-keysaz vm listList virtual machines
az vm list -g myRG -o tableaz vm startStart a virtual machine
az vm start -g myRG -n myVMaz vm stopStop a virtual machine
az vm stop -g myRG -n myVMaz vm deallocateDeallocate a virtual machine
az vm deallocate -g myRG -n myVMaz vm deleteDelete a virtual machine
az vm delete -g myRG -n myVM --yesaz vm resizeResize a virtual machine
az vm resize -g myRG -n myVM --size Standard_DS3_v2az vm showShow VM details
az vm show -g myRG -n myVM -o jsonaz vm list-sizesList available VM sizes
az vm list-sizes -l eastus -o tableaz vm open-portOpen a port on a VM
az vm open-port -g myRG -n myVM --port 80az storage account createCreate a storage account
az storage account create -n mystorageacct -g myRG -l eastus --sku Standard_LRSaz storage account listList storage accounts
az storage account list -g myRG -o tableaz storage account deleteDelete a storage account
az storage account delete -n mystorageacct -g myRG --yesaz storage container createCreate a blob container
az storage container create -n mycontainer --account-name mystorageacctaz storage blob uploadUpload a blob
az storage blob upload -f ./file.txt -c mycontainer -n file.txt --account-name mystorageacctaz storage blob listList blobs in a container
az storage blob list -c mycontainer --account-name mystorageacct -o tableaz storage blob downloadDownload a blob
az storage blob download -c mycontainer -n file.txt -f ./downloaded.txt --account-name mystorageacctaz storage account show-connection-stringShow connection string
az storage account show-connection-string -n mystorageacct -g myRGaz ad user createCreate an Azure AD user
az ad user create --display-name 'John' --password Pa$$w0rd --user-principal-name john@contoso.comaz ad user listList Azure AD users
az ad user list -o tableaz ad sp create-for-rbacCreate a service principal
az ad sp create-for-rbac --name myServicePrincipal --role contributor --scopes /subscriptions/{sub-id}az role assignment createCreate a role assignment
az role assignment create --assignee user@contoso.com --role Reader --scope /subscriptions/{sub-id}az role assignment listList role assignments
az role assignment list --assignee user@contoso.com -o tableaz ad group createCreate an Azure AD group
az ad group create --display-name DevTeam --mail-nickname devteamaz loginLog in to Azure
az loginaz functionapp createCreate a Function App
az functionapp create -g myRG -n myFuncApp --storage-account mystorageacct --consumption-plan-location eastus --runtime nodeaz functionapp listList Function Apps
az functionapp list -g myRG -o tableaz functionapp deleteDelete a Function App
az functionapp delete -g myRG -n myFuncAppaz webapp createCreate a Web App
az webapp create -g myRG -p myPlan -n myWebApp --runtime 'NODE:18-lts'az webapp listList Web Apps
az webapp list -g myRG -o tableaz webapp deployDeploy to a Web App
az webapp deploy -g myRG -n myWebApp --src-path ./app.zip --type zipaz appservice plan createCreate an App Service plan
az appservice plan create -g myRG -n myPlan --sku B1 --is-linuxaz aks createCreate an AKS cluster
az aks create -g myRG -n myAKS --node-count 3 --generate-ssh-keysaz aks get-credentialsGet AKS cluster credentials
az aks get-credentials -g myRG -n myAKSaz aks listList AKS clusters
az aks list -o tableaz aks scaleScale AKS cluster nodes
az aks scale -g myRG -n myAKS --node-count 5az aks deleteDelete an AKS cluster
az aks delete -g myRG -n myAKS --yesaz acr createCreate a container registry
az acr create -g myRG -n myACR --sku Basicaz acr loginLog in to container registry
az acr login --name myACRaz network vnet createCreate a virtual network
az network vnet create -g myRG -n myVNet --address-prefix 10.0.0.0/16az network vnet subnet createCreate a subnet
az network vnet subnet create -g myRG --vnet-name myVNet -n mySubnet --address-prefixes 10.0.1.0/24az network nsg createCreate a network security group
az network nsg create -g myRG -n myNSGaz network nsg rule createCreate an NSG rule
az network nsg rule create -g myRG --nsg-name myNSG -n AllowHTTP --priority 100 --destination-port-ranges 80 --access Allow --protocol Tcpaz network public-ip createCreate a public IP address
az network public-ip create -g myRG -n myPublicIP --sku Standardaz network lb createCreate a load balancer
az network lb create -g myRG -n myLB --sku Standard --frontend-ip-name myFrontEnd --backend-pool-name myBackEndaz network dns zone createCreate a DNS zone
az network dns zone create -g myRG -n contoso.comaz group createCreate a resource group
az group create -n myRG -l eastusaz group listList resource groups
az group list -o tableaz group deleteDelete a resource group
az group delete -n myRG --yes --no-waitaz account listList subscriptions
az account list -o tableaz account setSet active subscription
az account set --subscription 'My Subscription'az configureManage Azure CLI configuration
az configure --defaults group=myRG location=eastusaz resource listList resources
az resource list -g myRG -o tableaz tag createCreate a tag
az tag create --resource-id /subscriptions/{sub-id}/resourceGroups/myRG --tags env=prodaz sql server createCreate a SQL Server
az sql server create -g myRG -n myserver -u sqladmin -p Pa$$w0rd -l eastusaz sql db createCreate a SQL database
az sql db create -g myRG -s myserver -n mydb --service-objective S0az sql db listList SQL databases
az sql db list -g myRG -s myserver -o tableaz sql db deleteDelete a SQL database
az sql db delete -g myRG -s myserver -n mydb --yesaz sql server firewall-rule createCreate a firewall rule
az sql server firewall-rule create -g myRG -s myserver -n AllowMyIP --start-ip-address 203.0.113.1 --end-ip-address 203.0.113.1az cosmosdb createCreate a Cosmos DB account
az cosmosdb create -g myRG -n mycosmosdbaz mysql server createCreate a MySQL Server
az mysql server create -g myRG -n mymysql -u mysqladmin -p Pa$$w0rd -l eastus --sku-name GP_Gen5_2