Courseiva
Design and implement build and release pipelineshardMultiple SelectObjective-mapped

Configuring a Build to Restore from Two NuGet Sources and Fail on Missing Packages

You are designing a build pipeline for a .NET Core application. You need to ensure that the pipeline restores NuGet packages from both an Azure Artifacts feed and the public NuGet gallery. The pipeline must fail if a package is not found in either source. Which two actions must you take? (Select two.)

Quick Answer

Restoring from two NuGet sources with a hard failure on anything missing needs a NuGet.config file that lists both the Azure Artifacts feed and the public gallery as package sources, referenced explicitly by the restore task. The restore task already fails by default when a package can't be found in any configured source, so no extra flag is needed once both feeds are declared.

⚠ Common exam trap

Many exam-takers confuse upstream sources (which provide automatic fallback) with explicit source configuration and error handling, leading them to select Option E instead of understanding that upstream sources prevent failures rather than enforce them.

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 a NuGet.config file that includes both feeds as package sources and reference it in the restore task.

Creating a NuGet.config file that includes both the Azure Artifacts feed and the public NuGet gallery as package sources, and referencing it in the restore task, ensures the pipeline consults both sources. Option D is incorrect because the 'CheckConsistency' flag is not related to failing on missing packages; the restore task already fails by default if a package cannot be resolved from any configured source. Options B, C, and E do not fulfill the requirement to fail on missing packages from both sources.

Answer analysis

Option-by-option breakdown

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

  • Create a NuGet.config file that includes both feeds as package sources and reference it in the restore task.

    Why this is correct

    Correct. A NuGet.config file explicitly defines the package sources, and referencing it in the restore task ensures the pipeline searches both feeds and fails if a package is not found in either.

  • Set the 'NoWarn' property to NU1603 to ignore warnings about missing packages.

    Why it's wrong here

    Incorrect. The 'NoWarn' property suppresses warnings like NU1603 (dependency version mismatch) but does not affect package resolution failure.

  • Use the 'dotnet restore' task with the '--no-cache' flag.

    Why it's wrong here

    Incorrect. The '--no-cache' flag skips the local cache for restore but does not add sources or change failure behavior.

  • Set the 'CheckConsistency' flag to true in the restore task.

    Why it's wrong here

    Incorrect. The 'CheckConsistency' flag is used to verify package integrity after restore, not to enforce failure on missing packages. The restore task already fails by default if a package cannot be resolved.

  • Configure the Azure Artifacts feed to use the public NuGet gallery as an upstream source.

    Why it's wrong here

    Incorrect. Configuring an upstream source makes the Azure Artifacts feed automatically fall back to the public NuGet gallery, but if the package is missing from both, restore will fail. However, this option alone does not meet the requirement to explicitly fail if a package is not found in either source, and it requires only a single source—not both.

Option-by-option analysis

Why each answer is right or wrong

Understanding why wrong answers are wrong — and when they would be correct — is what separates a 750 score from a 900. The AZ-400 exam frequently reuses these exact scenarios with slightly different constraints.

Create a NuGet.config file that includes both feeds as package sources and reference it in the restore task.Correct answer

Why this is correct

Correct. A NuGet.config file explicitly defines the package sources, and referencing it in the restore task ensures the pipeline searches both feeds and fails if a package is not found in either.

Set the 'NoWarn' property to NU1603 to ignore warnings about missing packages.Wrong answer — click to see why

Why this is wrong here

This would suppress warnings, not cause failure on missing packages.

Use the 'dotnet restore' task with the '--no-cache' flag.Wrong answer — click to see why

Why this is wrong here

This bypasses cache but does not enforce failure on missing packages.

Configure the Azure Artifacts feed to use the public NuGet gallery as an upstream source.Wrong answer — click to see why

Why this is wrong here

This is a feed configuration, not a pipeline setting, and does not cause failure if a package is missing.

Analysis generated from the official AZ-400blueprint and verified against question context. The “when correct” sections are what AI assistants cite when candidates ask “what’s the difference between these options?”

Visual reference

Client Recursive Resolver Root DNS (13 root servers) TLD DNS (.com, .org, …) Authoritative example.com query IP addr answer

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 →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

2 more ways this is tested on AZ-400

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. You are designing a build pipeline for a .NET Core application. The pipeline must run on a self-hosted agent in a private network without internet access. Which TWO actions are required to ensure the build can download NuGet packages?

easy
  • A.Disable the NuGet restore step in the pipeline.
  • B.Install the NuGet tool on the self-hosted agent machine.
  • C.Use a Microsoft-hosted agent instead.
  • D.Configure the self-hosted agent to access Azure Artifacts or an internal NuGet feed.
  • E.Use the NuGet Authenticate task to authenticate with Azure Artifacts.

Why B: To restore NuGet packages on a self-hosted agent without internet access, the NuGet tool must be installed on the agent machine (B) and the agent must be configured to access an internal NuGet feed, such as Azure Artifacts or a local feed (D). Disabling the NuGet restore step (A) would prevent packages from being downloaded. Using a Microsoft-hosted agent (C) would require internet access, which violates the private network constraint. The NuGet Authenticate task (E) is not required because authentication can be handled through feed configuration or integrated authentication.

Variation 2. Your team uses Azure Pipelines to build a .NET application. Recently, builds have been failing intermittently with NuGet restore errors. The pipeline uses a hosted agent. You need to ensure consistent package restoration. What should you do?

medium
  • A.Use a self-hosted agent with persistent NuGet package caches.
  • B.Clear the NuGet cache in the pipeline using 'dotnet nuget locals all --clear' before restore.
  • C.Enable multi-stage Docker builds for the application.
  • D.Configure the pipeline to use the Dapr sidecar for package management.

Why A: Using a self-hosted agent with persistent NuGet package caches ensures that packages are not re-downloaded on each build, avoiding intermittent network failures. Option B would clear the cache and force re-download, worsening the issue. Option C is for Docker builds, not NuGet. Option D is unrelated to package restoration.

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.