Skip to content

Add Work Item Filters for Functions sample (DTS backend, .NET and Python)#277

Open
bachuv wants to merge 4 commits into
Azure-Samples:mainfrom
bachuv:vabachu/work-item-filters-functions
Open

Add Work Item Filters for Functions sample (DTS backend, .NET and Python)#277
bachuv wants to merge 4 commits into
Azure-Samples:mainfrom
bachuv:vabachu/work-item-filters-functions

Conversation

@bachuv
Copy link
Copy Markdown
Contributor

@bachuv bachuv commented Apr 28, 2026

Purpose

Adds samples demonstrating the work item filtering feature for Durable Functions with the Durable Task Scheduler backend. When multiple Function apps share the same task hub, work item filtering ensures each app only receives work items for the functions it has registered, preventing dispatch failures.

Each sample is shipped as a pair of apps so the multi-worker filtering behavior is demonstrable end-to-end:

  • .NET (samples/durable-functions/dotnet/WorkItemFiltering/ + WorkItemFiltering.AppB/) — .NET 8 isolated worker. App A registers greeting, fan-out, sub-orchestration, and entity functions; App B registers an orders orchestration with a ship_order activity. Both target the same task hub.
  • Python (samples/durable-functions/python/work-item-filtering/ + work-item-filtering-app-b/) — Python v2 programming model, same pattern. Uses a manual extensions.csproj (installed via func extensions install) to pin Microsoft.Azure.WebJobs.Extensions.DurableTask.AzureManaged 1.8.1 instead of the public extension bundle.

A run-both.ps1 script in each language folder builds both apps, launches them on ports 7071/7072, and runs five scenarios to validate filter routing (own-app, cross-app A→B, cross-app B→A, and unknown-orchestration-stays-Pending).

Also updates .github/workflows/build-samples.yml with build steps for the new projects.

Does this introduce a breaking change?

[ ] Yes
[x] No

Pull Request Type

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:

How to Test

Get the code:

git clone https://github.com/bachuv/Durable-Task-Scheduler.git
cd Durable-Task-Scheduler
git checkout vabachu/work-item-filters-functions

Start DTS emulator + Azurite (one-time):

docker run --name dtsemulator -d -p 8080:8080 -p 8082:8082 mcr.microsoft.com/dts/dts-emulator:latest
docker run --name azurite -d -p 10000:10000 -p 10001:10001 -p 10002:10002 mcr.microsoft.com/azure-storage/azurite

Run the .NET split-worker demo:

cd samples/durable-functions/dotnet
.\run-both.ps1

Run the Python split-worker demo:

cd samples/durable-functions/python
.\run-both.ps1

Both scripts print a 5-row table; rows 1–4 should be Completed, row 5 should stay Pending.

What to Check

  • Both .NET projects (WorkItemFiltering, WorkItemFiltering.AppB) build cleanly
  • Both Python projects install their requirements and resolve extensions via func extensions install
  • run-both.ps1 (in both languages) prints 4× Completed + 1× Pending
  • Microsoft.DurableTask: Information log line "Work item filtering enabled. Registered N orchestrators..." appears in each host's startup log
  • host.json includes "workItemFilteringEnabled": true under storageProvider in all four apps
  • New CI steps in build-samples.yml succeed for the new projects

Other Information

Samples consume the publicly released Microsoft.Azure.Functions.Worker.Extensions.DurableTask.AzureManaged 1.8.1 (.NET) and Microsoft.Azure.WebJobs.Extensions.DurableTask.AzureManaged 1.8.1 (Python) packages from nuget.org.

@bachuv bachuv changed the title Add Work Item Filters for Functions sample (.NET and Python) Add Work Item Filters for Functions sample (DTS backend, .NET and Python) Apr 30, 2026
@bachuv bachuv marked this pull request as ready for review May 19, 2026 18:38
Copilot AI review requested due to automatic review settings May 19, 2026 18:38
Copy link
Copy Markdown
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

Note

Copilot was unable to run its full agentic suite in this review.

Adds new Durable Functions samples demonstrating work item filtering when using the Durable Task Scheduler (DTS) backend, including a two-app scenario to show filter isolation and cross-app orchestration scheduling.

Changes:

  • Add .NET 8 isolated worker sample apps (App A + App B) with orchestrations, activities, and entities configured for workItemFilteringEnabled.
  • Add Python v2 programming model sample apps (App A + App B), including manual extension management via extensions.csproj.
  • Update CI workflow to build/install the newly added sample dependencies.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
samples/durable-functions/python/work-item-filtering/test.http Adds guided HTTP demo steps for the Python sample.
samples/durable-functions/python/work-item-filtering/requirements.txt Adds Python dependencies for the sample.
samples/durable-functions/python/work-item-filtering/host.json Enables workItemFilteringEnabled for the Python sample.
samples/durable-functions/python/work-item-filtering/function_app.py Implements Python orchestrations/activities/entities + HTTP starters.
samples/durable-functions/python/work-item-filtering/extensions.csproj Pins AzureManaged provider packages for manual extension install.
samples/durable-functions/python/work-item-filtering/README.md Documents setup, extension install, and filter behavior for Python sample.
samples/durable-functions/python/work-item-filtering-app-b/requirements.txt Adds Python dependencies for App B.
samples/durable-functions/python/work-item-filtering-app-b/host.json Enables workItemFilteringEnabled for Python App B.
samples/durable-functions/python/work-item-filtering-app-b/function_app.py Implements App B orchestration/activity + HTTP starters.
samples/durable-functions/python/work-item-filtering-app-b/extensions.csproj Pins AzureManaged provider packages for App B manual extension install.
samples/durable-functions/python/run-both.ps1 Runs both Python apps to demonstrate isolation/cross-app scheduling.
samples/durable-functions/dotnet/run-both.ps1 Runs both .NET apps to demonstrate isolation/cross-app scheduling.
samples/durable-functions/dotnet/WorkItemFiltering/test.http Adds guided HTTP demo steps for the .NET sample.
samples/durable-functions/dotnet/WorkItemFiltering/host.json Enables workItemFilteringEnabled for .NET App A.
samples/durable-functions/dotnet/WorkItemFiltering/WorkItemFiltering.csproj Adds .NET 8 isolated worker project and DTS AzureManaged package.
samples/durable-functions/dotnet/WorkItemFiltering/README.md Documents setup and filter behavior for .NET sample.
samples/durable-functions/dotnet/WorkItemFiltering/Program.cs Minimal host bootstrap for .NET sample.
samples/durable-functions/dotnet/WorkItemFiltering/Functions.cs Implements orchestrations/activities/entities + HTTP starters.
samples/durable-functions/dotnet/WorkItemFiltering.AppB/host.json Enables workItemFilteringEnabled for .NET App B.
samples/durable-functions/dotnet/WorkItemFiltering.AppB/Program.cs Minimal host bootstrap for .NET App B.
samples/durable-functions/dotnet/WorkItemFiltering.AppB/Functions.cs Implements App B orchestration/activity + HTTP starter.
samples/durable-functions/dotnet/WorkItemFiltering.AppB/AppB.csproj Adds .NET 8 isolated worker project for App B and dependencies.
.github/workflows/build-samples.yml Adds CI steps to build/install the new samples.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread samples/durable-functions/python/work-item-filtering/test.http Outdated
Comment thread samples/durable-functions/dotnet/WorkItemFiltering/test.http Outdated
Comment thread samples/durable-functions/python/work-item-filtering/test.http Outdated
Comment thread samples/durable-functions/python/work-item-filtering/function_app.py Outdated
Comment thread samples/durable-functions/python/work-item-filtering-app-b/function_app.py Outdated
Comment thread .github/workflows/build-samples.yml
Comment thread samples/durable-functions/dotnet/WorkItemFiltering/Functions.cs Outdated
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.

2 participants