Durable Functions in the .NET Isolated Worker: A Comprehensive Overview

Durable Functions in the .NET Isolated Worker: A Comprehensive Overview

Durable Functions in the .NET isolated worker offer a powerful way to run your Durable Functions app on a .NET version different from the Azure Functions host. This article provides an overview of the benefits and features of using Durable Functions in the .NET isolated worker.

Why Use Durable Functions in the .NET Isolated Worker?

Utilizing the .NET isolated worker model provides several benefits, including:

  • Improved Performance: The isolated worker process offers enhanced performance compared to traditional hosting environments.
  • Enhanced Security: Isolated workers provide a more secure environment for running your Durable Functions app.
  • New SDK Features: The .NET isolated worker SDK includes new features and improvements over in-process Durable Functions.

Feature Improvements over In-process Durable Functions

The .NET isolated worker SDK includes several feature improvements over in-process Durable Functions, including:

  • Direct Orchestration Input Injection: Orchestration inputs can be injected directly into orchestrations, simplifying the development process.
  • Support for Strongly Typed Calls: The SDK supports strongly typed calls and class-based activities and orchestrations, providing a more robust development experience.

Source Generator and Class-based Activities and Orchestrations

To take advantage of the source generator and class-based activities and orchestrations, follow these steps:

  1. Add Package Reference: Add the following package reference to your project: <PackageReference Include="Microsoft.DurableTask.Generators" Version="1.0.0-preview.1" />.
  2. Implement Class-based Activities and Orchestrations: Implement your activities and orchestrations as strongly typed classes, inheriting types from the Durable SDK.

Here's an example of how to implement class-based activities and orchestrations:

// Define activity class
public class MyActivity : TaskActivity<string, string>
{
    public override Task<string> RunAsync(TaskActivityContext context, string input)
    {
        // Implementation
    }
}

// Define orchestration class
public class MyOrchestration : TaskOrchestrator<string, string>
{
    public override Task<string> RunAsync(TaskOrchestrationContext context, string input)
    {
        // Implementation
        return context.CallActivityAsync<string>(nameof(MyActivity), input);
    }
}
        

Durable Entities

Durable entities are also supported in the .NET isolated worker, providing a powerful way to manage stateful entities within your Durable Functions app.

Migration Guide

If you're migrating from a .NET Durable Functions 2.x project to the .NET isolated worker, follow these steps:

  1. Update Project: Update your project to use the Azure Functions .NET isolated worker.
  2. Update NuGet Packages: Update your Durable Functions NuGet package references to the latest versions.


<ItemGroup>
  <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="2.9.0" />
</ItemGroup>
<ItemGroup>
  <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask" Version="1.1.0" />
</ItemGroup>
        

By leveraging Durable Functions in the .NET isolated worker, you can take advantage of the latest features and improvements to build robust and scalable serverless applications.



要查看或添加评论,请登录

Senthil Gopal的更多文章

社区洞察

其他会员也浏览了