Question

Difficulty: MediumConfigure Azure App Service Web Apps

An organization has deployed a web app named app-finance to Azure App Service. The application needs to retrieve a database connection string from an Azure Key Vault named kv-prod. The web app is configured to use a system-assigned managed identity, and Key Vault access policies have been configured to allow this identity to read secrets. You need to add an application setting named DbConnectionString to the web app that references the secret DbPassword in the Key Vault. Which value should you set for the DbConnectionString app setting?

  1. @Microsoft.KeyVault(SecretUri=https://kv-prod.vault.azure.net/secrets/DbPassword)Answer
  2. B
    @Microsoft.KeyVault(VaultName=kv-prod,SecretName=DbPassword)
  3. C
    @Microsoft.Azure.KeyVault(SecretUri=https://kv-prod.vault.azure.net/secrets/DbPassword)
  4. D
    https://kv-prod.vault.azure.net/secrets/DbPassword

Answer

The app setting should be configured with the value @Microsoft.KeyVault(SecretUri=https://kv-prod.vault.azure.net/secrets/DbPassword) to resolve the secret from the Key Vault.
The correct format for a Key Vault reference in Azure App Service is `@Microsoft.KeyVault(SecretUri=https://<vault-name>.vault.azure.net/secrets/<secret-name>)` or `@Microsoft.KeyVault(VaultName=<vault-name>;SecretName=<secret-name>)`. The option using the `@Microsoft.KeyVault` prefix with the correct `SecretUri` value successfully retrieves the secret.

Step-by-Step Solution

1
Identify the resource details
The Key Vault is named kv-prod and the secret is named DbPassword, with the corresponding secret URI being https://kv-prod.vault.azure.net/secrets/DbPassword.
This establishes the targets for referencing the Key Vault resource.
2
Select the correct Key Vault reference syntax for App Service
Determine that the syntax requires the prefix @Microsoft.KeyVault with either SecretUri or a semicolon-separated VaultName/SecretName pair.
Correct syntax is required for the App Service runtime to intercept and resolve the reference.
3
Construct the reference string
@Microsoft.KeyVault(SecretUri=https://kv-prod.vault.azure.net/secrets/DbPassword)
Using the SecretUri parameter matches the official syntax precisely.

Key Concept

Key Vault references in Azure App Service allow an application to access secrets from Key Vault as environment variables without code changes.
Estimated Time:1m 30s
Rate this question