Managed Identities · AZ-204: Developing Solutions for Microsoft Azure Implement Azure Security

An App Service has both a system-assigned managed identity and a user-assigned managed identity attached. The application must use the user-assigned…

Practice question from Managed Identities (AZ-204: Developing Solutions for Microsoft Azure Implement Azure Security), with the correct answer and a step-by-step solution.

hard · MCQ · Q-CB0728

An App Service has both a system-assigned managed identity and a user-assigned managed identity attached. The application must use the user-assigned identity to access Blob Storage. Which change explicitly selects that identity when using the Azure .NET SDK?

  1. A.Use new DefaultAzureCredential() without any options, because the SDK always selects the user-assigned identity.
  2. B.Use new DefaultAzureCredential(new DefaultAzureCredentialOptions { ManagedIdentityClientId = userAssignedClientId }) when constructing the BlobServiceClient.Correct answer
  3. C.Pass the user-assigned identity's client ID as the storage account name when constructing the BlobServiceClient.
  4. D.Set the storage account's access key as the ManagedIdentityClientId value.

Solution

When multiple managed identities are available, the application should specify the user-assigned identity's client ID. ManagedIdentityClientId causes DefaultAzureCredential to request tokens for that identity rather than relying on ambiguous identity selection.

More from Managed Identities

All of Managed Identities

Practise more Implement Azure Security

Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.

Start practising free

Free to start · No credit card needed