I want to execute stored procedure on my azure function timer trigger. The function deployed successfully. But, when the function runs, I get this error stack trace messages
Microsoft.Azure.WebJobs.Host.FunctionInvocationException:
...
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw:
...
Inner exception System.ComponentModel.Win32Exception handled at System.Data.SqlClient.SqlConnection.OnError:
...
Here is the code,
[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
}
Thanks.
======
EDITED :
Here is the exception messages,
System.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.