public async Task <IActionResult> Run(
            [HttpTrigger("GET", Route = "generate/neoevents/{numberOfEvents}")] HttpRequestMessage request,
            [ServiceBus("neo-events", Connection = "GeneratorConnection")] IAsyncCollector <DetectedNeoEvent> collector,
            int numberOfEvents)
        {
            var generatedEvents = NeoEventGenerator.Generate(numberOfEvents);

            var addToCollectorTasks = generatedEvents.Select(neo => collector.AddAsync(neo));

            await Task.WhenAll(addToCollectorTasks);

            return(new JsonResult(generatedEvents));
        }
        public async Task Run(
            [TimerTrigger("*/15 * * * * *")] TimerInfo myTimer,
            [ServiceBus("neo-events", Connection = "GeneratorConnection")] IAsyncCollector <DetectedNeoEvent> collector,
            ILogger log)
        {
            var maxNrOfEventsToGenerate = Convert.ToInt32(Environment.GetEnvironmentVariable("MaxNumberOfEventsToGenerate"));

            var nrOfEventsToGenerate = new Random().Next(1, maxNrOfEventsToGenerate);

            var addToCollectorTasks = NeoEventGenerator.Generate(nrOfEventsToGenerate)
                                      .Select(neo => collector.AddAsync(neo));

            await Task.WhenAll(addToCollectorTasks);
        }