DevOps • Cloud • Azure
Azure CLI Commands Cheat Sheet
Practical Azure CLI commands for virtual machines, storage, networking, AKS, containers, App Service, Azure Functions, SQL, monitoring, identity and DevOps automation.
Azure CLI Setup and Version
7 commandsaz versionDisplay the installed Azure CLI version and component versions.
az --versionShow Azure CLI version information.
az upgradeUpgrade Azure CLI to the latest available version.
az extension listList installed Azure CLI extensions.
az extension add --name <extension>Install an Azure CLI extension.
az extension update --name <extension>Update an installed Azure CLI extension.
az extension remove --name <extension>Remove an Azure CLI extension.
Azure Login and Authentication
7 commandsaz loginSign in interactively to an Azure account.
az login --use-device-codeAuthenticate using a device code.
az logoutSign out from the current Azure account.
az account showDisplay the currently selected Azure subscription.
az account listList subscriptions available to the authenticated account.
az account set --subscription <subscription-id>Set the active Azure subscription.
az account clearClear the current Azure account subscription cache.
Azure Resource Groups
6 commandsaz group listList Azure resource groups.
az group show --name <resource-group>Display details about a resource group.
az group create --name <resource-group> --location <location>Create a resource group in a specified Azure region.
az group delete --name <resource-group>Delete a resource group and its resources.
az group exists --name <resource-group>Check whether a resource group exists.
az group deployment list --resource-group <resource-group>List deployments associated with a resource group.
Azure Virtual Machines
12 commandsaz vm listList virtual machines.
az vm list --show-detailsList virtual machines with detailed information.
az vm show --resource-group <resource-group> --name <vm-name>Show details for a virtual machine.
az vm create --resource-group <resource-group> --name <vm-name> --image Ubuntu2204 --admin-username azureuser --generate-ssh-keysCreate an Ubuntu virtual machine and generate SSH keys.
az vm start --resource-group <resource-group> --name <vm-name>Start an Azure virtual machine.
az vm stop --resource-group <resource-group> --name <vm-name>Stop an Azure virtual machine.
az vm deallocate --resource-group <resource-group> --name <vm-name>Stop and deallocate a virtual machine to release compute resources.
az vm restart --resource-group <resource-group> --name <vm-name>Restart a virtual machine.
az vm delete --resource-group <resource-group> --name <vm-name>Delete a virtual machine.
az vm list-ip-addresses --resource-group <resource-group> --name <vm-name>Display IP address information for a virtual machine.
az vm open-port --resource-group <resource-group> --name <vm-name> --port <port>Create a network security rule allowing inbound traffic on a port.
az vm run-command invoke --resource-group <resource-group> --name <vm-name> --command-id RunShellScript --scripts '<command>'Execute a shell command inside a Linux virtual machine.
Azure VM Images and Disks
5 commandsaz vm image list --location <location> --publisher Canonical --offer 0001-com-ubuntu-server-jammy --sku 22_04-lts --allList matching Ubuntu VM images.
az disk listList managed disks.
az disk show --resource-group <resource-group> --name <disk-name>Show details about a managed disk.
az disk create --resource-group <resource-group> --name <disk-name> --size-gb 32Create a managed disk.
az disk delete --resource-group <resource-group> --name <disk-name>Delete a managed disk.
Azure Storage Accounts
5 commandsaz storage account listList storage accounts.
az storage account show --resource-group <resource-group> --name <storage-account>Show storage account details.
az storage account create --resource-group <resource-group> --name <storage-account> --location <location> --sku Standard_LRSCreate a storage account.
az storage account delete --resource-group <resource-group> --name <storage-account>Delete a storage account.
az storage account keys list --resource-group <resource-group> --account-name <storage-account>List access keys for a storage account.
Azure Blob Storage
6 commandsaz storage container list --account-name <storage-account> --auth-mode loginList blob containers using Azure identity authentication.
az storage container create --name <container> --account-name <storage-account> --auth-mode loginCreate a blob container.
az storage blob list --container-name <container> --account-name <storage-account> --auth-mode loginList blobs in a container.
az storage blob upload --account-name <storage-account> --container-name <container> --name <blob> --file <file> --auth-mode loginUpload a local file to Azure Blob Storage.
az storage blob download --account-name <storage-account> --container-name <container> --name <blob> --file <file> --auth-mode loginDownload a blob to a local file.
az storage blob delete --account-name <storage-account> --container-name <container> --name <blob> --auth-mode loginDelete a blob.
Azure Virtual Network
6 commandsaz network vnet listList virtual networks.
az network vnet show --resource-group <resource-group> --name <vnet-name>Show details for a virtual network.
az network vnet create --resource-group <resource-group> --name <vnet-name> --address-prefix 10.0.0.0/16Create a virtual network.
az network vnet subnet list --resource-group <resource-group> --vnet-name <vnet-name>List subnets in a virtual network.
az network vnet subnet create --resource-group <resource-group> --vnet-name <vnet-name> --name <subnet-name> --address-prefix 10.0.1.0/24Create a subnet.
az network vnet peering list --resource-group <resource-group> --vnet-name <vnet-name>List VNet peerings.
Azure Network Security Groups
5 commandsaz network nsg listList network security groups.
az network nsg show --resource-group <resource-group> --name <nsg-name>Show an NSG and its configuration.
az network nsg create --resource-group <resource-group> --name <nsg-name>Create a network security group.
az network nsg rule list --resource-group <resource-group> --nsg-name <nsg-name>List security rules in an NSG.
az network nsg rule create --resource-group <resource-group> --nsg-name <nsg-name> --name <rule-name> --priority 100 --access Allow --protocol Tcp --direction Inbound --destination-port-ranges 22Create an inbound NSG rule allowing TCP traffic on a port.
Azure Public IP and Networking
5 commandsaz network public-ip listList public IP addresses.
az network public-ip show --resource-group <resource-group> --name <public-ip>Show public IP details.
az network public-ip create --resource-group <resource-group> --name <public-ip> --sku StandardCreate a public IP address.
az network nic listList network interfaces.
az network nic show --resource-group <resource-group> --name <nic-name>Show network interface details.
Azure Load Balancer
4 commandsaz network lb listList Azure load balancers.
az network lb show --resource-group <resource-group> --name <load-balancer>Show load balancer details.
az network lb rule list --resource-group <resource-group> --lb-name <load-balancer>List load-balancing rules.
az network lb probe list --resource-group <resource-group> --lb-name <load-balancer>List health probes.
Azure Container Registry
7 commandsaz acr listList Azure Container Registries.
az acr show --name <registry>Show details for an Azure Container Registry.
az acr create --resource-group <resource-group> --name <registry> --sku BasicCreate an Azure Container Registry.
az acr login --name <registry>Authenticate Docker with an Azure Container Registry.
az acr repository list --name <registry>List repositories in an Azure Container Registry.
az acr repository show-tags --name <registry> --repository <repository>List image tags in an ACR repository.
az acr build --registry <registry> --image <repository>:<tag> .Build a container image in Azure Container Registry.
Azure Kubernetes Service
8 commandsaz aks listList Azure Kubernetes Service clusters.
az aks show --resource-group <resource-group> --name <aks-cluster>Show AKS cluster details.
az aks create --resource-group <resource-group> --name <aks-cluster> --node-count 2 --generate-ssh-keysCreate an AKS cluster with two nodes.
az aks scale --resource-group <resource-group> --name <aks-cluster> --node-count 3Change the node count of an AKS cluster.
az aks get-credentials --resource-group <resource-group> --name <aks-cluster>Download AKS credentials and merge them into the local kubeconfig.
az aks stop --resource-group <resource-group> --name <aks-cluster>Stop an AKS cluster where supported.
az aks start --resource-group <resource-group> --name <aks-cluster>Start a stopped AKS cluster.
az aks nodepool list --resource-group <resource-group> --cluster-name <aks-cluster>List node pools in an AKS cluster.
Azure Container Instances
5 commandsaz container listList Azure Container Instances.
az container show --resource-group <resource-group> --name <container>Show container instance details.
az container logs --resource-group <resource-group> --name <container>Display logs from a container instance.
az container restart --resource-group <resource-group> --name <container>Restart a container instance.
az container delete --resource-group <resource-group> --name <container>Delete a container instance.
Azure App Service
7 commandsaz webapp listList Azure App Service web apps.
az webapp show --resource-group <resource-group> --name <webapp>Show details for a web app.
az webapp create --resource-group <resource-group> --plan <app-service-plan> --name <webapp>Create a web app using an existing App Service plan.
az webapp start --resource-group <resource-group> --name <webapp>Start a web app.
az webapp stop --resource-group <resource-group> --name <webapp>Stop a web app.
az webapp restart --resource-group <resource-group> --name <webapp>Restart a web app.
az webapp log tail --resource-group <resource-group> --name <webapp>Stream application logs from a web app.
Azure App Service Deployment
3 commandsaz webapp deployment list-publishing-profiles --resource-group <resource-group> --name <webapp>List publishing profiles for an App Service application.
az webapp deployment source config --resource-group <resource-group> --name <webapp> --repo-url <repository-url> --branch <branch>Configure source deployment from a repository.
az webapp deployment list-publishing-profiles --resource-group <resource-group> --name <webapp>Retrieve publishing profile information for deployment workflows.
Azure Functions
6 commandsaz functionapp listList Azure Function Apps.
az functionapp show --resource-group <resource-group> --name <function-app>Show details about a Function App.
az functionapp start --resource-group <resource-group> --name <function-app>Start a Function App.
az functionapp stop --resource-group <resource-group> --name <function-app>Stop a Function App.
az functionapp restart --resource-group <resource-group> --name <function-app>Restart a Function App.
az functionapp log tail --resource-group <resource-group> --name <function-app>Stream logs from an Azure Function App.
Azure SQL
6 commandsaz sql server listList Azure SQL logical servers.
az sql server show --resource-group <resource-group> --name <server>Show Azure SQL server details.
az sql db list --resource-group <resource-group> --server <server>List databases on an Azure SQL server.
az sql db show --resource-group <resource-group> --server <server> --name <database>Show details for an Azure SQL database.
az sql db create --resource-group <resource-group> --server <server> --name <database> --service-objective S0Create an Azure SQL database.
az sql db delete --resource-group <resource-group> --server <server> --name <database>Delete an Azure SQL database.
Azure Monitor
4 commandsaz monitor metrics list-definitions --resource <resource-id>List available metrics for an Azure resource.
az monitor metrics list --resource <resource-id>Retrieve metrics for an Azure resource.
az monitor activity-log list --resource-group <resource-group>List Azure activity log events for a resource group.
az monitor activity-log list --status FailedList failed activity log events.
Azure Log Analytics
3 commandsaz monitor log-analytics workspace listList Log Analytics workspaces.
az monitor log-analytics workspace show --resource-group <resource-group> --workspace-name <workspace>Show Log Analytics workspace details.
az monitor log-analytics query --workspace <workspace-id> --analytics-query '<KQL-query>'Run a Kusto Query Language query against a Log Analytics workspace.
Azure Key Vault
7 commandsaz keyvault listList Azure Key Vaults.
az keyvault show --name <vault>Show Key Vault details.
az keyvault create --name <vault> --resource-group <resource-group> --location <location>Create an Azure Key Vault.
az keyvault secret list --vault-name <vault>List secrets stored in a Key Vault.
az keyvault secret show --vault-name <vault> --name <secret>Retrieve metadata and the current value of a Key Vault secret when authorized.
az keyvault secret set --vault-name <vault> --name <secret> --value '<value>'Create or update a Key Vault secret.
az keyvault secret delete --vault-name <vault> --name <secret>Delete a Key Vault secret.
Azure Managed Identity
4 commandsaz identity listList user-assigned managed identities.
az identity show --resource-group <resource-group> --name <identity>Show a user-assigned managed identity.
az identity create --resource-group <resource-group> --name <identity>Create a user-assigned managed identity.
az identity delete --resource-group <resource-group> --name <identity>Delete a user-assigned managed identity.
Microsoft Entra ID
5 commandsaz ad signed-in-user showDisplay information about the currently signed-in Microsoft Entra user.
az ad user listList Microsoft Entra users when authorized.
az ad user show --id <user>Show information about a Microsoft Entra user.
az ad group listList Microsoft Entra groups.
az ad sp list --display-name <name>Find service principals by display name.
Azure Role-Based Access Control
5 commandsaz role definition listList Azure RBAC role definitions.
az role definition list --name ContributorShow the Contributor role definition.
az role assignment list --assignee <principal-id>List role assignments for a user, group or service principal.
az role assignment create --assignee <principal-id> --role Contributor --scope <scope>Assign an Azure RBAC role at a specified scope.
az role assignment delete --assignee <principal-id> --role Contributor --scope <scope>Remove an Azure RBAC role assignment.
Azure Resource Management
4 commandsaz resource listList Azure resources in the current subscription.
az resource show --resource-group <resource-group> --name <resource-name> --resource-type <resource-type>Show details for an Azure resource.
az resource tag --tags environment=production team=devopsApply tags to Azure resources.
az resource delete --ids <resource-id>Delete a resource by resource ID.
Azure Resource Locks
3 commandsaz lock list --resource-group <resource-group>List management locks in a resource group.
az lock create --name <lock-name> --lock-type CanNotDelete --resource-group <resource-group>Create a resource lock that prevents deletion.
az lock delete --name <lock-name> --resource-group <resource-group>Delete a management lock.
Azure Policy
4 commandsaz policy definition listList Azure Policy definitions.
az policy assignment listList Azure Policy assignments.
az policy state listList policy compliance state information.
az policy state summarizeSummarize Azure Policy compliance.
Azure Resource Graph
3 commandsaz graph query -q 'Resources | project name, type, resourceGroup, location'Query Azure resources using Azure Resource Graph.
az graph query -q 'Resources | where type =~ "Microsoft.Compute/virtualMachines" | project name, resourceGroup, location'Find virtual machines using Resource Graph.
az graph query -q 'Resources | summarize count() by type'Count Azure resources by resource type.
Azure Cost Management
3 commandsaz consumption usage listList usage details when supported for the subscription and billing configuration.
az consumption budget list --resource-group <resource-group>List budgets associated with a resource group where supported.
az consumption budget show --resource-group <resource-group> --budget-name <budget>Show budget details.
Azure DevOps
8 commandsaz extension add --name azure-devopsInstall the Azure DevOps CLI extension.
az devops configure --defaults organization=https://dev.azure.com/<organization> project=<project>Configure default Azure DevOps organization and project.
az devops project listList Azure DevOps projects.
az repos listList Git repositories in the configured Azure DevOps project.
az repos show --repository <repository>Show Azure Repos repository details.
az pipelines listList Azure Pipelines.
az pipelines run --name <pipeline>Run an Azure Pipeline.
az pipelines runs listList pipeline runs.
Azure Container Apps
5 commandsaz containerapp listList Azure Container Apps.
az containerapp show --resource-group <resource-group> --name <container-app>Show Azure Container App details.
az containerapp revision list --resource-group <resource-group> --name <container-app>List revisions of a Container App.
az containerapp logs show --resource-group <resource-group> --name <container-app>Show Container App logs.
az containerapp revision restart --resource-group <resource-group> --name <container-app> --revision <revision>Restart a Container App revision.
Azure DNS
4 commandsaz network dns zone listList Azure DNS zones.
az network dns zone show --resource-group <resource-group> --name <zone>Show an Azure DNS zone.
az network dns record-set list --resource-group <resource-group> --zone-name <zone>List DNS record sets.
az network dns record-set a add-record --resource-group <resource-group> --zone-name <zone> --record-set-name <record-set> --ipv4-address <ip>Add an IPv4 address to an A record set.
Azure CLI Output and Querying
6 commandsaz <command> --output tableDisplay command output in a readable table.
az <command> --output jsonReturn command output as JSON.
az <command> --output yamlReturn command output as YAML.
az <command> --output tsvReturn command output as tab-separated values.
az <command> --query '<JMESPath-expression>'Filter and transform Azure CLI output using JMESPath.
az <command> --only-show-errorsSuppress non-error output where supported.
Azure CLI Troubleshooting
8 commandsaz account showVerify the active Azure account and subscription.
az account list --output tableCheck which subscriptions are available.
az account set --subscription <subscription-id>Switch to the correct Azure subscription.
az group list --output tableVerify resource-group access.
az provider list --output tableList Azure resource providers and their registration state.
az provider show --namespace Microsoft.ComputeCheck the registration state of a specific Azure resource provider.
az config getDisplay Azure CLI configuration settings.
az config set core.only_show_errors=trueConfigure Azure CLI to show only errors.
CI/CD Azure DevOps Workflow
7 commandsaz loginAuthenticate to Azure before deployment.
az account set --subscription <subscription-id>Select the subscription used by the deployment pipeline.
az group create --name <resource-group> --location <location>Create or ensure the deployment resource group exists.
az acr build --registry <registry> --image <repository>:<tag> .Build and publish a container image using Azure Container Registry.
az aks get-credentials --resource-group <resource-group> --name <aks-cluster>Configure kubectl access to an AKS cluster.
az webapp deploy --resource-group <resource-group> --name <webapp> --src-path <package>Deploy an application package to Azure App Service.
az monitor activity-log list --resource-group <resource-group>Inspect Azure activity logs after a deployment.
Azure DevOps Workflow
- 1. Authenticate
az login - 2. Select subscription
az account set --subscription <subscription-id> - 3. Build container image
az acr build --registry <registry> --image myapp:$BUILD_NUMBER . - 4. Deploy to AKS
az aks get-credentials --resource-group <resource-group> --name <aks-cluster> - 5. Verify deployment
kubectl get pods - 6. Check Azure monitoring
az monitor activity-log list --resource-group <resource-group>
Common Azure CLI Troubleshooting Workflow
Check authentication
az account showCheck subscription
az account list --output tableCheck resource group
az group show --name <resource-group>Check resource provider
az provider show --namespace Microsoft.ComputeInspect activity logs
az monitor activity-log list --status Failed