Skip to main content

Guidelines to understand durable functions with .Net Core, C# and Stateful Serverless

What are Durable Functions?

Durable Functions are an extension of Azure functions that allows writing stateful functions in a serverless compute environment. Create a reliable stateful workflow by enabling durable functions using Azure Functions. Create a workflow with serverless functions, managing errors, and running activities in a parallel way. The functions allow managing state, checkpoints, and restarts for you. Using this, you can have long-running functions and have stated that remember your workflow.

What is the supported language for Durable function?

  • JavaScript: It support version 2.x of Azure functions. It needs 1.7.0 for Durable function extension
  • C#: It comes with both precompiled class libraries and C# script
  • Python: It requires the 1.8.5 version for durable functions extension
  • F#: It has precompiled class libraries and supports F# only if it supports 1.x of Azure function.

Let’s take an example to understand better,

You have to manage a model which divides into different checkpoints. Each point is closer to one step as you move. Let’s say there’s a game where you want to load a bunch of various resources when everything is loaded and ready. It will look like a workflow that enables you to specify something along with the flow. We can observe different architect patterns with different flows, isn’t it?
If you think this must be expensive, then you’re wrong. The model of payment will work very closely with Azure function. You can pay for the function if only you use it. So sounds impressive, right? Let’s begin with the article as to how the durable functions work and its necessary explanation.
There are a few concepts that we need to consider before dealing with durable functions. Let’s take a run over those.
  • Orchestrator Function: We define the workflow and set up with what happened in it. What activities we need to carry out and what’s done in it.
  • Activity Function: To work with Orchestrator function, activity function is a basic unit to consider. The activity functions can have as many activities it needs to add. You can give descriptive names as per your choice and can represent the flow your way.
  • Client Functions: If you want to trigger functions, then client functions are the new instance of an Orchestrator. These functions are an entry point from which an instance is created and works on Durable Orchestrator functions.

 If this still confused you, let get into another form for better understanding…

Taking another example, say as order processing where order process with the following tasks:
  • Check the inventory
  • Charge the Customer
  • Creating a Shipment
.NET Core
Source: dev.to
Check the above image to see how the client functions and how the order created. Typically, it’s an HTTP endpoint where we hit from an application. The second thing we can do is start the function of an instance of orchestration by using instance id (a unique reference to specific flow). Later the next thing we carry out is by checking the inventory, charging the customer, and next creating a shipment.

How durable functions work with .Net core and stateful serverless?

To move on with technical functions, the first thing that comes is with Orchestration which usually is asynchronous, so we don’t have an idea when does it finish. So, to overcome this issue, we have to pay the running cost for its durable functions and save the state. Here when the orchestration functions work hard, the orchestrator wakes up and re-executes the entire function from start to local state rebuild up.
Don’t worry about re-running during replay as the code will call its function and consult the execution history of current orchestration. If the function has already executed, it replays that function, and the code continues to run. If this sounds better, then continue until the function code is finished and schedule new async work.

Few guidelines to understand how to learn the functions

The best way to learn is to build something simple. By using the VS code, we can install and make the process easy to go.

How to create a project?

Open the command palette and type COMMAND + SHIFT + P
Create a new project by choosing a language. If we select C# while creating a new project, then the list of choices are as follows:
  • DurableFunctionsOrchestration
  • HttpTrigger
  • BlobTrigger
  • IoTHubTrigger
  • QueueTrigger
  • ServiceBusQueueTrigger
  • ServiceBusTopicTrigger
  • TimerTrigger
Choose Durable Functions Orchestration. Next choose the storage account by selecting the Subscription, storage account, and Resource group. Also, you need to save the state of function somewhere for later recovery.
Note: The below codes taken techcommunity site

Check how your project will look alike:

.Net Core
Here in the program, there is a method named as FunctionName(“orchestration”) and parameter context as IDurableOrchestrationContext. The context calls callActivitivitySync() and names as Orchestration_Hello to pass the string.

Orchestration_Hello

Here, the below function is an activity function. The function can do a lot of things and take a database along with HTTP requests.
.Net Core

Debugging

Check the debugging flow and how to start up with a durable function from the VS code and its breakpoints.
Debugging
Until the orchestrator done thoroughly, the function will carry on its activity.

HttpStart Response

For HttpStart response, we have to end up producing the point as we have in URL, which follows like below:
HttpStart Response

This the code we constructed:

constructed

Wrap Up:

If you’re looking to use durable functions, then you can hire ASP.Net Core Development team to create a project. There is a lot more to learn about the durable functions, and we have covered most of them over here.
They are moving on with an announcement done by Microsoft that has bought significant technological trends where Pro ASP.Net Core MVC 2 is one of the tools that has evaluated to improve the productivity and development process. The technologies will be accessible to developers and can use in their current work. These Pro ASP.Net Core MVC 2 tools will work as low barriers to entry-level, and so you can consider it in your future projects. I hope this post was informative and easy to understand.

Comments

Popular posts from this blog

How Much Does It Cost To Hire An App Developer In 2019?

It is considered a very important question that how much it effectively costs for the purpose of hiring an app developer and that too in the year 2019. Nowadays, due to the rising trend, it is very important to hire iPhone developer. Also, it seems that each business, as well as every brand, has its own app in the year 2019. In that way, you can also hire iPhone app developer India. Even, there are many of the local coffee shops which possess an app for the purpose of ordering a frappuccino available at your doorstep or you can collect it on discounts. For developing these apps, sometimes it becomes very important to preferably hire iPhone programmer. There is a gradual presence of many of the IT entrepreneur who is usually making a fortune from a hit app. So, here are given some of the ever-actual issues of how to  hire iPhone app developer  for the development purpose. We will preferably talk about some of the important as well as general tips which can prove helpful to hire io

Engagement Models For Laravel Application Development

  In the mobile app, the development backend holds prime importance. It has a trusted and dependable technology that would take good care of your backend operations with ease. For this purpose, Laravel creator said, “we want to simplify the development process”. Today the Laravel 5.4 is the latest released version that enforces the same ideology with new features. Leverage the best Laravel application development service & create a well-tailored web app. Hire a Laravel development company to scale business growth. Laravel provides predefined architecture and customized backend logic to stand out differently from the crowd. Hire Laravel developers in India and choose the company that understands your needs. We are one of the best leading web application development companies in India. We offer a wide range of engagement models that suits our customer’s needs. Let’s dive into understanding the engagement models in a better way. What are engagement models? An engagement model is a

5 Features while Developing On-Demand ‘Mover n Packers’ App like Uber Movers

Peeping into a few years back, though there were mobiles trending, mobile apps were more limited towards messaging and gaming, but a year or two year back scenario depicts a different story in all. On-demand applications that can be for Food or say Cab Booking or for Salon or for the  Guard booking app  for the event, anything, and everything can be covered in the app itself. UBER is considered more of as a BRAND instead of just an app to book the cab. It has widespread its scope beyond the app in various fields across the globe. Along with the services of moving human from one destination to another, not just limiting to that, Uber is even into Movers and Packers, namely Uber Movers. According to the report, “UberMovers provides free and professional moving services for up to ½ an hour for students in Atlanta between 9 a.m. to 2 p.m. on Saturdays only”. Similar moving services, it provides in Nashville even. Eventually, it is spreading its wings further too. Are you the one prov