gpt4 book ai didi

c# - 如何避免在执行 C# Azure Function 期间出现 SqlClient 超时错误?

转载 作者:太空狗 更新时间:2023-10-30 01:13:33 24 4
gpt4 key购买 nike

我用 C# 创建了一个函数应用程序时间触发器。在逻辑内部,我调用并执行在 SQL Server 中创建的存储过程。

存储过程的执行时间超过 8 分钟,并且我在 Azure 函数应用日志中收到以下错误:

2018-04-02T11:03:46.409 [Error] Exception while executing function: Functions.AbarIomWeeklyUsage. mscorlib: Exception has been thrown by the target of an invocation. .Net SqlClient Data Provider: Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. The wait operation timed out. 2018-04-02T11:03:46.425 [Error] Function completed (Failure, Id=1b85e7ef-ea52-4fd3-ab79-f27d188c5cac, Duration=30323ms)

到目前为止我尝试了两件事:1.利用应用程序连接字符串中的连接超时2.在host.json

中添加超时

但它仍然给我同样的错误 30 秒超时。

有人有同样的经历或有解决方案吗?

最佳答案

您肯定超过了默认命令超时(默认为 30 秒)。如果不设置SqlCommand.CommandTimeout你会得到一个SqlException。在代码中将命令的 CommandTimeout(没有对此进行配置)设置为 10 分钟(600 秒),与函数超时相同。

关于c# - 如何避免在执行 C# Azure Function 期间出现 SqlClient 超时错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49610670/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com