public static async Task RunAsync(
            [CosmosDBTrigger(
                 databaseName: databaseId,
                 collectionName: eventsCollectionId,
                 ConnectionStringSetting = "CosmosDBConnectionString",
                 CreateLeaseCollectionIfNotExists = true)
            ] IReadOnlyList <Document> input,
            [CosmosDB(
                 databaseName: databaseId,
                 collectionName: viewCollectionId,
                 ConnectionStringSetting = "CosmosDBConnectionString"
                 )] DocumentClient client,
            ILogger log)
        {
            if (input != null && input.Count > 0)
            {
                await CreateViewCollectionIfNotExistsAsync(client);

                var processor = new ViewProcessor(client, databaseId, viewCollectionId, log);

                log.LogInformation($"Processing {input.Count} events");

                foreach (var p in input)
                {
                    var @event = DeviceEvent.FromDocument(p);

                    if (@event != null)
                    {
                        var tasks = new List <Task>();

                        tasks.Add(processor.UpdateViewAsync(@event));

                        // Update other views....

                        await Task.WhenAll(tasks);
                    }
                }
            }
        }