πŸ”’ Guided

Pre-launch preview. Authorised access only.

Incorrect code

Guided by A Guide to Cloud
Explore AB-900 AI-901
Guided AZ-400 Domain 4
Domain 4 β€” Module 3 of 4 75%
22 of 25 overall

AZ-400 Study Guide

Domain 1: Design and Implement Processes and Communications

  • Work Item Tracking: Boards, GitHub & Flow
  • DevOps Metrics: Dashboards That Drive Decisions
  • Collaboration: Wikis, Teams & Release Notes

Domain 2: Design and Implement a Source Control Strategy

  • Branching Strategies: Trunk-Based, Feature & Release
  • Pull Requests: Policies, Protections & Merge Rules
  • Repository Management: LFS, Permissions & Recovery

Domain 3: Design and Implement Build and Release Pipelines

  • Package Management: Feeds, Versioning & Upstream
  • Testing Strategy: Quality Gates & Release Gates
  • Test Implementation: Code Coverage & Pipeline Tests
  • Azure Pipelines: YAML from Scratch Free
  • GitHub Actions: Workflows from Scratch Free
  • Pipeline Agents: Self-Hosted, Hybrid & VM Templates
  • Multi-Stage Pipelines: Templates, Variables & Approvals
  • Deployment Strategies: Blue-Green, Canary & Ring Free
  • Safe Rollouts: Slots, Dependencies & Hotfix Paths
  • Deployment Implementations: Containers, Scripts & Databases
  • Infrastructure as Code: ARM vs Bicep vs Terraform
  • IaC in Practice: Desired State & Deployment Environments
  • Pipeline Maintenance: Health, Migration & Retention

Domain 4: Develop a Security and Compliance Plan

  • Pipeline Identity: Service Principals, Managed IDs & OIDC Free
  • Authorization & Access: GitHub Roles & Azure DevOps Security
  • Secrets & Secure Pipelines: Key Vault & Workload Federation
  • Security Scanning: GHAS, Defender & Dependabot

Domain 5: Implement an Instrumentation Strategy

  • Monitoring for DevOps: Azure Monitor & App Insights
  • Metrics & KQL: Analysing Telemetry & Traces

AZ-400 Study Guide

Domain 1: Design and Implement Processes and Communications

  • Work Item Tracking: Boards, GitHub & Flow
  • DevOps Metrics: Dashboards That Drive Decisions
  • Collaboration: Wikis, Teams & Release Notes

Domain 2: Design and Implement a Source Control Strategy

  • Branching Strategies: Trunk-Based, Feature & Release
  • Pull Requests: Policies, Protections & Merge Rules
  • Repository Management: LFS, Permissions & Recovery

Domain 3: Design and Implement Build and Release Pipelines

  • Package Management: Feeds, Versioning & Upstream
  • Testing Strategy: Quality Gates & Release Gates
  • Test Implementation: Code Coverage & Pipeline Tests
  • Azure Pipelines: YAML from Scratch Free
  • GitHub Actions: Workflows from Scratch Free
  • Pipeline Agents: Self-Hosted, Hybrid & VM Templates
  • Multi-Stage Pipelines: Templates, Variables & Approvals
  • Deployment Strategies: Blue-Green, Canary & Ring Free
  • Safe Rollouts: Slots, Dependencies & Hotfix Paths
  • Deployment Implementations: Containers, Scripts & Databases
  • Infrastructure as Code: ARM vs Bicep vs Terraform
  • IaC in Practice: Desired State & Deployment Environments
  • Pipeline Maintenance: Health, Migration & Retention

Domain 4: Develop a Security and Compliance Plan

  • Pipeline Identity: Service Principals, Managed IDs & OIDC Free
  • Authorization & Access: GitHub Roles & Azure DevOps Security
  • Secrets & Secure Pipelines: Key Vault & Workload Federation
  • Security Scanning: GHAS, Defender & Dependabot

Domain 5: Implement an Instrumentation Strategy

  • Monitoring for DevOps: Azure Monitor & App Insights
  • Metrics & KQL: Analysing Telemetry & Traces
Domain 4: Develop a Security and Compliance Plan Premium ⏱ ~12 min read

Secrets & Secure Pipelines: Key Vault & Workload Federation

Manage secrets with Azure Key Vault and workload identity federation. Implement secretless authentication with OIDC, protect sensitive files, and prevent secret leakage in pipelines.

Why secrets management is the foundation of secure DevOps

β˜• Simple explanation

Think of your house keys.

You would not tape your house key to the front door. You would not post a photo of it on social media. You would not make 50 copies and hand them out to everyone who visits. Yet developers do the equivalent with passwords, API keys, and certificates every day β€” hardcoding them in source code, pasting them in chat, or storing them in plain text config files.

Secrets management gives you a secure lockbox (Azure Key Vault) and a way to let your pipelines open the lockbox without ever holding a key themselves (workload identity federation).

Secrets sprawl is one of the most common security failures in DevOps. The AZ-400 exam tests your ability to design a defence-in-depth strategy for secrets: centralised storage in Azure Key Vault, secretless authentication where possible, secure file handling during deployments, and pipeline-level controls to prevent accidental leakage.

  • Azure Key Vault β€” centralised secrets, keys, and certificates with RBAC and audit logging
  • Workload identity federation β€” OIDC-based secretless auth for both GitHub Actions and Azure Pipelines
  • Pipeline secrets β€” GitHub Actions secrets, Azure DevOps variable groups, secure files
  • Leakage prevention β€” secret masking, output filtering, and pipeline design patterns

Azure Key Vault

Azure Key Vault is the centralised secret store for Azure environments. It stores three types of objects:

Object TypePurposeExample
SecretsAny string value β€” passwords, connection strings, API keysDatabase password, SaaS API key
KeysCryptographic keys for encryption and signing (HSM-backed optional)Data encryption key, JWT signing key
CertificatesTLS/SSL certificates with automatic renewalApp Service TLS cert, code signing cert

Access control: RBAC vs Access Policies

Key Vault supports two permission models. Azure RBAC is recommended for new vaults.

Key Vault Access: RBAC vs Access Policies
FeatureAzure RBAC (Recommended)Vault Access Policies (Legacy)
Permission granularityPer-object-type roles (Secrets Officer, Key Vault Reader, etc.)Per-vault policy with key/secret/certificate permissions
ScopeCan be applied at management group, subscription, resource group, or vault levelVault level only
Central managementYes β€” same RBAC system as all Azure resourcesNo β€” each vault has its own access policy list
Conditional accessSupports Entra ID Conditional Access policiesNo conditional access support
Maximum principalsThousands (Azure RBAC limits)1,024 access policy entries per vault
AuditAzure RBAC audit logs + Key Vault diagnostic logsKey Vault diagnostic logs only

Key Vault RBAC roles

RolePermissions
Key Vault AdministratorFull management of all vault objects
Key Vault Secrets OfficerAll operations on secrets (but not keys or certificates)
Key Vault Secrets UserRead secret values β€” the role you give to pipelines
Key Vault Certificates OfficerManage certificates (issue, renew, import)
Key Vault Crypto OfficerAll operations on keys
Key Vault ReaderRead vault metadata (not secret values)
Question

What Key Vault RBAC role should a pipeline's service principal have to read secrets at deployment time?

Click or press Enter to reveal answer

Answer

Key Vault Secrets User. This role allows reading secret values but cannot create, update, or delete secrets. It also cannot access keys or certificates unless additional roles are assigned. This follows least privilege β€” the pipeline only needs to read, not manage.

Click to flip back

Key Vault in pipelines

Azure Pipelines: AzureKeyVault task

The AzureKeyVault@2 task fetches secrets from Key Vault and maps them to pipeline variables:

steps:
  - task: AzureKeyVault@2
    inputs:
      azureSubscription: 'my-service-connection'
      KeyVaultName: 'my-keyvault'
      SecretsFilter: 'db-password,api-key'  # comma-separated, or * for all
      RunAsPreJob: true  # fetch before any other steps

Fetched secrets are automatically masked in logs. They can be referenced as $(db-password) in subsequent steps.

Azure Pipelines: Variable group linked to Key Vault

Instead of fetching per-pipeline, link a variable group to a Key Vault. All secrets from the vault become available as variables in any pipeline that references the group. Changes in Key Vault propagate automatically β€” no pipeline edits needed.

GitHub Actions: Key Vault with azure/login

steps:
  - uses: azure/login@v2
    with:
      client-id: ${{ secrets.AZURE_CLIENT_ID }}
      tenant-id: ${{ secrets.AZURE_TENANT_ID }}
      subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

  - uses: azure/cli@v2
    with:
      inlineScript: |
        az keyvault secret show --vault-name my-kv --name db-password --query value -o tsv

Alternatively, use azure/cli@v2 with az keyvault secret show to retrieve individual secrets β€” this is the currently recommended approach.

Question

What are two ways to consume Azure Key Vault secrets in Azure Pipelines?

Click or press Enter to reveal answer

Answer

1. The AzureKeyVault@2 task β€” fetches specific secrets (or all secrets) from a vault and maps them to pipeline variables in a single pipeline. 2. Variable group linked to Key Vault β€” link a variable group to a vault, and any pipeline referencing that group gets all its secrets automatically. The variable group approach is better for shared secrets used across many pipelines.

Click to flip back

Workload identity federation in depth

Module 20 introduced OIDC concepts. Here we cover the implementation details.

GitHub Actions OIDC claims

When a GitHub Actions workflow requests an OIDC token, the token contains claims that identify:

  • Issuer: https://token.actions.githubusercontent.com
  • Subject: Encodes the repo, branch, environment, or tag β€” e.g., repo:org/repo:ref:refs/heads/main
  • Audience: api://AzureADTokenExchange (default for Azure)

The federated credential on the Entra ID app registration specifies which subject claims to trust. This is how you restrict which branches or environments can authenticate.

Subject claim filtering

FilterSubject ClaimUse Case
Branchrepo:org/repo:ref:refs/heads/mainOnly main branch can deploy to production
Environmentrepo:org/repo:environment:productionOnly the β€œproduction” environment can access prod resources
Tagrepo:org/repo:ref:refs/tags/v*Only tagged releases can publish packages
Pull requestrepo:org/repo:pull_requestPR workflows can access read-only resources
Scenario: Amira locks down OIDC for defence pipeline

πŸ›οΈ Major Collins requires that only the main branch of the deployment repository can access the production Azure subscription β€” no feature branches, no PRs, no tags.

Amira’s implementation:

  1. Creates an Entra ID app registration defence-prod-deploy
  2. Adds a federated credential:
    • Issuer: https://token.actions.githubusercontent.com
    • Subject: repo:defence-org/deploy-infra:ref:refs/heads/main
    • Audience: api://AzureADTokenExchange
  3. Assigns the app Contributor role scoped to the production resource group only
  4. The GitHub Actions workflow uses azure/login@v2 with the app’s client-id
  5. Any attempt to authenticate from a feature branch fails β€” the subject claim does not match

Result: Even if an attacker compromises a feature branch workflow, they cannot access production Azure resources.

GitHub Actions secrets

GitHub provides three levels of secret storage:

LevelScopeSet ByUse Case
Repository secretsSingle repo, all environmentsRepo adminRepo-specific API keys
Environment secretsSingle repo, specific environment onlyRepo adminProduction credentials (with environment protection rules)
Organisation secretsMultiple repos (configurable: all, private, or selected)Org ownerShared secrets like container registry credentials

Environment secrets are particularly powerful when combined with environment protection rules β€” require reviewer approval before a workflow job can access the environment’s secrets.

Secret masking in GitHub Actions

GitHub automatically masks any secret value that appears in workflow logs. However, masking has limitations:

  • Structured formats (JSON, XML) may partially expose values if the secret appears as a substring
  • echo or print statements that transform secrets (base64 encode, substring) may bypass masking
  • Multi-line secrets need special handling with add-mask

Azure Pipelines secure files

Secure files store binary files (certificates, provisioning profiles, SSH keys) that pipelines need during execution but should not be stored in source control.

Key characteristics:

  • Uploaded to the Azure DevOps project library
  • Encrypted at rest
  • Downloaded by pipelines using the DownloadSecureFile@1 task
  • Pipeline permissions control which pipelines can access each file
  • Approval checks can require human approval before download
  • Files are placed in a temporary directory and deleted after the pipeline completes
steps:
  - task: DownloadSecureFile@1
    name: sshKey
    inputs:
      secureFile: 'deploy_rsa'

  - script: |
      mkdir -p ~/.ssh
      cp $(sshKey.secureFilePath) ~/.ssh/id_rsa
      chmod 600 ~/.ssh/id_rsa
    displayName: 'Install SSH key'
Question

What are Azure Pipelines secure files, and when should you use them instead of Key Vault secrets?

Click or press Enter to reveal answer

Answer

Secure files store binary files (certificates, SSH keys, provisioning profiles) encrypted in the Azure DevOps project library. Use them for files that must exist on disk during deployment β€” unlike Key Vault secrets (which are string values), secure files preserve binary format. Pipelines download them with DownloadSecureFile@1, and they are auto-deleted after the job.

Click to flip back

Preventing secret leakage

Pipeline design patterns

  1. Never echo secrets β€” avoid echo $(secret) or print(secret). Even with masking, transformations can leak values.
  2. Use secret variables β€” mark pipeline variables as secret. Azure Pipelines masks them and prevents them from being logged.
  3. Audit pipeline outputs β€” review pipeline logs for accidental exposure. Secrets in error messages are a common leak vector.
  4. Restrict fork PR builds β€” forks can modify workflows to exfiltrate secrets. Require approval for fork PR builds.
  5. Separate contexts β€” production secrets should only be accessible from production deployment stages, not from CI build stages.

Azure DevOps specific controls

  • Variable groups with permissions β€” restrict which pipelines can reference a variable group
  • Secret masking β€” variables marked as secret are masked in all log output
  • Audit logs β€” Azure DevOps audit stream captures who accessed what and when
  • Pipeline decorators β€” inject security scanning steps into all pipelines (org-wide enforcement)

GitHub Actions specific controls

  • Required reviewers on environments β€” secrets in a protected environment cannot be accessed until a reviewer approves
  • Deployment branches β€” restrict which branches can deploy to an environment
  • CODEOWNERS β€” require specific reviewers for workflow file changes (.github/workflows/)
  • OpenSSF Scorecards β€” automated security health check for GitHub repositories
Question

How do you prevent a forked repository from exfiltrating secrets in a GitHub Actions PR workflow?

Click or press Enter to reveal answer

Answer

1. Set 'Require approval for all outside collaborators' on fork PR workflows. 2. Use environment protection rules β€” fork PRs cannot trigger environment-protected jobs without approval. 3. Set GITHUB_TOKEN to read-only by default. 4. Never pass secrets to steps that run untrusted code. 5. Consider using 'pull_request_target' with caution β€” it runs in the base repo context and has access to secrets.

Click to flip back

Secret rotation strategy

Secret TypeRotation ApproachFrequency
Service principal client secretsAutomate with Azure Automation or Logic Apps. Create new secret, update consumers, delete old.Every 90 days (or eliminate with OIDC)
Key Vault secretsEnable expiry notifications, automate rotation with Event Grid + Azure FunctionsPer compliance policy (30-365 days)
GitHub PATsSet short expiry, use fine-grained PATs, replace with GitHub Apps where possibleEvery 90 days
CertificatesUse Key Vault auto-renewal for supported CAs (DigiCert, GlobalSign)Before expiry (auto with Key Vault)
SSH keysRotate and replace in secure files and Key VaultEvery 6-12 months
πŸ’‘ Exam tip: Secretless is always the best answer

When the exam presents a scenario asking how to improve pipeline security, the answer hierarchy is:

  1. Eliminate the secret entirely β€” workload identity federation, managed identities
  2. Centralise in Key Vault β€” with RBAC, audit logging, and rotation
  3. Use platform secret storage β€” GitHub Secrets, Azure DevOps secret variables
  4. Rotate frequently β€” short expiry, automated rotation

If an answer option mentions β€œworkload identity federation” or β€œmanaged identity” and the scenario supports it, that is almost certainly correct.

Knowledge check

Knowledge Check

Dr. Amira's client stores database passwords as Azure DevOps pipeline variables (not marked as secret). A junior developer's PR accidentally prints the connection string in build logs. What TWO changes should Amira make first?

Knowledge Check

Kai wants his GitHub Actions workflow to deploy to a staging Azure environment from any branch, but only the 'main' branch should be able to deploy to production. He is using workload identity federation. How should he configure this?

🎬 Video coming soon

Secrets & Secure Pipelines: Key Vault & Workload Federation

Next up: Security Scanning: GHAS, Defender and Dependabot

← Previous

Authorization & Access: GitHub Roles & Azure DevOps Security

Next β†’

Security Scanning: GHAS, Defender & Dependabot

Guided

I learn, I simplify, I share.

A Guide to Cloud YouTube Feedback

© 2026 Sutheesh. All rights reserved.

Guided is an independent study resource and is not affiliated with, endorsed by, or officially connected to Microsoft. Microsoft, Azure, and related trademarks are property of Microsoft Corporation. Always verify information against Microsoft Learn.