Exemplo n.º 1
0
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", Route = null)] HttpRequest req,
            ILogger log, ExecutionContext ec)
        {
            log.LogInformation($"{ec.FunctionName} (http trigger) function executed at: {DateTime.UtcNow}");
            int requestsMade = 0;
            var worker       = new ZodiacGeneratorWorker(_zodiacContext);

            try
            {
                if (Int32.TryParse(req.Query["NumberOfCalls"], out int numRequests))
                {
                    requestsMade = await worker.Run(log, ec.FunctionName, numRequests);
                }
                else
                {
                    requestsMade = 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 OkObjectResult($"ZodiacGenerator generated {requestsMade} requests"));
        }
Exemplo n.º 2
0
        public async Task Run([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer, ILogger log, ExecutionContext ec)
        {
            try
            {
                log.LogInformation($"{ec.FunctionName} (timer trigger) function executed at: {DateTime.UtcNow}");
                var worker = new ZodiacGeneratorWorker(_zodiacContext);
                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;
            }
        }