Soru

Zorluk: ZorDefine API Management Policies

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?

Cevap:<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>

Cevap

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.

Adım Adım Çözüm

1
Identify the policy element that allows rate limiting with a custom key.
rate-limit-by-key
The counter-key attribute is used in the policy to track limits by subscription ID, which is only supported by rate-limit-by-key, not the standard rate-limit policy.
2
Identify the policy element that performs response cache lookup during inbound processing.
cache-lookup
The cache-lookup policy must be placed in the inbound section to check for a cached response before making a call to the backend.
3
Identify the policy element that stores response payloads in the cache during outbound processing.
cache-store
The cache-store policy must be placed in the outbound section to cache responses coming back from the backend for the specified duration.

Anahtar Kavram

Azure API Management policies configuration for rate limiting by key and response caching.
Bu soruyu puanla