DEV Community

Sanjeevi Subramani
Sanjeevi Subramani

Posted on • Originally published at lkgforit.com on

Azure API Management Policy for operation filter at API level policy

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>

Enter fullscreen mode Exit fullscreen mode

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>

Enter fullscreen mode Exit fullscreen mode

Top comments (0)