Soru

Zorluk: OrtaDefine API Management Policies

An enterprise application uses Azure API Management (APIM). You need to configure an inbound policy that evaluates the 'X-Client-Type' request header. If the header value is 'Internal', the request must route to an internal backend service. Otherwise, it should route to the default backend service. Which XML element names must be used to complete the conditional logic in the policy snippet?

Cevap:xml
<inbound>
<base />
<【choose】>
<【when】 condition="@(context.Request.Headers.GetValueOrDefault('X-Client-Type') == 'Internal')">
<set-backend-service base-url="https://internal-api.service.local" />
</【when】>
</【choose】>
</inbound>

Cevap

blank_1: choose, blank_2: when
The choose element evaluates nested when elements sequentially from top to bottom. The first when element with a condition that evaluates to true is applied. This conditional routing structure allows policies to dynamically change backend targets or execute specific operations based on headers.

Adım Adım Çözüm

1
Identify the policy structure needed for conditional execution.
The choose block is the correct control-flow policy in Azure API Management.
Azure API Management uses the <choose> element to act as a switch-case statement for evaluating conditions sequentially.
2
Determine the conditional branch element.
The <when> element represents a specific condition to evaluate.
Inside a <choose> element, one or more <when> elements must be defined to evaluate expressions and run nested policies if true.

Anahtar Kavram

Conditional policy execution in Azure API Management
Tahmini Süre:1m 30s
Bu soruyu puanla