Azure API Management Policy for operation filter at API level policy | Api management policy | Operation Filter at API level

{tocify} $title={Table of Contents}

If you want to apply policy at method level in Azure API Management, we can apply using Azure portal on selecting the method and editing the policy.

But if you want to use API level policy to apply only for some operations (methods) then we can achieve that with when condition.

<choose>
            <when condition="@(context.Operation.Name.Equals("myOperationName"))">

                -----Your policy here-------

            </when>
</choose>

The above policy is used at API level and I use the 'myOperationName' value with the operation for which i need to apply a policy.

We can also apply for multiple operations (methods) with OR condition like below:

<choose>
            <when condition="@(context.Operation.Name.Equals("myOperationName") || context.Operation.Name.Equals("myOperation2Name"))">

                -----Your policy here-------

            </when>
</choose>

Post a Comment

Previous Post Next Post

postad

post ad 2