Use Custom Variables in Policy Expressions

Q

How to use custom variables created by "set-variable" statements in policy expressions?

✍: FYIcenter.com

A

If you want to access custom variables created by "set-variable" statements, you can use the IReadOnlyDictionary object through "context.Variables".

For example, the following policy creates a custom variable during the inbound processing step and used it in the output processing step:

<inbound>
    <set-variable name="method" value="@(context.Request.Method)"/>
</inbound>
<outbound>
    <trace source="DEBUG">@(context.Variables["method"])</trace>
</outbound>

 

Using Azure API Policy

⇒⇒Microsoft Azure API Management Tutorials

2017-09-23, 119👍, 0💬