question

AzureDeveloper-6812 avatar image
0 Votes"
AzureDeveloper-6812 asked JayaC-MSFT answered

Rate Limit By Client

There is a product available in our API manager and use by multiple client applications in our organization.

We want to define a rate limit (quota limit) for the client, so that if the limit is exceeded, we will stop all incoming requests.

Example: We have a payment product and are consuming three customers (C1, C2, C3)

For C1 - No of Requests for sec -- 1000
For C2 - No of Requests for sec -- 5000
For C3 - No of Requests for sec -- 10000


is there any way to handle this validation in the product policy file based on the client-id?

Note: We have a single product for all the clients.

azure-api-management
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @AzureDeveloper-6812, Thank you for your question. We will review and update at the earliest.

0 Votes 0 ·

1 Answer

JayaC-MSFT avatar image
0 Votes"
JayaC-MSFT answered

Hello @AzureDeveloper-6812, you may consider separate subscriptions for the user groups / clients , e.g.

 rate-limit-by-key calls="10" renewal-period="15" counter-key="@(context.Subscription.Id)"

Otherwise you can achieve this by using any user-agent or userKey and send as a request parameter

e.g.

 rate-limit-by-key calls="10" renewal-period="15" counter-key="@(context.Request.Url.Query.GetValueOrDefault("userKey", ""))"

You may also check the context.Request.IpAddress if that helps.

https://docs.microsoft.com/en-us/azure/api-management/api-management-policy-expressions#ContextVariables

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.