Home / Topics / Azure for DevOps / Cheatsheet
Azure for DevOps

Cheatsheet

Dense CLI, IaC and config reference for day-to-day Azure work and interviews. Azure CLI 2.6x syntax, Terraform azurerm v4, Bicep.


CLI setup, context and output

TaskCommand
Log in (browser / device code)az login / az login --use-device-code
Log in as managed identityaz login --identity (user-assigned: add --client-id <id>)
Log in as service principal with OIDC tokenaz login --service-principal -u <clientId> -t <tenantId> --federated-token "$TOKEN"
List / set subscriptionaz account list -o table / az account set --subscription <id>
Who am Iaz account show --query "{sub:name, user:user.name, tenant:tenantId}" -o table
My object IDaz ad signed-in-user show --query id -o tsv
Get an access tokenaz account get-access-token --resource https://management.azure.com
Set defaultsaz config set defaults.group=rg-shop defaults.location=centralindia
Output formats-o json|jsonc|table|tsv|yaml|none
Filter (JMESPath)--query "[?location=='centralindia'].{n:name, id:id}"
Call any ARM / Graph APIaz rest --method get --url <url>
Extensionsaz extension add -n <name> / az extension list -o table
Upgrade CLIaz upgrade
Debug a callaz group list --debug 2>&1 | grep -i "request url"

Resource groups, tags, locks and Resource Graph

TaskCommand
Create RG with tagsaz group create -n rg-shop-dev -l centralindia --tags env=dev owner=platform
Delete RG (async)az group delete -n rg-shop-dev --yes --no-wait
Merge tagsaz tag update --resource-id <id> --operation merge --tags costcenter=cc-104
Resources by tagaz resource list --tag env=dev -o table
Lock / list locksaz lock create -n no-delete -g rg --lock-type CanNotDelete / az lock list -o table
Move resourcesaz resource move --destination-group rg-new --ids <id1> <id2>
Provider registrationaz provider register -n Microsoft.ContainerService --wait
Activity Log, last dayaz monitor activity-log list -g rg --offset 1d -o table
Resource Graph count by typeaz graph query -q "Resources | summarize count() by type"
Unattached disksaz graph query -q "Resources | where type =~ 'microsoft.compute/disks' and properties.diskState == 'Unattached' | project name, resourceGroup"

Entra ID, RBAC and managed identities

TaskCommand
Assign role (user/group)az role assignment create --assignee <upn-or-objectId> --role Reader --scope <scope>
Assign role (new identity, skip lookup)az role assignment create --assignee-object-id <oid> --assignee-principal-type ServicePrincipal --role AcrPull --scope <acrId>
List assignments (all scopes, inherited, groups)az role assignment list --assignee <id> --all --include-inherited --include-groups -o table
Who has Owner hereaz role assignment list --role Owner --scope <scope> --include-inherited -o table
Show a role's actionsaz role definition list -n "AcrPush" --query "[].permissions"
Create custom roleaz role definition create --role-definition @role.json
Create user-assigned identityaz identity create -g rg -n id-shop-web
Identity IDsaz identity show -g rg -n id-shop-web --query "{clientId:clientId, principalId:principalId}"
Enable system identity on VMaz vm identity assign -g rg -n vm-app
Federated credential (GitHub)az identity federated-credential create -g rg --identity-name id-ci -n gh-prod --issuer https://token.actions.githubusercontent.com --subject repo:org/repo:environment:prod --audiences api://AzureADTokenExchange
Federated credential (AKS pod)... --issuer <aks oidc url> --subject system:serviceaccount:<ns>:<sa>
App registration + SPaz ad app create --display-name app-ci then az ad sp create --id <appId>
SP with secret (avoid)az ad sp create-for-rbac -n sp-legacy --role AcrPush --scopes <acrId>
List / reset secretaz ad app credential list --id <appId> / az ad app credential reset --id <appId> --append
Group membership checkaz ad group member check --group <group> --member-id <oid>

Federated subjects GitHub sends: repo:O/R:ref:refs/heads/main, repo:O/R:environment:prod, repo:O/R:pull_request, repo:O/R:ref:refs/tags/v1.0.0. Azure DevOps: issuer https://vstoken.dev.azure.com/<org-id>, subject sc://<org>/<project>/<service-connection>.

Key roles: Owner, Contributor, Reader, User Access Administrator, Role Based Access Control Administrator, Network Contributor, AcrPull, AcrPush, Key Vault Secrets User / Officer, Storage Blob Data Reader / Contributor, Azure Kubernetes Service Cluster User Role, Azure Kubernetes Service RBAC Reader / Writer / Admin / Cluster Admin, Monitoring Contributor, Log Analytics Reader.

Networking

TaskCommand
VNet + subnetaz network vnet create -g rg -n vnet-shop --address-prefixes 10.20.0.0/16 --subnet-name snet-app --subnet-prefixes 10.20.1.0/24
Add subnetaz network vnet subnet create -g rg --vnet-name vnet-shop -n snet-pe --address-prefixes 10.20.2.0/24
NSG + ruleaz network nsg create -g rg -n nsg-app then az network nsg rule create -g rg --nsg-name nsg-app -n allow-8080 --priority 100 --direction Inbound --access Allow --protocol Tcp --source-address-prefixes 10.20.0.0/24 --destination-port-ranges 8080
Attach NSG to subnetaz network vnet subnet update -g rg --vnet-name vnet-shop -n snet-app --network-security-group nsg-app
ASGaz network asg create -g rg -n asg-web; use --source-asgs asg-web in rules
Route table + UDRaz network route-table create -g rg -n rt-spoke then az network route-table route create -g rg --route-table-name rt-spoke -n default --address-prefix 0.0.0.0/0 --next-hop-type VirtualAppliance --next-hop-ip-address 10.0.1.4
Peering (run on both sides)az network vnet peering create -g rg -n a-to-b --vnet-name vnet-a --remote-vnet <vnetBId> --allow-vnet-access --allow-forwarded-traffic
NAT Gatewayaz network nat gateway create -g rg -n nat-shop --public-ip-addresses pip-nat then az network vnet subnet update ... --nat-gateway nat-shop
Private Endpointaz network private-endpoint create -g rg -n pe-kv --vnet-name vnet-shop --subnet snet-pe --private-connection-resource-id <kvId> --group-id vault --connection-name kv-conn
Private DNS zone + linkaz network private-dns zone create -g rg -n privatelink.vaultcore.azure.net / az network private-dns link vnet create -g rg -z privatelink.vaultcore.azure.net -n link -v <vnetId> -e false
Zone group on PEaz network private-endpoint dns-zone-group create -g rg --endpoint-name pe-kv -n default --private-dns-zone privatelink.vaultcore.azure.net --zone-name kv
Effective NSG / routesaz network nic list-effective-nsg -g rg -n <nic> / az network nic show-effective-route-table -g rg -n <nic> -o table
IP flow verifyaz network watcher test-ip-flow -g rg --vm vm --direction Inbound --protocol TCP --local 10.20.1.4:443 --remote 1.2.3.4:50000
Next hopaz network watcher show-next-hop -g rg --vm vm --source-ip 10.20.1.4 --dest-ip 8.8.8.8
App Gateway backend healthaz network application-gateway show-backend-health -g rg -n agw

Private DNS zone names: Key Vault privatelink.vaultcore.azure.net · Blob privatelink.blob.core.windows.net · ACR privatelink.azurecr.io · Azure SQL privatelink.database.windows.net · PostgreSQL Flexible privatelink.postgres.database.azure.com · AKS API privatelink.<region>.azmk8s.io · App Service privatelink.azurewebsites.net.

Special subnets: GatewaySubnet (/27+), AzureFirewallSubnet (/26), AzureFirewallManagementSubnet (/26), AzureBastionSubnet (/26+), App Gateway v2 dedicated (/24 recommended), Container Apps workload profiles (/27+, delegated).

VMs and VMSS

TaskCommand
Create VM, no public IPaz vm create -g rg -n vm-app --image Ubuntu2204 --size Standard_B2s --vnet-name vnet-shop --subnet snet-app --public-ip-address "" --nsg "" --assign-identity --custom-data cloud-init.yaml --generate-ssh-keys
Sizes and availabilityaz vm list-skus -l centralindia --size Standard_D4 --resource-type virtualMachines -o table
Quota usageaz vm list-usage -l centralindia -o table
Run a command insideaz vm run-command invoke -g rg -n vm-app --command-id RunShellScript --scripts "uptime"
Deallocate (stop billing compute)az vm deallocate -g rg -n vm-app
Resizeaz vm resize -g rg -n vm-app --size Standard_D4s_v5
Boot logaz vm boot-diagnostics get-boot-log -g rg -n vm-app
Auto-shutdown (UTC)az vm auto-shutdown -g rg -n vm-app --time 1430
VMSS create (Flexible)az vmss create -g rg -n vmss-web --image Ubuntu2204 --orchestration-mode Flexible --instance-count 2 --zones 1 2 3
Scale VMSSaz vmss scale -g rg -n vmss-web --new-capacity 4
Bastion SSH with Entraaz network bastion ssh -n bas -g rg-hub --target-resource-id <vmId> --auth-type AAD

AKS

TaskCommand
Create (production-style)az aks create -g rg -n aks --tier standard --zones 1 2 3 --node-count 3 --network-plugin azure --network-plugin-mode overlay --network-dataplane cilium --enable-aad --enable-azure-rbac --disable-local-accounts --enable-oidc-issuer --enable-workload-identity --enable-addons azure-keyvault-secrets-provider,monitoring --attach-acr acrshop --os-sku AzureLinux --generate-ssh-keys
Credentials (Entra)az aks get-credentials -g rg -n aks --overwrite-existing && kubelogin convert-kubeconfig -l azurecli
Install kubectl + kubeloginaz aks install-cli
Show key factsaz aks show -g rg -n aks --query "{v:kubernetesVersion, state:provisioningState, power:powerState.code, oidc:oidcIssuerProfile.issuerUrl}"
Kubelet / cluster identityaz aks show -g rg -n aks --query "{kubelet:identityProfile.kubeletidentity.objectId, cluster:identity.principalId}"
Add user pool with autoscaleraz aks nodepool add -g rg --cluster-name aks -n apps --mode User --enable-cluster-autoscaler --min-count 2 --max-count 10 --zones 1 2 3
Add Spot poolaz aks nodepool add -g rg --cluster-name aks -n spot --priority Spot --eviction-policy Delete --spot-max-price -1 --enable-cluster-autoscaler --min-count 0 --max-count 5
Scale poolaz aks nodepool scale -g rg --cluster-name aks -n apps --node-count 5
Available upgradesaz aks get-upgrades -g rg -n aks -o table
Upgrade control plane, then poolaz aks upgrade -g rg -n aks -k 1.33.2 --control-plane-only / az aks nodepool upgrade -g rg --cluster-name aks -n apps -k 1.33.2 --max-surge 33%
Node image onlyaz aks nodepool upgrade -g rg --cluster-name aks -n apps --node-image-only
Auto-upgrade channelsaz aks update -g rg -n aks --auto-upgrade-channel patch --node-os-upgrade-channel NodeImage
Attach ACR / checkaz aks update -g rg -n aks --attach-acr acrshop / az aks check-acr -g rg -n aks --acr acrshop.azurecr.io
Authorized IPsaz aks update -g rg -n aks --api-server-authorized-ip-ranges 203.0.113.0/24
Run kubectl on private clusteraz aks command invoke -g rg -n aks --command "kubectl get pods -A"
Stop / startaz aks stop -g rg -n aks / az aks start -g rg -n aks
Autoscaler profileaz aks update -g rg -n aks --cluster-autoscaler-profile scale-down-unneeded-time=5m expander=least-waste
Enable KEDA / app routingaz aks update -g rg -n aks --enable-keda / az aks approuting enable -g rg -n aks
Secret rotationaz aks addon update -g rg -n aks -a azure-keyvault-secrets-provider --enable-secret-rotation --rotation-poll-interval 2m
Namespace-scoped Azure RBACaz role assignment create --assignee <id> --role "Azure Kubernetes Service RBAC Writer" --scope <aksId>/namespaces/shop

Workload identity checklist: OIDC issuer + workload identity enabled → user-assigned identity with data-plane role → federated credential system:serviceaccount:<ns>:<sa> → SA annotation azure.workload.identity/client-id → pod label azure.workload.identity/use: "true" → SDK DefaultAzureCredential.

ACR

TaskCommand
Createaz acr create -g rg -n acrshop --sku Standard --admin-enabled false
Login (Docker) / token onlyaz acr login -n acrshop / az acr login -n acrshop --expose-token
Cloud buildaz acr build -r acrshop -t shop/web:{{.Run.ID}} .
Import public imageaz acr import -n acrshop --source docker.io/library/nginx:1.27 --image base/nginx:1.27
Repos / tagsaz acr repository list -n acrshop -o table / az acr repository show-tags -n acrshop --repository shop/web --orderby time_desc -o table
Lock a tagaz acr repository update -n acrshop --image shop/web:1.4.2 --write-enabled false
Purge old imagesaz acr run -r acrshop --cmd "acr purge --filter 'shop/web:.*' --ago 30d --keep 10 --untagged" /dev/null
Disable public accessaz acr update -n acrshop --public-network-enabled false (Premium + Private Endpoint)
Geo-replicateaz acr replication create -r acrshop -l southindia (Premium)

App Service, Functions and Container Apps

TaskCommand
Plan + web app (container)az appservice plan create -g rg -n asp-shop --is-linux --sku P1v3 / az webapp create -g rg -p asp-shop -n app-shop --deployment-container-image-name acrshop.azurecr.io/shop/web:v1
App settings / portaz webapp config appsettings set -g rg -n app-shop --settings WEBSITES_PORT=8080
Key Vault reference[email protected](SecretUri=https://kv-shop.vault.azure.net/secrets/db-password/)
Slot + swapaz webapp deployment slot create -g rg -n app-shop --slot staging / az webapp deployment slot swap -g rg -n app-shop --slot staging
Stream logsaz webapp log tail -g rg -n app-shop
VNet integrationaz webapp vnet-integration add -g rg -n app-shop --vnet vnet-shop --subnet snet-integration
Function app (Flex Consumption)az functionapp create -g rg -n fn-shop --storage-account stshopfn --flexconsumption-location centralindia --runtime python --runtime-version 3.12
Container Apps env + appaz containerapp env create -g rg -n cae-shop -l centralindia / az containerapp create -g rg -n api --environment cae-shop --image acrshop.azurecr.io/shop/api:v1 --ingress external --target-port 8080 --registry-server acrshop.azurecr.io --registry-identity system
Traffic splitaz containerapp ingress traffic set -g rg -n api --revision-weight api--v1=90 api--v2=10

Storage

TaskCommand
Secure accountaz storage account create -g rg -n stshop --sku Standard_ZRS --kind StorageV2 --min-tls-version TLS1_2 --allow-blob-public-access false --https-only true
Disable shared keysaz storage account update -g rg -n stshop --allow-shared-key-access false
Container / upload (Entra auth)az storage container create -n reports --account-name stshop --auth-mode login / az storage blob upload --account-name stshop -c reports -f q3.pdf -n q3.pdf --auth-mode login
User delegation SASaz storage blob generate-sas --account-name stshop -c reports -n q3.pdf --permissions r --expiry 2026-12-01T00:00Z --auth-mode login --as-user --full-uri
Versioning + soft deleteaz storage account blob-service-properties update -g rg --account-name stshop --enable-versioning true --enable-delete-retention true --delete-retention-days 14
Lifecycle policyaz storage account management-policy create -g rg --account-name stshop --policy @policy.json
Network deny by defaultaz storage account update -g rg -n stshop --default-action Deny --bypass AzureServices
Copy at scaleazcopy login --identity then azcopy copy "https://src.blob.core.windows.net/c/*" "https://dst.blob.core.windows.net/c" --recursive

Tiers: Hot → Cool (30 days min) → Cold (90) → Archive (180, offline, hours to rehydrate). Redundancy: LRS, ZRS, GRS, GZRS, RA-GRS, RA-GZRS.

Key Vault

TaskCommand
Create (RBAC)az keyvault create -g rg -n kv-shop -l centralindia --enable-rbac-authorization true --retention-days 90 --enable-purge-protection true
Set / get secretaz keyvault secret set --vault-name kv-shop -n db-password --value "..." / az keyvault secret show --vault-name kv-shop -n db-password --query value -o tsv
Versionsaz keyvault secret list-versions --vault-name kv-shop -n db-password -o table
Secret expiryaz keyvault secret set-attributes --vault-name kv-shop -n db-password --expires 2027-01-01T00:00:00Z
Deleted vaults / recover / purgeaz keyvault list-deleted / az keyvault recover -n kv-shop / az keyvault purge -n kv-shop
Firewallaz keyvault update -n kv-shop --default-action Deny --bypass AzureServices / az keyvault network-rule add -n kv-shop --ip-address 1.2.3.4/32
Key rotation policyaz keyvault key rotation-policy update --vault-name kv-shop -n cmk --value @rotation.json

SecretProviderClass skeleton (CSI driver, workload identity):

yaml
apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata: { name: kv-shop, namespace: shop }
spec:
  provider: azure
  parameters:
    usePodIdentity: "false"
    clientID: "<uami-client-id>"
    keyvaultName: kv-shop
    tenantId: "<tenant-id>"
    objects: |
      array:
        - |
          objectName: db-password
          objectType: secret

Azure Monitor and KQL

TaskCommand
Workspaceaz monitor log-analytics workspace create -g rg -n law-shop --retention-time 30
Diagnostic settingaz monitor diagnostic-settings create -n to-law --resource <id> --workspace <lawId> --logs '[{"categoryGroup":"allLogs","enabled":true}]' --metrics '[{"category":"AllMetrics","enabled":true}]'
List metric namesaz monitor metrics list-definitions --resource <id> -o table
Query metricsaz monitor metrics list --resource <aksId> --metric node_cpu_usage_percentage --interval PT5M -o table
Query logsaz monitor log-analytics query -w <workspaceGuid> --analytics-query "<KQL>" -o table
Action groupaz monitor action-group create -g rg -n ag-oncall --short-name oncall --action email ops [email protected]
Metric alertaz monitor metrics alert create -g rg -n cpu-high --scopes <id> --condition "avg Percentage CPU > 80" --window-size 5m --action ag-oncall
Enable Container Insightsaz aks enable-addons -g rg -n aks -a monitoring --workspace-resource-id <lawId>
Managed Prometheusaz aks update -g rg -n aks --enable-azure-monitor-metrics --azure-monitor-workspace-resource-id <amwId>
kusto
// Error logs per pod, last hour
ContainerLogV2
| where TimeGenerated > ago(1h) and LogLevel in ("error", "critical")
| summarize errors = count() by PodNamespace, PodName
| top 10 by errors

// Kubernetes warning events
KubeEvents
| where TimeGenerated > ago(1h) and KubeEventType == "Warning"
| project TimeGenerated, Namespace, Name, Reason, Message

// Failed requests from App Insights (workspace-based)
AppRequests
| where TimeGenerated > ago(1h) and Success == false
| summarize count() by Name, ResultCode, bin(TimeGenerated, 5m)

// What changed (control plane)
AzureActivity
| where TimeGenerated > ago(1d) and ActivityStatusValue == "Success" and OperationNameValue endswith "write"
| project TimeGenerated, Caller, OperationNameValue, ResourceGroup, _ResourceId

// Who costs the most in Log Analytics
Usage
| where TimeGenerated > ago(30d) and IsBillable
| summarize GB = sum(Quantity) / 1000 by DataType
| top 10 by GB

Policy and cost

TaskCommand
Find a built-in policyaz policy definition list --query "[?contains(displayName,'Allowed locations')].{name:name, d:displayName}" -o table
Assign with parametersaz policy assignment create -n allowed-locs --policy e56962a6-4747-49cd-b67b-bf8b01975c4c --scope <scope> --params '{"listOfAllowedLocations":{"value":["centralindia","southindia"]}}'
Assign DINE / Modify (needs identity)az policy assignment create ... --mi-system-assigned --location centralindia --role Contributor --identity-scope <scope>
Compliance summaryaz policy state summarize --subscription <subId>
Non-compliant resourcesaz policy state list --filter "complianceState eq 'NonCompliant'" --query "[].resourceId" -o tsv
Trigger scanaz policy state trigger-scan -g rg
Remediateaz policy remediation create -n fix --policy-assignment <assignmentId>
Exemptionaz policy exemption create -n waiver --policy-assignment <id> --exemption-category Waiver --scope <scope> --expires-on 2026-12-31
Budgetaz consumption budget create --budget-name dev-monthly --amount 200 --time-grain Monthly --category cost --start-date 2026-11-01 --end-date 2027-10-31 -g rg-shop-dev
Advisor cost tipsaz advisor recommendation list --category Cost -o table

Effects: Deny, Audit, AuditIfNotExists, Append, Modify, DeployIfNotExists, DenyAction, Disabled, Manual. Savings levers: right-size → deallocate idle → Spot → Savings Plan / Reservations → Azure Hybrid Benefit → Log Analytics plans and caps.

Bicep and ARM

TaskCommand
Install / upgradeaz bicep install / az bicep upgrade
Build / decompile / lintaz bicep build -f main.bicep / az bicep decompile -f azuredeploy.json / az bicep lint -f main.bicep
Validate / what-if / deploy (RG)az deployment group validate|what-if|create -g rg -f main.bicep -p prod.bicepparam
Subscription scopeaz deployment sub create -l centralindia -f sub.bicep
Failed operationsaz deployment operation group list -g rg -n <deployment> --query "[?properties.provisioningState=='Failed']"
Deployment stackaz stack group create -n shop -g rg -f main.bicep --action-on-unmanage deleteResources --deny-settings-mode denyDelete
Export existing RGaz group export -n rg (then decompile)
bicep
targetScope = 'resourceGroup'
param location string = resourceGroup().location
param env string
var suffix = uniqueString(resourceGroup().id)

resource kv 'Microsoft.KeyVault/vaults@2023-07-01' = {
  name: 'kv-shop-${env}-${take(suffix, 5)}'
  location: location
  properties: {
    tenantId: subscription().tenantId
    sku: { family: 'A', name: 'standard' }
    enableRbacAuthorization: true
    enableSoftDelete: true
    softDeleteRetentionInDays: 90
  }
}

module acr 'br/public:avm/res/container-registry/registry:0.6.0' = {
  name: 'acr'
  params: { name: 'acrshop${env}${take(suffix, 5)}', acrSku: 'Standard' }
}

Check the AVM module's current version in the Bicep registry before using it; the version above is an example.

Terraform azurerm

hcl
terraform {
  required_providers {
    azurerm = { source = "hashicorp/azurerm", version = "~> 4.0" }
  }
  backend "azurerm" {
    resource_group_name  = "rg-tfstate"
    storage_account_name = "sttfstateshop"
    container_name       = "tfstate"
    key                  = "shop/prod.tfstate"
    use_azuread_auth     = true
  }
}
provider "azurerm" {
  features {}
  subscription_id = var.subscription_id
}
TaskCommand / snippet
Auth from CLI (laptop)az login, provider uses Azure CLI automatically
Auth OIDC (CI)ARM_CLIENT_ID, ARM_TENANT_ID, ARM_SUBSCRIPTION_ID, ARM_USE_OIDC=true
Auth managed identityARM_USE_MSI=true (+ ARM_CLIENT_ID for user-assigned)
Init with backend fileterraform init -backend-config=prod.backend.hcl
Saved plan / applyterraform plan -out tfplan / terraform apply tfplan
Drift checkterraform plan -detailed-exitcode (0 none, 1 error, 2 changes)
Import existingimport { to = azurerm_resource_group.rg id = "/subscriptions/<sub>/resourceGroups/rg" } + terraform plan -generate-config-out=gen.tf
Break leaseaz storage blob lease break --container-name tfstate --blob-name shop/prod.tfstate --account-name sttfstateshop --auth-mode login
Bulk exportaztfexport resource-group rg-shop
AcrPull for kubeletprincipal_id = azurerm_kubernetes_cluster.aks.kubelet_identity[0].object_id
Avoid PrincipalNotFoundskip_service_principal_aad_check = true on azurerm_role_assignment
Autoscaler-owned countlifecycle { ignore_changes = [default_node_pool[0].node_count] }
Rotate default pool safelytemporary_name_for_rotation = "systemtmp" in default_node_pool
Unsupported featureazapi_resource / azapi_update_resource with an ARM API version

v4 renames worth knowing: enable_auto_scaling → auto_scaling_enabled, enable_https_traffic_only → https_traffic_only_enabled, subscription_id required, resource_provider_registrations replaces auto-registration.

Pipelines: GitHub Actions and Azure DevOps

yaml
# GitHub Actions: OIDC login
permissions:
  id-token: write
  contents: read
jobs:
  deploy:
    runs-on: ubuntu-latest
    environment: prod
    steps:
      - uses: actions/checkout@v4
      - uses: azure/login@v2
        with:
          client-id: ${{ vars.AZURE_CLIENT_ID }}
          tenant-id: ${{ vars.AZURE_TENANT_ID }}
          subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
      - run: az acr build -r ${{ vars.ACR_NAME }} -t shop/web:${{ github.sha }} .
yaml
# Azure Pipelines: WIF service connection + environment
stages:
- stage: Deploy
  jobs:
  - deployment: aks
    environment: shop-prod          # approvals and checks live here
    pool: { vmImage: ubuntu-latest }
    strategy:
      runOnce:
        deploy:
          steps:
          - checkout: self
          - task: AzureCLI@2
            inputs:
              azureSubscription: arm-shop-prod
              scriptType: bash
              scriptLocation: inlineScript
              inlineScript: |
                az aks get-credentials -g rg-shop -n aks-shop --overwrite-existing
                kubelogin convert-kubeconfig -l azurecli
                kubectl apply -f k8s/
Azure DevOps itemUse
##vso[task.setvariable variable=x;isOutput=true]vSet a variable from a script
$(var) / ${{ variables.var }} / $[ variables.var ]Macro (runtime) / template (compile) / runtime expression
Variable group linked to Key VaultSecrets fetched at runtime
extends: template: x.yml@templatesEnforced pipeline skeleton
Environment checksApprovals, branch control, business hours, required template, exclusive lock
az pipelines run --name shop-ci --branch mainQueue a run from CLI (azure-devops extension)

Common errors decoder

Error textFirst thing to check
AuthorizationFailed ... does not have authorization to perform actionRole at that scope; right subscription; re-login after grant
LinkedAuthorizationFailed ... subnets/join/actionRights on the subnet in the network RG
AADSTS70021 No matching federated identity recordSubject string vs federated credential (branch / environment / PR)
AADSTS7000222 client secret keys ... are expiredRotate, then move to OIDC
AADSTS50076 ... must use multi-factor authenticationAutomation running as a human account
ForbiddenByRbac (Key Vault)Key Vault data role (Secrets User / Officer)
ForbiddenByFirewall / Client address is not authorizedVault firewall, Private Endpoint DNS
AuthorizationPermissionMismatch (Storage)Missing Storage Blob Data role
AuthorizationFailure (Storage)Storage network rules / private access
QuotaExceeded ... Cores quotaaz vm list-usage, raise quota or change family
SkuNotAvailable / ZonalAllocationFailedOther size or zone; capacity reservation
MissingSubscriptionRegistrationaz provider register -n <namespace>
RequestDisallowedByPolicyPolicy assignment ID in the error; comply or exempt
ScopeLockedaz lock list
ImagePullBackOff ... 401 Unauthorized (ACR)Kubelet identity AcrPull; az aks check-acr
ImagePullBackOff ... no such host (ACR)privatelink.azurecr.io zone link / firewall FQDNs
MountVolume.SetUp failed ... secrets-store ... 403Workload identity role on Key Vault, clientID, network
User does not have access to the resource in Azure (kubectl)AKS RBAC role at cluster or namespace scope
kubelogin is not installedaz aks install-cli, kubelogin convert-kubeconfig
UpgradeFailed ... Pod Disruption BudgetRelax PDB, add replicas, resume upgrade
InsufficientSubnetSizeFlat CNI IP math; Overlay; smaller surge
EXTERNAL-IP <pending> + AuthorizationFailedCluster identity Network Contributor on subnet

AWS to Azure quick map

AWSAzure
Organizations, OU, SCPManagement groups, Azure Policy (deny)
AccountSubscription (+ resource groups inside)
IAM role for EC2 / IRSA / Pod IdentityManaged identity / AKS workload identity
IAM Identity CenterEntra ID + PIM
VPC, subnet (per AZ)VNet, subnet (spans zones)
Security group / NACLNSG on NIC / NSG on subnet (+ ASG)
Transit GatewayVirtual WAN or hub-spoke with firewall
Interface / gateway endpointPrivate Endpoint / Service Endpoint
NAT gatewayNAT Gateway
ALB / NLB / CloudFront / Global AcceleratorApplication Gateway / Load Balancer / Front Door / Front Door or cross-region LB
Route 53Azure DNS + Traffic Manager
EC2, ASG, Launch templateVM, VMSS, VMSS model / Compute Gallery image
EKS, ECR, Fargate, LambdaAKS, ACR, Container Apps / ACI, Functions
S3, EBS, EFSBlob Storage, Managed Disks, Azure Files
Secrets Manager, KMS, CloudHSMKey Vault, Key Vault keys, Managed HSM
CloudWatch, X-Ray, CloudTrailAzure Monitor, Application Insights, Activity Log
Config, Security Hub, GuardDutyAzure Policy, Defender for Cloud
CloudFormation, CDKARM templates, Bicep
CodeCommit, CodeBuild, CodePipelineAzure Repos, Azure Pipelines (or GitHub)

Numbers worth remembering

ItemValue
Management group depth6 levels below root
Role assignments per subscription4,000
Custom roles per tenant5,000
Tags per resource50
Reserved IPs per subnet5
Smallest subnet/29
NSG rule priority range100 to 4096 (lower wins)
SNAT ports per NAT Gateway public IP64,512
RBAC propagationusually minutes, up to about 10 (longer at management group scope)
Activity Log retention90 days (export for longer)
Platform metrics retention93 days
Key Vault soft delete7 to 90 days, default 90
Spot eviction notice30 seconds
AKS supported versionsN-2 minor versions (GA)
AKS Standard tier SLA99.95% with zones, 99.9% without
AKS default max pods per node (Azure CNI)30 (Overlay default 250)
Flat Azure CNI IPs per nodemaxPods + 1
Blob min retention for early-deletion feesCool 30, Cold 90, Archive 180 days
Storage account name3–24 chars, lowercase letters and numbers, globally unique
Key Vault name3–24 chars, globally unique
az acr login token lifetimeabout 3 hours

Limits change. Confirm current values in the Azure subscription and service limits documentation when it matters.

Top 15 interview one-liners

  1. Tenant is identity, subscription is billing and quota, resource group is lifecycle, management group is governance.
  2. RBAC decides who can act; Azure Policy decides what resources may look like. You need both.
  3. RBAC is additive. Owner has no data-plane access, so reading blobs or secrets needs data roles like Storage Blob Data Reader or Key Vault Secrets User.
  4. Prefer managed identities, then federated credentials. Client secrets are the last resort.
  5. GitHub and Azure DevOps log in with OIDC: the federated subject (branch, environment or service connection) must match exactly.
  6. Azure subnets span availability zones. Peering is not transitive; spoke-to-spoke traffic goes through a hub firewall or Virtual WAN.
  7. NSGs are stateful with priorities, and inbound traffic must pass the subnet NSG first, then the NIC NSG.
  8. A Private Endpoint is only half the job; the other half is private DNS (privatelink zones linked to the VNets that resolve them).
  9. The kubelet identity pulls from ACR (AcrPull). The cluster identity manages Azure resources such as LBs and subnets.
  10. New AKS clusters: Azure CNI Overlay with Cilium, Entra + Azure RBAC, local accounts off, workload identity, Standard tier in prod.
  11. AKS upgrades go one minor version at a time, control plane first, with surge nodes and PDBs that allow at least one disruption.
  12. Key Vault CSI mounts secrets at pod start and can rotate files. Env vars from synced Secrets don't rotate without a restart.
  13. Container Insights with managed identity auth needs a Data Collection Rule. Log Analytics ingestion is the AKS bill surprise.
  14. Bicep has no state file because ARM is the state. Terraform has explicit state, so protect it with Entra auth, versioning and locks.
  15. Biggest cost wins: deallocate idle compute, right-size before you reserve, Spot for interruptible work, and control log ingestion.
Feedback