You are deploying an Azure App Service web application that needs to retrieve a database connection string from an Azure Key Vault named my-keyvault. The connection string is stored as a secret named db-conn-string. You decide to use a Key Vault reference in the App Service application settings to retrieve the secret. Which of the following values represents the correct syntax format to reference this secret?
- @Microsoft.KeyVault(SecretUri=https://my-keyvault.vault.azure.net/secrets/db-conn-string/)Answer
- B@Azure.KeyVault(SecretUri=https://my-keyvault.vault.azure.net/secrets/db-conn-string/)
- C@Microsoft.KeyVault(SecretName=db-conn-string)
- D{"SecretUri": "https://my-keyvault.vault.azure.net/secrets/db-conn-string"}
Answer
The correct format is the option that uses the @Microsoft.KeyVault prefix followed by the SecretUri parameter pointing to the secret's URI, specifically: @Microsoft.KeyVault(SecretUri=https://my-keyvault.vault.azure.net/secrets/db-conn-string/).
The correct format uses the prefix '@Microsoft.KeyVault' followed by the 'SecretUri' parameter pointing to the URI of the secret in Azure Key Vault: @Microsoft.KeyVault(SecretUri=https://my-keyvault.vault.azure.net/secrets/db-conn-string/). This allows the App Service to authenticate using its managed identity and retrieve the secret at runtime.
Step-by-Step Solution
Key Concept
Azure Key Vault Reference Syntax in Azure App Service Configuration