The Durable Task Framework (DTF) is a workflow execution framework that is based on async/await and backed by Azure Service Bus. I was recently in need of a long running workflow engine and wanted to take advantage of all the async/await goodness. I looked at a bunch of options, including Windows Workflow Foundation, BizTalk, Logic Apps and WorkflowEngine.net. I haven’t gone too deep into DTF, but from the surface it looks like it is lightweight enough and pretty straight forward with minimal dependencies.
DTF is on GitHub here: https://github.com/Azure/durabletask
It has two main components: Orchestrations and Tasks. Orchestrations “orchestrate” your application logic and executes custom code inline and calls out to Tasks. Your custom orchestrations are derived from TaskOrchestration<TResult, TInput> and your custom tasks are derived from TaskActivity<TInput, TResult>
To use it as is today, you should either get a release of it here or if you want to build it locally, I recommend that you sync to my PR here, or just use my fork here, which updates all the NuGet packages to the latest versions and upgrades it to .NET 4.6.1.Once you clone the repo, open up the DurableTaskSamples.sln, build and run unit tests to make sure all is good. Make sure you restore NuGetpackages, right click solution name and click “Restore NuGet Packages”
Here’s a quick walkthrough on how to get it setup.
1. Go to the new Azure Portal and create a new Storage Account. Click New and then search for “storage account”.
Select “Resource Manager” deployment model
Give it a name, select pricing model, subscription, resource group and location.
Get the connection string from the Settings –> Access Keys blade
Copy that connection string to the “StorageConnectionString” appSetting in DurableTaskSamples/App.config
Grab the connectionstring for that service bus and paste it into “ServiceBusConnectionSTring” appSetting in DurableTaskSamples/App.config
You can also change the taskHubName appSetting if you want to.
Double click on DurableTaskSamples Properties and change the Debug->Start Options->Command line arguments to this: “-c –s Greetings”
Set a breakpoint in Program.cs, SendGreetingTaks.Execute and GetUserTask.Execute and hit F5.
Step through the code and you should see this:
Enter your name and continue to step through the code and you’ll see this.
As you can see, for this very simple orchestration “GreetingsOrchestration” there are two called tasks “GetUserTask”, which does the name prompt and “SendGreetingTask”, which writes the greeting to the console.
GreetingsOrchestration derives from TaskOrchestration<string, string> and has a RunTask method that calls GetUserTask and SendGreetingTask.
GetUserTask derives from TaskActivity<string, string> and implements the Execute method
SendGreetingTask derives from TaskActivity<string, string> and implements the Excute method
One other thing I noticed is that you can Schedule a task using its namespace like so:
That would basically allow you to create data driven workflows that are mapped to TaskActivitys via namespaces. Another thing to note in the above same is the use of “await Task.WhenAny”. This allows you to have conditional forks in your logic.
I’m still learning DTF myself, but so far is looks like a lightweight async task executor that might be a great alternative to Workflow Foundation.