AZ-400 Practice Question: Design and implement build and release pipelines
You are configuring a build pipeline in Azure Pipelines that compiles a .NET application. You need to ensure that the pipeline uses a specific version of the .NET SDK, which is installed on the agents. The agents are Microsoft-hosted. What should you add to your YAML pipeline?
⚠ Common exam trap
The trap here is assuming that a script to check the version or a variable will influence which SDK is used; only the UseDotNet@2 task actually sets the SDK for subsequent tasks.
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 UseDotNet@2 task with the desired version specified.
The UseDotNet@2 task is designed to install or select a specific .NET SDK version on the agent. This ensures that the build uses the correct SDK. Other options do not effectively control the SDK version used by the build.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
A variable named 'DotNetVersion' set to the desired version and referenced in the build task.
Why it's wrong here
Simply setting a variable does not change the SDK version used by the build. The build task does not automatically use such a variable unless it is explicitly configured to do so. The UseDotNet@2 task is the proper mechanism to set the SDK version for the pipeline.
- ✓
The UseDotNet@2 task with the desired version specified.
Why this is correct
The UseDotNet@2 task installs or selects the specified .NET SDK version on the agent. This ensures that subsequent tasks, such as the build, use the correct SDK. It is the recommended way to pin the .NET SDK version in Azure Pipelines.
- ✗
A task that runs 'dotnet --version' to verify the SDK version.
Why it's wrong here
Running 'dotnet --version' only displays the version; it does not install or select a specific SDK version. Microsoft-hosted agents come with multiple SDK versions, and the default may not be the one you need. This task does not ensure the correct SDK is used for the build.
- ✗
A script that downloads and installs the .NET SDK from the official website.
Why it's wrong here
Manually downloading and installing the SDK is unnecessary and error-prone. Microsoft-hosted agents already have multiple SDKs installed, and the UseDotNet@2 task can select the desired version without manual installation. This approach adds complexity and potential failure points.
Go deeper
Related to this question
Learn chapter
Source Control Strategy Design
Key term
Azure Pipelines
Azure Pipelines is a cloud-based CI/CD service from Microsoft that automatically builds, tests, and deploys code to any platform or cloud.
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 696-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 and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Microsoft exam blueprint
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.