Skip to content

Initial integration of Durable Task Scheduler (i.e. emulator) #9294

Closed
philliphoff wants to merge 16 commits intomainfrom
philliphoff-durable-task-scheduler
Closed

Initial integration of Durable Task Scheduler (i.e. emulator) #9294
philliphoff wants to merge 16 commits intomainfrom
philliphoff-durable-task-scheduler

Conversation

@philliphoff
Copy link
Contributor

@philliphoff philliphoff commented May 13, 2025

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes #8926

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

@github-actions github-actions bot added the area-integrations Issues pertaining to Aspire Integrations packages label May 13, 2025
@philliphoff
Copy link
Contributor Author

philliphoff commented May 13, 2025

Looks like I need to get a couple packages into the Azure DevOps feeds:

  • Microsoft.DurableTask.Client.AzureManaged
  • Microsoft.DurableTask.Worker.AzureManaged

return WebUtility.UrlEncode(value);
}

string IManifestExpressionProvider.ValueExpression => WebUtility.UrlEncode(_reference.ValueExpression);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is #3117

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know! Will be happy to drop this implementation when there's a common solution.


var app = builder.Build();

app.MapPost("/create", async ([FromBody] EchoValue value, [FromServices] DurableTaskClient durableTaskClient) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It magically knows!

Suggested change
app.MapPost("/create", async ([FromBody] EchoValue value, [FromServices] DurableTaskClient durableTaskClient) =>
app.MapPost("/create", async (EchoValue value, DurableTaskClient durableTaskClient) =>

Comment on lines +13 to +18
clientBuilder.UseDurableTaskScheduler(
builder.Configuration.GetConnectionString("taskhub") ?? throw new InvalidOperationException("Scheduler connection string not configured."),
options =>
{
options.AllowInsecureCredentials = true;
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we build a client integration?

Copy link
Contributor Author

@philliphoff philliphoff May 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...yes? It's complicated because consuming applications can be either DTS "clients" or "workers" (and sometimes both), and there are separate SDKs for each which means multiple client integrations. Also, there are two sets of SDKs that apps can use (and you might consider another scenario a third) which further expands the matrix.

I'd say we should start with client integrations for the "modern" SDK, worker first and then client, as the former is the most common. Then, if there's demand, look at integrations for the "older" SDKs. That said, any client integrations would be follow up PRs.


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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this in the sample?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intent was to have examples that demonstrate the two main DTS scenarios: use of the DTS emulator and use of an existing DTS instance.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I'm having a hard time understanding is the deployment story here. Is this an azure resource as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, DTS is an Azure resource (though I'm not intending to support deployment in this initial pass). I did a little experimenting with the Bicep base resource type that other Azure resources are built upon, but they rely on Azure provisioning libraries that do not exist, yet, for DTS.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this model is going to be:
AddAzureDurableTaskScheudler().RunAsEmulator() yes?


namespace Aspire.Hosting.Azure;

interface IResourceWithDashboard : IResource
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style nit:

Suggested change
interface IResourceWithDashboard : IResource
internal interface IResourceWithDashboard : IResource

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, do we need this? This naming is very generic and only used by one resource.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used by both DTS resources, where each implements in a slightly different manner. I've updated the name to be DTS specific.

builder
.WithEndpoint(name: DurableTaskConstants.Scheduler.Emulator.Endpoints.Worker, scheme: "http", targetPort: 8080)
.WithEndpoint(name: DurableTaskConstants.Scheduler.Emulator.Endpoints.Dashboard, scheme: "http", targetPort: 8082)
.WithAnnotation(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WithEnvironment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed that overload; updated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also WithHttpEndpoint. Do we also need to add health checks?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated that, too. I suppose health checks for the emulator could be useful, though I need to look at the API and examples. I'd be inclined to leave that as a separate, follow up PR.

.RunAsEmulator(
options =>
{
options.WithDynamicTaskHubs();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this explicit call needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as a demonstration of configuring options on the emulator. (Not every Aspire application will want to use dynamic task hub names.)

Signed-off-by: Phillip Hoff <phillip@orst.edu>
@philliphoff
Copy link
Contributor Author

Closing in favor of replacement PR #13711.

@dotnet-policy-service dotnet-policy-service bot added this to the 13.2 milestone Dec 30, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Jan 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-integrations Issues pertaining to Aspire Integrations packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Aspire Support for Durable Task Scheduler

2 participants