AZ-400 Develop a security and compliance plan Practice Question
Your organization uses Azure DevOps to manage CI/CD pipelines. The security team requires that all pipeline runs use a specific service connection that references a managed identity in Microsoft Entra ID. However, some developers have been using personal access tokens (PATs) in their pipelines, bypassing the managed identity. What should you implement to enforce the use of the managed identity service connection?
⚠ Common exam trap
Watch out — candidates often confuse branch policies (which control code changes) with runtime enforcement mechanisms, overlooking that only pipeline decorators can inject mandatory validation into every pipeline execution.
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
✓
Use a pipeline decorator to validate the service connection and fail the pipeline if an unauthorized connection is used.
Pipeline decorators allow you to inject custom validation steps into every pipeline run at the organization or project level. By using a decorator that checks the service connection ID used in each job and fails the run if it does not match the approved managed identity connection, you can enforce compliance without relying on developer cooperation or manual policy configuration.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Configure a branch policy on the main branch to require a specific service connection.
Why it's wrong here
Branch policies on the main branch enforce signing, approval, and build validation on pull requests or direct pushes, but they operate at the commit level and have no insight into the runtime parameters of tasks in a pipeline. Once a pipeline is triggered, the policy does not examine or restrict task inputs like the service connection name or ID, and a malicious YAML can set the service connection directly. Thus, branch policies are a code-quality gate, not a service-connection security control.
- ✓
Use a pipeline decorator to validate the service connection and fail the pipeline if an unauthorized connection is used.
Why this is correct
Pipeline decorators are injected into every job at execution time, allowing you to add a validation step that inspects the service connection ID used by tasks such as AzureCLI or AzurePowerShell. Because the decorator runs as part of the job definition, you can compare the connection against an approved list and call an error to fail the pipeline before deployment proceeds. This control is centralized at the organization level and cannot be bypassed by a repository without modifying the decorator itself, making it the only enforceable option.
- ✗
Restrict the use of PATs by setting an agent pool-level permission.
Why it's wrong here
Agent pool-level permissions, such as 'Use' or 'Manage', restrict which agents members of the pool can run jobs on or control pool configuration; they do not govern which service connection a pipeline references. Additionally, PAT restrictions are an organization-level authentication policy that limits personal access token usage, but they do not intercept or validate the service connection being used in a task. As a result, a user with a valid PAT could still define a pipeline that invokes an unauthorized service connection.
- ✗
Store the service connection ID in a variable group and reference it in each pipeline.
Why it's wrong here
Variable groups provide a central place to store values like service connection IDs, but referencing them in a pipeline is purely convention—anyone can hardcode a different connection in their YAML or override the variable value via pipeline variables. Azure DevOps does not validate that the connection used matches the variable; it only substitutes the string at runtime. This approach fails to enforce authorization, since there is no logic that checks the variable and fails on mismatch.
Go deeper
Related to this question
Learn chapter
Introduction to DevOps and Azure DevOps
Key term
Azure DevOps
Azure DevOps is a Microsoft service that provides development tools for planning, building, testing, and deploying software applications using automated pipelines and collaboration features.
Key term
Pipeline
A pipeline is an automated series of steps that takes code from development to production, ensuring quality and speed.
About these practice questions
This AZ-400 question is part of Courseiva's 823-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
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.