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/Option | Example | Description |
---|
az login | az login | Log in to your Azure account |
az logout | az logout | Log out of your Azure account |
az account list | az account list | List all Azure accounts connected to the CLI |
Resource Management
#
Command/Option | Example | Description |
---|
az group create | az group create --name myResourceGroup --location eastus | Create a new resource group |
az group delete | az group delete --name myResourceGroup | Delete a resource group |
az group list | az group list | List all resource groups |
az resource list | az resource list | List all resources in a resource group |
Virtual Machines
#
Command/Option | Example | Description |
---|
az vm create | az vm create --resource-group myResourceGroup --name myVM --image UbuntuLTS | Create a new virtual machine |
az vm start | az vm start --resource-group myResourceGroup --name myVM | Start a virtual machine |
az vm stop | az vm stop --resource-group myResourceGroup --name myVM | Stop a virtual machine |
az vm deallocate | az vm deallocate --resource-group myResourceGroup --name myVM | Deallocate a virtual machine |
az vm delete | az vm delete --resource-group myResourceGroup --name myVM | Delete a virtual machine |
az vm list | az vm list | List all virtual machines in a subscription |
Storage
#
Command/Option | Example | Description |
---|
az storage account create | az storage account create --name mystorageaccount --resource-group myResourceGroup --location eastus --sku Standard_LRS | Create a storage account |
az storage account list | az storage account list | List all storage accounts in a subscription |
az storage account delete | az storage account delete --name mystorageaccount --resource-group myResourceGroup | Delete a storage account |
Networking
#
Command/Option | Example | Description |
---|
az network vnet create | az network vnet create --name myVnet --resource-group myResourceGroup --address-prefix 10.0.0.0/16 | Create a virtual network |
az network nsg create | az network nsg create --resource-group myResourceGroup --name myNSG | Create a network security group |
az network nsg rule create | az network nsg rule create --resource-group myResourceGroup --nsg-name myNSG --name myRule --priority 100 --destination-port-ranges 80 | Create a security rule in an NSG |
SQL Databases
#
Command/Option | Example | Description |
---|
az sql server create | az sql server create --name myserver --resource-group myResourceGroup --location eastus --admin-user myadmin --admin-password mypassword | Create a SQL server |
az sql db create | az sql db create --resource-group myResourceGroup --server myserver --name mydb --service-objective S0 | Create a SQL database |
az sql server list | az sql server list | List all SQL servers in a subscription |
az sql db list | az sql db list --resource-group myResourceGroup --server myserver | List all SQL databases in a server |
Kubernetes
#
Command/Option | Example | Description |
---|
az aks create | az aks create --resource-group myResourceGroup --name myAKSCluster --node-count 1 --enable-addons monitoring --generate-ssh-keys | Create a managed Kubernetes cluster |
az aks get-credentials | az aks get-credentials --resource-group myResourceGroup --name myAKSCluster | Get access credentials for a managed Kubernetes cluster |
az aks scale | az aks scale --resource-group myResourceGroup --name myAKSCluster --node-count 3 | Scale the number of node pools in a managed Kubernetes cluster |
az aks delete | az aks delete --resource-group myResourceGroup --name myAKSCluster | Delete a managed Kubernetes cluster |
App Services
#
Command/Option | Example | Description |
---|
az webapp create | az webapp create --resource-group myResourceGroup --plan myAppServicePlan --name myWebApp | Create a web app |
az webapp list | az webapp list | List all web apps in a subscription |
az webapp delete | az webapp delete --resource-group myResourceGroup --name myWebApp | Delete 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.