Question 334 of 823
Why a Variable Group Can't Find a Secret That Exists in Key Vault
A financial services company uses Azure DevOps and requires that all secrets (e.g., API keys, connection strings) be stored in Azure Key Vault. They have a pipeline that runs automated tests and deploys to staging. The pipeline uses a variable group linked to Key Vault to retrieve secrets. Recently, the pipeline failed with the error: 'Secret 'DbPassword' not found in Key Vault 'kv-prod'. Ensure the secret exists and the service principal has List permission.' The secret exists in the vault. What is the most likely cause?
Quick Answer
The variable-to-secret name match for a Key Vault-linked variable group is case-sensitive — if the variable group defines dbpassword or DBPassword while the vault's secret is named DbPassword, the lookup fails with a 'not found' error even though the secret genuinely exists. That specific error message is the signature of a case mismatch, not a permissions problem.
⚠ Common exam trap
It's easy for candidates to assume the error 'secret not found' always means the secret is missing or permissions are wrong, but Azure DevOps specifically tests the case-sensitive mapping between variable group variable names and Key Vault secret names, which is a subtle but critical detail.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
The variable name in the variable group does not exactly match the secret name in Key Vault (case-sensitive).
Variable groups linked to Azure Key Vault in Azure DevOps require an exact case-sensitive match between the variable name in the variable group and the secret name in Key Vault. Even though the secret 'DbPassword' exists in the vault, if the variable group defines the variable as 'dbpassword' or 'DBPassword', the lookup will fail with the 'not found' error. The error message explicitly states the secret was not found, which is the typical symptom of a case mismatch, not a permissions or connectivity issue.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The variable group is linked to the wrong Key Vault instance.
Why it's wrong here
If linked to wrong vault, the error would still be 'not found' but would mention the other vault.
- ✓
The variable name in the variable group does not exactly match the secret name in Key Vault (case-sensitive).
Why this is correct
Azure DevOps maps variable names to secret names, and the match is case-sensitive.
- ✗
The service principal does not have Get permission on the secret.
Why it's wrong here
The error indicates 'not found', not 'access denied'.
- ✗
The Key Vault is in a different Azure region than the Azure DevOps organization.
Why it's wrong here
Region does not affect secret retrieval.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Same concept, more angles
8 more ways this is tested on AZ-400
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. Your Azure DevOps pipeline uses a variable group to store secrets. The variable group is linked to a Key Vault. You need to use a secret variable in a pipeline task. How should you reference the secret in the YAML pipeline?
medium- A.Reference the variable as $(VariableName) but only in a script task using 'env' mapping.
- B.Use the 'task.getVariable' method in a PowerShell script.
- ✓ C.Reference the variable as $(VariableName) in the pipeline tasks.
- D.Use the Azure Key Vault task to retrieve the secret and then reference the output variable.
Why C: When a variable group is linked to an Azure Key Vault, secret variables are automatically available in the pipeline. You can reference them directly using the standard $(VariableName) syntax in any pipeline task. No special task or script is required. Option A is incorrect because you do not need to restrict to script tasks or use 'env' mapping; the $(VariableName) works everywhere. Option B is incorrect because 'task.getVariable' is a scripting method used within tasks, not a YAML syntax. Option D is incorrect because the Azure Key Vault task is unnecessary; the variable group handles the retrieval automatically.
Variation 2. Your build pipeline uses a YAML template that references variables from a variable group. The variable group is linked to a library. You need to ensure that sensitive variables are not exposed in logs. Which THREE actions should you take?
hard- A.Set the variable group to 'Allow access to all pipelines'.
- ✓ B.Store the secrets in Azure Key Vault and reference them in the variable group.
- C.Use 'Write-Host' to output the variable values for debugging.
- ✓ D.Mark the variables as 'secret' in the variable group.
- ✓ E.Configure permissions on the library to restrict which pipelines can use the variable group.
Why B: To keep sensitive variables out of pipeline logs, you should store secrets in Azure Key Vault and reference them in a variable group (B), mark variables as secret in the variable group (D), and configure permissions on the library to restrict which pipelines can use the variable group (E). Key Vault integration and secret marking ensure that values are masked automatically, while restricting access limits the risk of unauthorized pipelines that could expose secrets.
Variation 3. Your organization uses Azure DevOps and GitHub. You need to ensure that secrets such as API keys are not exposed in pipeline logs. What should you do?
easy- A.Store the API key in a plain text variable and reference it as $(apiKey)
- ✓ B.Store the API key in Azure Key Vault and use a variable group linked to the vault
- ✓ C.Store the API key in a secret variable
- D.Use the Logging Command to suppress output
Why B: Both secret variables and variable groups linked to Azure Key Vault are masked in pipeline logs. Azure Pipelines automatically masks secret variables, and variables from Key Vault variable groups are also treated as secrets. Therefore, both B and C prevent exposure. The question asks 'what should you do?' without requiring a single best method, so both B and C should be considered correct.
Variation 4. Which THREE steps should you take to implement a secure CI/CD pipeline that uses secrets from Azure Key Vault?
hard- ✓ A.Use the Azure Key Vault task to download secrets as variables
- ✓ B.Use secret variables in the pipeline that reference Key Vault secrets
- C.Store secrets as plain text variables in the pipeline library
- D.Hardcode secrets in the YAML file and use variables to mask them
- ✓ E.Grant the build agent managed identity access to the Key Vault
Why A: The Azure Key Vault task in Azure Pipelines can download secrets as pipeline variables at runtime, allowing the pipeline to securely reference them without exposing the secret values in logs or configuration. This task authenticates to Key Vault using a service connection or managed identity, ensuring secrets are never stored in the pipeline definition.
Variation 5. Your organization uses Azure DevOps with classic pipelines. Security audit requires that all pipeline variables containing secrets (e.g., API keys) are stored in Azure Key Vault and referenced dynamically. Currently, secrets are stored as plain text in the pipeline UI. You need to migrate to Key Vault with minimal downtime and ensure that secret values are never exposed in logs. What should you do?
hard- A.Store secrets in a secure file in Azure DevOps.
- ✓ B.Create a variable group linked to Key Vault, mark variables as 'secret', and reference them in pipelines. Update pipeline steps to use the variable group.
- C.Use the 'Azure Key Vault' task to download secrets as pipeline variables.
- D.Add each secret as a pipeline variable with the 'secret' type.
Why B: The correct approach is to create a variable group linked to Azure Key Vault in the Library, mark the variables as 'secret', and reference that variable group in the pipeline. This ensures secrets are stored in Key Vault (not in Azure DevOps) and masked in logs. Option A (secure file) still stores secrets in Azure DevOps and may not prevent log exposure. Option C (Azure Key Vault task) downloads secrets as pipeline variables, which could expose them if not properly masked. Option D (secret pipeline variables) stores secrets in Azure DevOps, not Key Vault, and while masked, they remain in the pipeline definition.
Variation 6. A company uses Azure DevOps for CI/CD. They have multiple pipelines that deploy to different environments. They want to ensure that secrets like API keys are not exposed in pipeline logs. What is the best approach?
medium- A.Use Azure App Configuration with Key Vault references
- ✓ B.Create a Variable Group linked to Azure Key Vault
- C.Use Azure Kubernetes Service secrets
- D.Use pipeline variables marked as 'secret'
Why B: Variable Groups linked to Azure Key Vault allow you to securely store secrets in Key Vault and reference them in pipelines without exposing the actual values in logs or output. Option A is incorrect: Azure App Configuration with Key Vault references is designed for application configuration, not for managing pipeline secrets directly. Option C is incorrect: Azure Kubernetes Service (AKS) secrets are specific to Kubernetes workloads and not intended for general pipeline secret management. Option D is incorrect: Pipeline variables marked as 'secret' are masked in logs, but they are still stored in Azure DevOps and lack the centralized security and auditing capabilities of Key Vault.
Variation 7. Your team uses Azure Pipelines for CI/CD. You need to ensure that a secret variable stored in Azure Key Vault is available to a build pipeline without exposing it in logs. What should you do?
medium- ✓ A.Store the secret in a variable group linked to Key Vault and reference it without marking it secret.
- B.Add the secret as a plain text variable in the pipeline YAML.
- C.Use a Key Vault task to fetch the secret and map it to a pipeline variable marked 'secret'.
- D.Add the secret to the repository's .env file and use a script to read it.
Why A: To securely use a secret from Azure Key Vault in an Azure Pipeline without exposing it in logs, the simplest and recommended approach is to create a variable group linked to the Key Vault. When you reference the secret by name, Azure Pipelines automatically masks its value in logs. There is no need to manually mark the variable as secret; the linked variable group handles it. The Azure Key Vault task is an alternative but not the primary method; additionally, the task automatically creates secret variables and does not require manual mapping.
Variation 8. Your pipeline runs on a Microsoft-hosted agent. You need to securely reference an Azure Key Vault secret in a pipeline variable without exposing the value in logs. Which variable group type should you use and how should you reference the secret?
medium- ✓ A.Create a variable group linked to Key Vault, then reference as $(KeyVaultName.SecretName)
- B.Use the 'Azure Key Vault' task to download secrets and assign to variables
- C.Store the secret as a plain text variable and mark it as 'secret'
- D.Reference the secret directly as $(SecretName) from a library variable group
Why A: To securely reference an Azure Key Vault secret without exposing the value in logs, create a variable group linked to the Key Vault. This automatically maps each secret to a pipeline variable whose name equals the secret name and masks its value. Reference it directly as $(SecretName). Option A identifies the correct variable group type but uses an incorrect reference. Option D uses the correct reference but does not explicitly state that the variable group must be linked to Key Vault. Therefore, none of the options are fully correct.
Last reviewed: Jun 11, 2026
This AZ-400 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AZ-400 exam.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.