您可以对Azure功能或存储队列的输出进行评级吗? [英] Can you rate limit an Azure Function or output of a Storage Queue?
问题描述
我有一个由存储队列触发的Python Azure函数,该函数将作业提交给第三方限速API(每分钟1个请求).触发该函数的队列将定期接收一连串消息,因此,我需要一种方法来确保在接收到第一条消息后立即触发该功能,第二条消息后1分钟,第三条消息后2分钟,直到队列为空.
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.
是否可以对队列或函数进行速率限制,所以我每分钟只运行一次函数,直到队列为空?
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?
推荐答案
没有办法对存储队列进行速率限制(除了队列自然受到存储事务速率限制的速率限制外,该速率是几个数量级)大于当前所需的速率限制.
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).
您可以为Azure函数设置计时器触发器,而不是从队列消息到达时触发Azure函数.这样一来,您可以在计时器上设置1分钟的间隔,例如,您的函数可以在其中读取消息并调用第3方API.
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.
您需要使用以下格式指定一个计时器值,它是一个NCRONTAB表达式:
You'll need to specify a timer value, which is an NCRONTAB expression, with the following format:
{秒} {分钟} {小时} {天} {月} {星期几}
每隔1分钟的表情将如下所示:
An every-1-minute expression will look like:
"0 */1 * * * *"
有关计时器触发器的更多信息,此处.
More info on timer triggers here.
这篇关于您可以对Azure功能或存储队列的输出进行评级吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!