If your Azure Function App is failing to read Key Vault secrets during runtime and you're encountering a "secret not found or access denied" error, consider the following troubleshooting steps:
- Check Key Vault Access Policies: Ensure that the managed identity assigned to your Azure Function App has the correct access policies configured in the Key Vault. You should verify that the identity has both
GetandListpermissions for secrets. - Managed Identity Configuration: Confirm that the system-assigned managed identity is correctly enabled for your Azure Function App. You can check this in the Azure portal under the Identity section of your Function App.
- Key Vault Firewall Settings: Although you mentioned that the Key Vault firewall is set to allow Azure services, double-check that there are no additional network restrictions that might prevent access from your Function App.
- Secret Existence: Make sure that the secret you are trying to access actually exists in the Key Vault and that the name used in your Function App matches the secret's name in the Key Vault.
- Application Settings: Ensure that your application settings in the Azure Function App are correctly configured to reference the Key Vault secrets. If you are using Key Vault references, verify that the syntax is correct.
- Diagnostics Tools: Utilize Azure's built-in diagnostics tools to gather more information about the failure. You can go to your Function App in the Azure portal, select Diagnose and solve problems, and look for any relevant diagnostic information related to Key Vault access.
By following these steps, you should be able to identify and resolve the issue preventing your Azure Function App from accessing Key Vault secrets during runtime.
References: