Your team is configuring a distributed C# application hosted on an Azure Virtual Machine Scale Set (VMSS) to access an Azure Storage account. Multiple VMSS instances will be scaled out and in dynamically. The identity used for accessing the storage account must persist independently of the VMSS lifecycle.
Which two configurations are required to ensure the application can successfully authenticate and read blobs from the storage account using the Azure.Identity library? (Select two.)
- Assign the Storage Blob Data Reader role to the user-assigned managed identity at the storage account resource scope.Answer
- BConfigure a system-assigned managed identity on the Virtual Machine Scale Set and grant it the Storage Blob Data Reader role.
- Instantiate the DefaultAzureCredential class by passing a DefaultAzureCredentialOptions instance with the ManagedIdentityClientId property set to the client ID of the user-assigned managed identity.Answer
- DInstantiate the DefaultAzureCredential class by configuring the AZURE_CLIENT_ID environment variable to match the object ID (principal ID) of the user-assigned managed identity.
Answer
To implement this solution, you must assign the Storage Blob Data Reader role to the user-assigned managed identity at the storage account scope, and instantiate the DefaultAzureCredential class by passing a DefaultAzureCredentialOptions instance with the ManagedIdentityClientId property set to the client ID of the user-assigned managed identity.
To ensure the managed identity persists independently of the Virtual Machine Scale Set lifecycle, a user-assigned managed identity must be used instead of a system-assigned one. The user-assigned identity must be granted appropriate access permissions, such as the Storage Blob Data Reader role at the storage account scope. When using DefaultAzureCredential with a user-assigned identity in code, the identity's client ID must be specified (for example, via DefaultAzureCredentialOptions) so that the credential knows which identity to use for token acquisition.
Step-by-Step Solution
Key Concept
Selecting and configuring user-assigned managed identities for applications with dynamic lifecycles using the Azure SDK.