【问题标题】:Is there a way of varying the value of the rate limit by subscription in Azure API Management有没有办法通过 Azure API 管理中的订阅来改变速率限制的值
【发布时间】:2020-05-07 14:34:27
【问题描述】:

在 Azure API 管理中,可以通过订阅和密钥来限制调用率: https://docs.microsoft.com/en-us/azure/api-management/api-management-access-restriction-policies#LimitCallRateByKey

我的问题 - 有没有办法通过订阅来改变通话限制和续订期限?比如订阅 A 每分钟可以调用 100 次,而订阅 B 每 10 秒可以调用 500 次?

我认为订阅变量可以解决这个问题,但我认为这是不可能的。有没有其他办法?

谢谢, 克里斯。

【问题讨论】:

    标签: azure azure-api-management rate-limiting


    【解决方案1】:

    如果我猜对了,这可能是一种解决方案:

    <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>...
    

    这样,我认为您可以通过特定订阅 ID 或名称来改变速率限制。

    【讨论】:

    • 啊,是的!这可以很好地工作。谢谢你,我会试一试,然后回来。
    猜你喜欢
    • 2021-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-09
    • 1970-01-01
    相关资源
    最近更新 更多