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>

 

'choose ... when ...' Statements to Control Execution Flows

'set-variable' Statement to Create Custom Variables

Using Azure API Policy

⇑⇑ Microsoft Azure API Management Tutorials

2018-01-24, 2636🔥, 0💬