From the course: Scaling Applications with Microsoft Azure

Create Durable Functions - Azure Tutorial

From the course: Scaling Applications with Microsoft Azure

Start my 1-month free trial

Create Durable Functions

- [Instructor] So let's check how can we create durable functions. For the first step, let's create a new project in Visual Studio. I need to go on C#, Cloud, and then select your Azure functions. And let's give a proper name to this, so MyDurableFunction. And then just press OK. So now I need to select here, I have an option to select v1 or v2. So I'm going for V2. I will select here the empty template. And let's just press OK. So there we go, we have our project here and it's ready. Let's just right-click in the project, choose the option Add and then select the first option, which is New Azure Function. And in here, we should select an Azure function. Let's just give here also a proper name to this. I will just call it MainFunction. And I will just press Add. Now we need to select what kind of trigger do we want. In our case, and because we are working with durable functions, I'm just going for the Durable Function Orchestration. I always need the Orchestration one. So I will just press OK. So when we have this, the template already adds some code. Of course, you can edit the code, usually you're going to do this because you don't want this to be your function, for sure. But as a demo purpose, I'm just going to stick with this one here. And as you can see, here I'm using one of the patterns of the durable functions. And so I'm just saying on line 20 to execute the main function, line 21 and 22, the same thing, but with different input. Of course I could have more than one function. I just needed to create down here like I have here on line 29, I have the function called MainFunction_Hello. I could had more functions. And I will just need it on line 20, 21, and 22 to call those other functions. So let's just run our function as it is, and let's just see what is the output. So there we go, it starts to run our functions. And then in the end, we should see our HTTP endpoint. There we go. I'm just going here, copy my HTTP endpoint, I'm just going to fire up a browser, just to be able to do the HTTP endpoint request. And there we go, our function is running. It's running the three Hello's for the three CDs that I have, Tokyo, Seattle, and London. And as you can see in here highlighted, we still have to say Hello to London. Of course the other two CD's will be up in the console application.

Contents