public async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log, ExecutionContext ec) { log.LogInformation($"{ec.FunctionName} (http trigger) function executed at: {DateTime.UtcNow}"); int numSimulations; var worker = new UIControllerWorker(_zodiacContext); try { if (Int32.TryParse(req.Query["NumberOfSimulations"], out int numRequests)) { numSimulations = await worker.Run(log, ec.FunctionName, numRequests); } else { numSimulations = await worker.Run(log, ec.FunctionName); } } catch (Exception e) { log.LogError($"Exeception during execution of {ec.FunctionName}. Message: {e.Message}. Check Inner Exception", e); return(new StatusCodeResult(500)); } var responseMessage = $"{ec.FunctionName} performed {numSimulations} simulations"; return(new OkObjectResult(responseMessage)); }
public async Task Run([TimerTrigger("0 * * * * *")] TimerInfo myTimer, ILogger log, ExecutionContext ec) { int numSimulations = 0; try { log.LogInformation($"{ec.FunctionName} (timer trigger) function executed at: {DateTime.UtcNow}"); var worker = new UIControllerWorker(_zodiacContext); numSimulations = await worker.Run(log, ec.FunctionName); return; } catch (Exception e) { log.LogError($"Exeception during execution of {ec.FunctionName}. Message: {e.Message}. Check Inner Exception", e); throw e; } log.LogInformation($"{ec.FunctionName} ran {numSimulations} simulations"); }