public async Task FetchLearnerGenderAsync([TimerTrigger("%LearnerGenderTrigger%")] TimerInfo timer, ExecutionContext context, ILogger logger) { if (timer == null) { throw new ArgumentNullException(nameof(timer)); } var functionLogDetails = CommonHelper.CreateFunctionLogRequest(context.FunctionName); try { logger.LogInformation($"Function {context.FunctionName} started"); var stopwatch = Stopwatch.StartNew(); await _commonService.CreateFunctionLog(functionLogDetails); var response = await _learnerService.FetchLearnerGenderAsync(); var message = $"Function {context.FunctionName} completed processing.\n" + $"\tStatus: {(response.IsSuccess ? FunctionStatus.Processed.ToString() : FunctionStatus.Failed.ToString())}\n" + $"\tTotal learners to process: {response.TotalCount}\n" + $"\tLearners retrieved from lrs: {response.LrsCount}\n" + $"\tModified learners to process: {response.ModifiedCount}\n" + $"\tRows saved: {response.SavedCount}\n" + $"\tAdditional message: {response.Message}"; CommonHelper.UpdateFunctionLogRequest(functionLogDetails, response.IsSuccess ? FunctionStatus.Processed : FunctionStatus.Failed, message); await _commonService.UpdateFunctionLog(functionLogDetails); stopwatch.Stop(); logger.LogInformation($"Function {context.FunctionName} completed processing. Time taken: {stopwatch.ElapsedMilliseconds: #,###}ms"); } catch (Exception ex) { var errorMessage = $"Function {context.FunctionName} failed to process with the following exception = {ex}"; logger.LogError(errorMessage); CommonHelper.UpdateFunctionLogRequest(functionLogDetails, FunctionStatus.Failed, errorMessage); _ = (functionLogDetails.Id > 0) ? await _commonService.UpdateFunctionLog(functionLogDetails) : await _commonService.CreateFunctionLog(functionLogDetails); throw; } }