Skip to content

[New article]: New Durable Task Scheduler integration #3400

Open
@philliphoff

Description

@philliphoff

Proposed topic or title

.NET Aspire Durable Task Scheduler integration

Location in table of contents.

/ Integrations / Azure / Azure Functions / Durable Task Scheduler

Reason for the article

We're in the process of adding .NET Aspire integration for a new Azure resource, the Durable Task Scheduler (DTS), a backend for Durable Task based applications (such as Azure Durable Functions). Developers utilizing DTS in their applications may need documentation describing how to make use of DTS within .NET Aspire.

Article abstract

Durable Task applications (e.g. Azure Durable Functions) can use the Azure Durable Task Scheduler (DTS) to manage execution of its orchestrations and entities. .NET Aspire applications can use this integration to make use of existing or emulated DTS instances.

Getting started

Install the package

In your AppHost project, install the .NET Aspire Durable Task Hosting library with NuGet:

dotnet add package Aspire.Hosting.Azure.Functions --prerelease

Durable Task Scheduler usage example

Using the emulator

In the Program.cs file of AppHost, add Durable Task Scheduler resources and consume the connection using the following methods:

var builder = DistributedApplication.CreateBuilder(args);

var scheduler = builder.AddDurableTaskScheduler("scheduler")
                       .RunAsEmulator();

var taskHub = scheduler.AddDurableTaskHub("taskhub");

builder.AddProject<Projects.MyApp>("myapp")
       .WithReference(taskHub);

builder.Build().Run();

NOTE: When referencing the taskhub resource, the connection string will include the task hub name whereas the connection string for a scheduler resource will not. Use the latter when an application specifies the task hub name separately from the connection string (e.g. Azure Durable Functions).

Using an existing Durable Task Scheduler

In the Program.cs file of AppHost, add Durable Task Scheduler resources and consume the connection using the following methods:

var builder = DistributedApplication.CreateBuilder(args);

var scheduler =
    builder.AddDurableTaskScheduler("scheduler")
           .RunAsExisting(builder.AddParameter("scheduler-connection-string"));

var taskHub =
    scheduler.AddTaskHub("taskhub")
             .WithTaskHubName(builder.AddParameter("taskhub-name"));

builder.AddProject<Projects.MyApp>("myapp")
       .WithReference(taskHub);

builder.Build().Run();

Relevant searches

N/A

Associated work items

Metadata

Metadata

Assignees

No one assigned

    Labels

    Pri1High priority, do before Pri2 and Pri3area-docsdoc-ideaIndicates issues that are suggestions for new topics [org][type][category]

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions