Skip to content

Add ContinueAsNewOptions with NewVersion support#682

Open
YunchuWang wants to merge 5 commits intomainfrom
wangbill/continue-as-new-version
Open

Add ContinueAsNewOptions with NewVersion support#682
YunchuWang wants to merge 5 commits intomainfrom
wangbill/continue-as-new-version

Conversation

@YunchuWang
Copy link
Member

@YunchuWang YunchuWang commented Mar 21, 2026

Summary

This PR adds support for specifying a new orchestration version when calling ContinueAsNew, enabling version migration scenarios for long-running orchestrations.

Fixes #672

Changes

New: ContinueAsNewOptions class

  • Added ContinueAsNewOptions with a NewVersion property that allows callers to specify the version the next generation of the orchestration should run as.

Updated: TaskOrchestrationContext

  • Added a new virtual overload: ContinueAsNew(ContinueAsNewOptions, object?, bool) that accepts the options class.
  • Default implementation delegates to the existing abstract ContinueAsNew(object?, bool) method, preserving backward compatibility.

Updated: TaskOrchestrationContextWrapper

  • Overrides the new method to call the DurableTask.Core two-parameter ContinueAsNew(string newVersion, object newInput) when NewVersion is specified.

Tests

  • 3 unit tests in TaskOrchestrationContextWrapperTests: verify version propagation, null-version fallback, and preserveUnprocessedEvents passthrough.
  • 1 integration test (ContinueAsNewWithNewVersion): end-to-end validation that an orchestrator can migrate from no version to v2 and read back ctx.Version correctly.

E2E Testing Results

Test Backend Result
ContinueAsNewWithNewVersion (in-process) Core dispatcher + emulator PASSED
Azure Functions + Azurite Azure Storage via Core dispatcher PASSED (gen 1 sends NewVersion='v2', Core creates ExecutionStartedEvent with version=v2). Gen 2 blocked by extension's versionMatchStrategy: CurrentOrOlder default — see note below.
DTS Beskar integration test In-memory Beskar backend PASSED (with PR #3 fix) — Assert.Equal("v2", metadata.ReadOutputAs<string>())

Azure Functions versionMatchStrategy note: When gen 2 arrives with version v2 and the worker has no declared version, the default CurrentOrOlder strategy rejects it. Users must set "versionMatchStrategy": "None" in host.json or deploy a new worker with the target version. This is a pre-existing config constraint, not a bug in these PRs.

Downstream Changes Required

Release Order: This PR (#1) must merge first and publish a new NuGet package. Then PRs #2 and #3 can be merged (they depend on the ContinueAsNewOptions type from this package).

# Repo PR What's Needed Status
1 durabletask-dotnet This PR (#682) SDK: ContinueAsNewOptions + TaskOrchestrationContextWrapper override Ready for review
2 azure-functions-durable-extension #3404 FunctionsOrchestrationContext override to delegate new 3-param ContinueAsNew to inner context Depends on #1 NuGet publish
3 AAPT-DTMB ADO PR #15133055 PartitionGrain.WorkItems.cs: use action.CompleteOrchestration.NewVersion in ExecutionStartedEvent + integration test Depends on #1 NuGet publish

History

  • ContinueAsNew(string newVersion, object input) has existed in DurableTask.Core since Oct 2014 (initial commit by Affan Dar)
  • CompleteOrchestrationAction.newVersion (proto field 4) has existed since Jan 2022 (initial protobuf commit by Chris Gillum)
  • The portable SDK abstraction in durabletask-dotnet was the only layer that never exposed newVersion — until now

Motivation

See #672 — users need to evolve orchestration logic over time. The underlying infrastructure (proto field CompleteOrchestrationAction.newVersion, Core dispatcher, gRPC sidecar) all already support version changes on ContinueAsNew, but the portable SDK abstraction layer (TaskOrchestrationContext) had no way to pass a new version through.

Copilot AI review requested due to automatic review settings March 21, 2026 07:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an SDK-level mechanism to specify a target orchestration version when calling ContinueAsNew, enabling version migration for long-running (eternal) orchestrations while keeping existing ContinueAsNew(object?, bool) implementations working.

Changes:

  • Introduces ContinueAsNewOptions with a NewVersion property in the public abstractions layer.
  • Adds a new TaskOrchestrationContext.ContinueAsNew(ContinueAsNewOptions, object?, bool) overload and wires it through TaskOrchestrationContextWrapper to DurableTask.Core’s versioned ContinueAsNew.
  • Adds unit + integration tests validating version propagation and fallback behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/Abstractions/ContinueAsNewOptions.cs Adds a new options type carrying NewVersion.
src/Abstractions/TaskOrchestrationContext.cs Adds a virtual ContinueAsNew overload that accepts ContinueAsNewOptions.
src/Worker/Core/Shims/TaskOrchestrationContextWrapper.cs Implements the versioned continue-as-new behavior when NewVersion is provided.
test/Worker/Core.Tests/Shims/TaskOrchestrationContextWrapperTests.cs Unit tests validating wrapper behavior with/without version.
test/Grpc.IntegrationTests/OrchestrationPatterns.cs End-to-end integration test validating version migration via ContinueAsNew.
src/Abstractions/TaskOrchestrator.cs Updates XML doc cref to reference the intended ContinueAsNew overload explicitly.

@YunchuWang YunchuWang force-pushed the wangbill/continue-as-new-version branch from 9256bad to 32efcc8 Compare March 21, 2026 07:14
Copilot AI review requested due to automatic review settings March 21, 2026 07:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Copilot AI review requested due to automatic review settings March 21, 2026 16:29
@YunchuWang YunchuWang force-pushed the wangbill/continue-as-new-version branch from 4708a53 to c344e34 Compare March 21, 2026 16:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 21, 2026 16:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

YunchuWang added a commit to Azure/azure-functions-durable-extension that referenced this pull request Mar 21, 2026
…ationContext

Forward the new ContinueAsNew overload that accepts ContinueAsNewOptions
(with NewVersion) to the inner context. Without this override, the base
class default silently drops the options, preventing version migration
via ContinueAsNew from working in Azure Functions isolated worker.

Depends on: microsoft/durabletask-dotnet#682 (adds ContinueAsNewOptions)
Requires bumping Microsoft.DurableTask.Worker.Grpc to the version that
includes ContinueAsNewOptions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add newVersion support to TaskOrchestrationContext.ContinueAsNew

2 participants