You are developing a C# ASP.NET Core web application deployed to Azure App Service. The application is deployed as two regional instances: app-us-east and app-us-west. Both instances must retrieve shared secrets from a central Azure Key Vault named kv-shared. Additionally, app-us-east must write data to a regional Azure Storage account named sa-east-logs, while app-us-west must write data to sa-west-logs. To configure the managed identities, you perform the following steps:
1. Create a single user-assigned managed identity named uami-shared and assign it to both App Services, granting it Get and List secrets permissions on kv-shared.
2. Enable a system-assigned managed identity on both app-us-east and app-us-west, and grant each regional identity Contributor access to its corresponding regional storage account (sa-east-logs or sa-west-logs).
In your C# code, you instantiate the SDK clients as follows:
csharp
// Accessing the shared Key Vault
var kvClient = new SecretClient(
new Uri("https://kv-shared.vault.azure.net/"),
new DefaultAzureCredential()
);
// Accessing the regional storage account
var blobClient = new BlobServiceClient(
new Uri("https://sa-east-logs.blob.core.windows.net/"),
new DefaultAzureCredential()
);
What is the authentication outcome when the app-us-east instance attempts to run this code and connect to both services?
- AThe application fails to connect to both resources because Azure App Service does not support configuring both a system-assigned managed identity and a user-assigned managed identity on the same resource instance simultaneously.
- The application successfully connects to the regional storage account, but fails to authenticate to the shared Key Vault because DefaultAzureCredential defaults to the system-assigned managed identity when both identity types are enabled, causing token requests without a specified client ID to use the system-assigned identity.Cevap
- CThe application successfully connects to both the shared Key Vault and the regional storage account because DefaultAzureCredential automatically queries the Azure Instance Metadata Service to retrieve and attempt tokens for all assigned identities until one succeeds.
- DThe application successfully connects to the shared Key Vault, but fails to authenticate to the regional storage account because user-assigned managed identities take precedence in the DefaultAzureCredential resolution order.