【发布时间】:2020-11-06 22:31:41
【问题描述】:
我想在我的天蓝色函数计时器触发器上执行存储过程。 功能部署成功。 但是,当函数运行时,我收到此错误堆栈跟踪消息
Microsoft.Azure.WebJobs.Host.FunctionInvocationException:
...
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw:
...
Inner exception System.ComponentModel.Win32Exception handled at System.Data.SqlClient.SqlConnection.OnError:
...
这是代码,
[FunctionName("DimensionFactTableUpdate")]
public static async Task Run([TimerTrigger("%CronJobSchedule%")]TimerInfo myTimer, TraceWriter log)
{
log.Info($"C# Timer trigger UpdateFactDimensionTable function executed at: {DateTime.Now}");
var _connectionString = Environment.GetEnvironmentVariable("DbConnectionString");
var _storedProcedureDimension = Environment.GetEnvironmentVariable("StoredProcedureDimension");
if (string.IsNullOrEmpty(_connectionString) || string.IsNullOrEmpty(_storedProcedureDimension))
return;
#region UPDATE DIMENSION TABLE
try
{
log.Info($"[START] Update dimension table at: {DateTime.Now}");
using (var connection = new SqlConnection(_connectionString))
{
connection.Open();
using (var command = new SqlCommand(_storedProcedureDimension, connection) { CommandType = System.Data.CommandType.StoredProcedure })
{
var status = await command.ExecuteNonQueryAsync();
}
}
log.Info($"[END] Update Dimension table at: {DateTime.Now}");
}
catch(Exception ex)
{
log.Error(ex.ToString());
}
#endregion
}
谢谢。
======
已编辑:
这是异常消息,
System.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
【问题讨论】:
-
你能包括完整的例外吗? (异常的 ToString。)而不是堆栈跟踪的部分
-
如果
connectionstring和storedprecuderdimension变量不为空或不为空,则可以验证它们。 -
@PrebenHuybrechts 这是异常消息 > System.Data.SqlClient.SqlException (0x80131904):执行超时。在操作完成之前超时时间已过或服务器没有响应。谢谢
标签: c# .net sql-server azure-functions