简体   繁体   English

您能否对存储队列的 Azure Function 或 output 进行速率限制?

[英]Can you rate limit an Azure Function or output of a Storage Queue?

I have a Storage Queue triggered Python Azure Function that submits a job to a third-party rate-limited API (1 request/minute). I have a Storage Queue triggered Python Azure Function that submits a job to a third-party rate-limited API (1 request/minute). The queue that triggers the function will periodically receive a burst of messages, so I need a way to ensure that the function will be triggered immediately upon receiving the first message, 1 minute later on the second message, 2 minutes later on the third message, etc. until the queue is empty.触发 function 的队列会周期性地接收突发消息,所以我需要一种方法来确保 function 在收到第一条消息后立即触发,第二条消息在 1 分钟后触发,第三条消息在 2 分钟后触发,等等,直到队列为空。

Is it possible to either rate-limit the queue or the function so I am only running the function once a minute until the queue is empty?是否可以对队列或 function 进行速率限制,所以我每分钟只运行一次 function 直到队列为空?

There's no way to rate-limit a storage queue (other than the queue naturally being rate-limited by the storage transaction rate limits, which are several orders of magnitude greater than your currently-desired rate-limit).没有办法对存储队列进行速率限制(除了队列自然受到存储事务速率限制的速率限制,这比您当前所需的速率限制大几个数量级)。

Rather than trigger your Azure function off of queue message arrival, you can set up a timer trigger for your Azure function. Rather than trigger your Azure function off of queue message arrival, you can set up a timer trigger for your Azure function. This will allow you to set up, say, a 1-minute interval on the timer, where your function can read a message and call the 3rd-party API.这将允许您在计时器上设置 1 分钟的间隔,您的 function 可以读取消息并调用第 3 方 API。

You'll need to specify a timer value, which is an NCRONTAB expression, with the following format:您需要指定一个计时器值,它是一个 NCRONTAB 表达式,格式如下:

{second} {minute} {hour} {day} {month} {day-of-week}

An every-1-minute expression will look like:每 1 分钟一次的表达式如下所示:

"0 */1 * * * *"

More info on timer triggers here .有关计时器触发器的更多信息,请点击此处

Take a look at the NextVisibleTime property:看一下NextVisibleTime属性:

CloudQueueMessage.NextVisibleTime CloudQueueMessage.NextVisibleTime

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Python 中的 Azure 函数输出绑定的上下文中设置队列存储消息 TTL? - How can I set Queue Storage message TTL in the context of an Azure Function output binding in Python? 如何安排或排队api调用以维持速率限制? - How can I schedule or queue api calls to maintain rate limit? 禁止打印来自 Azure 队列存储的响应 - Suppress printing of response from Azure Queue Storage Python + Azure 存储队列receive_messages() - Python + Azure Storage Queue receive_messages() Azure function 和 Azure Blob 存储 - Azure function and Azure Blob Storage 在 azure blob 存储中设置文件上传限制 - Set file upload limit in azure blob storage 如何修复 Azure Function (Python) 测试错误与 Http 触发器和队列消息 Z29C2C44725E - How To Fix Error For Test of Azure Function (Python) With Http Trigger and Queue Message Output toomanyrequests:您已达到拉取率限制。 您可以通过身份验证和升级来增加限制 - toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading Azure blob 存储 function 使用 Python - 设置多个 Z78E6221F6393D1356DZ668 - Azure blob storage function using Python - Setting multiple output bindings is not working 如何将 Azure Blob 存储中的 CSV 处理为 ZA7F5F352326B9278411736 中的 stream - How can you process a CSV from Azure Blob Storage as a stream in Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM