[英]Azure API Management Rate Limit By Json Body
您好,我正在尝试对 azure api 管理的 json 身体值应用速率限制我有这样的规则
<rate-limit-by-key calls="6" renewal-period="180" counter-key="@(context.Request.Body.As<JObject>()["phoneNumber"].ToString())" increment-condition="@(context.Response.StatusCode >= 200 && context.Response.StatusCode < 300)" />
但速率限制不起作用。
我的测试成功了。
请求正文:
{
"phoneNumber": "+1234"
}
政策:
<inbound>
<base />
<rate-limit-by-key calls="6" renewal-period="180" counter-key="@(context.Request.Body.As<JObject>()["phoneNumber"].ToString())" increment-condition="@(context.Response.StatusCode >= 200 && context.Response.StatusCode < 300)" />
<return-response>
<set-status code="200" reason="OK" />
<set-body />
</return-response>
</inbound>
return-response仅用于测试。
几次尝试后的响应体:
{
"statusCode": 429,
"message": "Rate limit is exceeded. Try again in 174 seconds."
}
这与您的实施有何不同?
你有不同的请求正文吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.