public async static Task <ResponseModel> InternalRun(JobModel model, IBackgroundJob job, ILogger logger, ExecutionContext context) { logger.LogInformation($"Run of Job {model.Job} for ID = '{model.Id}'."); ResponseModel response = new ResponseModel() { Id = model.Id }; try { var config = new ConfigurationBuilder() .SetBasePath(context.FunctionAppDirectory) .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true) .AddEnvironmentVariables() .Build(); StatusRelay relay = new StatusRelay(config); await relay.Initialize(); response = await job.Run(model, relay, logger, config); } catch (Exception ex) { logger.LogError(ex.Message, ex); logger.LogError(ex.StackTrace); response.Success = false; response.Message = ex.Message; } return(response); }