Question

Difficulty: EasyAzure Key Vault Secret, Key, and Certificate Management

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?

  1. @Microsoft.KeyVault(SecretUri=https://my-keyvault.vault.azure.net/secrets/db-conn-string/)Answer
  2. B
    @Azure.KeyVault(SecretUri=https://my-keyvault.vault.azure.net/secrets/db-conn-string/)
  3. C
    @Microsoft.KeyVault(SecretName=db-conn-string)
  4. 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

1
Identify the service and feature being configured.
Azure App Service Application Settings using a Key Vault reference.
This allows the App Service to automatically resolve the secret from Key Vault without application code changes.
2
Determine the prefix required for Key Vault references.
The prefix must be exactly '@Microsoft.KeyVault'.
Azure App Service parser looks for this specific prefix to resolve Key Vault secrets at runtime.
3
Identify the required parameter format inside the parentheses.
The parameter is 'SecretUri=' followed by the full URI of the secret.
This uniquely identifies the secret vault, secret name, and optionally the version.

Key Concept

Azure Key Vault Reference Syntax in Azure App Service Configuration
Rate this question