You are deploying an Azure App Service web app that must retrieve a database connection string from an Azure Key Vault using a user-assigned managed identity for compliance reasons. The Key Vault uses Azure Role-Based Access Control (RBAC) for authorization.
The user-assigned managed identity has been assigned the 'Key Vault Secrets User' role on the Key Vault. You use the following Bicep template snippet to deploy the web app:
bicep
resource webApp 'Microsoft.Web/sites@2022-03-01' = {
name: webAppName
location: location
identity: {
type: 'UserAssigned'
userAssignedIdentities: {
'${userAssignedIdentityId}': {}
}
}
properties: {
siteConfig: {
appSettings: [
{
name: 'ConnectionStrings__Default'
value: '@Microsoft.KeyVault(SecretUri=https://kv-prod-01.vault.azure.net/secrets/DbConn)'
}
]
}
}
}
During deployment validation, the application fails to start, and the logs indicate that the application setting `ConnectionStrings__Default` cannot resolve the Key Vault reference.
Which configuration change must you apply to the Bicep template to ensure the web app can resolve the connection string?
- AModify the App Service setting value to @Microsoft.KeyVault(SecretUri=https://kv-prod-01.vault.azure.net/secrets/DbConn;IdentityId=userAssignedIdentityId).
- BRevert the Key Vault permission model to Key Vault access policies and add an access policy that grants the Get secret permission directly to the Web App's resource principal.
- Set the keyVaultReferenceIdentity property under properties to the value of userAssignedIdentityId.Answer
- DEnable a system-assigned managed identity on the Web App and assign the user-assigned identity to the identityDelegationSettings block.