Guidelines to Durable Functions with .Net Core, C#

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

Author image By Tejas Patel  |  Monday, July 27, 2020 06:10 PM  |  5 min read  |   229

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.

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

Contact us

 

 


Author image

Tejas Patel

Tejas Patel is a Co-Founder of Concetto Labs and he have 18+ years of technical experience in building high quality and scalable Web & Mobile Applications.

Why Our Client Love Us?

  • Fast kick-off
  • Agile Ready
  • 98% Client Retention
  • 360-Degree solutions

Our integrity and process focuses largely on providing every customer the best recommendations for their respective business. Our clients become recurring customers because we always go beyond their expectations to deliver the best solutions.

Get In Touch
Mr. Sieva Savko
Customer for over 4 years Mr. Sieva Savko Norway

Concetto Labs have provided us with a tremendous amount of help. Their competence in various IT fields led to a positive outcome while facing different challenges. A lot of value was given by their helpful professional staff. To describe this company in three words: effectiveness, collaboration, trust. I would also like to personally thank Mr. Tejas Patel for his positive, friendly, and highly competent approach. The all-around support provided by him made every task at hand a no-brainer.

Miss. Caroline Jack
Customer for over 4 years Miss. Caroline Jack South Africa

It has been an absolute pleasure working with the Concetto Labs team! We have worked together on a few projects now, all of which have been successful. You can rely on good communication and response times from these guys. And they go above and beyond to ensure that the result is achieved. Because of their great service, they have become an integral part of our business and we will continue to use them going forward.

Mr. Richard Bartlett
Customer for over 3 years Mr. Richard Bartlett United States

Concetto Labs is a group of incredibly talented individuals. They are very responsive and communicate with you each and every step of the process. I worked with Manish Patel throughout the entire process and must say that I have never conducted business with a more honest and professional individual. Together with his team, Manish created www.travcentiverewards.com exactly how we envisioned it to be. Thanks for all of your hard work.

Mr. Conrad Abraham
Customer for over 2 years Mr. Conrad Abraham United States

Concetto Labs team is my go-to for any simple or complex development projects. They have risen to the challenge. Great project management, communication, and super quick turnaround. I’ve done multiple projects with them and don’t plan on changing that.

Mr. Edward Chin
Customer for over 4 years Mr. Edward Chin Canada

Concetto Labs was able to bring my complex idea to life. Throughout the project, Concetto Labs maintained constant communications and was always professional - considering I had no experience in what I wanted to create their welcoming attitude, patience, and knowledge in the field created the perfect environment to work in. I was so impressed with their work that I've kept them on board as my go-to experts. Thanks for the worthwhile experience and the breathtaking product.

Karuna Govind
Karuna Govind CTO & Co Founder (Coupay) London, UK

We started working with Concettolabs due to the influx of work on mobile (Flutter) and frontend (React.js). It's been fantastic working with them. Good, consistent communication and good quality of work means they may be our first choice for many projects to come.

Arunabha Choudhury
Arunabha Choudhury Director (Fuzzann Technologies Private Limited) India

We are a healthcare IT company and wanted to build a Mobile Application for both Android and IOS using Flutter. The Concetto Lab team has been very patient with our project requirements and made sure all our queries are answered. It was a great show of professionalism and customer relationship. Even during the project, the team was very accommodating of all the changes we requested. The project was delivered successfully and we deployed the app in the Android Play Store. Overall, the entire process has been very transparent and the team was able to deliver exactly what we had envisioned the project outcome to look like.

GlobalClients
Good Firms Clutch App Futura Microsoft Associate Mobile App Top Developers Gesia
Close
Are you enjoying reading what you see?

Feel like discussing more about this with our Sales Experts? Click on Create Similar Button.