You are configuring an Azure App Service web app named webapp-prod that runs on a Linux App Service Plan. The web app must retrieve a database connection string from an Azure Key Vault named vault-prod.
To adhere to security best practices, you create a User-Assigned Managed Identity named identity-prod, grant it Secret Get permissions on vault-prod, and assign identity-prod to webapp-prod. You decide not to enable the System-Assigned Managed Identity.
You need to configure the web app's settings so that it can resolve the connection string from the latest version of the secret named db-conn in vault-prod.
Which of the following configurations must you apply?
- Set the web app's keyVaultReferenceIdentity site configuration property to the resource ID of identity-prod, and configure an application setting named DbConnectionString with the value @Microsoft.KeyVault(VaultName=vault-prod;SecretName=db-conn).Answer
- BConfigure an application setting named keyVaultReferenceIdentity with the value set to the client ID of identity-prod, and configure an application setting named DbConnectionString with the value @Microsoft.KeyVault(VaultName=vault-prod;SecretName=db-conn).
- CSet the web app's keyVaultReferenceIdentity site configuration property to the resource ID of identity-prod, and configure an application setting named DbConnectionString with the value {"uri":"https://vault-prod.vault.azure.net/secrets/db-conn"}.
- DConfigure the Key Vault access policy to grant the web app's system identity permission to get secrets, and configure an application setting named DbConnectionString with the value @KeyVault(SecretUri=https://vault-prod.vault.azure.net/secrets/db-conn).
Answer
Set the web app's keyVaultReferenceIdentity site configuration property to the resource ID of identity-prod, and configure an application setting named DbConnectionString with the value @Microsoft.KeyVault(VaultName=vault-prod;SecretName=db-conn).
The correct configuration is to set the web app's keyVaultReferenceIdentity site configuration property to the resource ID of the user-assigned identity, and use the @Microsoft.KeyVault(VaultName=vault-prod;SecretName=db-conn) syntax for the application setting. This ensures App Service is explicitly told which user-assigned identity to use for token acquisition and provides the proper syntax for resolving the latest secret version.
Step-by-Step Solution
Key Concept
Key Vault references in Azure App Service with User-Assigned Managed Identities require specifying the keyVaultReferenceIdentity site configuration property using the identity's resource ID, along with the proper @Microsoft.KeyVault reference syntax.