A developer is configuring a C# ASP.NET Core web application hosted on an Azure App Service. The application must retrieve a database connection string stored in an Azure Key Vault named kv-prod using a Key Vault reference in the App Service configuration. The App Service is configured with a system-assigned managed identity. Which configuration should the developer apply to retrieve the secret value successfully?
- Set the application setting value to @Microsoft.KeyVault(SecretUri=https://kv-prod.vault.azure.net/secrets/db-conn/) and assign the Key Vault Secrets User role to the App Service system-assigned managed identity.Cevap
- BSet the application setting value to @Microsoft.KeyVault(SecretUrl=https://kv-prod.vault.azure.net/secrets/db-conn/) and assign the Key Vault Secrets User role to the App Service system-assigned managed identity.
- CSet the application setting value to @Microsoft.KeyVault(SecretUri=https://kv-prod.vault.azure.net/secrets/db-conn/) and assign the Key Vault Reader role to the App Service system-assigned managed identity.
- DSet the application setting value to @Microsoft.KeyVault(SecretUri=https://kv-prod.vault.azure.net/secrets/db-conn/) and assign the Key Vault Secrets User role to a new user-assigned managed identity, because system-assigned managed identities are not supported for Key Vault references.
Cevap
Set the application setting value to @Microsoft.KeyVault(SecretUri=https://kv-prod.vault.azure.net/secrets/db-conn/) and assign the Key Vault Secrets User role to the App Service system-assigned managed identity.
The correct configuration requires setting the application setting to the format @Microsoft.KeyVault(SecretUri=https://kv-prod.vault.azure.net/secrets/db-conn/) and granting the system-assigned managed identity the Key Vault Secrets User role. The SecretUri parameter is the correct syntax for referencing a secret by its URI, and the Key Vault Secrets User role provides the necessary permissions to read the secret's value at runtime.
Adım Adım Çözüm
Anahtar Kavram
Key Vault References in App Service