Skip to content

Add durable task example - #59

Open
madebygps wants to merge 9 commits into
Azure-Samples:mainfrom
madebygps:feature/durabletask-example
Open

Add durable task example#59
madebygps wants to merge 9 commits into
Azure-Samples:mainfrom
madebygps:feature/durabletask-example

Conversation

@madebygps

Copy link
Copy Markdown
Collaborator

DTS Integration and Demo Examples

  • Added examples/agent_durabletask.py and examples/spanish/agent_durabletask.py as demos showing how agent state persists across worker restarts using Durable Task Scheduler, with clear instructions and both English and Spanish versions. [1] [2]
  • Updated README.md, AGENTS.md, and examples/spanish/README.md to document how to run the DTS emulator locally, deploy to Azure, and run the new DTS demo, including instructions and links to dashboards. [1] [2] [3] [4] [5] [6]

Development Environment Enhancements

  • Modified .devcontainer/docker-compose.yml to add a dts-emulator service, expose necessary ports, and set the DTS_ENDPOINT environment variable for the app service. [1] [2]
  • Updated .devcontainer/devcontainer.json to forward DTS emulator ports (8080 and 8082) into the container for local development and dashboard access.

Configuration and Infrastructure

  • Extended .env.sample with DTS_ENDPOINT and DTS_TASKHUB variables to support local and Azure DTS configuration.
  • Added infra/dts.bicep to provision Azure Durable Task Scheduler and Task Hub resources, including RBAC assignment, for cloud deployment scenarios.

madebygps and others added 8 commits April 7, 2026 15:02
- Add agent_durabletask.py with minimal worker-client hosted agent
- Add Spanish translation
- Add dts-emulator service to devcontainer docker-compose
- Add agent-framework-durabletask dependency
- Update AGENTS.md test plan
Add optional Azure DTS deployment (behind DEPLOY_DTS flag) so the
agent_durabletask example can run against a real DTS scheduler instead
of only the local emulator.

Infrastructure:
- infra/dts.bicep: scheduler + task hub + RBAC (Durable Task Data Contributor)
- main.bicep: conditional module call gated by deployDts param
- main.parameters.json, write_dot_env.sh/.ps1: wire DTS_ENDPOINT/DTS_TASKHUB

Example updates:
- Rework agent_durabletask.py into a realistic IT support scenario that
  naturally motivates the worker restart (user leaves to reboot laptop)
- Use sync DefaultAzureCredential for DTS SDK, async for OpenAI client
- Align with repo conventions: module-level client/agent setup,
  async main(), gpt-5.4 default, no unnecessary abstractions
- Update Spanish translation to match

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add agent_durabletask.py to the examples table
- Add optional DTS emulator Docker step under local environment setup
- Add 'Deploying the Durable Task Scheduler' section with azd env set
  DEPLOY_DTS instructions
- Update both English and Spanish READMEs

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Match the pattern used by REDIS_URL and OTEL — active local defaults
that azd provision overwrites with the Azure endpoint.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The earlier DTS commit accidentally replaced the AZURE_SEARCH_KNOWLEDGE_BASE_NAME
and AZURE_AI_PROJECT lines instead of appending. Restore them and fix stray
blank line and missing trailing newline.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 new Durable Task Scheduler (DTS) persistence demo and supporting local/devcontainer/Azure provisioning guidance so users can see agent session state survive worker restarts.

Changes:

  • Added new DTS demo scripts in English and Spanish (examples/agent_durabletask.py, examples/spanish/agent_durabletask.py).
  • Added optional Azure infrastructure for DTS (infra/dts.bicep) and wiring in infra/main.bicep + parameterization.
  • Updated devcontainer, env templates, and docs (README/AGENTS + Spanish README) to run the DTS emulator locally and deploy DTS in Azure.
Show a summary per file
File Description
pyproject.toml Adds agent-framework-durabletask dependency for the new demos.
infra/write_dot_env.sh Writes DTS outputs into .env after provisioning.
infra/write_dot_env.ps1 Same as above for Windows postprovision hook.
infra/main.parameters.json Adds deployDts parameter wired from DEPLOY_DTS.
infra/main.bicep Optionally provisions DTS and outputs DTS_ENDPOINT/DTS_TASKHUB.
infra/dts.bicep New module provisioning a scheduler + task hub + RBAC.
examples/agent_durabletask.py New English DTS persistence demo script.
examples/spanish/agent_durabletask.py New Spanish DTS persistence demo script.
README.md Documents running emulator locally and deploying DTS for the demo.
examples/spanish/README.md Spanish documentation for emulator + Azure DTS deployment for the demo.
AGENTS.md Adds DTS requirements section and example listing.
.env.sample Adds DTS env vars for configuring the demo.
.devcontainer/docker-compose.yml Adds dts-emulator service and sets DTS_ENDPOINT for the app container.
.devcontainer/devcontainer.json Forwards DTS dashboard port in devcontainer.

Copilot's findings

Tip

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

  • Files reviewed: 14/15 changed files
  • Comments generated: 7

Comment thread examples/agent_durabletask.py Outdated
Comment thread examples/spanish/agent_durabletask.py Outdated
Comment thread infra/dts.bicep Outdated
Comment thread .devcontainer/devcontainer.json
Comment thread infra/write_dot_env.sh Outdated
Comment thread infra/write_dot_env.ps1 Outdated
Comment thread .env.sample Outdated
- Use 'or' pattern for DTS_ENDPOINT/DTS_TASKHUB to treat empty strings
  as missing (both EN and ES examples)
- Parameterize ipAllowlist in dts.bicep (default: 0.0.0.0/0 for demo)
- Guard DTS vars in write_dot_env.sh/.ps1 so empty values aren't written
  when DTS isn't deployed
- Clarify .env.sample comment about devcontainer vs host endpoints

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

@madebygps madebygps left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Addressed all actionable comments — see individual replies. Pushed fix in 33e24be.

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