0
votes

In Azure API Management it's possible to limit call rates by subscription and key: https://docs.microsoft.com/en-us/azure/api-management/api-management-access-restriction-policies#LimitCallRateByKey

My question - is there a way of varying the limit on calls and renewal period by subscription? So for example, subscription A can call an operation 100 times per minute but subscription B can call it 500 times per 10 seconds?

I think being able to have variables on subscriptions could solve this but I don't think that is possible. Is there any other way?

Thanks, Chris.

1

1 Answers

1
votes

If I get you right, this might be one solution:

<policies>
<inbound>
    <base />
    <choose>
        <when condition="@(context.Subscription.Id == "123")">
            <rate-limit-by-key calls="500" renewal-period="60" counter-key="@(context.Subscription.Id)" />
        </when>
        <when condition="@(context.Subscription.Name == "example-b")">
            <rate-limit-by-key calls="100" renewal-period="60" counter-key="@(context.Subscription.Id)" />
        </when>
        <otherwise>
            <rate-limit-by-key calls="10" renewal-period="60" counter-key="@(context.Subscription.Id)" />
        </otherwise>
    </choose>
</inbound>
<backend>
    <base />
</backend>...

This way, I think you can vary the rate limit by specific subscription id's or names.