You are troubleshooting an Azure API Management (APIM) instance. A backend API requires an API key, which is stored in Azure Key Vault. You have created an APIM named value named `BackendApiKey` that references the Key Vault secret using the APIM instance's system-assigned managed identity.
You apply the following policy to the inbound section of the API:
xml
<inbound>
<base />
<set-header name="X-Api-Key" exists-action="override">
<value>{{BackendApiKey}}</value>
</set-header>
</inbound>
When clients call the API, they receive an HTTP 500 Internal Server Error. The APIM trace logs show that the named value `BackendApiKey` could not be resolved from Key Vault.
Which of the following is the most likely cause of this error?
- The system-assigned managed identity of the Azure API Management instance has not been granted GET permissions on secrets in the Key Vault access policies or Azure role-based access control (RBAC).Answer
- BThe <set-header> policy is placed in the <inbound> section, but named values referencing Key Vault secrets can only be resolved within the <outbound> section.
- CThe APIM instance is attempting to resolve the Key Vault reference using a system-assigned managed identity, but Key Vault secret resolution in APIM is only supported when using a user-assigned managed identity.
- DThe syntax used to reference the named value in the policy is incorrect; it must use the App Configuration reference format @Microsoft.KeyVault(SecretUri=...) instead of double curly braces.
Answer
The system-assigned managed identity of the Azure API Management instance has not been granted GET permissions on secrets in the Key Vault access policies or Azure role-based access control (RBAC).
For Azure API Management to retrieve a secret from Key Vault using a system-assigned managed identity, the identity must have GET permission on secrets in the Key Vault. This can be configured either through Key Vault access policies or by assigning the Key Vault Secrets User RBAC role to the APIM instance's identity.
Step-by-Step Solution
Key Concept
Azure API Management named values can reference secrets stored in Azure Key Vault. When using a managed identity to fetch these secrets, the identity must be granted GET permission in Key Vault.
Estimated Time:1m 30s