Having a bit of a problem getting a stored procedure being executed from an Azure timer triggered function and am struggling to find out why.
I have a bunch of small stored procedures that do some row updates and inserts based on some logic which are executed using Azure timer triggered functions with no issues however one of them misbehaves.
The stored procedure is rather adaptive index defragmentation from here: (https://github.com/microsoft/tigertoolbox/tree/master/AdaptiveIndexDefrag)
It takes about a minute to run and it is scheduled to run during the night on a daily basis.
Here is the code to execute function responsible executing the above sproc:
public static class MyFunction {
[FunctionName("MyFunction")]
public static async Task Run([TimerTrigger("0 0 0 */1 * * ")] TimerInfo myTimer, ILogger log) {
await using var conn = new SqlConnection("connection string");
await using var command = new SqlCommand("do_the_thing", conn) {CommandType = CommandType.StoredProcedure};
try {
command.Connection.Open();
var result = await command.ExecuteScalarAsync();
log.LogInformation($"Query result: {result}");
}
catch (Exception ex_) {
log.LogError(ex_, "OH NO!");
}
log.LogInformation("Went smoothly");
}
}
The result value is -1, Azure monitor says query executed successfully, but looking at the logs and load sql server side, the stored procedure have not been run.
All other functions running smaller sprocs reuse the above code. I have made a test function with a test sproc using the exact code and it works fine, however executing index defrag one always fails but no error or exception is given. All looks fine, the only indicator that tells me that sproc failed to run is the duration timer of the Azure function responsible executing index defrag sproc, it is always too short, max I have seen is 2.5 sec when it should be over a minute.
Any help will be appreciated.
tbl_AdaptiveIndexDefrag_Analysis_logis there anything in there? What parameters are you calling it with? In other words: can you edit and post the full calling code? - Charlieface@debugMode=1parameter, and receiving the messages viaSqlConnection.InfoMessageevent? - Charlieface