HTTP 触发 Azure 函数在大约五分钟后停止发送到服务总线

问题描述 投票:0回答:1

我有一个 HTTP 触发 Azure Function 应用程序,其运行时版本为 ~4 和 Python 3.9。我的应用程序由 POST 请求触发,该请求指示如何处理输入数据以及处理多长时间(一次调用可能会运行数小时)。它处理流式 Azure 事件中心数据并将输出发送到 Azure 服务总线。

问题是,初始化服务总线客户端(异步)大约 5 分钟后,消息没有传输到服务总线,同时我没有收到任何错误/异常和警告!在运行应用程序的前 5 5 分钟内,一切都按预期运行,但之后,除了向服务总线发送消息之外,应用程序中的所有内容都正常运行。请注意,这发生在云上;当我在本地运行代码时,它工作正常,没有任何问题。我应该提到的是,Azure Function 资源没有网络和防火墙限制。

我检查了 Azure Function 上的文件系统日志,发现了此错误:

Encountered a System.Threading.Tasks.TaskCanceledException exception after 300001.013ms with message: The request was canceled due to the configured HttpClient.Timeout of 300 seconds elapsing

这是日志的顺序:

http://0.0.0.0:8181'./appsvctmp/volatile/logs/runtime/95819576165bdac59778b1cfad868566f03e09116048c0c4ad5d3516e6e96024.log
2024-09-24T09:14:42.276924535Z: [INFO]  Updated CA certificates
2024-09-24T09:14:44.077950242Z: [INFO]  warn: Microsoft.AspNetCore.Hosting.Diagnostics[15]
2024-09-24T09:14:44.077984542Z: [INFO]        Overriding HTTP_PORTS '8080' and HTTPS_PORTS ''. Binding to values defined by URLS instead 'http://0.0.0.0:8181'.
2024-09-24T10:44:06.466821919Z: [INFO]  fail: Middleware[0]
2024-09-24T10:44:06.492710253Z: [INFO]        Failed to forward request to http://169.254.132.4. Encountered a System.Threading.Tasks.TaskCanceledException exception after 300001.013ms with message: The request was canceled due to the configured HttpClient.Timeout of 300 seconds elapsing.. Check application logs to verify the application is properly handling HTTP traffic./appsvctmp/volatile/logs/runtime/4a6c3e8d7bd7e27e90a3050994cc782ccd484a5ab6b1a7d91dc1dd71ef66ceb3.log
2024-09-24T10:48:52.067841706Z: [INFO]  Updated CA certificates
2024-09-24T10:48:55.093252187Z: [INFO]  warn: Microsoft.AspNetCore.Hosting.Diagnostics[15]
2024-09-24T10:48:55.093292687Z: [INFO]        Overriding HTTP_PORTS '8080' and HTTPS_PORTS ''. Binding to values defined by URLS instead 'http://0.0.0.0:8181'.Ending Log Tail of existing logs ---Starting Live Log Stream ---

这里有什么问题以及如何解决它?

我知道函数应用 HTTP 响应存在硬性限制超时,但我没想到它会影响其他 HTTP 连接,例如服务总线连接。

azure azure-functions azure-functions-runtime
1个回答
0
投票

默认情况下,该函数的最长运行时间为 5 分钟。因此,一个函数不适合进行长达数小时的工作。最好使用网络作业或类似的东西进行后台工作。或者创建一个事件中心触发的函数,将消息转发到服务总线。

© www.soinside.com 2019 - 2024. All rights reserved.