Soru

Zorluk: OrtaDefine API Management Policies

A developer is configuring response caching for an API in Azure API Management. The developer applies the following policy configuration:

xml
<policies>
<inbound>
<base />
<cache-lookup vary-by-developer="false" vary-by-developer-groups="false" downstream-caching-type="none" />
<cache-store duration="3600" />
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
</policies>

Why does this policy configuration fail to save?

  1. A
    The cache-lookup policy is located in the inbound section, but it must be placed in the outbound section.
  2. B
    The policy configuration fails because a user-assigned managed identity must be explicitly configured inside the cache-store element to authorize access to the cache.
  3. The cache-store policy is located in the inbound section, but it must be placed in the outbound section.Cevap
  4. D
    The configuration fails because the duration attribute must reference a Key Vault secret via an access policy rather than using a hardcoded integer.

Cevap

The cache-store policy is located in the inbound section, but it must be placed in the outbound section.
The correct answer states that the cache-store policy is located in the inbound section, but it must be placed in the outbound section. Azure API Management policies execute in specific stages of the message lifecycle. The cache-lookup policy must be in the inbound section to intercept incoming requests and return a cached response if available. Conversely, the cache-store policy must be in the outbound section because it reads the HTTP response headers and body returned by the backend service to write them to the cache for future requests.

Adım Adım Çözüm

1
Analyze the placement of the caching policies in the XML configuration.
Both cache-lookup and cache-store are placed inside the inbound policy section.
Correct placement of policies is required for valid schema parsing and execution flow.
2
Determine the execution flow of caching in Azure API Management.
Looking up cached responses must occur before forwarding to the backend (inbound). Storing the backend response must occur after the backend returns a response (outbound).
Since the backend response only exists after the backend scope executes, storing that response must happen in the outbound pipeline.
3
Identify the misplaced policy element causing the schema validation error.
The cache-store policy is in the inbound section, which violates the Azure API Management policy schema definitions.
Fixing the placement by moving cache-store to the outbound section resolves the schema validation error.

Anahtar Kavram

Azure API Management response caching policies must be placed in their correct execution sections: cache-lookup in inbound, and cache-store in outbound.
Bu soruyu puanla