microsoft / microsoft/aspire.dev

Update Azure Functions docs with examples for use of Durable Task Scheduler

Open
#214 1 comment 0 reactions 1 assignee View on GitHub

@IEvangelist is already working on this.

Since Jun 2, 2026.

Dominant language
MDX
Stars
193
Forks
87
Avg merge
1d 22h
Merged PRs (30d)
73

Description

dotnet/aspire#13711 adds resources related to the Durable Task Scheduler (DTS) to the Azure Functions host library, which allow customers to start the DTS emulator (or connect to an existing Azure resource) for use with Azure Functions applications.

There is an existing doc for use of Azure Functions within Aspire; with this PR the doc should be updated with similar examples of using Azure Functions with DTS.

Under Hosting integration, a new section could be added similar to:

Durable Task Scheduler (Durable Functions)

The Azure Functions hosting library also provides resource APIs for using the Durable Task Scheduler (DTS) with Durable Functions.

In the AppHost.cs file of AppHost, add a Scheduler resource, create one or more Task Hubs, and pass the connection string and hub name to your Functions project:

using Aspire.Hosting;
using Aspire.Hosting.Azure;
using Aspire.Hosting.Azure.Functions;

var builder = DistributedApplication.CreateBuilder(args);

var storage = builder.AddAzureStorage("storage").RunAsEmulator();

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

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

builder.AddAzureFunctionsProject<Projects.Company_FunctionApp>("funcapp")
    .WithHostStorage(storage)
    .WithEnvironment("DURABLE_TASK_SCHEDULER_CONNECTION_STRING", scheduler)
    .WithEnvironment("TASKHUB_NAME", taskHub.Resource.TaskHubName);

builder.Build().Run();
Use the DTS emulator

RunAsEmulator() starts a local container running the Durable Task Scheduler emulator.

When a Scheduler runs as an emulator, Aspire automatically provides:

  • A "Scheduler Dashboard" URL for the scheduler resource.
  • A "Task Hub Dashboard" URL for each Task Hub resource.
  • A DTS_TASK_HUB_NAMES environment variable on the emulator container listing the Task Hub names associated with that scheduler.
Use an existing Scheduler

If you already have a Scheduler instance, configure the resource using its connection string:

var schedulerConnectionString = builder.AddParameter(
    "dts-connection-string",
    "Endpoint=https://existing-scheduler.durabletask.io;Authentication=DefaultAzure");

var scheduler = builder.AddDurableTaskScheduler("scheduler")
    .RunAsExisting(schedulerConnectionString);

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.