You are developing an ASP.NET Core web application hosted on an Azure App Service. The application must retrieve database connection strings from an Azure Key Vault. The security architecture requires that:
1. The application must authenticate to Azure Key Vault without storing any credentials or secrets in code or configuration files.
2. The identity used for authentication must be shared across multiple web applications in the same environment to simplify access control management.
Which configuration should you implement to meet these requirements?
- AEnable a system-assigned managed identity on the App Service, assign it the Key Vault Secrets User role on the Key Vault, and configure the App Service application settings.
- BCreate an App Registration in Microsoft Entra ID, configure a client secret, store the secret in the App Service application settings, and grant it permissions on the Key Vault.
- Create a user-assigned managed identity, assign it the Key Vault Secrets User role on the Key Vault, associate the identity with the App Service, and configure the client ID in the application settings.Answer
- DCreate a user-assigned managed identity, associate it with the App Service, and configure Key Vault access policies to grant access to the App Service's default system identity.
Answer
Create a user-assigned managed identity, assign it the Key Vault Secrets User role on the Key Vault, associate the identity with the App Service, and configure the client ID in the application settings.
The correct option is to create a user-assigned managed identity, assign it the Key Vault Secrets User role, associate it with the App Service, and configure the client ID in the settings. This ensures the identity is shared across resources without storing secrets and allows DefaultAzureCredential to resolve the specified identity.
Step-by-Step Solution
Key Concept
User-assigned managed identities allow for shared access across multiple Azure resources with an independent lifecycle from the resource, whereas system-assigned managed identities are restricted to a single resource.