AZ-204 Implement Azure security Practice Question
A company uses Azure App Service to host a web application. They need to ensure that only authenticated users from their Microsoft Entra ID tenant can access the app. They also want to prevent unauthenticated requests from reaching the app code. Which configuration should they implement?
⚠ Common exam trap
Candidates often confuse authentication (proving identity) with authorization (checking permissions) and incorrectly choose option C, thinking role assignment alone blocks unauthenticated users, but App Roles only work after authentication and do not prevent unauthenticated requests from reaching the app code.
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
✓
Enable App Service Authentication with Microsoft Entra ID as the identity provider and set 'Action to take when request is not authenticated' to 'Log in with Microsoft Entra ID'.
Enabling App Service Authentication (EasyAuth) with Microsoft Entra ID as the identity provider and setting 'Action to take when request is not authenticated' to 'Log in with Microsoft Entra ID' ensures that all unauthenticated requests are redirected to Microsoft Entra ID for authentication before they reach the application code. This configuration blocks unauthenticated requests at the platform layer, preventing any unauthenticated traffic from hitting the app's runtime, which meets the requirement of keeping unauthenticated requests away from the app code.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Configure IP restrictions in the web.config to allow only the company's office IP range.
Why it's wrong here
Configuring IP restrictions in the web.config file only filters incoming requests based on their source IP address. While this can limit access to specific networks, it does not perform user authentication or verify user identity against Microsoft Entra ID. An authenticated user from a permitted IP could access the application, but an unauthenticated user from that same IP would also be allowed, failing to enforce user authentication.
- ✗
Implement a custom middleware in the app to validate tokens from Microsoft Entra ID.
Why it's wrong here
Implementing custom middleware within the application to validate Microsoft Entra ID tokens requires significant code changes and ongoing maintenance. Crucially, this approach means unauthenticated requests still reach the application's runtime before the middleware can process them, consuming application resources. It also shifts the responsibility of authentication from the robust platform to the application, which is less efficient and secure than leveraging built-in App Service capabilities.
- ✗
Assign users to Microsoft Entra ID App Roles and check roles in the app.
Why it's wrong here
Assigning users to Microsoft Entra ID App Roles and checking these roles within the application addresses authorization, which determines what an *authenticated* user is permitted to do. This mechanism does not, however, enforce authentication itself. Unauthenticated requests would still reach the application, and the application would then need to handle the lack of an authenticated user or token, failing to block unauthenticated access at the gateway level.
- ✓
Enable App Service Authentication with Microsoft Entra ID as the identity provider and set 'Action to take when request is not authenticated' to 'Log in with Microsoft Entra ID'.
Why this is correct
Enabling App Service Authentication (often called Easy Auth) with Microsoft Entra ID offloads authentication concerns to the platform. By setting 'Action to take when request is not authenticated' to 'Log in with Microsoft Entra ID', the App Service acts as a gateway, automatically redirecting all unauthenticated requests to the Microsoft Entra ID login page. This ensures that no unauthenticated requests reach the application code, as the platform handles token validation and user session management transparently, enhancing security and reducing application complexity.
Go deeper
Related to this question
About these practice questions
This AZ-204 question is part of Courseiva's 881-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. 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-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.