Courseiva
Design and implement build and release pipelineseasyMultiple ChoiceObjective-mapped

AZ-400 Practice Question: Design and implement build and release pipelines

Your build pipeline uses a hosted agent. You notice that every build starts with a clean workspace, increasing build time. You want to improve performance by caching the Node.js 'node_modules' folder. Which task should you add to the pipeline?

⚠ Common exam trap

Test-takers frequently confuse the Cache task with artifact tasks (Publish/Download Build Artifacts), assuming artifacts can be used for caching, but artifacts are designed for immutable output storage and lack the key-based restoration and automatic eviction that the Cache task provides for performance optimization.

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

Cache task

The Cache task (option D) is correct because it allows you to cache the 'node_modules' folder between pipeline runs on hosted agents, avoiding the need to reinstall dependencies from scratch each time. By specifying a cache key (e.g., based on package-lock.json) and the path to cache, subsequent builds can restore the folder from cache, significantly reducing build time.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Publish Build Artifacts task

    Why it's wrong here

    The Publish Build Artifacts task uploads files to the Azure Pipelines artifact store so they can be consumed by other stages or releases, but it does not preserve content between runs for reuse. Each run produces new artifacts—there is no key-based lookup or automatic restoration on subsequent pipelines. Thus it does not satisfy a caching requirement.

  • Copy Files task

    Why it's wrong here

    The Copy Files task merely copies source files to a destination folder on the agent or a UNC path, performing no packaging or artifact registration. It is a stateless filesystem operation with no cache key, scope, or ability to restore files in a later pipeline run. It cannot accelerate later builds by reusing previously downloaded dependencies.

  • Download Build Artifacts task

    Why it's wrong here

    The Download Build Artifacts task retrieves artifacts that were previously published by a specific build or release, linking to that run's artifact set. While it can mix with caching, its purpose is to fetch declared outputs, not to automatically cache and restore dependency folders across runs. It does not provide a custom cache key or automatic save/load semantics.

  • Cache task

    Why this is correct

    The Cache task is designed exactly for this: it captures a specified folder after a run and restores it on subsequent runs using a defined key (typically a hash of package manifests) and cache hit variables. When the key matches, it avoids expensive re-downloads or recompilation, making it the correct way to persist dependency caches on hosted agents. Its whole purpose is cross-run reuse, unlike tasks that publish, copy, or download artifacts.

About these practice questions

Courseiva writes every AZ-400 question from scratch — 823 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

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.