Azure CLI

Azure CLI Cheatsheet #

Azure CLI is a command-line tool used for managing Azure resources. It can be used to create, manage, and delete Azure resources from the command line or scripts.

Configuration #

Command/OptionExampleDescription
az loginaz loginLog in to your Azure account
az logoutaz logoutLog out of your Azure account
az account listaz account listList all Azure accounts connected to the CLI

Resource Management #

Command/OptionExampleDescription
az group createaz group create --name myResourceGroup --location eastusCreate a new resource group
az group deleteaz group delete --name myResourceGroupDelete a resource group
az group listaz group listList all resource groups
az resource listaz resource listList all resources in a resource group

Virtual Machines #

Command/OptionExampleDescription
az vm createaz vm create --resource-group myResourceGroup --name myVM --image UbuntuLTSCreate a new virtual machine
az vm startaz vm start --resource-group myResourceGroup --name myVMStart a virtual machine
az vm stopaz vm stop --resource-group myResourceGroup --name myVMStop a virtual machine
az vm deallocateaz vm deallocate --resource-group myResourceGroup --name myVMDeallocate a virtual machine
az vm deleteaz vm delete --resource-group myResourceGroup --name myVMDelete a virtual machine
az vm listaz vm listList all virtual machines in a subscription

Storage #

Command/OptionExampleDescription
az storage account createaz storage account create --name mystorageaccount --resource-group myResourceGroup --location eastus --sku Standard_LRSCreate a storage account
az storage account listaz storage account listList all storage accounts in a subscription
az storage account deleteaz storage account delete --name mystorageaccount --resource-group myResourceGroupDelete a storage account

Networking #

Command/OptionExampleDescription
az network vnet createaz network vnet create --name myVnet --resource-group myResourceGroup --address-prefix 10.0.0.0/16Create a virtual network
az network nsg createaz network nsg create --resource-group myResourceGroup --name myNSGCreate a network security group
az network nsg rule createaz network nsg rule create --resource-group myResourceGroup --nsg-name myNSG --name myRule --priority 100 --destination-port-ranges 80Create a security rule in an NSG

SQL Databases #

Command/OptionExampleDescription
az sql server createaz sql server create --name myserver --resource-group myResourceGroup --location eastus --admin-user myadmin --admin-password mypasswordCreate a SQL server
az sql db createaz sql db create --resource-group myResourceGroup --server myserver --name mydb --service-objective S0Create a SQL database
az sql server listaz sql server listList all SQL servers in a subscription
az sql db listaz sql db list --resource-group myResourceGroup --server myserverList all SQL databases in a server

Kubernetes #

Command/OptionExampleDescription
az aks createaz aks create --resource-group myResourceGroup --name myAKSCluster --node-count 1 --enable-addons monitoring --generate-ssh-keysCreate a managed Kubernetes cluster
az aks get-credentialsaz aks get-credentials --resource-group myResourceGroup --name myAKSClusterGet access credentials for a managed Kubernetes cluster
az aks scaleaz aks scale --resource-group myResourceGroup --name myAKSCluster --node-count 3Scale the number of node pools in a managed Kubernetes cluster
az aks deleteaz aks delete --resource-group myResourceGroup --name myAKSClusterDelete a managed Kubernetes cluster

App Services #

Command/OptionExampleDescription
az webapp createaz webapp create --resource-group myResourceGroup --plan myAppServicePlan --name myWebAppCreate a web app
az webapp listaz webapp listList all web apps in a subscription
az webapp deleteaz webapp delete --resource-group myResourceGroup --name myWebAppDelete a web app

This cheatsheet covers the most commonly used Azure CLI commands and options, helping you to manage configurations, resources, virtual machines, storage, networking, SQL databases, Kubernetes, and app services effectively.

Azure CLI

Explore our comprehensive cheatsheets to enhance your knowledge and efficiency. Each cheatsheet provides detailed command options, examples, and descriptions to help you master various tools and technologies.