In a world that seems to be highlighting the merits of no code and low code solutions, I see a few excellent reasons to orchestrate with code.
Given options such as Azure Logic Apps and Power Automate, why orchestrate with code? Well I recently had to make this decision on a project. As we were designing an architecture for a solution with a number of complex workflows, our initial thoughts went to Azure Logic Apps. And why not, it’s a good choice. It’s serverless, so you don’t need to worry about hosting, scaling or managing. Logic Apps handle this stuff for you for free. There are many other great reasons to use Logic Apps. For instance, it has an excellent designer with hundreds of connectors to help with orchestrations, so you can just focus on the business logic not the code.
On Microsoft’s site, they mentioned when you do need to write code, you can write snippets with Azure functions. It is in this advantage that got me to dig a little deeper. Sure, the ability to extend with code is an advantage, but then I am dealing with 2 technologies and moving away from the “focus on business logic and not code” advantage.
Another option is to build out the complex workflows with Durable Functions, instead of a Logic App. On November 5th, 2019 Microsoft announced general availability of Durable Functions version 2.0.
Now at face value, it is easy to think that this decision will naturally lead to a more complex hard to follow workflow, that will have you thinking more about the code than the business logic.
Not the case…
Durable Functions are an extension of Azure Functions that lets you write stateful functions in a serverless compute environment. Behind the scenes, the Durable Function extension manages state, checkpoints, and restarts for you, allowing you to focus on your business logic.
In fact, On Microsoft’s site they state the primary use case for Durable Functions is simplifying complex, stateful coordination requirements in serverless applications.
Version 2.0 of Durable Functions makes it even easier to simplify complex orchestrations, with updates such as:
- The ability to natively consume HTTP APIs (using the orchestration trigger binding).
- The Durable Entities function type provides the ability to build highly concurrent, stateful, serverless applications
- Other Durable Function Types include:
– Client Functions
– Orchestrator functions,
– Activity function
– And Entity functions
With the updates of version 2 in mind, I go back to the factors that led me to choose Durable Functions over Logic Apps for complex workflows. Its architecture. There is a righteousness in focusing on the business logic more than the code, but let’s not forget about the code or the architecture. If you did a google search on the benefits of Durable Functions (and I have) you will see lists that includes benefits, such as serverless and consumption-based pricing model, behind the scenes features to manage state, checkpoints, versioning, retries and cancels and the ability to run activities in parallel. You may even see more control or the ability to express your workflow in code. Suddenly more-code (not low-code) becomes the advantage, but why?
Well with Azure Functions it is easy to develop and test locally, this testability factor could certainly be thought of as a big advantage. However, I would say even more than that is design control and Architecture.
Sure, Logic Apps offer a wide variety in flow control, connectors, behaviors, and message handling features that allow you to focus on ways to optimize the business process. However, for complex orchestrations, the ability to implement well known design patterns is a huge advantage. Consider that in a low-code solution such as a Logic App, as the workflow complexity increases and the number of workflow branches increase, the business logic in the designer may get a bit unwieldy
So whereas I do see the ability to leverage tools that allow you to focus on the business logic, not the code, as a big advantage; when the business logic workflows grow or get to be complex and bloated, the ability to Simplify Architecture of complex workflows may make Durable Functions a great choice for your more complex workflows.