Azure API Management Policy for operation filter at API level policy

Policy at method level using api level policy

Azure API Management Policy for operation filter at API level policy
Sanjeevi Subramani's photo
Sanjeevi Subramani

Published on Jun 7, 2021

1 min read

Subscribe to my newsletter and never miss my upcoming articles

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>

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>
 
Share this