Courseiva
Develop for Azure storagemediumDrag & DropObjective-mapped

AZ-204 Develop for Azure storage Practice Question

Arrange the steps to implement Azure AD authentication in an ASP.NET Core web app in the correct order.

Drag steps to the numbered slots on the right, or tap a step then tap a slot.

Steps
Order
1Step 1
2Step 2
3Step 3
4Step 4
5Step 5

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

Register app in Azure AD → Configure settings in appsettings.json → Add Microsoft.Identity.Web NuGet package → Configure middleware in Startup.cs → Secure endpoints with [Authorize] attribute

First register the app in Azure AD, then configure settings, add NuGet, configure middleware, and secure endpoints.

Answer analysis

Option-by-option breakdown

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

  • Register app in Azure AD → Configure settings in appsettings.json → Add Microsoft.Identity.Web NuGet package → Configure middleware in Startup.cs → Secure endpoints with [Authorize] attribute

    Why this is correct

    This is the correct order because you must first register your app in Azure AD to obtain the Application ID and tenant ID. Then configure the settings (like client ID, tenant ID) in appsettings.json. Next, add the Microsoft.Identity.Web NuGet package to integrate authentication. Then configure the authentication middleware in Startup.cs (e.g., AddMicrosoftIdentityWebApp). Finally, secure endpoints by adding the [Authorize] attribute to controllers or actions.

  • Add Microsoft.Identity.Web NuGet package → Register app in Azure AD → Configure settings in appsettings.json → Configure middleware in Startup.cs → Secure endpoints with [Authorize] attribute

    Why it's wrong here

    This order is incorrect because while the Microsoft.Identity.Web NuGet package can be installed at any point, its effective configuration for Azure AD authentication depends on specific values like the Application (client) ID and Directory (tenant) ID. These critical identifiers are only obtained after the application has been successfully registered in Azure AD. Attempting to configure `appsettings.json` or the authentication middleware without these concrete values would lead to using placeholders or incomplete settings, preventing the application from authenticating correctly at runtime.

  • Configure middleware in Startup.cs → Register app in Azure AD → Add Microsoft.Identity.Web NuGet package → Configure settings in appsettings.json → Secure endpoints with [Authorize] attribute

    Why it's wrong here

    This sequence is incorrect because configuring authentication middleware in `Startup.cs` (e.g., using `services.AddMicrosoftIdentityWebApp`) directly relies on the `Microsoft.Identity.Web` NuGet package being installed to provide the necessary extension methods. Furthermore, this middleware configuration itself references specific settings from `appsettings.json`, which in turn depend on the Azure AD app registration details. Attempting to configure middleware first would result in compilation errors due to missing methods and subsequent runtime failures because the required dependencies and configuration values are not yet present.

  • Secure endpoints with [Authorize] attribute → Register app in Azure AD → Configure settings in appsettings.json → Add Microsoft.Identity.Web NuGet package → Configure middleware in Startup.cs

    Why it's wrong here

    This order is incorrect because applying the `[Authorize]` attribute to controllers or actions is the final step in enforcing access control, but it is entirely dependent on a fully functional authentication pipeline. The `[Authorize]` attribute relies on the ASP.NET Core authentication middleware, which is configured in `Startup.cs`, to process authentication challenges and validate user tokens. Without the preceding steps of app registration, package installation, and proper middleware configuration, the `[Authorize]` attribute would simply fail to function, leading to unauthorized access or runtime exceptions as no authentication scheme would be active to handle the authorization request.

About these practice questions

One of 881 original AZ-204 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

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This AZ-204 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-204 exam.