Author : MD TAREQ HASSAN | Updated : 2020/11/24

Policy in APIM

Important notes about policy

Policy configuration example

<policies>
    <inbound>
        <rate-limit calls="5" renewal-period="60" />
        <quota calls="100" renewal-period="604800" />
        <base />
    </inbound>
    <backend>
        <base />
    </backend>
    <outbound>
        <base />
    </outbound>
    <on-error>
        <base />
    </on-error>
</policies>

Policy expression

Syntax

Examples

<authentication-basic username="@(context.User.Id)">

<set-variable name="isIOS" value="@(context.Request.Headers["User-Agent"].Contains("iPad") || context.Request.Headers["User-Agent"].Contains("iPhone"))" />

Policy hierarchy

<policies>

    <inbound>
        ... ...
        <base />
    </inbound>

    ... ...
	
</policies>

Adding Policy to Product

Product level policy will be appliet to all APIs of that product

Adding Policy to Product Step 1

Adding Policy to Product Step 2

Adding Policy to Product Step 3

Adding policy to all APIs

Adding policy to all APIs Step 1

Adding policy to all APIs Step 2

Adding policy to all APIs Step 3

Add policy to an operation

Add policy to an operation Step 1

Add policy to an operation Step 2