A developer is configuring a V4 Azure Function App to connect to a secure database. The database connection string is stored in Azure Key Vault. The developer wants to reference this secret directly in the Function App's application settings without writing custom code to retrieve it. The Function App has a system-assigned managed identity enabled. Which of the following configurations is required to successfully retrieve the secret at runtime?
- Grant the system-assigned managed identity GET permission on secrets in the Key Vault access policy, and set the application setting value using the @Microsoft.KeyVault(SecretUri=...) syntax.Cevap
- BGrant the system-assigned managed identity GET permission on secrets in the Key Vault access policy, and set the application setting value using the keyvault://[vaultname]/[secretname] URI format.
- CConfigure the application setting value using the @Microsoft.KeyVault(SecretUri=...) syntax, but enable a user-assigned managed identity on the Function App without granting it any permissions in Key Vault.
- DGrant the system-assigned managed identity Contributor permissions on the Key Vault resource group, and set the application setting value using the secret's name only.
Cevap
Grant the system-assigned managed identity GET permission on secrets in the Key Vault access policy, and set the application setting value using the @Microsoft.KeyVault(SecretUri=...) syntax.
The correct configuration resolves the secret automatically because it meets both the syntax and permission criteria. The system-assigned managed identity must be granted the GET secret permission in the Key Vault's access policy (or via Azure RBAC Key Vault Secrets User), and the application setting must use the `@Microsoft.KeyVault(SecretUri=...)` syntax for the runtime to locate and retrieve the secret.
Adım Adım Çözüm
Anahtar Kavram
Configuring Key Vault references in Azure Functions application settings