How to do it...

Perform the following steps:

  1. Create a new function by right-clicking on ExcelImport.DurableFunctions, click on Add, and then choose New Azure Function, as shown in the following screenshot:

  1. In the Add new Item popup, choose Azure Function, provide the name ExcelImport_Orchestrator, and click on Add, as shown in the following screenshot:

  1. In the New Azure Function popup, select the Durable Function Orchestration template and click on the OK button, which creates the following:
    • HttpStart: This is the Durable Function's starter function (an HTTP trigger), which works as a client that can invoke the Durable Orchestrator. However, in our project, we will not be using this HTTP Trigger; we will be using the logic inside it in our ExcelImportBlobTrigger Blob trigger to invoke the Durable Orchestrator.
    • RunOrchestrator: This is the actual durable Orchestrator that is capable of invoking and managing the activity functions.
    • SayHello: A simple activity function. We will create a few activity functions. Let's go ahead and remove this method:

  1. In the ExcelImportBlobTrigger Blob trigger, let's make the following code changes to invoke the Orchestrator:
    • Decorate the function to be async
    • Add the Orchestration client output bindings
    • Call StartNewAsync using the DurableOrchestrationClient
  2. The code in the ExcelImportBlobTrigger function should look like the following after making these changes:
using System.IO;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
namespace ExcelImport.DurableFunctions
{
public static class ExcelImportBlobTrigger
{
[FunctionName("ExcelImportBlobTrigger")]
public static async void Run(
[BlobTrigger("Excelimports/{name}", Connection = "StorageConnection")]Stream myBlob,
string name,
[OrchestrationClient]DurableOrchestrationClient starter,
ILogger log)
{
string instanceId = await starter.StartNewAsync("ExcelImport_Orchestrator", name);
log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
}
}
}
  1. Create a breakpoint in the ExcelImport_Orchestrator Orchestrator function and run the application by pressing F5.
  2. Let's now upload a new file (while ExcelImport.DurableFunctions is running) by running the ExcelImport.Client function. (You can also directly upload the Excel file from the Azure portal.) After the file is uploaded, in just a few moments the breakpoint in the ExcelImport_Orchestrator function should be hit, as shown in the following screenshot:

We have learned how to invoke the Durable Orchestration function from the Blob trigger.