Azure CLI commands

Azure CLI command lines for release 2.91.0, taken from the Examples and syntax blocks of Microsoft's reference and grouped by task: signing in, resource groups, virtual machines, storage, containers and Kubernetes, web apps, identity, Key Vault, networking, deployments and the CLI's own settings. Each line is az, a command group and a verb; names such as MyResourceGroup or MyVm are the documentation's sample values. Other service groups, among them databases and messaging, are left out.

196 commands in 14 sections. Checked row by row against Azure CLI reference (2.91.0, latest): reference index and top-level commands on . Edited by Jay.

Signing in and subscriptions 15

CommandWhat it does
az loginSign in interactivelyUses Web Account Manager on Windows and a browser on Linux and macOS, with device code as the fallback.
az login --use-device-codeSign in with a device codeFor sessions that cannot open a browser, such as remote SSH or Cloud Shell.
az login --tenant 00000000-0000-0000-0000-000000000000Sign in to a specific tenantThe value is the tenant object ID or its .onmicrosoft.com domain.
az login --service-principal --username APP_ID --password CLIENT_SECRET --tenant TENANT_IDSign in as a service principalAuthenticates an application with its secret; the tenant has to be named.
az login --identitySign in with a managed identityWithout further options the system-assigned identity is used.
az login --tenant TENANT_ID --skip-subscription-discoverySign in without listing subscriptionsEnough for tenant-level work such as the az ad commands.
az logoutSign outRemoves the access the CLI had to the subscriptions of the account.
az account showShow the active subscriptionTells which subscription commands currently act on, together with its tenant ID.
az account list --output tableList available subscriptionsA subscription that is not in this list cannot be made active.
az account list --query "[?isDefault]"Show only the default subscriptionThe JMESPath filter keeps only the entry flagged as default.
az account set --subscription "My Demos"Switch subscription by nameLater commands act on it; moving to another tenant's subscription also changes the active tenant.
az account show --query id --output tsvPrint only the subscription IDReturns the bare value, ready to store in a script variable.
az account list-locationsList Azure regionsShows the regions that the subscription in use supports.
az account clearClear the subscription cacheAfterwards az login is needed again before other commands work.
az account get-access-tokenGet an access tokenPrints a token for the active account so that other tools can call Azure.

Resource groups and resources 12

CommandWhat it does
az group create -l westus -n MyResourceGroupCreate a resource group-l is the region and -n the name of the new group.
az group listList resource groups
az group list --query "[?location=='westus']"List groups in one regionThe JMESPath filter keeps the groups whose location is westus.
az group exists -n MyResourceGroupCheck whether a group exists
az group delete --name "myResourceGroup"Delete a resource groupRemoves the group and every resource that belongs to it.
az resource list --location westusList resources in a region
az resource show -g MyResourceGroup -n MyVm --resource-type "Microsoft.Compute/virtualMachines"Show any resource by typeAddresses the resource through its group, its name and the full resource type.
az resource tag --tags vmlist=vm1 -g MyResourceGroup -n MyVm --resource-type "Microsoft.Compute/virtualMachines"Tag a resourceReplaces the existing tags unless -i is added for an incremental update.
az resource move --destination-group ResourceGroup --destination-subscription-id SubscriptionId --ids "ResourceId1" "ResourceId2" "ResourceId3"Move resources to another groupThe target may sit in a different subscription.
az tag update --resource-id /subscriptions/{sub-id}/resourcegroups/{rg} --operation replace --tags key1=value1 key3=value3Replace tags on a groupMerging and selectively deleting tags are the other operations of this command.
az lock create --name lockName --resource-group group --lock-type ReadOnlyLock a resource groupThe lock type is either ReadOnly or CanNotDelete.
az provider register --namespace 'Microsoft.PolicyInsights'Register a resource provider

Virtual machines 20

az vm stop only powers a machine off and billing continues; az vm deallocate is the command that ends the compute charges.

CommandWhat it does
az vm create -n MyVm -g MyResourceGroup --image Ubuntu2204Create a Linux VMUbuntu2204 is an image alias; SSH authentication is set up automatically.
az vm create -g MyResourceGroup -n MyVm --image Debian11 --custom-data MyCloudInitScript.ymlCreate a VM with cloud-initThe script file configures the machine on first boot.
az vm create -n MyVm -g MyResourceGroup --image CentOS85Gen2 --count 3Create several VMs at onceA number is appended to the name, giving MyVm0, MyVm1 and MyVm2.
az vm listList all VMs
az vm list -g MyResourceGroup -dList VMs with details-d adds public IP address, FQDN and power state, which makes the call slower.
az vm show -g MyResourceGroup -n MyVm -dShow one VMWith -d the output also carries addresses and the power state.
az vm start -g MyResourceGroup -n MyVmStart a stopped VM
az vm stop --resource-group MyResourceGroup --name MyVmPower off a VMThe machine keeps being billed until it is deallocated.
az vm deallocate -g MyResourceGroup -n MyVmDeallocate a VMReleases the compute resources so charges stop; the status becomes Stopped (Deallocated).
az vm restart -g MyResourceGroup -n MyVmRestart a VM
az vm restart --ids $(az vm list -g MyResourceGroup --query "[].id" -o tsv)Restart every VM in a groupThe inner command feeds the resource IDs of the group to --ids.
az vm delete -g MyResourceGroup -n MyVm --yesDelete a VMThe --yes flag removes the machine without asking for confirmation.
az vm resize -g MyResourceGroup -n MyVm --size Standard_DS3_v2Change the VM size
az vm list-skus -l westusList compute SKUs in a regionReplaces the deprecated az vm list-sizes.
az vm open-port -g MyResourceGroup -n MyVm --port 80-100 --priority 100Open inbound portsAdds a rule to the network security group on the VM's NIC or subnet.
az vm list-ip-addresses -g MyResourceGroup -n MyVmShow the IP addresses of a VM
az vm run-command invoke -g MyResourceGroup -n MyVm --command-id RunShellScript --scripts "sudo apt-get update && sudo apt-get install -y nginx"Run a script inside a VMRunShellScript targets Linux; Windows machines take RunPowerShellScript.
az vm auto-shutdown -g MyResourceGroup -n MyVm --time 1730 --email "[email protected]" --webhook "https://example.com/"Schedule a daily shutdown--time is the UTC time of day in hhmm format; the address and the webhook receive the notification.
az vm auto-shutdown -g MyResourceGroup -n MyVm --offRemove the shutdown schedule
az vm disk attach -g MyResourceGroup --vm-name MyVm --name disk_name --newAttach a new data disk--new creates a managed disk of the default size before attaching it.

Storage accounts and blobs 19

CommandWhat it does
az storage account create -n mystorageaccount -g MyResourceGroup -l westus --sku Standard_LRSCreate a storage accountStandard_LRS is the SKU for locally redundant storage.
az storage account listList storage accounts
az storage account show -g MyResourceGroup -n MyStorageAccountShow account properties
az storage account show-connection-string -g MyResourceGroup -n MyStorageAccountGet the connection stringThe value can be supplied to data commands through AZURE_STORAGE_CONNECTION_STRING.
az storage account keys list -g MyResourceGroup -n MyStorageAccountList the access keys
az storage account keys renew -g MyResourceGroup -n MyStorageAccount --key primaryRegenerate an access key--key names which of the keys gets a new value, here the primary one.
az storage container create -n mystoragecontainerCreate a blob containerStays private to the account owner unless --public-access is set.
az storage container create -n mystoragecontainer --public-access blobCreate a public-read containerBlobs become readable anonymously; containers are private unless this is set.
az storage container listList containers
az storage container delete --account-key 00000000 --account-name MyAccount --name mycontainerDelete a container
az storage blob upload -f /path/to/file -c mycontainer -n MyBlobUpload a file as a blob-f is the local file, -c the container and -n the blob name.
az storage blob upload-batch -d mycontainer -s PATH-TO-DIRECTORYUpload a whole directoryEvery file under the local path goes to the container named with -d.
az storage blob download -f /path/to/file -c mycontainer -n MyBlobDownload a blob to a file
az storage blob download-batch -d . -s mycontainer --pattern "dir/*"Download a virtual directoryFetches the blobs under dir/ into the working directory.
az storage blob list -c mycontainer --prefix fooList blobs by name prefixMatches foo, foobar and foo/bar alike.
az storage blob show -c mycontainer -n MyBlobShow blob properties
az storage blob delete -c mycontainer -n MyBlob --account-name mystorageaccount --auth-mode loginDelete a blob with your sign-in--auth-mode login authenticates with the credentials of az login in place of an account key.
az storage blob delete-batch -s mycontainer --pattern "dir/*"Delete blobs by patternThe pattern limits the recursive delete to the blobs under dir/.
az storage blob generate-sas -c myycontainer -n MyBlob --permissions r --expiry $end --https-onlyCreate a read-only blob SASThe token expires at the time in $end and only works over HTTPS.

Container registries and instances 14

CommandWhat it does
az acr create -n myregistry -g MyResourceGroup --sku StandardCreate a container registry
az acr login -n myregistryLog Docker in to a registryWorks through the Docker CLI, which therefore has to be installed.
az acr login -n myregistry --expose-tokenGet a registry tokenPrints a token and skips the Docker login, so Docker is not required.
az acr build -t sample/hello-world:{{.Run.ID}} -r myregistry .Build and push an image in AzureThe current directory is uploaded as build context; the result is tagged and pushed to the registry.
az acr list -o tableList registries as a table
az acr import -n myregistry --source docker.io/library/hello-world:latest -t targetrepository:targettagImport an image from Docker HubCopies the image between registries directly, with no docker pull, tag and push on your machine.
az acr repository list -n myregistryList repositories
az acr repository show-tags -n myregistry --repository MyRepositoryList the tags of a repository
az container create -g MyResourceGroup --name myapp --image myimage:latest --cpu 1 --memory 1Run a container instanceStarts a container group with one core and 1 GB of memory.
az container listList container groups
az container logs --name MyContainerGroup --resource-group MyResourceGroupRead container logs
az container exec -g MyResourceGroup --name mynginx --container-name nginx --exec-command "/bin/bash"Open a shell in a containerRuns a command inside a running container, here an interactive bash session.
az containerapp up -n my-containerapp --source .Deploy a container app from sourceBuilds from the Dockerfile in the directory, or generates a container when none is found.
az containerapp list -g MyResourceGroupList container apps in a group

Kubernetes clusters 14

CommandWhat it does
az aks create -g MyResourceGroup -n MyManagedClusterCreate an AKS clusterTakes the default Kubernetes version, a Standard load balancer and scale-set nodes.
az aks get-credentials --name MyManagedCluster --resource-group MyResourceGroupFetch kubectl credentialsMerges the cluster entry into the .kube/config file that kubectl reads.
az aks install-cliInstall the Kubernetes toolsDownloads kubectl and kubelogin, the credential plugin for Azure authentication.
az aks listList AKS clusters
az aks show --name MyManagedCluster --resource-group MyResourceGroupShow cluster details
az aks scale --name MyManagedCluster --node-count 3 --resource-group MyResourceGroupScale the node poolSets the node count of the pool, three in this example.
az aks get-upgrades --name MyManagedCluster --resource-group MyResourceGroupList available upgradesCheck it before az aks upgrade to see which versions the cluster can move to.
az aks upgrade --kubernetes-version 1.12.6 --name MyManagedCluster --resource-group MyResourceGroupUpgrade a cluster
az aks update -g MyResourceGroup -n MyManagedCluster --attach-acr acrNameAttach a registry to a clusterGrants the acrpull role on the registry named after the option.
az aks stop --name myAKSCluster --resource-group myResourceGroupStop a clusterHalts the control plane and the nodes while cluster state is kept.
az aks start --name myAKSCluster --resource-group myResourceGroupStart a stopped clusterComes back with the earlier control plane state and node count.
az aks nodepool add -g MyResourceGroup -n nodepool1 --cluster-name MyManagedCluster --os-sku UbuntuAdd a node pool--os-sku chooses the operating system of the new nodes.
az aks nodepool list --cluster-name CLUSTER --resource-group GROUPList node poolsLists pools, not nodes; kubectl get nodes shows the nodes themselves.
az aks delete --name MyManagedCluster --resource-group MyResourceGroupDelete a cluster

Web apps and functions 21

az webapp up is marked as deprecated; the reference names webapp create followed by webapp deploy as its replacement.

CommandWhat it does
az appservice plan create -g MyResourceGroup -n MyPlan --is-linuxNew App Service plan for LinuxThe plan name is what az webapp create expects after -p.
az webapp create -g MyResourceGroup -p MyPlan -n MyUniqueAppNameCreate a web app-p names the App Service plan that hosts the app.
az webapp create -g MyResourceGroup -p MyPlan -n MyUniqueAppName --runtime "node:20LTS" --deployment-local-gitNode app with local GitSets the runtime stack and switches on local Git deployment.
az webapp list-runtimesList built-in runtime stacksGives the values that --runtime accepts.
az webapp deploy -g ResourceGroup -n AppName --src-path app.zipDeploy a zip packageFor a remote build, first switch on the SCM_DO_BUILD_DURING_DEPLOYMENT app setting.
az webapp upCreate and deploy from a folderRun it in the code folder; the command is deprecated in favour of webapp create plus webapp deploy.
az webapp up --dryrunPreview what webapp up would createPrints the planned app details and changes nothing.
az webapp list --resource-group MyResourceGroupList web apps in a group
az webapp show --name MyWebapp --resource-group MyResourceGroupShow a web app
az webapp browse --name MyWebapp --resource-group MyResourceGroupBrowse to a web appNot available in Azure Cloud Shell.
az webapp restart --name MyWebapp --resource-group MyResourceGroupRestart a web app
az webapp delete --name MyWebapp --resource-group MyResourceGroupDelete a web app
az webapp config appsettings set -g MyResourceGroup -n MyUniqueApp --settings WEBSITE_NODE_DEFAULT_VERSION=6.9.1Set an app settingSettings are KEY=VALUE pairs; several can follow --settings.
az webapp config appsettings list --name MyWebapp --resource-group MyResourceGroup --subscription MySubscriptionList app settings
az webapp log tail --name NAME --resource-group GROUPTail the web app log
az webapp log download --name MyWebApp --resource-group MyResourceGroupDownload the log historyThe logs arrive as a single zip file.
az functionapp create -g MyResourceGroup -p MyPlan -n MyUniqueAppName -s MyStorageAccountCreate a function appA storage account is required and is passed with -s.
az functionapp create --consumption-plan-location westus --name MyUniqueAppName --os-type Windows --resource-group MyResourceGroup --runtime dotnet-isolated --storage-account MyStorageAccountCreate a consumption-plan function appHosts the app on the consumption plan of the named region instead of an App Service plan.
az functionapp list-runtimesList function runtime stacks
az functionapp list --resource-group MyResourceGroupList function apps in a group
az functionapp delete --name MyFunctionApp --resource-group MyResourceGroupDelete a function app

Identity and access 10

CommandWhat it does
az ad signed-in-user showShow the signed-in user
az ad sp create-for-rbacCreate a service principalNo role is assigned by default, and a name with a time stamp is generated.
az ad sp create-for-rbac --name myServicePrincipalName1 --role reader --scopes /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRG1Create a principal with a roleAssigns the reader role, limited to one resource group through --scopes.
az ad sp listList service principalsOnly the first 100 come back unless a filter or --all is given.
az ad sp show --id 00000000-0000-0000-0000-000000000000Show a service principal--id accepts the appId, the object ID or an identifier URI.
az role assignment create --assignee sp_name --role Reader --scope /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/virtualMachines/MyVmAssign a role on a resourceHere the Reader role is granted on a single virtual machine.
az role assignment list --assignee 00000000-0000-0000-0000-000000000000 --scope /subscriptions/00000000-0000-0000-0000-000000000000List the roles of an assigneeShows what the assignee holds at the subscription scope given.
az role assignment delete --assignee 00000000-0000-0000-0000-000000000000 --scope /subscriptions/00000000-0000-0000-0000-000000000000Remove role assignmentsDeletes every assignment the assignee holds at subscription scope.
az identity create --name myIdentityName --resource-group myResourceGroupCreate a user-assigned identity
az identity list --resource-group MyResourceGroupList identities in a group

Key Vault 9

CommandWhat it does
az keyvault create --location westus2 --name MyKeyVault --resource-group MyResourceGroupCreate a key vault
az keyvault listList key vaults
az keyvault show --name MyKeyVaultShow a key vault
az keyvault set-policy -n MyVault --key-permissions get list --upn {UPN}Grant key permissions to a userUpdates the access policy of the vault for the given user principal name.
az keyvault delete --name MyKeyVault --resource-group MyResourceGroupDelete a key vault
az keyvault secret set --name MySecretName --vault-name MyKeyVault --value MyVaultStore a secretCreates the secret, or updates it when the name is already in use.
az keyvault secret set --name MySecretName --vault-name MyKeyVault --file /path/to/file --encoding MyEncodingStore a secret from a file
az keyvault secret show --name "ExamplePassword" --vault-name VAULT-NAME --query "value"Read the value of a secretThe query prints the secret as plain text rather than the full JSON record.
az keyvault secret list --vault-name VAULTList the secrets in a vaultReturns identifiers and attributes only, never the values or the individual versions.

Networking 14

CommandWhat it does
az network vnet create -g MyResourceGroup -n MyVnet --address-prefix 10.0.0.0/16 --subnet-name MySubnet --subnet-prefixes 10.0.0.0/24Create a virtual networkOne call creates the network with its address space and a first subnet.
az network vnet listList virtual networks
az network vnet show -g MyResourceGroup -n MyVNetShow a virtual network
az network vnet subnet create -g MyResourceGroup --vnet-name MyVnet -n MySubnet --address-prefixes 10.0.0.0/24 --network-security-group MyNsg --route-table MyRouteTableCreate a subnetAttaches an existing NSG and a custom route table at creation time.
az network vnet subnet list -g MyResourceGroup --vnet-name MyVNetList the subnets of a network
az network vnet subnet update -g MyResourceGroup -n MySubnet --vnet-name MyVNet --network-security-group MyNsgAttach an NSG to a subnet
az network nsg create -g MyResourceGroup -n MyNsg --tags foo=barCreate a network security group
az network nsg show -g MyResourceGroup -n MyNsg --query "defaultSecurityRules[]" -o tableShow an NSG's default rulesQuery and table output turn the built-in rules into a readable list.
az network nsg rule create -g MyResourceGroup --nsg-name MyNsg -n MyNsgRule --priority 100Add an allow rule100 is the highest priority a rule can have and 4096 the lowest.
az network nsg rule create -g MyResourceGroup --nsg-name MyNsg -n MyNsgRule --priority 4096 --source-address-prefixes 208.130.28.0/24 --source-port-ranges 80 --destination-address-prefixes '*' --destination-port-ranges 80 8080 --access Deny --protocol Tcp --description "Deny from specific IP address ranges on 80 and 8080."Deny traffic from an IP rangeBlocks TCP from one source range to ports 80 and 8080.
az network nsg rule list -g MyResourceGroup --nsg-name MyNsgList the rules of an NSG
az network public-ip create -g MyResourceGroup -n MyIp --dns-name MyLabel --allocation-method StaticReserve a static public IP--dns-name adds a DNS label to the address.
az network public-ip list -g MyResourceGroupList public IPs in a group
az network public-ip show -g MyResourceGroup -n MyIp --query "{fqdn: dnsSettings.fqdn,address: ipAddress}"Print the FQDN and address

Template deployments 11

CommandWhat it does
az deployment group create --resource-group testrg --name rollout01 --template-uri https://myresource/azuredeploy.json --parameters @myparameters.jsonDeploy a remote templateParameters come from a local JSON file, marked by the @ prefix.
az deployment group create --resource-group testgroup --template-file demotemplate.json --parameters exampleString='inline string' exampleArray='("value1", "value2")'Deploy a local templateParameter values are written inline as key=value pairs.
az deployment group create --resource-group testrg --parameters parameters.bicepparamDeploy from a bicepparam file
az deployment group validate --resource-group testrg --template-file {template-file}Validate a templateGive exactly one of --template-file, --template-uri and --template-spec.
az deployment group what-if --resource-group testrg --name rollout01 --template-uri https://myresource/azuredeploy.json --parameters @myparameters.jsonPreview deployment changesTo run the check and then deploy in one go, add --confirm-with-what-if to the create command.
az deployment group list -g testrgList deployments of a group
az deployment sub create --location WestUS --template-uri https://myresource/azuredeploy.json --parameters @myparameters.jsonDeploy at subscription scope--location says where the metadata of the deployment is kept.
az bicep installInstall the Bicep CLI
az bicep upgradeUpgrade the Bicep CLI
az bicep build --file {bicep_file}Compile a Bicep file
az bicep decompile --file {json_template_file}Convert an ARM template to Bicep

Monitoring and activity logs 5

CommandWhat it does
az monitor activity-log list -g {ResourceGroup} --offset 1hList recent activity of a groupReturns the events recorded for one resource group during the past hour.
az monitor activity-log list --start-time 2018-07-01 --offset 7dList activity from a start dateWith a start time the offset counts forward, here one week.
az monitor activity-log list --correlation-id b5eac9d2-e829-4c9a-9efb-586d19417c5fTrace one operation in the logFinds the events of the last six hours that share the correlation ID.
az monitor metrics list --resource {ResourceName} --metric "Percentage CPU"Read a metric of a resourceFor a VM this returns the CPU usage of the past hour.
az monitor metrics list-definitions --resource /subscriptions/{subscriptionID}/resourceGroups/{resourceGroup}/Microsoft.Network/networkSecurityGroups/{resourceName}List the metrics a resource offers

CLI settings and extensions 18

The online reference follows the latest release, which was 2.91.0 of 6 October 2026 when this page was checked.

CommandWhat it does
az versionShow installed versionsLists the CLI modules and extensions as JSON unless another output format is configured.
az upgradeUpdate the Azure CLIGoes to the latest release only and, by default, updates every installed extension too.
az config set auto-upgrade.enable=yesTurn on automatic upgradesDisabled by default; once on, the CLI checks regularly and prompts after a command finishes.
az config getShow all configuration valuesAdd a section such as core, or a key such as core.no_color, to narrow the result.
az config set defaults.location=westus2 defaults.group=MyResourceGroupSet a default group and regionCommands then use these values where the arguments would otherwise be required.
az config set core.only_show_errors=trueHide warnings permanentlySame effect as passing --only-show-errors on every command.
az configureConfigure the CLI interactivelyThe reference recommends az config for automation and for the full set of options.
az configure --defaults group=myRG web=myweb vm=myvmSet default names with configureStores a default resource group, web app and VM name in one call.
az extension list-available --output tableList extensions that can be installedCovers the extensions that Microsoft itself publishes and looks after.
az extension add --name anextensionInstall an extension by nameAdds a command group that does not ship with the core CLI.
az extension add --upgrade --name anextensionInstall or update an extensionWith --upgrade an extension that is already installed is brought up to date.
az extension listList installed extensions
az extension remove --name MyExtensionUninstall an extension
az find "az storage"Suggest commands for a groupGive a group to see its most popular commands, or a full command to see common parameters.
az interactiveStart interactive modeOpens a shell with autocompletion, command descriptions and examples; the mode is in preview.
az rest --method get --url https://graph.microsoft.com/beta/auditLogs/directoryAuditsCall a REST endpoint directlySigns the request with the logged-in credential, so no token handling is needed.
az feedbackSend feedback to the CLI teamInteractive; opens a prefilled GitHub issue in the browser when it can.
az surveyTake the Azure CLI surveyThe questionnaire takes about three minutes.

Output formats and queries 14

--output accepts json, jsonc, none, table, tsv, yaml and yamlc, and json is what you get without it.

CommandWhat it does
az vm list --output jsonPrint JSON outputJSON is the default, so the option only matters when another default is configured.
az vm list --output tablePrint a tableEasy to scan, but nested objects and some fields are left out.
az vm list --output tsvPrint tab-separated valuesNo keys or extra symbols, which suits piping into other tools.
az account show --output jsoncPrint colorized JSONOverrides the configured default for this one command.
az config set core.output=tableChange the default output formatSaves typing --output on every command; none is also accepted when no console output is wanted.
az vm list --query "[].{resource:resourceGroup, name:name}" --output tableChoose the table columnsThe JMESPath expression renames the two properties, and the names become column headings.
az vm list --output tsv --query '[].[id, location, resourceGroup, name]'Fix the column order of TSVTSV has no guaranteed order unless a multiselect list in --query sets one.
az vm show --resource-group QueryDemo --name TestVM --query "osProfile.linuxConfiguration.ssh.publicKeys"Query one nested propertyDots walk down the JSON object to the value wanted.
az vm list --resource-group QueryDemo --query "[?storageProfile.osDisk.osType=='Linux'].{Name:name, admin:osProfile.adminUsername}" --output tableFilter a list with a conditionOnly array elements whose OS type equals Linux pass the [?...] filter.
az vm list --resource-group QueryDemo --query "sort_by([].{Name:name, Size:storageProfile.osDisk.diskSizeGb}, &Size)" --output tableSort the resultssort_by is a JMESPath function; &Size names the key to order on.
az group create --name myResourceGroup --location eastus --helpShow help for a commandWorks on groups as well, where it lists subgroups and commands; -h is the short form.
az group create --name myResourceGroup --location eastus --verboseRun with verbose loggingAdds detail such as how long the command took.
az group create --name myResourceGroup --location eastus --debugRun with full debug logsMicrosoft asks for this output when a bug is reported.
az interactive --only-show-errorsShow errors onlyRemoves messages such as the preview notice of this command.

Notes

Session and scope

az login signs in through Web Account Manager on Windows and a browser on Linux and macOS, and falls back to a device code when neither is available; az login --use-device-code asks for that flow directly. az account show tells which subscription commands act on, az account list --output table lists the ones available, and az account set --subscription "My Demos" switches by name or ID, the step people forget when a resource "does not exist". az config set defaults.location=westus2 defaults.group=MyResourceGroup stores a default region and resource group so they need not be repeated, and az extension add --name anextension installs a command group that ships separately. az interactive starts a shell with autocompletion, command descriptions and examples.

The commands you meet first

az group create -l westus -n MyResourceGroup creates a resource group, which the commands for other services then take with -g or --resource-group. az vm create -n MyVm -g MyResourceGroup --image Ubuntu2204 builds a Linux VM with SSH authentication set up automatically. az vm stop --resource-group MyResourceGroup --name MyVm only powers it off: billing continues until az vm deallocate -g MyResourceGroup -n MyVm releases the compute resources. az aks get-credentials --name MyManagedCluster --resource-group MyResourceGroup merges a cluster into the kubectl configuration. az webapp up deploys the code in the current folder but is deprecated; the reference names az webapp create -g MyResourceGroup -p MyPlan -n MyUniqueAppName followed by az webapp deploy -g ResourceGroup -n AppName --src-path app.zip as the replacement. az deployment group create --resource-group testrg --parameters parameters.bicepparam starts a deployment from a Bicep parameter file.

Scripting and troubleshooting

JSON is the default output. az vm list --output table prints a table that is easier to scan, az vm list --output tsv prints bare tab-separated values for other tools, and --query takes a JMESPath expression that picks fields out of the result, as in az account show --query id --output tsv, which returns only the subscription ID. az config set core.output=table changes the default format. When a command misbehaves, add --verbose for more logging or --debug for the full log, which Microsoft asks for with bug reports. az find "az storage" suggests the most used commands of a group, and az feedback opens a prefilled GitHub issue for the CLI team.

Questions

How do I switch subscriptions in the Azure CLI?

az account list --output table shows the subscriptions you can use, and az account set --subscription "My Demos" makes one active; the option takes the subscription name or its ID. If the one you need is missing, run az account clear and sign in again with az login.

How do I get just one field from an az command's output?

Add --query with a JMESPath expression and --output tsv, for example az account show --query id --output tsv for the subscription ID. For several columns, az vm list --query "[].{resource:resourceGroup, name:name}" --output table selects and renames them.

How do I find the Azure CLI command for a task?

az find "az storage" shows the most popular commands of a group, and a search phrase in quotes works the same way. Adding --help to any group or command, as in az group create --name myResourceGroup --location eastus --help, prints its arguments and examples.

Why is an az command group missing?

Some groups are extensions, which are not shipped with the CLI itself. az extension list-available --output table shows what can be installed, az extension add --name anextension installs one by name, and az extension list shows what is installed already.

What is the difference between az vm stop and az vm deallocate?

az vm stop --resource-group MyResourceGroup --name MyVm powers the machine off, but it keeps being billed. az vm deallocate -g MyResourceGroup -n MyVm releases the compute resources: charges stop and the status changes to Stopped (Deallocated).

Which Azure CLI version is installed, and how is it updated?

az version prints the versions of the CLI modules and extensions. az upgrade moves to the latest release and, by default, updates the installed extensions as well.

Sources and checks

50 more source pages

Every row on this page was matched to a line in the documentation above on . A binding that could not be found there is not listed.

90 rows from the earlier version of this page were removed in that check: duplicates, and bindings the documentation does not list or lists differently.

Found a wrong or missing key? Tell us and it gets checked against the source. How we verify describes the process and its limits.