Azure Python函数重试限制在逻辑应用程序中不起作用

2024-10-02 14:19:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试了两种方法来限制“失败”函数的重试次数,但都不起作用(如下所述)。我的发展面临挑战,因此任何和所有的帮助都将不胜感激

上下文:在将电子邮件附件保存到blob后,该功能被放置在一个由电子邮件触发的逻辑应用程序中。保存文件后,函数将成功执行,但逻辑应用程序在运行2-3分钟后返回“BadRequest.Http请求失败:服务器未在超时限制内响应”。然后,逻辑应用程序再重试该函数4次

方法1:我将retry放在host.json中:

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[1.*, 2.0.0)"
  },
  "retry": {
    "strategy": "fixedDelay",
    "maxRetryCount": 0,
    "delayInterval": "00:00:05"
  }
}

方法2:我将相同的代码片段放入function.json中:

{
  "scriptFile": "__init__.py",
  "bindings": [
    {
      "authLevel": "anonymous",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req",
      "methods": [
        "get",
        "post"
      ]
    },
    {
      "type": "http",
      "direction": "out",
      "name": "$return"
    }
  ],
  "retry": {
    "strategy": "fixedDelay",
    "maxRetryCount": 0,
    "delayInterval": "00:00:10"
}
}

Tags: 方法函数namejson应用程序version电子邮件type
1条回答
网友
1楼 · 发布于 2024-10-02 14:19:01

重试策略由azure logic app定义,您不应该在函数中配置它,而应该在azure logic app actions中配置重试策略。您可以参考Retry policies

For the most basic exception and error handling, you can use a retry policy in any action or trigger where supported, for example, see HTTP action. A retry policy specifies whether and how the action or trigger retries a request when the original request times out or fails, which is any request that results in a 408, 429, or 5xx response. If no other retry policy is used, the default policy is used.

如果要将重试次数配置为0,请执行以下步骤

您可以单击Http操作右上角的···,然后单击Settings,然后选择Retry Policy下的None

enter image description here

相关问题 更多 >