Azure / Azure/api-management-policy-snippets

Aren't APIM's inbound policies able to read Redis Cache keys set externally?

Open
#115 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
399
Forks
170
PR merge metrics
No merged PRs in 30d

Description

We have a customer in West Europe and am setting up an APIM instance for them in the Central France region. We're running the REST API and the backend in West US. It takes ~20 seconds for a ~2MB file to travel from West US to Central France. In order to improve that delay, I'm attempting to write the file into a Redis instance that's located in Central France and have APIM's inbound policy read it from Redis and return it right away if present, instead of calling our West US located REST API. I could not get this to work, so am wondering what am I missing or is such a scenario not supported by APIM? A key in Redis is key in Redis and should be readable by any service that has access rights to the Redis instance.

I set the APIM's Managed Identity to have "Redis Contributor" permissions on the Redis instance.

I did find earlier #43 and am caching in the backend using the "2_" prefixed key and lookup in APIM's inbound policy using the bare key. It does not work. I did use VS Code's Azure Cache extension to verify that the "2_" prefixed key is present in the Redis cache.
![image](https://github.com/Azure/api-management-policy-snippets/assets/15199814/a2e44473-099d-4609-937c-2acba8148296)

I did add the two highlighted cache operations and do notice in the test call's trace that both are successful. This shows that APIM's policy can use the Redis instance.
![image](https://github.com/Azure/api-management-policy-snippets/assets/15199814/0a9c2194-bba2-4c9a-abbd-38e43862bf16)
![image](https://github.com/Azure/api-management-policy-snippets/assets/15199814/efd20d98-af98-4ee4-a3a6-da79dc3c4945)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the behavior described in issue #43, then inspect the APIM inbound-policy cache operations and the test-call trace referenced here. Verify the externally written `2_`-prefixed Redis key and the bare-key lookup under the stated West US/Central France setup. Done means establishing whether this scenario is supported and documenting a reproducible explanation or limitation; no repository files or tests are named.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, redis
Domain
api, cloud
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
18/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.