Signing in and subscriptions 15
| Command | What it does |
|---|---|
az login | Sign in interactivelyUses Web Account Manager on Windows and a browser on Linux and macOS, with device code as the fallback. |
az login --use-device-code | Sign 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-000000000000 | Sign 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_ID | Sign in as a service principalAuthenticates an application with its secret; the tenant has to be named. |
az login --identity | Sign in with a managed identityWithout further options the system-assigned identity is used. |
az login --tenant TENANT_ID --skip-subscription-discovery | Sign in without listing subscriptionsEnough for tenant-level work such as the az ad commands. |
az logout | Sign outRemoves the access the CLI had to the subscriptions of the account. |
az account show | Show the active subscriptionTells which subscription commands currently act on, together with its tenant ID. |
az account list --output table | List 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 tsv | Print only the subscription IDReturns the bare value, ready to store in a script variable. |
az account list-locations | List Azure regionsShows the regions that the subscription in use supports. |
az account clear | Clear the subscription cacheAfterwards az login is needed again before other commands work. |
az account get-access-token | Get an access tokenPrints a token for the active account so that other tools can call Azure. |
Resource groups and resources 12
| Command | What it does |
|---|---|
az group create -l westus -n MyResourceGroup | Create a resource group-l is the region and -n the name of the new group. |
az group list | List 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 MyResourceGroup | Check 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 westus | List 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=value3 | Replace 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 ReadOnly | Lock 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.
| Command | What it does |
|---|---|
az vm create -n MyVm -g MyResourceGroup --image Ubuntu2204 | Create 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.yml | Create a VM with cloud-initThe script file configures the machine on first boot. |
az vm create -n MyVm -g MyResourceGroup --image CentOS85Gen2 --count 3 | Create several VMs at onceA number is appended to the name, giving MyVm0, MyVm1 and MyVm2. |
az vm list | List all VMs |
az vm list -g MyResourceGroup -d | List VMs with details-d adds public IP address, FQDN and power state, which makes the call slower. |
az vm show -g MyResourceGroup -n MyVm -d | Show one VMWith -d the output also carries addresses and the power state. |
az vm start -g MyResourceGroup -n MyVm | Start a stopped VM |
az vm stop --resource-group MyResourceGroup --name MyVm | Power off a VMThe machine keeps being billed until it is deallocated. |
az vm deallocate -g MyResourceGroup -n MyVm | Deallocate a VMReleases the compute resources so charges stop; the status becomes Stopped (Deallocated). |
az vm restart -g MyResourceGroup -n MyVm | Restart 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 --yes | Delete a VMThe --yes flag removes the machine without asking for confirmation. |
az vm resize -g MyResourceGroup -n MyVm --size Standard_DS3_v2 | Change the VM size |
az vm list-skus -l westus | List compute SKUs in a regionReplaces the deprecated az vm list-sizes. |
az vm open-port -g MyResourceGroup -n MyVm --port 80-100 --priority 100 | Open inbound portsAdds a rule to the network security group on the VM's NIC or subnet. |
az vm list-ip-addresses -g MyResourceGroup -n MyVm | Show 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 --off | Remove the shutdown schedule |
az vm disk attach -g MyResourceGroup --vm-name MyVm --name disk_name --new | Attach a new data disk--new creates a managed disk of the default size before attaching it. |
Storage accounts and blobs 19
| Command | What it does |
|---|---|
az storage account create -n mystorageaccount -g MyResourceGroup -l westus --sku Standard_LRS | Create a storage accountStandard_LRS is the SKU for locally redundant storage. |
az storage account list | List storage accounts |
az storage account show -g MyResourceGroup -n MyStorageAccount | Show account properties |
az storage account show-connection-string -g MyResourceGroup -n MyStorageAccount | Get the connection stringThe value can be supplied to data commands through AZURE_STORAGE_CONNECTION_STRING. |
az storage account keys list -g MyResourceGroup -n MyStorageAccount | List the access keys |
az storage account keys renew -g MyResourceGroup -n MyStorageAccount --key primary | Regenerate an access key--key names which of the keys gets a new value, here the primary one. |
az storage container create -n mystoragecontainer | Create a blob containerStays private to the account owner unless --public-access is set. |
az storage container create -n mystoragecontainer --public-access blob | Create a public-read containerBlobs become readable anonymously; containers are private unless this is set. |
az storage container list | List containers |
az storage container delete --account-key 00000000 --account-name MyAccount --name mycontainer | Delete a container |
az storage blob upload -f /path/to/file -c mycontainer -n MyBlob | Upload 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-DIRECTORY | Upload 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 MyBlob | Download 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 foo | List blobs by name prefixMatches foo, foobar and foo/bar alike. |
az storage blob show -c mycontainer -n MyBlob | Show blob properties |
az storage blob delete -c mycontainer -n MyBlob --account-name mystorageaccount --auth-mode login | Delete 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-only | Create a read-only blob SASThe token expires at the time in $end and only works over HTTPS. |
Container registries and instances 14
| Command | What it does |
|---|---|
az acr create -n myregistry -g MyResourceGroup --sku Standard | Create a container registry |
az acr login -n myregistry | Log Docker in to a registryWorks through the Docker CLI, which therefore has to be installed. |
az acr login -n myregistry --expose-token | Get 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 table | List registries as a table |
az acr import -n myregistry --source docker.io/library/hello-world:latest -t targetrepository:targettag | Import 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 myregistry | List repositories |
az acr repository show-tags -n myregistry --repository MyRepository | List the tags of a repository |
az container create -g MyResourceGroup --name myapp --image myimage:latest --cpu 1 --memory 1 | Run a container instanceStarts a container group with one core and 1 GB of memory. |
az container list | List container groups |
az container logs --name MyContainerGroup --resource-group MyResourceGroup | Read 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 MyResourceGroup | List container apps in a group |
Kubernetes clusters 14
| Command | What it does |
|---|---|
az aks create -g MyResourceGroup -n MyManagedCluster | Create an AKS clusterTakes the default Kubernetes version, a Standard load balancer and scale-set nodes. |
az aks get-credentials --name MyManagedCluster --resource-group MyResourceGroup | Fetch kubectl credentialsMerges the cluster entry into the .kube/config file that kubectl reads. |
az aks install-cli | Install the Kubernetes toolsDownloads kubectl and kubelogin, the credential plugin for Azure authentication. |
az aks list | List AKS clusters |
az aks show --name MyManagedCluster --resource-group MyResourceGroup | Show cluster details |
az aks scale --name MyManagedCluster --node-count 3 --resource-group MyResourceGroup | Scale the node poolSets the node count of the pool, three in this example. |
az aks get-upgrades --name MyManagedCluster --resource-group MyResourceGroup | List 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 MyResourceGroup | Upgrade a cluster |
az aks update -g MyResourceGroup -n MyManagedCluster --attach-acr acrName | Attach a registry to a clusterGrants the acrpull role on the registry named after the option. |
az aks stop --name myAKSCluster --resource-group myResourceGroup | Stop a clusterHalts the control plane and the nodes while cluster state is kept. |
az aks start --name myAKSCluster --resource-group myResourceGroup | Start 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 Ubuntu | Add a node pool--os-sku chooses the operating system of the new nodes. |
az aks nodepool list --cluster-name CLUSTER --resource-group GROUP | List node poolsLists pools, not nodes; kubectl get nodes shows the nodes themselves. |
az aks delete --name MyManagedCluster --resource-group MyResourceGroup | Delete 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.
| Command | What it does |
|---|---|
az appservice plan create -g MyResourceGroup -n MyPlan --is-linux | New App Service plan for LinuxThe plan name is what az webapp create expects after -p. |
az webapp create -g MyResourceGroup -p MyPlan -n MyUniqueAppName | Create 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-git | Node app with local GitSets the runtime stack and switches on local Git deployment. |
az webapp list-runtimes | List built-in runtime stacksGives the values that --runtime accepts. |
az webapp deploy -g ResourceGroup -n AppName --src-path app.zip | Deploy a zip packageFor a remote build, first switch on the SCM_DO_BUILD_DURING_DEPLOYMENT app setting. |
az webapp up | Create 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 --dryrun | Preview what webapp up would createPrints the planned app details and changes nothing. |
az webapp list --resource-group MyResourceGroup | List web apps in a group |
az webapp show --name MyWebapp --resource-group MyResourceGroup | Show a web app |
az webapp browse --name MyWebapp --resource-group MyResourceGroup | Browse to a web appNot available in Azure Cloud Shell. |
az webapp restart --name MyWebapp --resource-group MyResourceGroup | Restart a web app |
az webapp delete --name MyWebapp --resource-group MyResourceGroup | Delete a web app |
az webapp config appsettings set -g MyResourceGroup -n MyUniqueApp --settings WEBSITE_NODE_DEFAULT_VERSION=6.9.1 | Set an app settingSettings are KEY=VALUE pairs; several can follow --settings. |
az webapp config appsettings list --name MyWebapp --resource-group MyResourceGroup --subscription MySubscription | List app settings |
az webapp log tail --name NAME --resource-group GROUP | Tail the web app log |
az webapp log download --name MyWebApp --resource-group MyResourceGroup | Download the log historyThe logs arrive as a single zip file. |
az functionapp create -g MyResourceGroup -p MyPlan -n MyUniqueAppName -s MyStorageAccount | Create 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 MyStorageAccount | Create a consumption-plan function appHosts the app on the consumption plan of the named region instead of an App Service plan. |
az functionapp list-runtimes | List function runtime stacks |
az functionapp list --resource-group MyResourceGroup | List function apps in a group |
az functionapp delete --name MyFunctionApp --resource-group MyResourceGroup | Delete a function app |
Identity and access 10
| Command | What it does |
|---|---|
az ad signed-in-user show | Show the signed-in user |
az ad sp create-for-rbac | Create 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/myRG1 | Create a principal with a roleAssigns the reader role, limited to one resource group through --scopes. |
az ad sp list | List service principalsOnly the first 100 come back unless a filter or --all is given. |
az ad sp show --id 00000000-0000-0000-0000-000000000000 | Show 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/MyVm | Assign 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-000000000000 | List 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-000000000000 | Remove role assignmentsDeletes every assignment the assignee holds at subscription scope. |
az identity create --name myIdentityName --resource-group myResourceGroup | Create a user-assigned identity |
az identity list --resource-group MyResourceGroup | List identities in a group |
Key Vault 9
| Command | What it does |
|---|---|
az keyvault create --location westus2 --name MyKeyVault --resource-group MyResourceGroup | Create a key vault |
az keyvault list | List key vaults |
az keyvault show --name MyKeyVault | Show 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 MyResourceGroup | Delete a key vault |
az keyvault secret set --name MySecretName --vault-name MyKeyVault --value MyVault | Store 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 MyEncoding | Store 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 VAULT | List the secrets in a vaultReturns identifiers and attributes only, never the values or the individual versions. |
Networking 14
| Command | What 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/24 | Create a virtual networkOne call creates the network with its address space and a first subnet. |
az network vnet list | List virtual networks |
az network vnet show -g MyResourceGroup -n MyVNet | Show 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 MyRouteTable | Create a subnetAttaches an existing NSG and a custom route table at creation time. |
az network vnet subnet list -g MyResourceGroup --vnet-name MyVNet | List the subnets of a network |
az network vnet subnet update -g MyResourceGroup -n MySubnet --vnet-name MyVNet --network-security-group MyNsg | Attach an NSG to a subnet |
az network nsg create -g MyResourceGroup -n MyNsg --tags foo=bar | Create a network security group |
az network nsg show -g MyResourceGroup -n MyNsg --query "defaultSecurityRules[]" -o table | Show 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 100 | Add 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 MyNsg | List the rules of an NSG |
az network public-ip create -g MyResourceGroup -n MyIp --dns-name MyLabel --allocation-method Static | Reserve a static public IP--dns-name adds a DNS label to the address. |
az network public-ip list -g MyResourceGroup | List 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
| Command | What it does |
|---|---|
az deployment group create --resource-group testrg --name rollout01 --template-uri https://myresource/azuredeploy.json --parameters @myparameters.json | Deploy 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.bicepparam | Deploy 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.json | Preview 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 testrg | List deployments of a group |
az deployment sub create --location WestUS --template-uri https://myresource/azuredeploy.json --parameters @myparameters.json | Deploy at subscription scope--location says where the metadata of the deployment is kept. |
az bicep install | Install the Bicep CLI |
az bicep upgrade | Upgrade 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
| Command | What it does |
|---|---|
az monitor activity-log list -g {ResourceGroup} --offset 1h | List 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 7d | List 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-586d19417c5f | Trace 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.
| Command | What it does |
|---|---|
az version | Show installed versionsLists the CLI modules and extensions as JSON unless another output format is configured. |
az upgrade | Update the Azure CLIGoes to the latest release only and, by default, updates every installed extension too. |
az config set auto-upgrade.enable=yes | Turn on automatic upgradesDisabled by default; once on, the CLI checks regularly and prompts after a command finishes. |
az config get | Show 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=MyResourceGroup | Set a default group and regionCommands then use these values where the arguments would otherwise be required. |
az config set core.only_show_errors=true | Hide warnings permanentlySame effect as passing --only-show-errors on every command. |
az configure | Configure the CLI interactivelyThe reference recommends az config for automation and for the full set of options. |
az configure --defaults group=myRG web=myweb vm=myvm | Set default names with configureStores a default resource group, web app and VM name in one call. |
az extension list-available --output table | List extensions that can be installedCovers the extensions that Microsoft itself publishes and looks after. |
az extension add --name anextension | Install an extension by nameAdds a command group that does not ship with the core CLI. |
az extension add --upgrade --name anextension | Install or update an extensionWith --upgrade an extension that is already installed is brought up to date. |
az extension list | List installed extensions |
az extension remove --name MyExtension | Uninstall 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 interactive | Start 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/directoryAudits | Call a REST endpoint directlySigns the request with the logged-in credential, so no token handling is needed. |
az feedback | Send feedback to the CLI teamInteractive; opens a prefilled GitHub issue in the browser when it can. |
az survey | Take 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.
| Command | What it does |
|---|---|
az vm list --output json | Print JSON outputJSON is the default, so the option only matters when another default is configured. |
az vm list --output table | Print a tableEasy to scan, but nested objects and some fields are left out. |
az vm list --output tsv | Print tab-separated valuesNo keys or extra symbols, which suits piping into other tools. |
az account show --output jsonc | Print colorized JSONOverrides the configured default for this one command. |
az config set core.output=table | Change 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 table | Choose 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 table | Filter 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 table | Sort the resultssort_by is a JMESPath function; &Size names the key to order on. |
az group create --name myResourceGroup --location eastus --help | Show 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 --verbose | Run with verbose loggingAdds detail such as how long the command took. |
az group create --name myResourceGroup --location eastus --debug | Run with full debug logsMicrosoft asks for this output when a bug is reported. |
az interactive --only-show-errors | Show errors onlyRemoves messages such as the preview notice of this command. |
No row on this page matches that filter.
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
- Azure CLI reference (2.91.0, latest): reference index and top-level commands List of command groups; syntax and Examples of az login, az logout, az configure, az find, az rest, az version
- Azure CLI reference (2.91.0, latest): az account Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az group Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az vm Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az storage account Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az storage blob Command table, syntax blocks and Examples
50 more source pages
- Azure CLI reference (2.91.0, latest): az storage container Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az aks Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az acr Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az webapp Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az functionapp Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az appservice plan Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az webapp config appsettings Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az webapp log Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az ad sp Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az ad signed-in-user Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az role assignment Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az identity Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az keyvault Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az keyvault secret Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az network vnet Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az network vnet subnet Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az network nsg Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az network nsg rule Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az network public-ip Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az deployment group Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az deployment sub Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az bicep Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az config Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az extension Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az monitor activity-log Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az monitor metrics Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az resource Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az tag Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az lock Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az provider Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az container Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az vm disk Command table, syntax blocks and Examples
- Microsoft Learn: Azure CLI release notes Version number and date of the latest release
- Microsoft Learn: Output formats for Azure CLI commands --output examples for json, table, tsv and jsonc, default output setting
- Microsoft Learn: How to query Azure CLI command output using a JMESPath query --query examples: properties, filters and sorting
- Microsoft Learn: How to work with global parameters in Azure CLI --help, --verbose, --debug, --only-show-errors, --output and their accepted values
- Microsoft Learn: How to manage Azure subscriptions with the Azure CLI az account show, list, set and clear
- Microsoft Learn: Sign in interactively using the Azure CLI az login with --tenant
- Microsoft Learn: Azure CLI configuration options az config set with default values
- Microsoft Learn: Use and manage extensions with the Azure CLI az extension list-available and how extensions are installed
- Microsoft Learn: How to update the Azure CLI az upgrade and the auto-upgrade settings
- Microsoft Learn: Create an Azure service principal with Azure CLI az ad sp create-for-rbac with and without a role
- Microsoft Learn: Azure CLI interactive mode az interactive
- Azure CLI reference (2.91.0, latest): az aks nodepool Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az containerapp Command table, syntax blocks and Examples
- Microsoft Learn: Stop and start an Azure Kubernetes Service (AKS) cluster az aks stop and az aks start examples
- Microsoft Learn: Quickstart, set and retrieve a secret from Azure Key Vault using Azure CLI az keyvault secret show and az group delete examples
- Azure CLI reference (2.91.0, latest): az acr repository Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az vm run-command Command table, syntax blocks and Examples
- Azure CLI reference (2.91.0, latest): az storage account keys Command table, syntax blocks and Examples
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.