CodexBloom - Programming Q&A Platform

Azure API Management Rate Limiting optimization guide as Expected with Multiple Products

πŸ‘€ Views: 82 πŸ’¬ Answers: 1 πŸ“… Created: 2025-07-24
azure-api-management rate-limiting api-gateway XML

I'm maintaining legacy code that I'm stuck on something that should probably be simple... I'm relatively new to this, so bear with me. I'm experiencing issues with rate limiting in Azure API Management (APIM). I have defined multiple products, each with their own rate limit policies, but it seems that the limits are not being enforced correctly when consumers are subscribed to multiple products. For example, I have two products: `ProductA` and `ProductB`. Each product has a separate rate limit of 100 requests per minute. However, when I make requests using a key that is subscribed to both products, I am able to make more than 100 requests per minute without receiving any rate limit errors. Here's how I have configured the policies for each product in the APIM Portal: ```xml <policies> <inbound> <rate-limit-by-key calls="100" renewal-period="60" increment-condition="(context.Request.Method == 'GET')" /> </inbound> <outbound> <base /> </outbound> </policies> ``` I have also tried configuring a global rate limit at the API level, but this did not help either. Additionally, I verified that the `rate-limit-by-key` policy is applied correctly by checking the logs, and the calls are indeed being counted per product. However, it seems they are not combining the limits correctly. I have checked the official documentation, but there’s no mention of this specific scenario. Is there a best practice to enforce rate limits across multiple products for the same consumer? Or could this be a limitation in how APIM handles rate limiting with multiple subscriptions? Any insights would be greatly appreciated! I'm working on a CLI tool that needs to handle this. This is part of a larger service I'm building. Has anyone dealt with something similar?