Muokkaa

Jaa


Durable Functions versions overview

Durable Functions is an extension of Azure Functions and Azure WebJobs that lets you write stateful functions in a serverless environment. The extension manages state, checkpoints, and restarts for you. If you aren't already familiar with Durable Functions, see the overview documentation.

New features in 2.x

This section describes the features of Durable Functions that are added in version 2.x.

Note

This section does not apply to Durable Functions in dotnet isolated worker. For that, see durable functions isolated process overview.

Durable entities

In Durable Functions 2.x, we introduced a new entity functions concept.

Entity functions define operations for reading and updating small pieces of state, known as durable entities. Like orchestrator functions, entity functions are functions with a special trigger type, entity trigger. Unlike orchestrator functions, entity functions don't have any specific code constraints. Entity functions also manage state explicitly rather than implicitly representing state via control flow.

To learn more, see the durable entities article.

Durable HTTP

In Durable Functions 2.x, we introduced a new Durable HTTP feature that allows you to:

  • Call HTTP APIs directly from orchestration functions (with some documented limitations).
  • Implement automatic client-side HTTP 202 status polling.
  • Built-in support for Azure Managed Identities.

To learn more, see the HTTP features article.

Migrate from 1.x to 2.x

This section describes how to migrate your existing version 1.x Durable Functions to version 2.x to take advantage of the new features.

Upgrade the extension

Install the latest 2.x version of the Durable Functions bindings extension in your project.

JavaScript, Python, and PowerShell

Durable Functions 2.x is available starting in version 2.x of the Azure Functions extension bundle.

Python support in Durable Functions requires Durable Functions 2.x or greater.

To update the extension bundle version in your project, open host.json and update the extensionBundle section to use version 4.x ([4.*, 5.0.0)).

{
    "version": "2.0",
    "extensionBundle": {
        "id": "Microsoft.Azure.Functions.ExtensionBundle",
        "version": "[4.*, 5.0.0)"
    }
}

Note

If Visual Studio Code is not displaying the correct templates after you change the extension bundle version, reload the window by running the Developer: Reload Window command (Ctrl+R on Windows and Linux, Command+R on macOS).

Java

Durable Functions 2.x is available starting in version 4.x of the Azure Functions extension bundle. You must use the Azure Functions 4.0 runtime to execute Java functions.

To update the extension bundle version in your project, open host.json and update the extensionBundle section to use version 4.x ([4.*, 5.0.0)).

{
    "version": "2.0",
    "extensionBundle": {
        "id": "Microsoft.Azure.Functions.ExtensionBundle",
        "version": "[4.*, 5.0.0)"
    }
}

.NET

Update your .NET project to use the latest version of the Durable Functions bindings extension.

See Register Azure Functions binding extensions for more information.

Update your code

Durable Functions 2.x introduces several breaking changes. Durable Functions 1.x applications aren't compatible with Durable Functions 2.x without code changes. This section lists some of the changes you must make when upgrading your version 1.x functions to 2.x.

Host.json schema

Durable Functions 2.x uses a new host.json schema. The main changes from 1.x include:

  • "storageProvider" (and the "azureStorage" subsection) for storage-specific configuration.
  • "tracing" for tracing and logging configuration.
  • "notifications" (and the "eventGrid" subsection) for Event Grid notification configuration.

See the Durable Functions host.json reference documentation for details.

Default task hub name changes

In version 1.x, if a task hub name wasn't specified in host.json, it was defaulted to "DurableFunctionsHub". In version 2.x, the default task hub name is now derived from the name of the function app. Because of this, if you haven't specified a task hub name when upgrading to 2.x, your code will be operating with new task hub, and all in-flight orchestrations will no longer have an application processing them. To work around this, you can either explicitly set your task hub name to the v1.x default of "DurableFunctionsHub", or you can follow our zero-downtime deployment guidance for details on how to handle breaking changes for in-flight orchestrations.

Public interface changes (.NET only)

In version 1.x, the various context objects supported by Durable Functions have abstract base classes intended for use in unit testing. As part of Durable Functions 2.x, these abstract base classes are replaced with interfaces.

The following table represents the main changes:

1.x 2.x
DurableOrchestrationClientBase IDurableOrchestrationClient or IDurableClient
DurableOrchestrationContext or DurableOrchestrationContextBase IDurableOrchestrationContext
DurableActivityContext or DurableActivityContextBase IDurableActivityContext
OrchestrationClientAttribute DurableClientAttribute

In the case where an abstract base class contained virtual methods, these virtual methods have been replaced by extension methods defined in DurableContextExtensions.

function.json changes

In Durable Functions 1.x, the orchestration client binding uses a type of orchestrationClient. Version 2.x uses durableClient instead.

Raise event changes

In Durable Functions 1.x, calling the raise event API and specifying an instance that didn't exist resulted in a silent failure. Starting in 2.x, raising an event to a non-existent orchestration results in an exception.