{"id":5125,"library":"azure-functions-durable","title":"Durable Functions for Python","description":"Durable Functions is an extension of Azure Functions that enables developers to write stateful functions in a serverless environment. It allows defining stateful workflows using orchestrator functions and stateful entities with entity functions. The extension automatically manages state, checkpoints, and restarts, abstracting away complex state management concerns. The current stable version is 1.5.0, with ongoing active development and regular releases.","status":"active","version":"1.5.0","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-functions-durable-python","tags":["azure","serverless","durable functions","orchestration","stateful","workflow"],"install":[{"cmd":"pip install azure-functions-durable","lang":"bash","label":"Install via pip"}],"dependencies":[{"reason":"Core library for Azure Functions programming model, providing decorators and runtime context.","package":"azure-functions","optional":false},{"reason":"Used for HTTP operations; updated in v1.3.3.","package":"aiohttp","optional":false}],"imports":[{"note":"Represents the context for an orchestration function's execution.","symbol":"DurableOrchestrationContext","correct":"from azure.durable_functions import DurableOrchestrationContext"},{"note":"Represents the client for interacting with Durable Functions orchestrations.","symbol":"DurableOrchestrationClient","correct":"from azure.durable_functions import DurableOrchestrationClient"},{"note":"Used to organize Durable Functions (orchestrators, activities, clients) into modular blueprints in the v2 programming model.","symbol":"Blueprint","correct":"from azure.durable_functions import Blueprint"},{"note":"Decorator for defining an orchestrator function.","symbol":"orchestration_trigger","correct":"from azure.durable_functions import orchestration_trigger"},{"note":"Decorator for defining an activity function.","symbol":"activity_trigger","correct":"from azure.durable_functions import activity_trigger"},{"note":"Decorator for injecting a Durable Functions client into a starter function (e.g., HTTP trigger).","symbol":"durable_client_input","correct":"from azure.durable_functions import durable_client_input"}],"quickstart":{"code":"import logging\nimport os\nimport azure.functions as func\nimport azure.durable_functions as df\n\n# Instantiate a Durable Functions Blueprint\nbp = df.Blueprint()\n\n# An HTTP-triggered function that starts an instance of the orchestration\n@bp.route(route=\"startOrchestrator\")\n@bp.durable_client_input(client_name=\"client\")\nasync def start_orchestrator(req: func.HttpRequest, client: df.DurableOrchestrationClient):\n    orchestration_id = await client.start_new(\"my_orchestrator\", None, \"World\")\n    logging.info(f\"Started orchestration with ID = '{orchestration_id}'.\")\n    return client.create_check_status_response(req, orchestration_id)\n\n# The orchestrator function, which orchestrates calls to other functions\n@bp.orchestration_trigger(context_name=\"context\")\ndef my_orchestrator(context: df.DurableOrchestrationContext):\n    # The orchestrator is deterministic, so use context.call_activity for side-effects\n    result1 = yield context.call_activity('say_hello', \"Tokyo\")\n    result2 = yield context.call_activity('say_hello', \"Seattle\")\n    result3 = yield context.call_activity('say_hello', \"London\")\n    return [result1, result2, result3]\n\n# An activity function, which performs the actual work\n@bp.activity_trigger(input_name=\"city\")\ndef say_hello(city: str) -> str:\n    logging.info(f\"Saying hello to {city}.\")\n    return f\"Hello {city}!\"\n\n# In your main function_app.py, register the blueprint:\n# import azure.functions as func\n# from your_module_name import bp\n# app = func.FunctionApp()\n# app.register_functions(bp)","lang":"python","description":"This quickstart demonstrates a basic 'Hello World' Durable Functions application using the Python v2 programming model and blueprints. It includes an HTTP-triggered starter function, an orchestrator function that calls an activity function multiple times in parallel (fan-out/fan-in pattern), and the activity function itself. To run this, you would typically set up an Azure Functions project locally, install `azure-functions-durable`, and ensure `AzureWebJobsStorage` is configured (e.g., to `UseDevelopmentStorage=true` for local Azurite)."},"warnings":[{"fix":"Replace non-deterministic calls with `context.current_utc_datetime` or encapsulate non-deterministic logic within activity functions, passing their results back to the orchestrator. Avoid modifying orchestrator code for active instances without careful planning.","message":"Orchestrator functions MUST be deterministic. Avoid using non-deterministic APIs like `datetime.now()`, `datetime.utcnow()`, `random.*`, static variables, or environment variables directly within orchestrators. Instead, use `context.current_utc_datetime` for time or pass non-deterministic values via activity function results or as inputs to the orchestrator. Violating this can lead to `NonDeterministicOrchestrationException` due to replay mismatches.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure you are using `azure-functions-durable` version 1.2.8 or higher. If you encounter issues, explicitly upgrade your package: `pip install --upgrade azure-functions-durable>=1.2.8`.","message":"Version 1.2.7 of `azure-functions-durable` was yanked from PyPI due to a critical startup error. Installing or running this specific version will lead to failures.","severity":"breaking","affected_versions":"1.2.7"},{"fix":"Ensure your Azure Functions project and local development environment use Python 3.9 or a newer supported version (e.g., 3.10, 3.11).","message":"The Python version requirement has been updated. Older versions (e.g., Python 3.6) are no longer supported. The library now requires Python 3.9 or higher.","severity":"gotcha","affected_versions":"<1.3.1 (for Python 3.6 support), all versions (for current >=3.9)"},{"fix":"For local development, install and start Azurite, and ensure your `local.settings.json` has `\"AzureWebJobsStorage\": \"UseDevelopmentStorage=true\"`. For cloud deployment, configure `AzureWebJobsStorage` to an Azure Storage account connection string.","message":"Local development of Durable Functions requires a storage emulator (like Azurite) or a connection to an Azure Storage account. Without it, functions will fail to start or store state.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}