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.

35 categories193 commandsAzure DevOps
193 commands across 35 categories

Azure CLI Setup and Version

7 commands
az version

Display the installed Azure CLI version and component versions.

az --version

Show Azure CLI version information.

az upgrade

Upgrade Azure CLI to the latest available version.

az extension list

List 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 commands
az login

Sign in interactively to an Azure account.

az login --use-device-code

Authenticate using a device code.

az logout

Sign out from the current Azure account.

az account show

Display the currently selected Azure subscription.

az account list

List subscriptions available to the authenticated account.

az account set --subscription <subscription-id>

Set the active Azure subscription.

az account clear

Clear the current Azure account subscription cache.

Azure Resource Groups

6 commands
az group list

List 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 commands
az vm list

List virtual machines.

az vm list --show-details

List 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-keys

Create 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 commands
az vm image list --location <location> --publisher Canonical --offer 0001-com-ubuntu-server-jammy --sku 22_04-lts --all

List matching Ubuntu VM images.

az disk list

List 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 32

Create a managed disk.

az disk delete --resource-group <resource-group> --name <disk-name>

Delete a managed disk.

Azure Storage Accounts

5 commands
az storage account list

List 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_LRS

Create 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 commands
az storage container list --account-name <storage-account> --auth-mode login

List blob containers using Azure identity authentication.

az storage container create --name <container> --account-name <storage-account> --auth-mode login

Create a blob container.

az storage blob list --container-name <container> --account-name <storage-account> --auth-mode login

List blobs in a container.

az storage blob upload --account-name <storage-account> --container-name <container> --name <blob> --file <file> --auth-mode login

Upload a local file to Azure Blob Storage.

az storage blob download --account-name <storage-account> --container-name <container> --name <blob> --file <file> --auth-mode login

Download a blob to a local file.

az storage blob delete --account-name <storage-account> --container-name <container> --name <blob> --auth-mode login

Delete a blob.

Azure Virtual Network

6 commands
az network vnet list

List 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/16

Create 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/24

Create a subnet.

az network vnet peering list --resource-group <resource-group> --vnet-name <vnet-name>

List VNet peerings.

Azure Network Security Groups

5 commands
az network nsg list

List 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 22

Create an inbound NSG rule allowing TCP traffic on a port.

Azure Public IP and Networking

5 commands
az network public-ip list

List 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 Standard

Create a public IP address.

az network nic list

List network interfaces.

az network nic show --resource-group <resource-group> --name <nic-name>

Show network interface details.

Azure Load Balancer

4 commands
az network lb list

List 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 commands
az acr list

List 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 Basic

Create 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 commands
az aks list

List 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-keys

Create an AKS cluster with two nodes.

az aks scale --resource-group <resource-group> --name <aks-cluster> --node-count 3

Change 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 commands
az container list

List 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 commands
az webapp list

List 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 commands
az 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 commands
az functionapp list

List 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 commands
az sql server list

List 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 S0

Create an Azure SQL database.

az sql db delete --resource-group <resource-group> --server <server> --name <database>

Delete an Azure SQL database.

Azure Monitor

4 commands
az 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 Failed

List failed activity log events.

Azure Log Analytics

3 commands
az monitor log-analytics workspace list

List 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 commands
az keyvault list

List 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 commands
az identity list

List 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 commands
az ad signed-in-user show

Display information about the currently signed-in Microsoft Entra user.

az ad user list

List Microsoft Entra users when authorized.

az ad user show --id <user>

Show information about a Microsoft Entra user.

az ad group list

List Microsoft Entra groups.

az ad sp list --display-name <name>

Find service principals by display name.

Azure Role-Based Access Control

5 commands
az role definition list

List Azure RBAC role definitions.

az role definition list --name Contributor

Show 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 commands
az resource list

List 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=devops

Apply tags to Azure resources.

az resource delete --ids <resource-id>

Delete a resource by resource ID.

Azure Resource Locks

3 commands
az 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 commands
az policy definition list

List Azure Policy definitions.

az policy assignment list

List Azure Policy assignments.

az policy state list

List policy compliance state information.

az policy state summarize

Summarize Azure Policy compliance.

Azure Resource Graph

3 commands
az 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 commands
az consumption usage list

List 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 commands
az extension add --name azure-devops

Install 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 list

List Azure DevOps projects.

az repos list

List Git repositories in the configured Azure DevOps project.

az repos show --repository <repository>

Show Azure Repos repository details.

az pipelines list

List Azure Pipelines.

az pipelines run --name <pipeline>

Run an Azure Pipeline.

az pipelines runs list

List pipeline runs.

Azure Container Apps

5 commands
az containerapp list

List 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 commands
az network dns zone list

List 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 commands
az <command> --output table

Display command output in a readable table.

az <command> --output json

Return command output as JSON.

az <command> --output yaml

Return command output as YAML.

az <command> --output tsv

Return command output as tab-separated values.

az <command> --query '<JMESPath-expression>'

Filter and transform Azure CLI output using JMESPath.

az <command> --only-show-errors

Suppress non-error output where supported.

Azure CLI Troubleshooting

8 commands
az account show

Verify the active Azure account and subscription.

az account list --output table

Check which subscriptions are available.

az account set --subscription <subscription-id>

Switch to the correct Azure subscription.

az group list --output table

Verify resource-group access.

az provider list --output table

List Azure resource providers and their registration state.

az provider show --namespace Microsoft.Compute

Check the registration state of a specific Azure resource provider.

az config get

Display Azure CLI configuration settings.

az config set core.only_show_errors=true

Configure Azure CLI to show only errors.

CI/CD Azure DevOps Workflow

7 commands
az login

Authenticate 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. 1. Authenticate
    az login
  2. 2. Select subscription
    az account set --subscription <subscription-id>
  3. 3. Build container image
    az acr build --registry <registry> --image myapp:$BUILD_NUMBER .
  4. 4. Deploy to AKS
    az aks get-credentials --resource-group <resource-group> --name <aks-cluster>
  5. 5. Verify deployment
    kubectl get pods
  6. 6. Check Azure monitoring
    az monitor activity-log list --resource-group <resource-group>

Common Azure CLI Troubleshooting Workflow

Check authentication

az account show

Check subscription

az account list --output table

Check resource group

az group show --name <resource-group>

Check resource provider

az provider show --namespace Microsoft.Compute

Inspect activity logs

az monitor activity-log list --status Failed