{"id":7195,"library":"durabletask-azuremanaged","title":"Durable Task Azure Managed Provider","description":"`durabletask-azuremanaged` is a Python library that provides an implementation for the `durabletask` SDK, enabling Python applications to leverage Azure's Durable Task Scheduler. It allows developers to define, run, and manage long-running, stateful workflows and orchestrations on Azure by integrating with its managed infrastructure for reliable task execution. As of version 1.4.0, it aligns with the `durabletask-py` SDK, typically seeing new releases in conjunction with the broader SDK's development.","status":"active","version":"1.4.0","language":"python","source_language":"en","source_url":"https://github.com/Azure/durabletask-py/tree/main/durabletask-azuremanaged","tags":["azure","durable-task","orchestration","workflow","serverless","cloud"],"install":[{"cmd":"pip install durabletask-azuremanaged","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"This library is a provider for the core Durable Task Python SDK.","package":"durabletask","optional":false}],"imports":[{"wrong":"from durabletask import AzureManagedTaskHub","symbol":"AzureManagedTaskHub","correct":"from durabletask import AzureManagedTaskHub"}],"quickstart":{"code":"import asyncio\nimport os\nfrom durabletask.client import TaskHubClient\nfrom durabletask.orchestration import OrchestrationContext, orchestrator\nfrom durabletask.worker import Worker\nfrom durabletask_azuremanaged.azure_managed_task_hub import AzureManagedTaskHub\n\nasync def run_orchestration_sample():\n    # Configure Azure Managed Task Hub with connection string and task hub name\n    # AZURE_DURABLETASK_CONNECTION_STRING: Primary/Secondary connection string\n    #     from the Azure Durable Task Hub resource.\n    # AZURE_DURABLETASK_HUB_NAME: A globally unique name for your task hub within the region.\n    connection_string = os.environ.get(\"AZURE_DURABLETASK_CONNECTION_STRING\", \"\")\n    task_hub_name = os.environ.get(\"AZURE_DURABLETASK_HUB_NAME\", \"MyPythonTaskHub\")\n\n    if not connection_string:\n        print(\"Please set the AZURE_DURABLETASK_CONNECTION_STRING environment variable.\")\n        return\n\n    # 1. Initialize the Azure Managed Task Hub backend\n    task_hub = AzureManagedTaskHub(\n        connection_string=connection_string,\n        task_hub_name=task_hub_name\n    )\n\n    # 2. Define an orchestrator function\n    @orchestrator\n    async def my_orchestrator(context: OrchestrationContext, input_value: str):\n        print(f\"Orchestration '{context.instance_id}' started with input: {input_value}\")\n        result = await context.call_activity(\"my_activity\", input_value)\n        print(f\"Activity returned: {result}\")\n        return f\"Orchestration completed with result: {result}\"\n\n    # 3. Define an activity function\n    async def my_activity(context: OrchestrationContext, value: str):\n        print(f\"Activity '{context.instance_id}' received: {value}\")\n        await asyncio.sleep(1) # Simulate some work\n        return f\"Processed: {value.upper()}\"\n\n    # 4. Initialize the Worker and register orchestrator/activity\n    worker = Worker(task_hub)\n    worker.add_orchestrator(my_orchestrator)\n    worker.add_activity(\"my_activity\", my_activity)\n\n    # 5. Initialize the TaskHubClient for scheduling orchestrations\n    client = TaskHubClient(task_hub)\n\n    # 6. Start the worker in the background (essential for processing tasks)\n    worker_task = asyncio.create_task(worker.run())\n\n    try:\n        # 7. Schedule a new orchestration\n        print(\"Scheduling new orchestration...\")\n        instance_id = await client.schedule_new_orchestration(my_orchestrator, \"Hello DurableTask!\")\n        print(f\"Orchestration instance ID: {instance_id}\")\n\n        # 8. Wait for the orchestration to complete\n        status = await client.wait_for_completion(instance_id, timeout=30)\n        print(f\"\\nOrchestration '{instance_id}' completed with status: {status.runtime_status}\")\n        print(f\"Output: {status.output}\")\n\n    finally:\n        # 9. Clean up: Shut down the worker\n        print(\"\\nShutting down worker...\")\n        worker_task.cancel()\n        try:\n            await worker_task\n        except asyncio.CancelledError:\n            pass # Expected when cancelling\n        await worker.shutdown()\n\nif __name__ == \"__main__\":\n    asyncio.run(run_orchestration_sample())","lang":"python","description":"This quickstart demonstrates how to set up `durabletask-azuremanaged` by configuring an `AzureManagedTaskHub` using environment variables. It then defines a simple orchestrator and activity, initializes a `Worker` to process them, and uses a `TaskHubClient` to schedule and monitor an orchestration. Ensure `AZURE_DURABLETASK_CONNECTION_STRING` and `AZURE_DURABLETASK_HUB_NAME` are set in your environment before running."},"warnings":[{"fix":"Ensure both `durabletask` and `durabletask-azuremanaged` are installed at compatible `1.x` versions or newer (e.g., `pip install durabletask durabletask-azuremanaged`).","message":"The `durabletask` SDK underwent significant breaking changes leading up to its `1.0.0` release. `durabletask-azuremanaged` versions 1.x are specifically designed for `durabletask` 1.x and are not compatible with older `durabletask` 0.x SDK versions.","severity":"breaking","affected_versions":"<1.0.0 (durabletask-azuremanaged) vs. <1.0.0 (durabletask)"},{"fix":"Choose a descriptive and globally unique `task_hub_name`. Consider including project, environment, and region in the name (e.g., `MyProjectDevEastUS`).","message":"The `task_hub_name` provided to `AzureManagedTaskHub` must be globally unique within a specific Azure region if using public endpoints. Reusing names can lead to conflicts, unexpected behavior, or data corruption.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always ensure your worker process(es) are deployed, running, and properly initialized to poll the task hub for new tasks. For development, run your worker in a separate thread or process, or alongside your client for testing.","message":"Orchestrations and activities will not execute or progress if a `durabletask.worker.Worker` instance configured with the same `AzureManagedTaskHub` is not actively running and connected.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Store `AZURE_DURABLETASK_CONNECTION_STRING` securely using environment variables, Azure Key Vault, or managed identities for production deployments. Avoid hardcoding credentials in source code.","message":"Azure connection strings for the Durable Task Hub typically include shared access keys. Managing these securely, for example, via Azure Key Vault or environment variables, is crucial. Hardcoding them is a security risk.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'1.4.0':61 'align':63 'allow':32 'applic':23 'azur':3,26,47,82 'azuremanag':8 'broader':78 'cloud':89 'conjunct':75 'defin':35 'develop':33,81 'durabl':1,28,84 'durable-task':83 'durabletask':7,19,67 'durabletask-azuremanag':6 'durabletask-pi':66 'enabl':21 'execut':57 'implement':16 'infrastructur':53 'integr':49 'leverag':25 'librari':12 'long':40 'long-run':39 'manag':4,38,52 'new':72 'orchestr':45,86 'provid':5,14 'py':68 'python':11,22 'releas':73 'reliabl':55 'run':36,41 'schedul':30 'sdk':20,69,79 'see':71 'serverless':88 'state':42 'task':2,29,56,85 'typic':70 'version':60 'workflow':43,87","created_at":"2026-04-16T13:47:49.274241+00:00","updated_at":"2026-04-16T13:47:49.274241+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\nImportError: cannot import name 'AzureManagedTaskHub' from 'durabletask' (/tmp/tmppfnioj0k/venv/lib/python3.12/site-packages/durabletask/__init__.py)"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.5.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/microsoft/durabletask-python","docs":null,"changelog":"https://github.com/microsoft/durabletask-python/blob/main/CHANGELOG.md","pypi":"https://pypi.org/project/durabletask-azuremanaged/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["azure","workflow"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}