You are configuring an inbound policy for an Azure API Management (APIM) instance. You need to route incoming API requests to a specific regional backend API based on the value of a custom header named `X-Region`. If the header value is `EU`, the request must be routed to `https://eu-backend.contoso.com/api`. Otherwise, the request must use the default backend. What are the correct API Management policy element names required to complete the XML configuration below?
Answer:xml
<inbound>
<base />
<choose>
<【when】 condition="@(context.Request.Headers.GetValueOrDefault("X-Region") == "EU")">
<【set-backend-service】 base-url="https://eu-backend.contoso.com/api" />
</【when】>
</choose>
</inbound>
<inbound>
<base />
<choose>
<【when】 condition="@(context.Request.Headers.GetValueOrDefault("X-Region") == "EU")">
<【set-backend-service】 base-url="https://eu-backend.contoso.com/api" />
</【when】>
</choose>
</inbound>
Answer
The correct policy elements are 'when' to evaluate the conditional routing expression and 'set-backend-service' to redirect the backend API base URL.
The correct elements are 'when' and 'set-backend-service'. The `<when>` element defines a conditional branch inside the `<choose>` parent element. The `<set-backend-service>` element alters the destination endpoint for the incoming API request during the inbound processing pipeline.
Step-by-Step Solution
Key Concept
Configuring conditional routing policies in Azure API Management using the choose-when policy structure and the set-backend-service policy element.
Estimated Time:1m 30s