You are developing a containerized API that will run on Azure Container Instances. The container groups are frequently created, destroyed, and recreated via automated workflows. The API must authenticate to the Microsoft Identity Platform to retrieve configuration keys from Azure App Configuration. You must ensure that recreating the Container Instances does not require updating permission grants in Azure App Configuration. Which two configurations should you implement? (Select two.)
- Create a user-assigned managed identity, assign it to the container group, and grant it the App Configuration Data Reader role.Answer
- Instantiate DefaultAzureCredential by passing DefaultAzureCredentialOptions with the ManagedIdentityClientId property set to the client ID of the user-assigned managed identity.Answer
- CEnable a system-assigned managed identity on the container group and grant it the App Configuration Data Reader role.
- DInstantiate DefaultAzureCredential by passing DefaultAzureCredentialOptions with the ManagedIdentityClientId property set to the Azure resource ID of the user-assigned managed identity.
Answer
Use a user-assigned managed identity assigned to the container group and configure DefaultAzureCredentialOptions in code using the client ID of that identity.
A user-assigned managed identity operates as a standalone Azure resource, so its lifecycle is decoupled from the container instances. Recreating the container instances will not delete the identity or its assigned roles. When writing the authentication code, DefaultAzureCredential needs to know which user-assigned identity to use, which is achieved by specifying the client ID via DefaultAzureCredentialOptions.ManagedIdentityClientId.
Step-by-Step Solution
Key Concept
User-assigned managed identity lifecycle and Client ID configuration in Azure SDK / MSAL authentication.