You are deploying a microservice named `order-service` to Azure Container Apps. The container image for the microservice is stored in a private Azure Container Registry (ACR) named `myregistry.azurecr.io`.
To ensure secure image retrieval, you must configure the Container App to pull the image using a user-assigned managed identity named `app-pull-identity`. The identity has already been granted the `AcrPull` role on the registry.
Which Bicep configuration block must you use to satisfy this requirement?
- identity: {
type: 'UserAssigned'
userAssignedIdentities: {
'/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/app-pull-identity': {}
}
}
properties: {
configuration: {
registries: [
{
server: 'myregistry.azurecr.io'
identity: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/app-pull-identity'
}
]
}
}Answer - Bidentity: {
type: 'UserAssigned'
userAssignedIdentities: {
'/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/app-pull-identity': {}
}
}
properties: {
configuration: {
registries: [
{
server: 'myregistry.azurecr.io'
identity: 'system'
}
]
}
} - Cidentity: {
type: 'UserAssigned'
userAssignedIdentities: {
'/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/app-pull-identity': {}
}
}
properties: {
configuration: {
registries: [
{
server: 'myregistry.azurecr.io'
identity: 'app-pull-identity'
}
]
}
} - Didentity: {
type: 'UserAssigned'
userAssignedIdentities: {
'/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/app-pull-identity': {}
}
}
properties: {
configuration: {
registries: [
{
server: 'myregistry.azurecr.io'
username: 'app-pull-identity'
passwordSecretRef: 'acr-pull-secret'
}
]
}
}
Answer
The configuration that sets the full resource ID of the user-assigned managed identity in both the identity block and the registries block is correct.
The correct configuration enables the user-assigned managed identity on the Container App resource by listing its resource ID under the userAssignedIdentities property and setting the type to 'UserAssigned'. It then specifies the same full resource ID in the registries configuration block under properties.configuration.registries. This instructs Azure Container Apps to use the designated user-assigned managed identity to authenticate and pull the image from the specified Azure Container Registry.
Step-by-Step Solution
Key Concept
Configuring registry authentication for Azure Container Apps using Bicep and user-assigned managed identities.