You are authoring a Bicep template to deploy an Azure App Service web app that requires access to a shared Azure Key Vault. The web app must use a user-assigned managed identity named `app-identity` that is defined in the same template.
You declare the user-assigned managed identity resource as follows:
bicep
resource appIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
name: 'app-identity'
location: location
}
You need to define the `identity` property of the App Service web app resource to assign this managed identity.
Which Bicep block should you include in the App Service resource definition?
- Aidentity: {
type: 'UserAssigned'
userAssignedIdentities: [
appIdentity.id
]
} - Bidentity: {
type: 'UserAssigned'
name: 'app-identity'
} - identity: {
type: 'UserAssigned'
userAssignedIdentities: {
'${appIdentity.id}': {}
}
}Answer - Didentity: {
type: 'UserAssigned'
identityId: appIdentity.id
}
Answer
The correct Bicep block must set the identity type to 'UserAssigned' and define the userAssignedIdentities property as a dictionary with the managed identity's resource ID as the key and an empty object as the value.
The correct Bicep block sets the type to 'UserAssigned' and maps the resource ID of the identity as a key in the userAssignedIdentities object with an empty object value. In ARM/Bicep, the user-assigned identities are represented as a dictionary/object to allow assigning multiple identities, where each key is the unique resource ID of an identity.
Step-by-Step Solution
Key Concept
Configuring user-assigned managed identities in Bicep/ARM templates
Estimated Time:1m 30s