Durable Task Python SDK provider implementation for Durable Azure Functions
Project description
Azure Functions Durable (Python) — 2.x
azure-functions-durable is the Python SDK provider for
Durable Azure Functions,
built on top of the durabletask SDK.
[!NOTE] 2.x is a ground-up rewrite of the Durable Functions Python SDK on top of the
durabletaskruntime. It is currently a preview (beta) release; APIs may change before the stable 2.0.0.
Requirements
- Python 3.13+
- The decorator-based Azure Functions programming model (
DFApp/Blueprint)
Installation
pip install azure-functions-durable
Overview
Author orchestrations, activities, and entities as Azure Functions and let the
Durable Task runtime handle scheduling, checkpointing, and replay. Both
durabletask-native two-argument functions (def orchestrator(ctx, input)) and
v1-style single-argument functions (def orchestrator(context)) are supported,
along with class-based entities and a compatibility layer over the v1 API.
Key capabilities include durable orchestrations and sub-orchestrations, durable
timers, external events, durable entities, retries, versioning, durable HTTP
calls (context.call_http(...)), recurring scheduled tasks, and history export.
Unit testing entities
Use execute_entity() to run one entity operation in-process without a
Functions host or Durable Task backend. It supports v1-style entity functions,
durabletask-native entity functions, and DurableEntity subclasses:
from azure.durable_functions.testing import execute_entity
from durabletask.entities import DurableEntity
class Counter(DurableEntity):
def add(self, amount: int) -> int:
value = self.get_state(int, 0) + amount
self.set_state(value)
return value
outcome = execute_entity(Counter, "add", input=2, state=3)
assert outcome.get_result() == 5
assert outcome.get_state() == 5
assert outcome.actions == ()
For an entity_trigger-decorated function, pass the exposed entity function:
import azure.durable_functions as df
from azure.durable_functions.testing import execute_entity
app = df.DFApp()
@app.entity_trigger(context_name="context")
def counter(context: df.DurableEntityContext) -> None:
value = context.get_state(initializer=lambda: 0)
value += context.get_input()
context.set_state(value)
context.set_result(value)
entity_function = counter.build().get_user_function().entity_function
outcome = execute_entity(entity_function, "add", input=2, state=3)
assert outcome.get_result() == 5
assert outcome.get_state() == 5
The returned EntityTestResult provides get_result() and get_state()
methods plus typed signal or orchestration-start actions scheduled by the
operation. Pass expected_type when reconstructing a custom payload:
assert outcome.get_state(expected_type=CounterState) == CounterState(value=5)
Links
- 2.x samples
- Migration guide from 1.x
- Changelog
- Durable Functions documentation
durabletaskon PyPI- Azure Functions Durable 1.x source
- Azure Functions Python library
- Azure Functions Python worker
- Repository
License
Licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file azure_functions_durable-2.0.0b2.tar.gz.
File metadata
- Download URL: azure_functions_durable-2.0.0b2.tar.gz
- Upload date:
- Size: 54.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: RestSharp/106.13.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f94d5003f5eee28433961dfdf50189bcd0044dec59150f7be897bd88cefd4eab
|
|
| MD5 |
a5ce824b5fcf865e50bee5e0e5f08eaf
|
|
| BLAKE2b-256 |
4d5fe15519f9879bbbe76c8aa13cbac3ddf190722cccfb3722bb42c904fa7f98
|
File details
Details for the file azure_functions_durable-2.0.0b2-py3-none-any.whl.
File metadata
- Download URL: azure_functions_durable-2.0.0b2-py3-none-any.whl
- Upload date:
- Size: 69.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: RestSharp/106.13.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
492c57e462664dd8fb1b6cd8c6938681f282f703a51253b74c6700ba185894bb
|
|
| MD5 |
568643a7d3107d89c525d36e2b986e4f
|
|
| BLAKE2b-256 |
b666ba9db851353200a42d192fd4bb168adfb4c9a6e6b1ba32c7a37bac9e2d71
|