Bulk inserting data into Cosmos DB
Now that we have scaled up the collection, it's time to insert the data into the Cosmos DB collection. In this recipe, you will learn about one of the simplest ways of inserting data into Cosmos DB.
How to do it...
Perform the following steps:
- Create a new activity trigger named
ImportData_AT
, which takes an employee collection as input and saves the data in the Cosmos DB container. Paste the following code into the new activity trigger that does the job:[FunctionName("ImportData_AT")] public static async Task<string> ImportData_AT( [ActivityTrigger] List<Employee> employees, [CosmosDB(ConnectionStringSetting = "CosmosDBConnectionString")]DocumentClient client, ILogger log) { foreach (Employee employee in employees) { await client.CreateDocumentAsync(UriFactory. CreateDocumentCollectionUri("cookbookdb", "EmployeeContainer"), employee); log.LogInformation($"Successfully...