如何定义 Azure 函数的重试次数和间隔? [英] How do I define retry count and interval for Azure function?

查看:51
本文介绍了如何定义 Azure 函数的重试次数和间隔?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 blob 触发的 Azure 函数.如果抛出异常,我想为要重试的函数定义重试策略(计数和间隔).有什么办法可以做到吗?

I have a blob triggered Azure function. I would like to define the retry policy (count and interval) for the function to be retried if it throws an exception. Is there a way I can do that ?

推荐答案

您可以通过 host.json 的 "queues" 配置部分中的 ma​​xDequeueCount 设置来控制最大重试次数(参见 这里).队列"配置影响 blob 函数的原因是因为在幕后控制队列用于将 blob 分派到您的函数.因此,您为队列"配置的设置也会影响 blob 触发功能.例如.默认重试次数为 5 - 如果 blob 处理失败次数超过此次数,则将其移至毒队列.

You can control the maximum number of retries via the maxDequeueCount setting in the "queues" config section of host.json (see here). The reason "queues" config affects blob functions is because behind the scenes a control queue is used for dispatching blobs to your functions. So the settings you configure for "queues" will affect the blob triggered functions as well. E.g. the default retry count is 5 - if a blob fails processing more than that, then it is moved to the poison queue.

您可以通过 visibilityTimeout 设置控制重试之间的时间.

You can control the time between retries via the visibilityTimeout setting.

请注意,这些设置适用于主机范围并适用于所有功能.您目前无法按功能控制这些.

Note that these settings are host wide and apply to all functions. You can't control these per function currently.

这篇关于如何定义 Azure 函数的重试次数和间隔?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆