External cache is not working as expected for the APIM

AB, Anand 0 Reputation points

I am trying to enable semantic caching for the APIM. I have updated the policy as per the documentaions, however during the trace, it is noticed that it is showing an error message "``No appropriate cache found for provided policy configuration. Policy execution will be skipped.``"

  1. Rakesh Mishra 9,700 Reputation points Microsoft External Staff Moderator

    Hello Anand,

    Thank you for reaching out to the Microsoft Q&A community.

    The warning No appropriate cache found for provided policy configuration. Policy execution will be skipped. indicates that Azure API Management (APIM) is either unable to properly connect to your configured external cache or is failing to execute the embeddings lookup prerequisite.

    Even if you have provisioned an Azure Cache for Redis and added it to APIM, this issue frequently occurs due to how the cache connection is configured in the portal or how the embeddings backend URL is formed. To resolve this, please check the following two configurations:

    1. Configure the External Cache as 'Default' with a Custom Connection String: When adding the external cache, selecting a specific region and picking your Redis instance directly from the dropdown can sometimes cause the caching policies to fail to resolve the instance.

    • Navigate to your APIM instance -> External cache (under the Settings blade).
    • If you have an existing cache linked, edit it or add a new one.
    • Set the Use from dropdown strictly to Default.
    • Set the Cache instance dropdown to Custom.
    • In the Connection String field, manually provide the connection string in this exact format: <your-redis-endpoint-url>,password=<your-access-key>,ssl=True,abortConnect=False

    2. Verify the Embeddings Backend Custom URL: According to official Microsoft documentation, the llm-semantic-cache-lookup policy operates "based on vector proximity of the prompt to previous requests." To calculate this, it relies on your Embeddings model backend. If the backend URL is incomplete, the policy fails to execute.

    • Navigate to Backends in your APIM instance.
    • Ensure the Custom URL for your embeddings backend includes the complete path to the deployment, not just the base Azure OpenAI URL. It must look similar to: https://<your-openai-resource>.openai.azure.com/openai/deployments/<your-embeddings-deployment-name>/embeddings

    3. Ensure RediSearch is Enabled As noted in the official documentation for Enable semantic caching for LLM APIs in Azure API Management:

    "An Azure Managed Redis instance with the RediSearch module enabled on the Redis cache. Note: You can only enable the RediSearch module when creating a new Azure Managed Redis cache. You can't add a module to an existing cache." Ensure your Redis cache was created with this module enabled, as vector similarity search is impossible without it.

    Once you have applied these changes, test your API operation again and check the API Inspector (Trace). You should now see successful cache lookup and store executions. Let me know if you need further assistance.


Sign in to comment