Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Out-of-process .NET SDK for the Durable Task Framework

License

NotificationsYou must be signed in to change notification settings

microsoft/durabletask-dotnet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build statusLicense: MIT

The Durable Task .NET SDK is a standalone .NET library for implementing Durable Task orchestrations, activities, and entities. It's specifically designed to connect to a "sidecar" process, such as theAzure Functions .NET Isolated host, or a managed Azure endpoint, such as theDurable Task Scheduler (preview).

This project is different from theDurable Task Framework, which supports running fully self-hosted apps using a storage-based backend like Azure Storage or MSSQL.

NuGet packages

The following nuget packages are available for download.

NameLatest versionDescription
Azure Functions ExtensionNuGet version (Microsoft.Azure.Functions.Worker.Extensions.DurableTask)For Durable Functions in .NET isolated.
Abstractions SDKNuGet version (Microsoft.DurableTask.Abstractions)Contains base abstractions for Durable. Useful for writing re-usable libraries independent of the chosen worker or client.
Client SDKNuGet version (Microsoft.DurableTask.Client)Contains the core client logic for interacting with a Durable backend.
Client.Grpc SDKNuGet version (Microsoft.DurableTask.Client.Grpc)The gRPC client implementation.
Client.AzureManaged SDKNuGet version (Microsoft.DurableTask.Worker.AzureManaged)The client implementation for use with theDurable Task Scheduler (preview).
Worker SDKNuGet version (Microsoft.DurableTask.Worker)Contains the core worker logic for having aIHostedService to process durable tasks.
Worker.Grpc SDKNuGet version (Microsoft.DurableTask.Worker.Grpc)The gRPC worker implementation.
Worker.AzureManaged SDKNuGet version (Microsoft.DurableTask.Worker.AzureManaged)The worker implementation for use with theDurable Task Scheduler (preview).
Source GeneratorsNuGet version (Microsoft.DurableTask.Generators)Source generators for type-safe orchestration and activity invocations.

Usage with Azure Functions

This SDK can be used to build Durable Functions apps that run in theAzure Functions .NET Isolated worker process.

To get started, add theMicrosoft.Azure.Functions.Worker.Extensions.DurableTask nuget package to your Function app project. Make sure you're using the latest .NET Worker SDK packages.

  <ItemGroup>    <PackageReferenceInclude="Microsoft.Azure.Functions.Worker"Version="1.10.0" />    <PackageReferenceInclude="Microsoft.Azure.Functions.Worker.Extensions.DurableTask"Version="1.2.2" />    <PackageReferenceInclude="Microsoft.Azure.Functions.Worker.Extensions.Http"Version="3.0.13" />    <PackageReferenceInclude="Microsoft.Azure.Functions.Worker.Sdk"Version="1.7.0"OutputItemType="Analyzer" />    <PackageReferenceInclude="Microsoft.DurableTask.Generators"Version="1.0.0"OutputItemType="Analyzer" />  </ItemGroup>

You can then use the following code to define a simple "Hello, cities" durable orchestration, triggered by an HTTP request.

usingMicrosoft.Azure.Functions.Worker;usingMicrosoft.Azure.Functions.Worker.Http;usingMicrosoft.DurableTask;usingMicrosoft.DurableTask.Client;usingMicrosoft.Extensions.Logging;namespaceIsolatedFunctionApp1.Untyped;staticclassHelloSequenceUntyped{[Function(nameof(StartHelloCitiesUntyped))]publicstaticasyncTask<HttpResponseData>StartHelloCitiesUntyped([HttpTrigger(AuthorizationLevel.Anonymous,"get","post")]HttpRequestDatareq,[DurableClient]DurableTaskClientclient,FunctionContextexecutionContext){ILoggerlogger=executionContext.GetLogger(nameof(StartHelloCitiesUntyped));stringinstanceId=awaitclient.ScheduleNewOrchestrationInstanceAsync(nameof(HelloCitiesUntyped));logger.LogInformation("Created new orchestration with instance ID = {instanceId}",instanceId);returnclient.CreateCheckStatusResponse(req,instanceId);}[Function(nameof(HelloCitiesUntyped))]publicstaticasyncTask<string>HelloCitiesUntyped([OrchestrationTrigger]TaskOrchestrationContextcontext){stringresult="";result+=awaitcontext.CallActivityAsync<string>(nameof(SayHelloUntyped),"Tokyo")+" ";result+=awaitcontext.CallActivityAsync<string>(nameof(SayHelloUntyped),"London")+" ";result+=awaitcontext.CallActivityAsync<string>(nameof(SayHelloUntyped),"Seattle");returnresult;}[Function(nameof(SayHelloUntyped))]publicstaticstringSayHelloUntyped([ActivityTrigger]stringcityName,FunctionContextexecutionContext){ILoggerlogger=executionContext.GetLogger(nameof(SayHelloUntyped));logger.LogInformation("Saying hello to {name}",cityName);return$"Hello,{cityName}!";}}

You can find the full sample file, including detailed comments, atsamples/AzureFunctionsApp/HelloCitiesUntyped.cs.

Class-based syntax

IMPORTANT: class based syntax in Durable Functions relies on a package reference toMicrosoft.DurableTask.Generators. This is still in "preview" and may be subject to significant change before 1.0 or even post-1.0. It is recommended to stick with function-syntax for now.

A new feature in this version of Durable Functions for .NET Isolated is the ability to define orchestrators and activities as classes instead of as functions. When using the class-based syntax, source generators are used to generate function definitions behind the scenes to instantiate and invoke your classes.

The source generators also generate type-safe extension methods on theclient andcontext objects, removing the need to reference other activities or orchestrations by name, or to use type parameters to declare the return type. The following sample demonstrates the same "Hello cities!" orchestration using the class-based syntax and source-generated extension methods.

usingMicrosoft.Azure.Functions.Worker;usingMicrosoft.Azure.Functions.Worker.Http;usingMicrosoft.DurableTask;usingMicrosoft.DurableTask.Client;usingMicrosoft.Extensions.Logging;namespaceIsolatedFunctionApp1.Typed;publicstaticclassHelloCitiesTypedStarter{[Function(nameof(StartHelloCitiesTyped))]publicstaticasyncTask<HttpResponseData>StartHelloCitiesTyped([HttpTrigger(AuthorizationLevel.Anonymous,"get","post")]HttpRequestDatareq,[DurableClient]DurableTaskClientclient,FunctionContextexecutionContext){ILoggerlogger=executionContext.GetLogger(nameof(StartHelloCitiesTyped));stringinstanceId=awaitclient.ScheduleNewHelloCitiesTypedInstanceAsync();logger.LogInformation("Created new orchestration with instance ID = {instanceId}",instanceId);returnclient.CreateCheckStatusResponse(req,instanceId);}}[DurableTask(nameof(HelloCitiesTyped))]publicclassHelloCitiesTyped:TaskOrchestrator<string?,string>{publicasyncoverrideTask<string>RunAsync(TaskOrchestrationContextcontext,string?input){stringresult="";result+=awaitcontext.CallSayHelloTypedAsync("Tokyo")+" ";result+=awaitcontext.CallSayHelloTypedAsync("London")+" ";result+=awaitcontext.CallSayHelloTypedAsync("Seattle");returnresult;}}[DurableTask(nameof(SayHelloTyped))]publicclassSayHelloTyped:TaskActivity<string,string>{readonlyILogger?logger;publicSayHelloTyped(ILoggerFactory?loggerFactory){this.logger=loggerFactory?.CreateLogger<SayHelloTyped>();}publicoverrideTask<string>RunAsync(TaskActivityContextcontext,stringcityName){this.logger?.LogInformation("Saying hello to {name}",cityName);returnTask.FromResult($"Hello,{cityName}!");}}

You can find the full sample file, including detailed comments, atsamples/AzureFunctionsApp/HelloCitiesTyped.cs.

Compatibility with Durable Functions in-process

This SDK isnot compatible with Durable Functions for the .NETin-process worker. It only works with the newer out-of-process .NET Isolated worker.

Usage with the Durable Task Scheduler

The Durable Task Scheduler for Azure Functions is a managed backend that is currently in preview. Durable Functions apps can use the Durable Task Scheduler as one of itssupported storage providers.

This SDK can also be used with the Durable Task Scheduler directly, without any Durable Functions dependency. To get started, sign up for theDurable Task Scheduler private preview and follow the instructions to create a new Durable Task Scheduler instance. Once granted access to the private preview GitHub repository, you can find samples and documentation for getting startedhere.

Obtaining the Protobuf definitions

This project utilizes protobuf definitions fromdurabletask-protobuf, which are copied (vendored) into this repository under thesrc/Grpc directory. See the correspondingREADME.md for more information about how to update the protobuf definitions.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to aContributor License Agreement (CLA) declaring that you have the right to, and actually do, grant usthe rights to use your contribution. For details, visithttps://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to providea CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructionsprovided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted theMicrosoft Open Source Code of Conduct.For more information see theCode of Conduct FAQ orcontactopencode@microsoft.com with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsofttrademarks or logos is subject to and must followMicrosoft's Trademark & Brand Guidelines.Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.Any use of third-party trademarks or logos are subject to those third-party's policies.

About

Out-of-process .NET SDK for the Durable Task Framework

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors27

Languages


[8]ページ先頭

©2009-2025 Movatter.jp