Skip to content

[Async stack 5/6] Functions async orchestration support - #363

Draft
andystaples wants to merge 7 commits into
andystaples-async-stack-4-async-contextfrom
andystaples-async-stack-5-functions-support
Draft

andystaples wants to merge 7 commits into
andystaples-async-stack-4-async-contextfrom
andystaples-async-stack-5-functions-support

Conversation

@andystaples

@andystaples andystaples commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Warning

This PR is part of a review-only stack and must not be merged individually. The whole stack will be squash-merged after every PR in it is approved.

Summary

Adds async def orchestrator support to the Azure Functions Durable provider using the same shape as the core SDK and Durable Task Scheduler provider: async def orchestrator(ctx: task.AsyncOrchestrationContext, input). The second argument is the orchestration input.

Async orchestrators

  • Two-parameter async def orchestrators pass straight through to the core worker, which supplies task.AsyncOrchestrationContext. This works through DFApp/Blueprint.orchestration_trigger, Orchestrator.create, and DurableFunctionsWorker.
  • Single-parameter async def orchestrators are not supported. orchestration_trigger and Orchestrator.create raise TypeError at decoration time, and the worker raises it before registration. The message points to the two-parameter shape. The function is inspected only, so no coroutine is created.
  • Single-parameter DurableOrchestrationContext orchestrators remain generator or regular functions with unchanged behavior, including task_all/task_any.

df.call_http

  • Adds azure.durable_functions.call_http(ctx, method, uri, *, content, headers, token_source, is_raw_str, retry_options). It returns a DurableHttpResponse.
  • With task.AsyncOrchestrationContext, it returns a cold coroutine: validation, serialization, and scheduling happen when the coroutine starts. With task.OrchestrationContext, it schedules immediately and returns a Task to yield. Other context types raise TypeError.
  • It shares its implementation with DurableOrchestrationContext.call_http: the built-in HTTP activity, 202/Location polling sub-orchestration, HttpRetryOptions, and token sources. The compat method's behavior is unchanged.

Typing

  • FunctionsOrchestrator covers task.Orchestrator (sync and two-parameter async) plus single-parameter DurableOrchestrationContext callables. The decorators and worker use it.

Limitations

  • The orchestrator_generator_wrapper testing helper drives generator orchestrators only. Test async orchestrators with the replay executor, a provider, or the in-memory backend.

Tests

  • Unit tests cover async replay through every Functions entry point, owned event timeouts, two-parameter pass-through, single-parameter rejection without coroutine warnings, and call_http for v1, eager, and async contexts (success, 202 polling, retry failure, cold validation, content encoding).
  • The dtask-style E2E app adds async fan-out, as_task_context() + task.when_any race, and async call_http probes, which test_coroutine_e2e.py runs against a real Functions host.
  • The package typing exercise covers call_http overloads and orchestrator registration.

Layer 6 contains the release-facing docs (READMEs, migration guide, changelogs). This PR contains no version bumps.

@andystaples
andystaples force-pushed the andystaples-async-stack-5-functions-support branch from a35936b to f9ae519 Compare November 12, 2026 18:57
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@andystaples
andystaples force-pushed the andystaples-async-stack-5-functions-support branch from f9ae519 to 69872f1 Compare November 12, 2026 21:02
andystaples and others added 5 commits November 12, 2026 15:34
…stack-5-functions-support

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…stack-5-functions-support

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…stack-5-functions-support

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…stack-5-functions-support

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…stack-5-functions-support

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…ttp helper

Remove AsyncDurableOrchestrationContext. Single-parameter async def
orchestrators now fail with TypeError when decorated or registered,
pointing to the two-parameter AsyncOrchestrationContext shape.

Add azure.durable_functions.call_http for durabletask orchestration
contexts. It returns a cold coroutine for AsyncOrchestrationContext and an
eager task for OrchestrationContext, and shares the existing durable HTTP
implementation with DurableOrchestrationContext.call_http.

Restore the generator-only orchestrator_generator_wrapper testing helper.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant