Question 819 of 881
Managed Identity for Azure Key Vault — App Service Access
You are developing an ASP.NET Core web API that is hosted on Azure App Service. The API needs to read secrets from Azure Key Vault at startup. You want to avoid storing any credentials in the application code or configuration. Which approach should you use?
Quick Answer
The answer is to enable the system-assigned managed identity for the App Service and configure Key Vault access policies to allow that identity. This approach is correct because a managed identity, automatically managed by Microsoft Entra ID, provides an Azure resource with an automatically generated service principal, allowing it to authenticate to Azure Key Vault without any credentials stored in code or configuration files. On the AZ-204 exam, this scenario tests your understanding of secure secret management in Azure compute environments, often appearing as a direct question about eliminating hardcoded credentials from App Service applications. A common trap is choosing a client secret or certificate-based approach, which violates the requirement to avoid stored credentials. Remember the memory tip: "Managed identity means no stored identity"—if the question demands zero credentials in code, always reach for a managed identity, not a service principal with a secret.
⚠ Common exam trap
A common mix-up: candidates think storing credentials in App Service application settings is acceptable because they are 'not in code,' but the question explicitly requires avoiding any stored credentials, making managed identity the only secure, credential-free approach.
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 the system-assigned managed identity for the App Service and configure Key Vault access policies to allow that identity.
Enabling a system-assigned managed identity for the App Service allows it to authenticate to Azure Key Vault without any credentials stored in code or configuration. The managed identity is automatically managed by Azure AD (now Microsoft Entra ID) and can be granted access to Key Vault secrets via access policies, eliminating the need for client IDs, client secrets, or connection strings.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Use the Key Vault SDK with a client ID and client secret stored in App Service application settings.
Why it's wrong here
While possible, this still requires storing a secret (the client secret) in application settings, which is not fully credential-free. Managed identity eliminates the need for any secret.
- ✓
Enable the system-assigned managed identity for the App Service and configure Key Vault access policies to allow that identity.
Why this is correct
Correct. Managed identity allows the App Service to authenticate to Microsoft Entra ID without any credentials. The Key Vault access policy grants the identity read access to secrets.
- ✗
Use Microsoft Entra ID application roles to assign the App Service a role that allows reading secrets.
Why it's wrong here
Application roles are not used for Key Vault access. Key Vault uses access policies or Azure RBAC roles (for Key Vault data plane) assigned to the identity.
- ✗
Store the Key Vault URL and a connection string with the secret in the application's app.config file.
Why it's wrong here
This exposes credentials in the configuration file, which is insecure and does not leverage Azure's security features.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Same concept, more angles
1 more way this is tested on AZ-204
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 have an Azure Function app that needs to retrieve a secret from Azure Key Vault at runtime. You want to avoid storing any credentials in code or configuration. Which mechanism should you use?
easy- A.Service principal with client secret
- ✓ B.Managed identity
- C.Access key
- D.Shared access signature (SAS)
Why B: Managed identity (B) is the correct mechanism because it allows the Azure Function app to authenticate to Azure Key Vault without storing any credentials in code or configuration. Azure automatically manages the identity and provides a token from Azure AD that the function can use to access the vault, eliminating the need for secrets or keys in the application.
Last reviewed: Jun 11, 2026
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.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.