Azure Durable Functions – Developing Serverless Stateful Workflow

Knowledge Sharing Azure Durable Functions at my workplace

Yesterday, I had an opportunity to share technical knowledge with my colleagues at Forefront Consulting during our monthly meeting in our division Technology. I was glad to share insi…


This content originally appeared on DEV Community and was authored by Jonah Andersson ??‍?SE

Knowledge Sharing Azure Durable Functions at my workplace

Yesterday, I had an opportunity to share technical knowledge with my colleagues at Forefront Consulting during our monthly meeting in our division Technology. I was glad to share insights and knowledge about the basics of one of my favorite Azure cloud services, Azure Durable Functions. Interesting questions came up that are worth checking out more.

What are Azure Durable Functions?

Well, if you have not worked with Azure development or is not familiar with Azure technologies, probably this article is jargon to you. It would be hard to understand right away what it is. However, if you are curious what it is and how it can help solve some of your application development problems, this cloud service (if you are working with Azure) is worth checking out!

I hope that this article will enlighten you and give you the basics of it. I personally like to share that this great Serverless technology exists!

What is Serverless?

Serverless Computing is starting to gain its popularity these days, especially in the world of cloud development.

Serverless computing (or serverless for short), is an execution model where the cloud provider (AWS, Azure, or Google Cloud) is responsible for executing a piece of code by dynamically allocating the resources. And only charging for the amount of resources used to run the code. The code is typically run inside stateless containers that can be triggered by a variety of events including http requests, database events, queuing services, monitoring alerts, file uploads, scheduled events (cron jobs), etc. The code that is sent to the cloud provider for execution is usually in the form of a function. Hence serverless is sometimes referred to as “Functions as a Service” or “FaaS”. Following are the FaaS offerings of the major cloud providers:
AWS: AWS Lambda
Microsoft Azure: Azure Functions
Google Cloud: Cloud Functions
While serverless abstracts the underlying infrastructure away from the developer, servers are still involved in executing our functions. (Source: Serverless-Stack.com)

So, Serverless is not really without servers. The infrastructure exists - there are servers. The only big difference is that cloud provider like Microsoft Azure takes care of it for you so that you can focus on solving and creating solutions through these cloud services like a Durable Functions.

Azure Durable Functions is an extension of Azure Functions

Azure Functions is a serverless solution that allows you to write less code, maintain less infrastructure, and save on costs. Instead of worrying about deploying and maintaining servers, the cloud infrastructure provides all the up-to-date resources needed to keep your applications running. You focus on the pieces of code that matter most to you, and Azure Functions handles the rest.

Azure Durable Functions on the other hand are built on top of Azure Functions. It is open-source. It does more than standard Azure Functions can do, especially when you have to develop a serverless long-running stateful workflow from the code along with the Azure Function in a serverless environment.

Major Benefits of Using Azure Durable Functions

  • Define and write workflows by code
  • Create long-running tasks
  • Have a need to work with multiple Azure Functions
  • If you need to create serverless stateful workflows that require human interaction, monitoring, and more
  • Need to make sure that the status of your workflow is consistent
  • Focus on developer productivity
  • Autoscaling capabilities
  • Pay only for what you use (Check out Azure Pricing Calculator)
  • Integration with other cloud services

Azure Durable Task Framework - The Technology Behind

Behind the scenes, the Durable Functions extension is built on top of the Durable Task Framework, an open-source library on GitHub that's used to build workflows in code.
Like Azure Functions is the serverless evolution of Azure WebJobs, Durable Functions is the serverless evolution of the Durable Task Framework. Microsoft and other organizations use the Durable Task Framework extensively to automate mission-critical processes. It's a natural fit for the serverless Azure Functions environment.

Major Components in Azure Durable Functions

Alt Text

Client functions are the entry point for creating an instance of a Durable Functions orchestration. They can run in response to an event from many sources, such as a new HTTP request arriving, a message being posted to a message queue, an event arriving in an event stream. You can write them in any of the supported languages.

Orchestrator functions describe how actions are executed. It is an important part of Durable Functions. The workflow of actions should be in the order in which they are to run. When you write the orchestration logic in code, it is important that these functions are deterministic.

One great thing about the orchestrator is that it sleeps!
When it sleeps you do not get charge for the service. Stateful workflows solve some problems that normal Azure Functions cannot have.

Learn more about Deterministic APIs

Activity functions are the basic units of work in a durable function orchestration. An activity function contains the actual work performed by the tasks being orchestrated.
Entity functions define operations for reading and updating small pieces of state, known as durable entities.

Alt Text

Entity Functions is a recent addition to Azure Durable Functions. Although these feature is only available in Durable Functions 2.0 and above. They are currently supported in .NET and JavaScript (as of this date this articles publication).

Entity functions define operations for reading and updating small pieces of state, known as durable entities. Like orchestrator functions, entity functions are functions with a special trigger type, the entity trigger. Unlike orchestrator functions, entity functions manage the state of an entity explicitly, rather than implicitly representing state via control flow. Entities provide a means for scaling out applications by distributing the work across many entities, each with a modestly sized state. Read more about Entity Functions.

Durable Functions Patterns

Durable Functions have different patterns that are worth checking out.

  • Function Chaining
  • Fan out/Fan in
  • Async HTTP APIs
  • Monitor
  • Human Interaction

Read more about it Azure Durable Functions Patterns

Best Practices of Developing Durable Functions (Orchestrator)

There are important things to consider when designing and creating your stateful workflows with Durable functions. As mentioned, orchestrator workflows must be deterministic.
Check out the DOs and DONTs when coding your workflow in your orchestrator function.

Alt Text

Further Reading and Learning Resources

If you like this article, please re-share the knowledge!
Feel free to leave feedback and ask questions.
Follow me [Twitter](https://twitter.com/cjkodare, connectvia my LinkedIn and visit my website


This content originally appeared on DEV Community and was authored by Jonah Andersson ??‍?SE


Print Share Comment Cite Upload Translate Updates
APA

Jonah Andersson ??‍?SE | Sciencx (2021-02-26T15:56:09+00:00) Azure Durable Functions – Developing Serverless Stateful Workflow. Retrieved from https://www.scien.cx/2021/02/26/azure-durable-functions-developing-serverless-stateful-workflow/

MLA
" » Azure Durable Functions – Developing Serverless Stateful Workflow." Jonah Andersson ??‍?SE | Sciencx - Friday February 26, 2021, https://www.scien.cx/2021/02/26/azure-durable-functions-developing-serverless-stateful-workflow/
HARVARD
Jonah Andersson ??‍?SE | Sciencx Friday February 26, 2021 » Azure Durable Functions – Developing Serverless Stateful Workflow., viewed ,<https://www.scien.cx/2021/02/26/azure-durable-functions-developing-serverless-stateful-workflow/>
VANCOUVER
Jonah Andersson ??‍?SE | Sciencx - » Azure Durable Functions – Developing Serverless Stateful Workflow. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/02/26/azure-durable-functions-developing-serverless-stateful-workflow/
CHICAGO
" » Azure Durable Functions – Developing Serverless Stateful Workflow." Jonah Andersson ??‍?SE | Sciencx - Accessed . https://www.scien.cx/2021/02/26/azure-durable-functions-developing-serverless-stateful-workflow/
IEEE
" » Azure Durable Functions – Developing Serverless Stateful Workflow." Jonah Andersson ??‍?SE | Sciencx [Online]. Available: https://www.scien.cx/2021/02/26/azure-durable-functions-developing-serverless-stateful-workflow/. [Accessed: ]
rf:citation
» Azure Durable Functions – Developing Serverless Stateful Workflow | Jonah Andersson ??‍?SE | Sciencx | https://www.scien.cx/2021/02/26/azure-durable-functions-developing-serverless-stateful-workflow/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.