问题描述
Azure Function在执行Function的时候,如果失败了,是否可以重试呢?
问题解答
Function app默认是不开启重试的,但是可以修改 host.json 文件来定义重试策略(retry),具体内容如下:
{
"retry": {
"strategy": "fixedDelay", //使用的重试策略
"maxRetryCount": 2, //最大重试次数
"delayInterval": "00:00:03" //在重试之间的延迟
}
}
参考资料
Azure Functions 2.x 及更高版本的 host.json 参考: https://docs.azure.cn/zh-cn/azure-functions/functions-host-json#retry
Azure Functions 错误处理和重试: https://docs.azure.cn/zh-cn/azure-functions/functions-bindings-error-pages?tabs=csharp#retry-policies-preview