public static async Task SaveDocument([ActivityTrigger] DocDBRecord item, ILogger log)
        {
            using (DocumentClient client = new DocumentClient(ConnectionString.ServiceEndpoint, ConnectionString.AuthKey))
            {
                Uri collectionUri = UriFactory.CreateDocumentCollectionUri(DatabaseId, CollectionId);

                await client.CreateDocumentAsync(collectionUri, item);

                log.LogInformation("Create record with id {ItemId} for run {RunId}", item.Id, item.RunId);
            }
        }
 public static async Task QueueProcessor([QueueTrigger("%QueueName%", Connection = "StorageConnectionString")]
                                         QueueWorkItem myQueueItem, [CosmosDB(
                                                                         databaseName: "%CosmosDBDatabase%",
                                                                         collectionName: "%CosmosDBCollection%",
                                                                         ConnectionStringSetting = "CosmosDBConnectionString",
                                                                         Id = "{Id}", PartitionKey = "{Partitionkey}")] DocDBRecord document,
                                         [Table("%ProcessingResultsTable%", Connection = "StorageConnectionString")] IAsyncCollector <ProcessingResult> tableOutput,
                                         ILogger log)
 {
     await DocumentProcessor.ProcessDocument(document, tableOutput, log, nameof(QueueProcessor));
 }
        public static async Task RunOrchestrator(
            [OrchestrationTrigger] DurableOrchestrationContext context)
        {
            LoadGeneratorOptions options = context.GetInput <LoadGeneratorOptions>();

            int runCount = options.RunCount;

            for (int runNumber = 0; runNumber < runCount; runNumber++)
            {
                Task[] taskList = new Task[options.ItemsPerRunCount];
                for (int runItemNumber = 0; runItemNumber < options.ItemsPerRunCount; runItemNumber++)
                {
                    DocDBRecord docDbRecord = DocDBRecord.Create(runNumber, runItemNumber, options.RunId, context.CurrentUtcDateTime.ToShortTimeString());
                    taskList[runItemNumber] = context.CallActivityAsync(SaveDocumentFunctionName, docDbRecord);
                }

                await Task.WhenAll(taskList);

                await context.CreateTimer(context.CurrentUtcDateTime.AddSeconds(options.SleepTimeInSeconds),
                                          CancellationToken.None);
            }
        }