Sisu.DurableTask.AspNetCore
0.0.5
dotnet add package Sisu.DurableTask.AspNetCore --version 0.0.5
NuGet\Install-Package Sisu.DurableTask.AspNetCore -Version 0.0.5
<PackageReference Include="Sisu.DurableTask.AspNetCore" Version="0.0.5" />
<PackageVersion Include="Sisu.DurableTask.AspNetCore" Version="0.0.5" />
<PackageReference Include="Sisu.DurableTask.AspNetCore" />
paket add Sisu.DurableTask.AspNetCore --version 0.0.5
#r "nuget: Sisu.DurableTask.AspNetCore, 0.0.5"
#:package Sisu.DurableTask.AspNetCore@0.0.5
#addin nuget:?package=Sisu.DurableTask.AspNetCore&version=0.0.5
#tool nuget:?package=Sisu.DurableTask.AspNetCore&version=0.0.5
Self-Hosted Durable Task Worker in Asp .Net Core
This project enables running DurableTask without a sidecar project, allowing the worker to be self-hosted. It provides a seamless way to integrate Durable Task functionality directly into your Asp .Net Core project.
Usage
To use this project effectively, you should already understand the concepts of the Microsoft Durable Task Framework and how to work with it. Microsoft provides comprehensive documentation that covers these topics in detail.
dotnet add package Sisu.DurableTask.AspNetCore
To respect the DurableTask domain and reserve it for official packages, I added a prefix to the project assembly. In Finnish culture, sisu represents determination, perseverance, and resilience, which felt like a fitting touch!
Then, register the host with your preferred orchestration service
using DurableTask.AspNetCore;
using DurableTask.AzureStorage;
var orchestrationServiceAndClient = new AzureStorageOrchestrationService(new()
{
StorageAccountClientProvider = new StorageAccountClientProvider("...."),
});
builder.Services.AddSelfHostedDurableTaskHub(orchestrationServiceAndClient);
Finally, register the durabletask-dotnet services and add UseSelfHosted to both the worker and client.
using Microsoft.DurableTask;
using Microsoft.DurableTask.Client;
using Microsoft.DurableTask.Worker;
// Add all the generated tasks
builder.Services.AddDurableTaskWorker(builder =>
{
builder
.AddTasks(r => r.AddAllGeneratedTasks());
.UseSelfHosted();
});
builder.Services.AddDurableTaskClient(b => b.UseSelfHosted());
Now you can inject the DurableTaskClient into your classes to schedule or manage durable tasks. For more detailed examples, check out the samples folder.
Durable Entities
To use durable entities, follow these steps:
Manually register entities: Add your entity to the
DurableTaskWorkerusingAddTasks(). Note that automatic registration viaAddAllGeneratedTasks()doesn't currently include entities (this will be addressed in a future version).Enable entity work item separation: Configure
UseSeparateQueueForEntityWorkItems = truein yourOrchestrationServicesettings.
// Configure the orchestration service
var orchestrationServiceAndClient = new AzureStorageOrchestrationService(new()
{
...
UseSeparateQueueForEntityWorkItems = true
});
// Register the worker with manual entity registration
builder.Services.AddDurableTaskWorker(builder =>
{
builder
.AddTasks(r =>
{
r.AddAllGeneratedTasks();
r.AddTask<MyCounterEntity>(); // Manually add your entity
})
.UseSelfHosted();
});
[DurableTask]
public sealed class MyCounterEntity : TaskEntity<int>
{
public void Add(int amount)
{
State += amount;
}
}
For more detailed examples, check out the samples folder.
Under the Hood
The durabletask-dotnet project is built on top of
the Durable Task Framework.
It provides an easy way to run durable tasks using Dependency Injection and IHostedService as a background service in your application.
One of its standout features is a type-safe source generator for orchestrators and activities, making it a breeze to work with. However,
"It's specifically designed to connect to a "sidecar" process, such as the Azure Functions .NET Isolated host, a special purpose sidecar container, or potentially even Dapr.",
so it use gRPC to communicate with the sidecar. In this project the gRPC communication
is replaced with a direct call to the DurableTaskHub service that runs in the same process.
Acknowledgements
durabletask-dotnet for providing the core Durable Task framework.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.DurableTask.Client (>= 1.18.0)
- Microsoft.DurableTask.Client.Grpc (>= 1.18.0)
- Microsoft.DurableTask.Worker (>= 1.18.0)
-
net8.0
- Microsoft.DurableTask.Client (>= 1.18.0)
- Microsoft.DurableTask.Client.Grpc (>= 1.18.0)
- Microsoft.DurableTask.Worker (>= 1.18.0)
-
net9.0
- Microsoft.DurableTask.Client (>= 1.18.0)
- Microsoft.DurableTask.Client.Grpc (>= 1.18.0)
- Microsoft.DurableTask.Worker (>= 1.18.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.