Perform the following steps:
- Create a new function named GenerateBARCode using the Durable Functions Orchestrator template. Replace the default code with the following, and click on the Save button to save the changes. The following code initially class the GetAllCustomers activity function, stores all the customer Ids in an array and then for each customer, it again calls another activity function that returns the number of Bar Codes that are generated. Finally, it waits till the Activity functions for all the customers gets completed an then returns the sum of all the Bar Codes that are generated for all the customers.
#r "Microsoft.Azure.WebJobs.Extensions.DurableTask"
public static async Task<int> Run(
DurableOrchestrationContext context)
{
int[] customers = await
context.CallActivityAsync<int[]>("GetAllCustomers",null);
var tasks = new Task<int>[customers.Length];
for (int nCustomerIndex = 0; nCustomerIndex < customers.Length; nCustomerIndex++)
{
tasks[nCustomerIndex] = context.CallActivityAsync<int>
("CreateBARCodeImagesPerCustomer", customers[nCustomerIndex]);
}
await Task.WhenAll(tasks);
int nTotalItems = tasks.Sum(item => item.Result);
return nTotalItems;
}
- In the Advanced editor of the Integrate tab, replace the default code with the following code:
{
"bindings": [
{
"name": "context",
"type": "orchestrationTrigger",
"direction": "in"
}
]
}