You are authoring an Azure Resource Manager (ARM) template to deploy an Azure App Service web app that needs to read secrets from an Azure Key Vault. During testing, developers will frequently delete and recreate the App Service web app. You must ensure that redeploying the web app does not require recreating Key Vault access policies or re-granting permissions.
Which configuration should you define in the resources section of the ARM template to enable the managed identity?
- Set the identity type to UserAssigned and define the resource ID of the existing user-assigned managed identity as a key in the userAssignedIdentities dictionary.Answer
- BSet the identity type to SystemAssigned and define the resource ID of the existing user-assigned managed identity as a key in the userAssignedIdentities dictionary.
- CSet the identity type to UserAssigned and define the client ID of the existing user-assigned managed identity as a key in the userAssignedIdentities dictionary.
- DSet the identity type to SystemAssigned and assign Key Vault permissions to the principal ID generated by the App Service resource.
Answer
Set the identity type to UserAssigned and define the resource ID of the existing user-assigned managed identity as a key in the userAssignedIdentities dictionary.
The correct configuration uses a user-assigned managed identity, which exists as a standalone Azure resource independent of the App Service web app. By configuring the identity type as 'UserAssigned' and referencing the identity's resource ID in the 'userAssignedIdentities' block, the web app can be deleted and redeployed without deleting the managed identity itself or breaking the Key Vault access policies configured for it.
Step-by-Step Solution
Key Concept
Selecting and configuring the correct managed identity type (System-Assigned vs User-Assigned) based on lifecycle requirements and ARM template properties.