This unit provides a reference for the following API Management policies:
- Control flow – Conditionally applies policy statements based on the results of the evaluation of Boolean expressions.
- Forward request – Forwards the request to the backend service.
- Limit concurrency – Prevents enclosed policies from executing by more than the specified number of requests at a time.
- Log to Event Hubs – Sends messages in the specified format to an event hub defined by a Logger entity.
- Mock response – Aborts pipeline execution and returns a mocked response directly to the caller.
- Retry – Retries execution of the enclosed policy statements, if and until the condition is met. Execution repeats at the specified time intervals and up to the specified retry count.
Control flow
The choose policy applies enclosed policy statements based on the outcome of evaluation of boolean expressions, similar to an if-then-else or a switch construct in a programming language.
XMLCopy
<choose>
<when condition="Boolean expression | Boolean constant">
<!— one or more policy statements to be applied if the above condition is true -->
</when>
<when condition="Boolean expression | Boolean constant">
<!— one or more policy statements to be applied if the above condition is true -->
</when>
<otherwise>
<!— one or more policy statements to be applied if none of the above conditions are true -->
</otherwise>
</choose>
The control flow policy must contain at least one <when/> element. The <otherwise/> element is optional. Conditions in <when/> elements are evaluated in order of their appearance within the policy. Policy statements enclosed within the first <when/> element are applied when the condition attribute is true. Policies enclosed within the <otherwise/> element, if present, are applied if all of the <when/> element condition attributes are false.
Leave a Reply