英文:
Azure function retry policies for multiple output bindings?
问题
-
在 Azure 函数中,是否已经内置了重试策略?如果写入失败,会尝试重新写入吗?还是只要成功写入其中一个就算成功?
-
对于 EventHub 和 EventGrid,是否需要编写自定义的重试代码,还是可以使用扩展功能?我相信有一个适用于 EventHub 的扩展,但我找不到适用于 EventGrid 的扩展。
英文:
I have an azure function which I want it to write to both an EventHub and EventGrid, and have some questions on the retry policies.
-
are there built in retry policies already in place? If one fails, does it try to write to it again? Or does it count as successful if only one of them has been written to?
-
Do I need to have custom retry code for eventhub and eventgrid, or are there extensions I can use for both? I believe there is one for EH, but could not find one for EG.
答案1
得分: 1
Event Hub:
事件中心(Event Hub):
Retry policies is available for EventHub Triggered functions which are applicable in function level.
EventHub 触发的函数支持重试策略,适用于函数级别。
Check the below table to know about which triggers support retries and where its behavior is configured.
查看下表以了解哪些触发器支持重试以及其行为配置在哪里。
- When the Event Hubs-triggered function fails and raises an exception, the retry policies will be assessed.
- 当事件中心触发的函数失败并引发异常时,将对重试策略进行评估。
- Then the policy assists the function runtime to re-run the failed execution until either it reaches the maximum number of retries or function executes successfully.
- 然后策略协助函数运行时重新运行失败的执行,直到达到最大重试次数或函数成功执行。
- In few rare situations, an execution will be re-tried more than the requested maximum number of retries.
- 在极少数情况下,执行可能会超过所请求的最大重试次数。
The current retry count will be stored in memory of the instance. The maximum retry count is a best effort, and When there is failure in Event Hubs, retry count re-set to zero, the trigger will be able to resume processing and retry the batch on a new instance.
当前的重试计数将存储在实例的内存中。最大重试计数是最大努力,当事件中心发生故障时,重试计数将重置为零,触发器将能够恢复处理并在新实例上重试批处理。
You can configure the maximum number of times to let the function tries to execute before it fails using:
您可以使用以下方式配置函数在失败之前尝试执行的最大次数:
[FixedDelayRetry(5, "00:00:10")]
.
- To use this, you need to install nuget package
Microsoft.Azure.WebJobs
. - 要使用此功能,您需要安装 NuGet 包
Microsoft.Azure.WebJobs
。
Reference:
Retry Policies for Event Hub Triggers
Event Grid:
事件网格(Event Grid):
- There is no built-in retry policy for Event Grid however, it provides durable delivery.
- 事件网格没有内置的重试策略,但它提供了持久的传递。
- If there is any failure in event grid subscription, It retries delivery based on a fixed retry schedule and retry policy.
- 如果事件网格订阅发生任何故障,它会根据固定的重试计划和重试策略进行重试传递。
- Event Grid by default delivers one event at a time to the subscriber, it tries to deliver the message at least once for each identical subscription immediately.
- 事件网格默认每次向订阅者传递一个事件,它会立即尝试为每个相同的订阅至少传递一次消息。
Retry Policies for Event Grid:
事件网格的重试策略:
- You can customize the retry policy when creating an event subscription by using the
Maximum number of attempts
andEvent time-to-live (TTL)
configurations. - 您可以通过使用“最大尝试次数”和“事件生存时间(TTL)”配置来在创建事件订阅时自定义重试策略。
- Maximum number of attempts: It's value must be between 1 and 30, default value is 30.
- 最大尝试次数:它的值必须介于 1 和 30 之间,默认值为 30。
- TTL: It's value must between 1 and 1440, default value is 1440 minutes.
- TTL:其值必须介于 1 和 1440 之间,默认值为 1440 分钟。默认情况下,事件网格会尝试 1440 分钟(1 天)或 30 次。
By default, Event Grid tries for 1440 minutes(1 day), or 30 times.
默认情况下,事件网格会尝试 1440 分钟(1 天)或 30 次。
-
If you set both Event time-to-live (TTL) and Maximum number of attempts in Event Grid, the event delivery will be dropped when it reaches any of the limits of the policy.
-
如果在事件网格中同时设置了事件生存时间(TTL)和最大尝试次数,当事件达到策略的任何限制时,事件传递将被丢弃。
-
You can set these values during creation of Event Grid subscription to let Event Grid try to deliver the event.
-
您可以在创建事件网格订阅时设置这些值,以让事件网格尝试传递事件。
As per my research, there seems to be no extension available for Event Grid as we have for Event Hub.
根据我的研究,似乎没有像事件中心那样的事件网格扩展可用。
References:
Azure Event Grid delivery and retry - Azure Event Grid
Dead letter and retry policies - Azure Event Grid
英文:
Event Hub:
Retry policies is available for EventHub Triggered functions which are applicable in function level.
Check the below table to know about which triggers support retries and where its behavior is configured.
- When the Event Hubs-triggered function fails and raises an exception, the retry policies will be assessed.
- Then the policy assists the function runtime to re-run the failed execution until either it reaches the maximum number of retries or function executes successfully.
- In few rare situations, an execution will be re-tried more than the requested maximum number of retries.
>The current retry count will be stored in memory of the instance. The maximum retry count is a best effort, and When there is failure in Event Hubs, retry count re-set to zero, the trigger will be able to resume processing and retry the batch on a new instance.
You can configure the maximum number of times to let the function tries to execute before it fails using:
[FixedDelayRetry(5, "00:00:10")]
.
- To use this, you need to install nuget package
Microsoft.Azure.WebJobs
.
Reference:
Retry Policies for Event Hub Triggers
Event Grid:
- There is no built-in retry policy for Event Grid however, it provides durable delivery.
- If there is any failure in event grid subscription, It retries delivery based on a fixed retry schedule and retry policy.
- Event Grid by default delivers one event at a time to the subscriber, it tries to deliver the message at least once for each identical subscription immediately.
Retry Policies for Event Grid:
- You can customize the retry policy when creating an event subscription by using the
Maximum number of attempts
andEvent time-to-live (TTL)
configurations.
- Maximum number of attempts: It's value must be between 1 and 30, default value is 30.
- TTL: It's value must between 1 and 1440, default value is 1440 minutes.
By default, Event Grid tries for 1440 minutes(1 day), or 30 times.
-
If you set both Event time-to-live (TTL) and Maximum number of attempts in Event Grid,the event delivery will be dropped when it reaches any of the limits of the policy.
-
You can set these values during creation of Event Grid subscription to let Event Grid try to deliver the event.
As per my research, there seems to be no extension available for Event Grid as we have for Event Hub.
References:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论