An Azure service that is used to implement corporate governance and standards at scale for Azure resources.
Hello Mateusz Wygoda,
Thank you for reaching out to the Microsoft Q&A forum.
While investigating we that splitting your cache by API so HR traffic goes to one Redis and “other” traffic to another makes perfect sense from a security standpoint. Unfortunately, APIM’s built-in external‐cache feature only lets you configure one cache per location (or per gateway), and there isn’t a “cache instance” attribute you can switch on per‐operation in the standard cache-lookup/store policies.
Here are a couple of workarounds you can consider:
Use multiple gateways
Spin up two self-hosted gateways (or two locations in a multi-region APIM): • Gateway HR – configure hr_redis as its External cache • Gateway Default – configure other_redis as its External cache
Then map API 1 to the HR gateway and API 2 to the Default gateway. Pros: you keep using built-in cache policies (cache-lookup/store) with no custom code Cons: you need to deploy and manage an extra gateway
Do custom caching inside your policies
Store both Redis connection strings in Named Values (secret)
In your inbound or backend policy for API 1 call a <send-request> or <send-request-policies> block to issue raw Redis commands (SET/GET) against the hr_redis endpoint
Similarly, inside API 2’s policy target the other_redis endpoint Pros: no extra gateway needed, full control over which Redis instance you hit Cons: you’re rolling your own Redis protocol calls, more complex policy logic
If neither approach is suitable, the only other option is to split the two APIs into separate APIM instances (each with its own External cache configured).
Hope that gives you a clear path forward!
Reference docs
• Configure External Redis in APIM (External cache blade) https://learn.microsoft.com/azure/api-management/api-management-howto-cache-external
• cache-lookup/store policies https://learn.microsoft.com/azure/api-management/cache-store-policy https://learn.microsoft.com/azure/api-management/cache-lookup-policy
• send-request policy (for custom Redis calls) https://learn.microsoft.com/azure/api-management/send-request-policy