You are developing an API gateway solution using Azure API Management (APIM). The API must implement rate limiting based on a client's subscription ID and cache the backend responses to reduce backend load. The rate limiting should trigger if a client makes more than 100 requests per 60 seconds. Responses must be cached for 3600 seconds.
Complete the XML policy definition by filling in the blanks. What are the correct XML elements for blank 1, blank 2, and blank 3?
Answer:<policies>
<inbound>
<base />
<【rate-limit-by-key】 calls="100" renewal-period="60" counter-key="@(context.Subscription.Id)" />
<【cache-lookup】 vary-by-developer="false" vary-by-developer-groups="false" downstream-caching-type="none" />
</inbound>
<outbound>
<base />
<【cache-store】 duration="3600" />
</outbound>
</policies>
<inbound>
<base />
<【rate-limit-by-key】 calls="100" renewal-period="60" counter-key="@(context.Subscription.Id)" />
<【cache-lookup】 vary-by-developer="false" vary-by-developer-groups="false" downstream-caching-type="none" />
</inbound>
<outbound>
<base />
<【cache-store】 duration="3600" />
</outbound>
</policies>
Answer
The correct XML elements to fill in the blanks are rate-limit-by-key for blank 1, cache-lookup for blank 2, and cache-store for blank 3.
The rate-limit-by-key policy allows rate limiting based on expressions like the client subscription ID. The cache-lookup policy evaluates the incoming request against cached responses in the inbound pipeline, while the cache-store policy saves the response payload in the cache during the outbound pipeline.
Step-by-Step Solution
Key Concept
Azure API Management policies configuration for rate limiting by key and response caching.