Azure DevOps (AZ-400)
Quick reference

Quick reference

Azure Pipelines YAML skeleton

yaml
trigger:
  batch: true
  branches: { include: [ main, release/* ] }
  paths: { exclude: [ docs/* ] }
pr: none                      # Azure Repos: use branch policy build validation
schedules:
- cron: '0 2 * * 1-5'           # UTC
  displayName: Nightly
  branches: { include: [ main ] }
  always: false                 # only if code changed
resources:
  repositories:
  - repository: templates
    type: git
    name: Platform/pipeline-templates
    ref: refs/tags/v3
  pipelines:
  - pipeline: ci
    source: Shop-CI
    trigger: { branches: { include: [ main ] } }
parameters:
- name: region
  type: string
  default: westeurope
  values: [ westeurope, northeurope ]
variables:
- group: shop-prod-kv          # Key Vault-linked variable group
- template: vars/common.yml
- name: buildConfiguration
  value: Release
stages:
- stage: Build
  jobs:
  - job: Build
    pool: { vmImage: ubuntu-latest }
    steps:
    - checkout: self
      fetchDepth: 1
    - task: Cache@2
      inputs:
        key: 'nuget | "$(Agent.OS)" | **/packages.lock.json'
        path: $(NUGET_PACKAGES)
    - script: dotnet test --collect:"XPlat Code Coverage"
    - task: PublishCodeCoverageResults@2
      inputs: { summaryFileLocation: '$(Agent.TempDirectory)/**/coverage.cobertura.xml' }
    - publish: $(Build.ArtifactStagingDirectory)
      artifact: drop
- stage: Prod
  dependsOn: Build
  condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
  jobs:
  - deployment: Deploy
    environment: prod           # approvals & checks live on the environment
    strategy:
      runOnce:
        deploy:
          steps:
          - task: AzureWebApp@1
            inputs:
              azureSubscription: prod-arm   # WIF service connection
              appName: shop-prod
              deployToSlotOrASE: true
              slotName: staging
              package: $(Pipeline.Workspace)/drop/**/*.zip

Expression syntax

SyntaxEvaluatedUse for
${{ variables.x }} / ${{ parameters.p }}Compile time (template expansion)conditional insertion, loops, template params
$[ variables.x ]Runtime, before the job startsconditions, dependency outputs, counters
$(x)Macro, just before a task runstask inputs and scripts
dependencies.Job.outputs['step.var']Runtime (same stage)pass values between jobs
stageDependencies.Stage.Job.outputs['step.var']Runtime (next stage)pass values between stages
counter(prefix, seed)Runtimeauto-increment build numbers per prefix

GitHub Actions workflow skeleton (OIDC to Azure)

yaml
name: deploy
on:
  push: { branches: [ main ] }
  workflow_dispatch:
permissions:
  id-token: write      # request the OIDC token
  contents: read
concurrency: { group: prod, cancel-in-progress: false }
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - run: npm ci && npm test
    - uses: actions/upload-artifact@v4
      with: { name: web, path: dist, retention-days: 14 }
  deploy:
    needs: build
    runs-on: ubuntu-latest
    environment: production   # protection rules: reviewers, wait timer, branches
    steps:
    - uses: actions/download-artifact@v4
      with: { name: web }
    - 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 webapp deploy -g rg-shop -n shop-prod --src-path web.zip

Git commands you must recognize

GoalCommand
Undo a pushed commit safelygit revert <sha> (merge commit: git revert -m 1 <sha>)
Undo local commits, keep changes stagedgit reset --soft HEAD~2
Find lost commitsgit reflog, then git branch rescue <sha>
Copy one commit to another branchgit cherry-pick <sha>
Annotated tag + pushgit tag -a v2.1.0 -m "Release 2.1.0"; git push origin v2.1.0
Purge a file from all historygit filter-repo --path secrets.json --invert-paths
Track big binariesgit lfs track "*.psd"; git add .gitattributes
Convert history to LFSgit lfs migrate import --include="*.zip" --everything
Large monorepo clonescalar clone <url> (partial clone + sparse checkout + maintenance)
Partial / shallow clonegit clone --filter=blob:none <url>; git clone --depth 1 <url>
Changelog from historygit log v2.0.0..v2.1.0 --pretty=format:"- %s (%h)" --no-merges

Azure CLI / Azure DevOps CLI essentials

bash
az extension add --name azure-devops
az devops configure --defaults organization=https://dev.azure.com/contoso project=Shop
az pipelines create --name Shop-CI --yml-path azure-pipelines.yml --repository Shop
az pipelines run --name Shop-CI --branch main
az repos policy approver-count create --branch main --repository-id <id> \
   --minimum-approver-count 2 --creator-vote-counts false --blocking true --enabled true
az artifacts universal publish --feed tools --name cli --version 1.4.0 --path ./bin
az boards work-item create --title "Investigate alert" --type Bug

# IaC
az bicep lint --file main.bicep
az deployment group what-if -g rg-shop --template-file main.bicep -p env=prod
az stack group create -n shop-stack -g rg-shop --template-file main.bicep \
   --action-on-unmanage deleteResources --deny-settings-mode denyDelete
az webapp deployment slot swap -g rg-shop -n shop-prod --slot staging --target-slot production
az appconfig feature enable --name appcs-shop --feature Beta --label prod

KQL cheat sheet

kql
// Failed requests per 5 minutes, last 24h
requests
| where timestamp > ago(24h) and success == false
| summarize failures = count() by bin(timestamp, 5m), resultCode
| render timechart

// P95 latency by operation (workspace-based table)
AppRequests
| where TimeGenerated > ago(1h)
| summarize p95 = percentile(DurationMs, 95), calls = count() by OperationName
| top 10 by p95 desc

// End-to-end trace for one operation
union requests, dependencies, exceptions, traces
| where operation_Id == '4bf92f3577b34da6a3ce929d0e0e4736'
| project timestamp, itemType, name, duration, success
| order by timestamp asc

// VM CPU average (Azure Monitor Agent / VM insights)
InsightsMetrics
| where Namespace == 'Processor' and Name == 'UtilizationPercentage'
| summarize avg(Val) by Computer, bin(TimeGenerated, 15m)

// Machines that stopped sending heartbeats
Heartbeat
| summarize last = max(TimeGenerated) by Computer
| where last < ago(15m)

// Who deleted resources?
AzureActivity
| where OperationNameValue endswith 'DELETE' and ActivityStatusValue == 'Success'
| project TimeGenerated, Caller, ResourceGroup, _ResourceId

Decision cheat sheet

If the question says...Think...
no secrets / no rotation for Azure authWorkload identity federation (OIDC) or managed identity
share one identity across many resourcesUser-assigned managed identity
only approved pipeline structure may deployextends template + 'Required template' check
human sign-off before prodEnvironment approval check (Actions: required reviewers)
block deploys while alerts fireQuery Azure Monitor alerts check / gate
consume nuget.org through one governed feedAzure Artifacts upstream sources
share only tested package versionsFeed views: promote to @Release
zero-downtime web app release, quick rollbackDeployment slots + swap (swap back to roll back)
release to a % or group of users without redeployFeature flags (App Configuration)
expose to internal users, then wider audiencesRing deployment
large binary files in GitGit LFS
huge monorepo is slowScalar / partial clone / sparse checkout
secret was committedRotate secret FIRST, then git filter-repo/BFG, force-push
leaked secret should never reach the serverSecret scanning push protection
vulnerable open-source packagesDependabot alerts / dependency scanning
SAST in the pipelineCodeQL (GHAS / GHAS for Azure DevOps)
one view of security across GitHub + ADO + GitLabDefender for Cloud DevOps security
audit + enforce OS config on Azure and Arc VMsAzure Machine Configuration
developers self-serve compliant environmentsAzure Deployment Environments
access to private network from hosted buildManaged DevOps Pools (VNet) / self-hosted agents
free access to work items and boards, no codeStakeholder access level
trace a request across microservicesApplication Insights: operation_Id, transaction view
VM CPU, memory, disk, network trendsVM insights (Azure Monitor Agent + DCR)