AZ-400 Question 145
Single answerYour company is implementing a new CI/CD pipeline in Azure DevOps. The first stage performs a build on a Microsoft-hosted Linux agent. The second stage must run specialized tests on a Windows machine with proprietary software that cannot be installed on the hosted agent. You have set up a Windows VM in your on-premises data center and installed a self-hosted Azure Pipelines agent on it. Which approach should you take to ensure the specialized tests run on the Windows VM while the build remains on the hosted agent?
- A
Use the same job for both build and test tasks, specifying 'runs-on: windows-latest' for all tasks
- B
Define separate jobs for build and test; use 'runs-on: ubuntu-latest' for the build job and 'runs-on: self-hosted' for the specialized test job
- C
Configure a single job with 'runs-on: self-hosted' in the pipeline, then override it at runtime for the build tasks
- D
Set up a container job with the proprietary software pre-installed, and run the specialized tests on the Microsoft-hosted agent
Show answer and explanation
Correct answer: B
Explanation
In Azure Pipelines, each job can target a specific agent pool or machine. To run certain tasks on a specialized self-hosted environment while others use Microsoft-hosted agents, you must split them into separate jobs. The first job (build) uses 'runs-on: ubuntu-latest' to utilize the hosted Linux agent, while the second job (test) specifies 'runs-on: self-hosted' to ensure the tasks run on your Windows VM. This approach aligns with Microsoft� recommended best practices for hybrid pipeline scenarios, allowing you to manage complex requirements such as proprietary dependencies on self-hosted agents.
- A. Incorrect.
Incorrect. Specifying 'windows-latest' for both build and test would use Microsoft's hosted Windows agent for all tasks, which does not meet the requirement to run specialized software on your self-hosted VM.
- B. Correct.
Correct. Creating separate jobs with distinct 'runs-on' labels ensures the build is executed on the hosted Ubuntu agent while the specialized tests run on the self-hosted Windows agent in your data center.
- C. Incorrect.
Incorrect. You cannot override 'runs-on' per task in a single job; each job can only target one type of agent. To leverage different agents, you must define separate jobs.
- D. Incorrect.
Incorrect. Using a container job on the hosted agent does not solve the need to use proprietary software on your on-premises VM. Containers on hosted agents also typically don�t provide direct access to specialized local software.