How to do it...

Perform the following steps:

  1. Create a new activity trigger named ImportData_AT, which takes employee collection as input and saves the data in the collection. Paste the following code into the new activity trigger:
[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", "EmployeeCollection"), employee);
log.LogInformation($"Successfully inserted {employee.Name}.");
}
return $"Data has been imported to Cosmos DB Collection Successfully!";
}
  1. Let's add the following line to the Orchestration function that invokes the ImportData_AT activity trigger:
await context.CallActivityAsync<string>("ImportData_AT", employees);
  1. Let's run the application and upload an Excel file to test the functionality. If everything went well, you should see all the records created in the Cosmos DB collection, as shown here: