-
Notifications
You must be signed in to change notification settings - Fork 286
Adding GetFunctionContext extension method on TaskOrchestrationContext
#3324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds a GetFunctionContext extension method on TaskOrchestrationContext to allow orchestrator code to access the underlying Azure Functions FunctionContext (when running under Functions hosting), enabling DI access via FunctionContext.InstanceServices.
Changes:
- Add
TaskOrchestrationContext.GetFunctionContext()extension method that returns the backingFunctionContextwhen available. - Expose the backing
FunctionContextfromFunctionsOrchestrationContextfor internal consumption by the extension method. - Add unit tests and bump package patch version + release notes entry.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/Worker.Extensions.DurableTask.Tests/TaskOrchestrationContextExtensionMethodsTests.cs | Adds unit tests covering null input, Functions-backed context, and non-Functions context behavior. |
| src/Worker.Extensions.DurableTask/Worker.Extensions.DurableTask.csproj | Bumps package version to 1.13.2 to ship the new API. |
| src/Worker.Extensions.DurableTask/TaskOrchestrationContextExtensionMethods.cs | Implements GetFunctionContext() extension method returning FunctionContext?. |
| src/Worker.Extensions.DurableTask/FunctionsOrchestrationContext.cs | Adds internal FunctionContext accessor used by the new extension method. |
| release_notes.md | Documents the new extension method under “New Features”. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| <!-- Version information --> | ||
| <VersionPrefix>1.13.1</VersionPrefix> | ||
| <VersionPrefix>1.13.2</VersionPrefix> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a new public API, should we bump the minor version instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bumped minor version instead of patch, in the new iteration pushed.
Summary
Adding
GetFunctionContextextension method onTaskOrchestrationContext. This returns theFunctionsContextinstance if the orchestrationcontext is running in Functions hosting context.Why is this change needed?
We need to retrieve a registered dependency from the DI container. This can be done via the
InstanceServicesproperty on FunctionContext. TheAddOrchestratorFuncis used to register the orchestration to support scenarios where we override the function executor with our custom executor. In those cases, theTaskOrchestrationContextparameter fails to bind when used as a function input parameter (because that binding happens in the DurableFunctionExecutor), particularly for Microsoft Agent Framework support scenarios.Issues / work items
n/a
Project checklist
pending_docs.mdrelease_notes.mdWebJobs.Extensions.DurableTaskpackage/src/Worker.Extensions.DurableTask/AssemblyInfo.csEventSourcelogsv2.xbranchWebJobs.Extensions.DurableTaskv3.x and will be retained only in thedevandmainbranchesAI-assisted code disclosure (required)
Was an AI tool used? (select one)
If AI was used:
AI verification (required if AI was used):
Testing
Automated tests
Manual validation (only if runtime/behavior changed)
1.
2.
3.
Notes for reviewers