What's not here, and why.
az deployment create/update belongs in Bicep or Terraform.
az devops / az pipelines: nobody runs these interactively.
az network application-gateway: console territory under pressure.
az sql managed instance: console under pressure.
az cosmosdb: SDK beats CLI for anything meaningful.
az cognitiveservices, az bot, not in scope.
Entra ID / AAD mutations beyond service principals: too destructive to run from a CLI reference.
cross-cutting: know these before anything else
auth patterns
az login
az login --use-device-code
az login --service-principal -u $APP_ID -p $SECRET --tenant $TENANT_ID
az login --identity
# --identity uses managed identity: correct pattern in CI/VMs
subscription / context
az account list --output table
az account set --subscription "My Prod Sub"
az account show --query '{Sub:name,ID:id,Tenant:tenantId}'
az account list --query '[?isDefault]'
# or scope per-command: --subscription <id>
--query (JMESPath) + --output
az vm list --query '[].{Name:name,RG:resourceGroup,State:powerState}' --output table
az resource list --query '[?tags.env==`prod`].id' --output tsv
# --output: table json jsonc tsv yaml
# tsv: tab-separated, no headers; safe for xargs / shell pipelines
resource groups & --resource-group
az group list --query '[].{Name:name,Location:location,State:properties.provisioningState}' --output table
az group show --name myRG --query 'properties.provisioningState'
# almost every az command accepts -g / --resource-group
# set default to avoid repeating it:
az configure --defaults group=myRG location=eastus
| Service / Command | Phase | Key commands | Use case |
|---|---|---|---|
| az login | auth |
az login
az login --use-device-code
az login --service-principal -u $APP_ID -p $CLIENT_SECRET --tenant $TENANT_ID
az login --service-principal -u $APP_ID --certificate $CERT_PATH --tenant $TENANT_ID
az login --identity
az logout
|
Certificate-based SP auth is preferred over client secret in CI: no secret rotation needed, and certificates can be stored in Key Vault. --identity uses the managed identity attached to the VM or ACI instance: the correct pattern for workloads running in Azure. Never store client secrets in environment files. |
| az ad sp | auth |
az ad sp show --id $APP_ID --query '{DisplayName:displayName,AppID:appId,ObjectID:id}'
az ad sp list --display-name myapp --query '[].{Name:displayName,AppID:appId,Enabled:accountEnabled}' --output table
az ad sp credential list --id $APP_ID --query '[].{KeyID:keyId,Type:type,Expires:endDateTime}' --output table
az ad sp credential reset --id $APP_ID --append
az role assignment list --assignee $APP_ID --query '[].{Role:roleDefinitionName,Scope:scope}' --output table
|
Inspection and credential rotation only: mutations belong in Terraform. credential list shows expiry dates; surface credentials expiring within 30 days before they break CI. role assignment list --assignee audits what a service principal can actually do across subscriptions. |
| az account | auth |
az account list --output table
az account set --subscription "Prod-West-EU"
az account show
az account get-access-token --query 'accessToken' --output tsv
az account get-access-token --resource https://management.azure.com/ --query '{Token:accessToken,Expires:expiresOn}'
|
get-access-token retrieves a bearer token for direct REST API calls: useful when the CLI doesn't expose a specific API surface. Pass the token to curl or httpie for ad-hoc ARM API calls. --resource scopes the token to a specific audience. |
| az vm | compute |
az vm list -g myRG --query '[].{Name:name,State:powerState,Size:hardwareProfile.vmSize,IP:privateIps}' --output table
az vm get-instance-view -g myRG -n myVM --query '{Statuses:instanceView.statuses[].displayStatus}'
az vm start -g myRG -n myVM
az vm stop -g myRG -n myVM
az vm restart -g myRG -n myVM
az vm run-command invoke -g myRG -n myVM --command-id RunShellScript --scripts "df -h && free -m"
|
get-instance-view shows the actual VM health state including OS provisioning status: more detailed than show. run-command invoke executes a shell script on the VM without SSH: the Azure equivalent of SSM run-command. Requires the VM agent to be running. Provision VMs via Terraform; use the CLI for runtime ops. |
| az vmss | compute |
az vmss list -g myRG --query '[].{Name:name,Capacity:sku.capacity,State:provisioningState}' --output table
az vmss list-instances -g myRG -n myVMSS --query '[].{ID:instanceId,State:provisioningState,PowerState:powerState}' --output table
az vmss scale -g myRG -n myVMSS --new-capacity 5
az vmss get-instance-view -g myRG -n myVMSS --instance-id 0
az vmss delete-instances -g myRG -n myVMSS --instance-ids 3
|
Manual scaling with scale --new-capacity overrides autoscale temporarily: useful during a traffic spike or when autoscale is misbehaving. delete-instances removes a specific unhealthy instance and triggers replacement. Always check list-instances before deleting to confirm the instance ID. |
| az aks | compute |
az aks list -g myRG --query '[].{Name:name,Version:kubernetesVersion,State:provisioningState,FQDN:fqdn}' --output table
az aks get-credentials -g myRG -n myAKS --overwrite-existing
az aks get-credentials -g myRG -n myAKS --admin
az aks nodepool list -g myRG --cluster-name myAKS --query '[].{Name:name,Count:count,VMSize:vmSize,State:provisioningState}' --output table
az aks nodepool scale -g myRG --cluster-name myAKS -n nodepool1 --node-count 5
az aks get-upgrades -g myRG -n myAKS --query 'upgrades[].kubernetesVersion' --output tsv
|
get-credentials --overwrite-existing refreshes kubeconfig without prompting: safe in scripts. --admin fetches cluster-admin credentials, bypassing AAD RBAC. Use only for break-glass access. get-upgrades lists available Kubernetes versions before scheduling a maintenance window. |
| az container | compute |
az container list -g myRG --query '[].{Name:name,State:instanceView.state,IP:ipAddress.ip}' --output table
az container show -g myRG -n myACI --query '{State:instanceView.state,Events:instanceView.events[-3:]}'
az container logs -g myRG -n myACI --follow
az container exec -g myRG -n myACI --exec-command "/bin/sh"
az container restart -g myRG -n myACI
|
ACI is underused as a one-shot job runner: no cluster overhead, billed per second. show with instanceView.events shows the last few lifecycle events: the first place to look when a container fails to start. exec gives an interactive shell without exposing a port. |
| az functionapp | compute |
az functionapp list -g myRG --query '[].{Name:name,State:state,Runtime:kind,URL:defaultHostName}' --output table
az functionapp show -g myRG -n myFunc --query '{State:state,OutboundIPs:outboundIpAddresses}'
az functionapp restart -g myRG -n myFunc
az functionapp config appsettings list -g myRG -n myFunc --query '[].{Key:name,Value:value}' --output table
az functionapp config appsettings set -g myRG -n myFunc --settings KEY=VALUE
az webapp log tail -g myRG -n myFunc
|
config appsettings list reveals environment variables, but values are shown in plaintext; avoid running this in shared terminal sessions. az webapp log tail works for both App Service and Function Apps: live log streaming without opening the portal. App setting mutations should go through Terraform; use the CLI for emergency overrides only. |
| az storage blob | storage |
az storage blob list --account-name mystorageaccount -c mycontainer --query '[].{Name:name,Size:properties.contentLength,Modified:properties.lastModified}' --output table
az storage blob upload --account-name mystorageaccount -c mycontainer -f ./file.tar.gz -n file.tar.gz
az storage blob download --account-name mystorageaccount -c mycontainer -n file.tar.gz -f ./file.tar.gz
az storage blob copy start --account-name mystorageaccount --destination-container dest -b srcblob --source-uri "https://src.blob.core.windows.net/..."
az storage blob generate-sas --account-name mystorageaccount -c mycontainer -n file.tar.gz --permissions r --expiry 2026-12-31 --https-only --output tsv
|
generate-sas produces a time-limited read URL: the correct way to share private blobs without changing container access policy. blob copy start is server-side: Azure copies blob-to-blob without routing through your machine. Always use --https-only on SAS tokens; HTTP SAS is a security misconfiguration. |
| az storage account | storage |
az storage account list -g myRG --query '[].{Name:name,SKU:sku.name,Replication:sku.tier,TLS:minimumTlsVersion,HTTPS:supportsHttpsTrafficOnly}' --output table
az storage account show -g myRG -n mystorageaccount --query '{PublicAccess:allowBlobPublicAccess,NetworkRules:networkAcls.defaultAction}'
az storage account keys list -g myRG -n mystorageaccount --query '[0].value' --output tsv
az storage account keys renew -g myRG -n mystorageaccount --key primary
az storage account network-rule list -g myRG -n mystorageaccount
|
show with allowBlobPublicAccess and networkAcls.defaultAction is a quick security posture check: any account with allowBlobPublicAccess: true and no network rules is a finding. Key renewal should be done with zero downtime: update the dependent services to key2 first, then renew key1. |
| az storage fs (ADLS Gen2) | storage |
az storage fs list --account-name myadls --query '[].{Name:name,State:properties.leaseState}' --output table
az storage fs file list --account-name myadls -f myfilesystem --recursive --query '[].{Path:name,Size:contentLength}' --output table
az storage fs access show --account-name myadls -f myfilesystem -p /mydir
az storage fs access set --account-name myadls -f myfilesystem -p /mydir --acl "user::rwx,group::r-x,other::---"
|
ADLS Gen2 exposes POSIX ACLs on top of blob storage: access show/set manages fine-grained directory permissions that aren't visible through standard blob commands. Critical for data lake access control where different teams need different directory-level permissions. |
| az disk | storage |
az disk list -g myRG --query '[].{Name:name,Size:diskSizeGb,State:diskState,SKU:sku.name}' --output table
az disk list -g myRG --query '[?diskState==`Unattached`].name' --output tsv
az snapshot create -g myRG -n myVM-snap-$(date +%Y%m%d) --source myVM-osdisk
az snapshot list -g myRG --query '[].{Name:name,Size:diskSizeGb,State:provisioningState,Date:timeCreated}' --output table
az snapshot delete -g myRG -n myVM-snap-old
|
Unattached disks accumulate storage costs silently: the diskState==Unattached query identifies orphans for cleanup. Always snapshot before risky operations. Snapshot names with $(date +%Y%m%d) suffix keep the list readable; use a consistent naming convention across the team. |
| az network nsg | networking |
az network nsg list -g myRG --query '[].name' --output tsv
az network nsg rule list -g myRG --nsg-name myNSG --query '[].{Name:name,Priority:priority,Dir:direction,Access:access,Port:destinationPortRange,Source:sourceAddressPrefix}' --output table
az network nsg rule list -g myRG --nsg-name myNSG --query '[?access==`Allow` && sourceAddressPrefix==`*`].{Name:name,Port:destinationPortRange}' --output table
az network nsg rule create -g myRG --nsg-name myNSG -n AllowHTTPS --priority 100 --protocol Tcp --destination-port-ranges 443 --access Allow
az network nsg rule delete -g myRG --nsg-name myNSG -n DenyAll
|
The third command surfaces all rules allowing traffic from any source: a quick audit for overly permissive NSGs. Priority ordering matters in NSGs (lower number = higher priority); always check existing priorities before adding a rule. NSG mutations belong in Terraform; use the CLI for emergency access changes only. |
| az network lb | networking |
az network lb list -g myRG --query '[].{Name:name,SKU:sku.name,State:provisioningState}' --output table
az network lb show -g myRG -n myLB --query '{FrontendIPs:frontendIPConfigurations[].publicIPAddress.id,BackendPools:backendAddressPools[].name}'
az network lb probe list -g myRG --lb-name myLB --query '[].{Name:name,Protocol:protocol,Port:port,Path:requestPath,Interval:intervalInSeconds}' --output table
az network lb address-pool show -g myRG --lb-name myLB -n myPool --query 'loadBalancerBackendAddresses[].ipAddress'
|
Health probe configuration is the first thing to check when traffic stops reaching backends: probe list shows the exact path and interval the LB uses. address-pool show confirms which backend IPs are registered: useful when a VM is missing from the pool after a restart. |
| az network dns | networking |
az network dns zone list -g myRG --query '[].{Name:name,RecordSets:numberOfRecordSets}' --output table
az network dns record-set list -g myRG -z example.com --query '[].{Name:name,Type:type,TTL:ttl}' --output table
az network dns record-set a show -g myRG -z example.com -n api --query 'aRecords[].ipv4Address'
az network dns record-set a add-record -g myRG -z example.com -n api -a 10.0.0.1
az network dns record-set a remove-record -g myRG -z example.com -n api -a 10.0.0.1
|
DNS record management from the CLI is version-controllable via scripts. Prefer over portal edits for anything that needs an audit trail. show on a specific record type is faster than listing all records when you know what you're looking for. DNS mutations to production zones should go through Terraform where possible. |
| az network vnet | networking |
az network vnet list -g myRG --query '[].{Name:name,AddressSpace:addressSpace.addressPrefixes,Subnets:subnets|length(@)}' --output table
az network vnet subnet list -g myRG --vnet-name myVNet --query '[].{Name:name,Prefix:addressPrefix,NSG:networkSecurityGroup.id,Delegation:delegations[0].serviceName}' --output table
az network vnet peering list -g myRG --vnet-name myVNet --query '[].{Name:name,Remote:remoteVirtualNetwork.id,State:peeringState}' --output table
az network public-ip list -g myRG --query '[].{Name:name,IP:ipAddress,FQDN:dnsSettings.fqdn,Allocation:publicIPAllocationMethod}' --output table
|
subnet list with delegations reveals subnets delegated to specific Azure services (App Service, ACI, etc): useful when diagnosing why a service can't be deployed to a subnet. Public IP list surfaces all internet-facing addresses in a resource group. Run it as a periodic inventory check. |
| az network watcher | networking |
az network watcher list --query '[].{Region:location,State:provisioningState}' --output table
az network watcher show-next-hop -g myRG --vm myVM --source-ip 10.0.0.4 --dest-ip 10.1.0.4
az network watcher test-connectivity -g myRG --source-resource myVM --dest-address 10.1.0.4 --dest-port 443
az network watcher flow-log show -g myRG --nsg myNSG
|
test-connectivity runs a reachability check between two resources from inside Azure's network plane: more reliable than pinging from a VM because it accounts for NSG rules, UDRs, and service endpoints. show-next-hop reveals the effective routing decision for a source/destination pair: the fastest way to diagnose asymmetric routing. |
| az keyvault secret | secrets |
az keyvault secret list --vault-name myKV --query '[].{Name:name,Enabled:attributes.enabled,Expires:attributes.expires}' --output table
az keyvault secret show --vault-name myKV -n mySecret --query 'value' --output tsv
az keyvault secret set --vault-name myKV -n mySecret --value "$(openssl rand -base64 32)"
az keyvault secret set-attributes --vault-name myKV -n mySecret --expires 2027-01-01T00:00:00Z
az keyvault secret delete --vault-name myKV -n mySecret
az keyvault secret recover --vault-name myKV -n mySecret
|
List with expiry dates surfaces secrets about to expire: automate this check in CI. show --output tsv extracts the raw value for piping; avoid printing it to a shared terminal. Soft-delete is enabled by default: recover restores deleted secrets within the retention period (default 90 days). Never store secrets in scripts; always retrieve at runtime. |
| az keyvault certificate | secrets |
az keyvault certificate list --vault-name myKV --query '[].{Name:name,Enabled:attributes.enabled,Expires:attributes.expires,Issuer:policy.issuerParameters.name}' --output table
az keyvault certificate show --vault-name myKV -n myCert --query '{Subject:policy.x509CertificateProperties.subject,SANs:policy.x509CertificateProperties.subjectAlternativeNames,Expires:attributes.expires}'
az keyvault certificate import --vault-name myKV -n myCert -f cert.pfx --password "$PFX_PASS"
az keyvault certificate download --vault-name myKV -n myCert -f cert.pem --encoding PEM
|
Certificate expiry audit from the CLI is automatable: pipe the list into a script that alerts when any cert expires within 30 days. show with SANs confirms the cert covers the right hostnames before importing. Import accepts PFX (PKCS#12); download produces PEM for direct use in application config. |
| az identity | secrets |
az identity list -g myRG --query '[].{Name:name,ClientID:clientId,PrincipalID:principalId}' --output table
az identity show -g myRG -n myManagedIdentity
az vm identity show -g myRG -n myVM
az aks show -g myRG -n myAKS --query '{Kubelet:identityProfile.kubeletidentity.clientId,ControlPlane:identity.principalId}'
|
Managed identities are the correct credential model for Azure workloads: no secrets to rotate. vm identity show confirms which identity is attached to a VM before troubleshooting Key Vault access failures. AKS exposes two identities: the control plane identity and the kubelet identity; they have different role assignments and are commonly confused. |
| az monitor log-analytics | observability |
az monitor log-analytics workspace list -g myRG --query '[].{Name:name,ID:customerId,RetentionDays:retentionInDays}' --output table
az monitor log-analytics query -w $WORKSPACE_ID --analytics-query "ContainerLog | where LogEntry contains 'ERROR' | project TimeGenerated, LogEntry | order by TimeGenerated desc | take 50"
az monitor log-analytics query -w $WORKSPACE_ID --analytics-query "AzureActivity | where ActivityStatus == 'Failed' | summarize count() by Caller, OperationName | order by count_ desc"
az monitor log-analytics query -w $WORKSPACE_ID --analytics-query "Heartbeat | summarize LastSeen=max(TimeGenerated) by Computer | where LastSeen < ago(5m)"
|
KQL queries from the CLI are scriptable and version-controllable: paste them into runbooks. The activity log query surfaces failed operations by caller: useful for post-incident attribution. The heartbeat query finds VMs that haven't reported in 5 minutes: a faster way to detect agent failures than the portal health view. |
| az monitor metrics | observability |
az monitor metrics list --resource $VM_RESOURCE_ID --metric "Percentage CPU" --interval PT5M --query 'value[0].timeseries[0].data[-12:].{Time:timeStamp,CPU:average}' --output table
az monitor metrics list-definitions --resource $VM_RESOURCE_ID --query '[].name.value' --output tsv
az monitor metrics alert list -g myRG --query '[].{Name:name,State:enabled,Severity:severity,Condition:criteria.allOf[0].metricName}' --output table
az monitor metrics alert show -g myRG -n myAlert --query '{Fired:lastFiredAt,Description:description,Condition:criteria}'
|
list-definitions reveals every metric available for a resource type. Use before writing an alert to confirm the metric name is exact. The CPU query pattern using [-12:] shows the last hour at 5-minute granularity. Alert lastFiredAt is useful when investigating whether an alert has been flapping or went quiet after a change. |
| az webapp log tail | observability |
az webapp log tail -g myRG -n myApp
az webapp log tail -g myRG -n myFunc
az webapp log show -g myRG -n myApp
az webapp log download -g myRG -n myApp --log-file /tmp/applogs.zip
az monitor activity-log list -g myRG --start-time 2026-05-01 --query '[].{Time:eventTimestamp,Caller:caller,Op:operationName.localizedValue,Status:status.localizedValue}' --output table
|
Works for both App Service and Functions: live log streaming without the portal. activity-log list scoped to a resource group shows every control-plane operation (creates, updates, deletes, role changes) with caller identity: the first place to look when something changed unexpectedly in a resource group. |
| az acr | data / platform |
az acr login -n myregistry
az acr list -g myRG --query '[].{Name:name,SKU:sku.name,LoginServer:loginServer}' --output table
az acr repository list -n myregistry --output tsv
az acr repository show-tags -n myregistry --repository myapp --orderby time_desc --top 10 --output tsv
az acr repository show-manifests -n myregistry --repository myapp --query '[?tags==null].digest' --output tsv | head -20
az acr run -r myregistry --cmd 'acr/tasks/myapp:latest' /dev/null
|
az acr login exchanges the current az session for a Docker credential: no PAT needed. Untagged manifests accumulate and inflate storage costs: the show-manifests + tags==null query identifies orphans. Use lifecycle policies for automated cleanup; use the CLI for one-off audits and emergency deletions. |
| az postgres flexible-server | data / platform |
az postgres flexible-server list -g myRG --query '[].{Name:name,SKU:sku.name,Version:version,State:state,FQDN:fullyQualifiedDomainName}' --output table
az postgres flexible-server show -g myRG -n myPGServer --query '{State:state,Storage:storage,Backup:backup,HA:highAvailability}'
az postgres flexible-server restart -g myRG -n myPGServer
az postgres flexible-server backup list -g myRG -n myPGServer --query '[].{Name:name,Type:backupType,Date:completedTime}' --output table
az postgres flexible-server connect -g myRG -n myPGServer -u myadmin -d mydb --interactive
|
connect --interactive opens a psql session through the Azure CLI without exposing the server publicly or managing firewall rules manually: uses the current az session for auth tunneling. Backup list confirms the last successful backup before a risky schema migration. |
| az servicebus | data / platform |
az servicebus namespace list -g myRG --query '[].{Name:name,SKU:sku.name,State:status}' --output table
az servicebus queue list -g myRG --namespace-name mySBNS --query '[].{Name:name,ActiveMessages:countDetails.activeMessageCount,DLQ:countDetails.deadLetterMessageCount,Size:sizeInBytes}' --output table
az servicebus topic list -g myRG --namespace-name mySBNS --query '[].{Name:name,Subscriptions:subscriptionCount,Size:sizeInBytes}' --output table
az servicebus queue show -g myRG --namespace-name mySBNS -n myQueue --query 'countDetails'
|
Inspection only: the CLI surface for Service Bus is too thin for message operations (use the SDK or Service Bus Explorer). queue list with deadLetterMessageCount is the first check when a consumer is falling behind: DLQ depth growing means messages are being rejected, not just unprocessed. |
| az group / az resource | data / platform |
az group list --query '[].{Name:name,Location:location,State:properties.provisioningState,Tags:tags}' --output table
az resource list -g myRG --query '[].{Name:name,Type:type,Location:location}' --output table
az resource list --tag env=prod --query '[].{Name:name,Type:type,RG:resourceGroup}' --output table
az resource tag --ids $RESOURCE_ID --tags env=prod owner=myteam
az group export -n myRG --include-comments > rg-template.json
|
az resource list --tag is the fastest cross-service inventory query: find everything tagged env=prod regardless of type. az group export generates an ARM template from the live resource group: useful as a starting point for Bicep or for auditing what's actually deployed vs what's in Terraform state. |
No entries match this filter.