AZ-400 Practice Question: Design and implement build and release pipelines
Exhibit
Refer to the exhibit.
```yaml
# azure-pipelines.yml
trigger:
branches:
include:
- main
- release/*
pool:
vmImage: ubuntu-latest
variables:
- group: 'Prod-Environment'
stages:
- stage: Build
jobs:
- job: BuildJob
steps:
- script: echo Building...
- stage: Deploy
jobs:
- deployment: DeployToProd
environment: 'Production'
strategy:
runOnce:
deploy:
steps:
- script: echo Deploying...
```The pipeline above fails with: 'The deployment job 'DeployToProd' references environment 'Production' which does not exist.' What should you do to resolve this error?
⚠ Common exam trap
Test-takers frequently think a script step can dynamically create the environment before the deployment job runs, but Azure DevOps validates environment references at pipeline compile time, not runtime, so the environment must already exist.
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
✓
Create an environment named 'Production' in Azure DevOps project settings.
The error indicates that the Azure DevOps pipeline references an environment named 'Production' that does not exist in the project. Environments must be explicitly created in Azure DevOps project settings before they can be used in deployment jobs. Option D resolves this by creating the required environment, allowing the deployment job to target it correctly.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Remove the 'environment' property from the deployment job.
Why it's wrong here
Removing the 'environment' property would eliminate the deployment job's core functionality, including approval gates, deployment history, and environment-specific security. The failure occurs because the referenced environment does not exist, not because the property itself is invalid, so deleting it would not address the root cause and would degrade the pipeline.
- ✗
Change the deployment strategy from 'runOnce' to 'rolling'.
Why it's wrong here
Changing from 'runOnce' to a 'rolling' strategy does not affect environment validation; both strategies require the target environment to already exist in Azure DevOps. The error happens when the deployment job attempts to resolve the 'Production' environment, so altering the strategy cannot resolve the missing environment.
- ✗
Add a script step before the deployment job to create the environment.
Why it's wrong here
Environments in Azure DevOps are project-level resources that must be predefined in Project Settings; they cannot be created dynamically by a pipeline script. Even a script executed before the deployment job runs under the pipeline's agent context and lacks the necessary permissions or interface to register an environment, so this step would not prevent the failure.
- ✓
Create an environment named 'Production' in Azure DevOps project settings.
Why this is correct
The deployment job fails because it references an environment named 'Production' that does not yet exist in the Azure DevOps project. You must create the environment in Project Settings > Pipelines > Environments before running the pipeline; this provides the required resource for deployment job execution and enables tracking, approvals, and security on that environment.
Visual reference
Go deeper
Related to this question
Learn chapter
Introduction to DevOps and Azure DevOps
Key term
Pipeline
A pipeline is an automated series of steps that takes code from development to production, ensuring quality and speed.
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.
About these practice questions
One of 823 original AZ-400 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.