Study guide
7.4 Variable Groups, Secret Variables & Key Vault Linking
Microsoft Certified: Azure DevOps Engineer Expert AZ-400
Track your progress as you read
Finished sections get a check mark.
1 Chapter 1: Flow of Work, Traceability & Work Tracking
1.1 Flow of Work, GitHub Flow & Feedback Cycles 1.2 Work Tracking with Azure Boards & GitHub Projects 1.3 End-to-End DevOps Traceability & Quality Tracking
2 Chapter 2: DevOps Metrics, Dashboards & Team Collaboration
2.1 DORA Metrics, Flow Metrics & Dashboard Design 2.2 Lifecycle Metrics Across the Six DevOps Phases 2.3 Work Item Queries, WIQL Charts & Analytics 2.4 Project Documentation: Wikis, Mermaid Diagrams & Release Notes 2.5 Webhooks, Service Hooks & Microsoft Teams ChatOps
3 Chapter 3: Git Branching Strategies & Pull Request Workflows
3.1 Git Branching Models & Strategy Design 3.2 Pull Request Workflows & Merge Strategies 3.3 Branch Policies, Quality Gates & Compliance Restrictions
4 Chapter 4: Repository Management, Optimization & Git Data Operations
4.1 Git LFS Architecture & .gitattributes Tracking 4.2 LFS History Migration, git-fat & File Locking 4.3 Git Repository Scaling, Scalar & Monorepo Governance 4.4 Repository Permissions & Git Tag Governance 4.5 Git Data Recovery & Sensitive-Data Scrubbing
5 Chapter 5: Package Management & Dependency Versioning
5.1 Selecting Package Tools: Azure Artifacts vs. GitHub Packages 5.2 Feed Scoping, Upstream Sources & Pipeline Authentication 5.3 Package Views, Immutability & Quality Promotion 5.4 Dependency Versioning: SemVer, CalVer & Automated Versioning 5.5 Pipeline Artifact Versioning & Artifact Storage Strategy
6 Chapter 6: Pipeline Infrastructure, Agents & Integration
6.1 Selecting a CI/CD Solution: Azure Pipelines vs. GitHub Actions 6.2 GitHub-Azure Pipelines Integration & Hybrid Migration 6.3 Hosted vs. Self-Hosted Agents & Runners 6.4 VMSS Elastic Pools, Container Jobs & Agent Governance 6.5 Pipeline Triggers, Filters & Concurrency Management
7 Chapter 7: YAML Pipeline Architecture & Reusable Elements
7.1 YAML Pipeline Anatomy: Stages, Jobs, Steps & Workspaces 7.2 Job Execution Order: DAG Dependencies, Parallelism & Conditions 7.3 Reusable Elements: Templates, Parameters & Variables 7.4 Variable Groups, Secret Variables & Key Vault Linking 7.5 YAML Environments, Checks & Deployment Approvals
8 Chapter 8: Testing Strategy, Quality Gates & Code Coverage
8.1 Test Strategy Design: Local, Unit & Integration Testing 8.2 Load, Stress & Performance Testing in Pipelines 8.3 Test Execution Tasks, Agents & Results Integration 8.4 Code Coverage Analysis & SonarQube Integration 8.5 Quality Gates, Release Gates & Governance Checks
9 Chapter 9: Modern Deployment Strategies & Zero-Downtime Delivery
9.1 Progressive Delivery: Blue-Green, Canary & Ring Deployments 9.2 Minimizing Downtime: Deployment Slots & Rolling Updates 9.3 Feature Flags with Azure App Configuration & Feature Manager 9.4 Designing the High-Priority Hotfix Path 9.5 Ordered Dependency Deployments, Resiliency & Rollback
10 Chapter 10: Artifact Deployment & Database DevOps
10.1 Containerized Application Delivery: ACR, AKS & Container Apps 10.2 Binary, Web App, Function & Scripted Deployments 10.3 Database DevOps: State-Based & Migration-Based Strategies
11 Chapter 11: Infrastructure as Code (IaC) & Azure Deployment Environments
11.1 Infrastructure as Code Strategy: Bicep, ARM & Terraform 11.2 Desired State Configuration & Azure Machine Configuration 11.3 Azure Deployment Environments (ADE) & Developer Self-Service
12 Chapter 12: Pipeline Maintenance, Health & Modernization
12.1 Pipeline Health, Flaky Tests & Reliability Engineering 12.2 Pipeline Optimization: Caching, Slicing & Concurrency 12.3 Artifact & Build Retention Governance 12.4 Modernizing CI/CD: Classic to YAML Migration
13 Chapter 13: Authentication, Authorization & Identity Governance
13.1 Microsoft Entra Service Principals & Managed Identities 13.2 Service Connections, Workload Identity & Personal Access Tokens 13.3 Azure DevOps Projects, Teams & Permission Evaluation 13.4 Access Levels, GitHub Roles & Outside Collaborators
14 Chapter 14: Secrets Management, Sensitive Data & DevSecOps Scanning
14.1 Azure Key Vault, Secret Variables & Secretless CI/CD 14.2 Security Scanning Strategy, GHAS & Secret Scanning 14.3 CodeQL SAST in Pipelines and Containers 14.4 Software Supply Chain, Container Scanning & Cloud Defender
15 Chapter 15: Telemetry Collection, Azure Monitor & Alerting
15.1 Azure Monitor Architecture, AMA & Data Collection Rules 15.2 Application Insights & Specialized Azure Monitor Insights 15.3 Alerting Rules, Action Groups & GitHub Repository Insights
16 Chapter 16: Telemetry Analysis, Distributed Tracing & SRE Practices
16.1 Distributed Tracing, Application Map & Exception Triage 16.2 KQL Log Analytics, SRE Observability & Error Budgets
7.4 Variable Groups, Secret Variables & Key Vault Linking
Key Takeaways Explain This Topic AI
A variable group is linked with the group keyword under variables and can be scoped to the pipeline, a stage or a single job.
A Key Vault-linked variable group resolves secret values at queue time through a service connection; only the names are stored in Azure DevOps.
Secret variables are masked in logs by literal substring match, so a secret that is transformed, base64-encoded or split across lines is no longer masked.
Secret variables are not injected into the script environment automatically and must be mapped explicitly with an env block.
In a YAML pipeline the most locally scoped definition wins: job-level, then stage-level, then pipeline-root YAML variables all override a queue-time value, and the Pipeline settings UI is weakest.
Last updated: September 2026
7.4 Variable Groups, Secret Variables & Key Vault Linking
In enterprise DevOps delivery pipelines, decoupling code from configuration and establishing strict release governance are paramount. Hardcoding database connection strings, API tokens, or cloud credentials in source repositories violates DevSecOps standards and exposes organizations to credential exfiltration.
Azure Pipelines addresses configuration management and environment protection through three tightly coupled primitives:
Variable Groups : Centralized configuration and secret stores defined in the Azure DevOps Library.
Azure Key Vault Integration : Native synchronization of cloud secrets without persisting plaintext credentials in Azure DevOps.
YAML Environments with Approvals and Checks : Logical deployment targets guarded by automated and manual pre-deployment gates that developers cannot bypass.
Mastering these features is critical for designing secure, auditable release pipelines on the AZ-400 exam.
1. Azure DevOps Variable Groups & Secret Masking Mechanics
A Variable Group is an enterprise configuration asset created under Pipelines → Library in Azure DevOps. Variable Groups allow teams to define sets of variables that can be shared across multiple build and release pipelines within a project.
Linking Variable Groups in YAML
To consume a variable group in a YAML pipeline, reference it in the root or stage-level variables: block. You can combine multiple variable groups with individual inline variables: variables:
- group: GlobalPlatformConfig # Group containing shared URLs and settings
- group: PaymentServiceSecrets # Group containing sensitive tokens
- name: buildConfiguration
- value: 'Release'
- Secret Variables and Log Masking
Variables can be designated as sensitive by clicking the lock icon next to the value in the Azure DevOps portal. Marking a variable as secret activates two critical security mechanisms:
Storage Encryption : The value is encrypted at rest using Azure DevOps service keys and is never exposed in plain text in the portal UI.
Log Masking : When an agent executes a step, the agent runtime registers all secret values in an internal redaction table. Any stdout or stderr stream emitting a secret value is intercepted, and the secret string is replaced with *** .
The Script Environment Variable Trap
By design, Azure Pipelines does not automatically inject secret variables as operating system environment variables into script tasks ( script , bash , powershell ). This prevents external malicious scripts or open-source dependencies from dumping the process environment to exfiltrate credentials.
To consume a secret variable inside a script, you must explicitly map it using the env: block: # Correct Pattern: Explicit mapping via env block
- script: |
- echo "Authenticating with external payment gateway..."
- python deploy.py --token "$PAYMENT_TOKEN"
- displayName: 'Invoke Deployment Script'
env:
PAYMENT_TOKEN: $(PaymentApiKey) # Secret variable from Variable Group
- # Anti-Pattern / Security Trap: Inlining secret into script command text
- # - script: python deploy.py --token $(PaymentApiKey)
# Risk: Some interpreters print command strings to debugging logs before agent masking engages.
2. Azure Key Vault Linked Variable Groups
Rather than manually entering and rotating secrets inside Azure DevOps, enterprise security standards dictate sourcing secrets directly from Azure Key Vault . [Azure Key Vault] ◄──(ARM Service Connection / Workload Identity)── [Azure DevOps Library]
- ▲ │
- Secret Rotated Linked Variable Group
- in Cloud Vault │
- │ ▼
- └────────────────── Next Pipeline Run Fetches Fresh Secret ─────────┘
- Configuration Steps
In Azure DevOps, navigate to Pipelines → Library → + Variable group .
Enable the toggle: Link secrets from an Azure key vault as variables .
Select an Azure subscription and an authorized ARM Service Connection (preferably configured with Workload Identity Federation / OIDC).
Select the target Key Vault name .
Click + Add to select individual secrets, or select all secrets.
Save the variable group.
Secret Synchronization and Caching Behavior
Run Initialization Fetch : Azure Key Vault linked variable groups do not maintain a persistent cache of secret values in Azure DevOps. When a pipeline run is queued, the orchestration engine authenticates to Azure Key Vault via the service connection and downloads the current secret versions.
Zero Pipeline Modification on Secret Rotation : When an administrator or automated process rotates a secret in Azure Key Vault, the subsequent execution of the Azure Pipeline automatically retrieves the new secret value without modifying the pipeline YAML or touching Azure DevOps settings.
Variable Group vs. AzureKeyVault@2 Task :
Variable Group : Secrets are resolved at pipeline initialization and can be scoped cleanly across entire stages or pipelines.
AzureKeyVault@2 Task : A specific pipeline task that runs on an agent to retrieve secrets dynamically during job execution. Used when secrets must be queried conditionally or dynamically at runtime using runtime parameters.
3. Variable Scoping, Precedence and Group Security
Variables can be declared in several places, and the exam tests which one wins. For YAML pipelines Microsoft documents this order, highest precedence first:
- Precedence Source Notes
- 1 (strongest) Job-level variables: in the YAML file The most locally scoped definition always wins
- 2 Stage-level variables: in the YAML file Overrides the pipeline root for that stage only
- 3 Pipeline-root variables: in the YAML file Overrides both queue-time and the settings UI
- 4 Variable set at queue time Only settable when the variable is marked Settable at queue time
- 5 (weakest) Pipeline variable set in the Pipeline settings UI Lowest precedence in a YAML pipeline
The counter-intuitive result is the one the exam tests: in a YAML pipeline a value hard-coded in the YAML file beats a queue-time override, which is the opposite of the classic release-pipeline model where queue time is strongest. If a variable must be overridable at queue time, do not also define it in the YAML file.
A variable group contributes its variables at the scope where it is linked, so a group linked at stage scope exists only in that stage. Within a single scope the last definition wins, so a variables: block that lists a group and then a literal name / value pair overrides the group's value for that name.
Two syntax families behave completely differently and cause most misconfigurations:
$(var) is a runtime macro : it is substituted when the task executes, so it can carry values produced earlier in the run, and it silently leaves the literal text in place if the variable does not exist.
${{ variables.var }} is a compile-time template expression : it is resolved while the YAML is being parsed, before any agent is assigned, so it can drive condition , dependsOn and template selection but can never see a value produced during the run.
Variable-group security is a separate plane from pipeline authoring. Each group carries Reader / User / Administrator roles plus a pipeline permissions list. A group with "Open access" is usable by every pipeline in the project, which is exactly how a low-trust sandbox pipeline gains production credentials. Restrict production groups to the named release pipelines instead. # Create a group and restrict it to a single pipeline
az pipelines variable-group create --name prod-release --authorize false --variables REGION=eastus2 --organization "$ORG" --project "$PROJECT"
Because secret variables are not injected into the script environment automatically, map them explicitly with an env: block; otherwise $(SqlPassword) inside an inline script expands to an empty string.