Perform the following steps:
- Create a new function named CreateBARCodeImagesPerCustomer using the Durable Functions Activity template. Replace the default code with the following, and then click on the Save button to save the changes.
#r "Microsoft.Azure.WebJobs.Extensions.DurableTask"
#r "Microsoft.WindowsAzure.Storage"
using Microsoft.WindowsAzure.Storage.Blob;
public static async Task<int> Run(DurableActivityContext
customerContext,ILogger log)
{
int ncustomerId = Convert.ToInt32
(customerContext.GetInput<string>());
Random objRandom = new Random(Guid.NewGuid().GetHashCode());
int nRandomValue = objRandom.Next(50000);
for(int nProcessIndex = 0;nProcessIndex<=nRandomValue;
nProcessIndex++)
{
log.LogInformation($" running for {nProcessIndex}");
}
return nRandomValue;
}
- In the Advanced editor of the Integrate tab, replace the default code with the following code:
{
"bindings": [
{
"name": "customerContext",
"type": "activityTrigger",
"direction": "in"
}
]
}
- Let's run the function using Postman. We will be stopping the App Service to simulate a restart of the VM where the function would be running, and to see how the Durable Function resumes from where it was paused.
- Make a POST request using Postman, as shown as follows:

- Once you click on the Send button, you will get a response with the status URL. Click on statusQueryGetURi to view the status of the function. Clicking on the statusQueryGetURi link will open it in a new tab within the Postman tool. Once the new tab is opened, click on the Send button to get the progress of the function.
- While the function is running, let's navigate to the function app's Overview blade and stop the service by clicking on the Stop button:

- The execution of the function will be stopped in the middle. Let's navigate to our storage account in Storage Explorer, and open the DurableFunctionsHubHistory table to see how much progress has been made:

- After some time—in my case, after just five minutes—go back to the Overview blade and start the function app service. You will notice that the Durable Function will resume from where it had stopped. We didn't write any code for this; it's an out-of-the-box feature. The following is the screenshot of the completed function:
