A developer is deploying a Go-based web application to Azure App Service. The application must retrieve a database connection string stored in an Azure Key Vault named `kv-prod-westus`. A system-assigned managed identity is enabled for the App Service.
You configure an application setting in the App Service with the key `DbConnectionString` and the value `@Microsoft.KeyVault(VaultName=kv-prod-westus;SecretName=DbConnectionString)`.
During testing, the application fails to retrieve the secret value and instead reads the raw reference string.
Which of the following is the most likely cause of this issue?
- AThe App Service application setting key must match the secret name in the Key Vault exactly for the reference to resolve.
- The system-assigned managed identity of the App Service has not been granted the 'Get' secret permission in the Key Vault access policies or Azure RBAC roles.Answer
- CThe Key Vault reference must be configured using a user-assigned managed identity, as system-assigned managed identities are not supported for Key Vault references.
- DThe Key Vault reference value is using incorrect syntax because the secret version parameter is required when referencing secrets by name.
Answer
The system-assigned managed identity of the App Service has not been granted the 'Get' secret permission in the Key Vault access policies or Azure RBAC roles.
The correct answer is that the system-assigned managed identity lacks the necessary 'Get' secret permission. When Azure App Service is unable to resolve a Key Vault reference—due to missing permissions, network restrictions, or deletion of the resource—it will populate the environment variable with the raw reference string instead of failing the deployment or throwing an exception.
Step-by-Step Solution
Key Concept
Key Vault references in Azure App Service require correct syntax and appropriate read permissions ('Get' secret permission) granted to the app's managed identity in the Key Vault.