Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions durabletask-azurefunctions/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## v0.1.0

- Initial implementation
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
85 changes: 85 additions & 0 deletions durabletask-azurefunctions/durabletask/azurefunctions/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

import json

from datetime import timedelta
from typing import Any, Optional
import azure.functions as func

from durabletask.entities import EntityInstanceId
from durabletask.client import TaskHubGrpcClient
from durabletask.azurefunctions.internal.azurefunctions_grpc_interceptor import AzureFunctionsDefaultClientInterceptorImpl


# Client class used for Durable Functions
class DurableFunctionsClient(TaskHubGrpcClient):
taskHubName: str
connectionName: str
creationUrls: dict[str, str]
managementUrls: dict[str, str]
Comment on lines +19 to +20
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

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

[nitpick] Potential compatibility issue with type hint syntax. The use of dict[str, str] (PEP 585 style) requires Python 3.9+. While pyproject.toml specifies requires-python = ">=3.9", consider whether this is the intended minimum version or if Dict[str, str] from typing should be used for broader compatibility.

Copilot uses AI. Check for mistakes.
baseUrl: str
requiredQueryStringParameters: str
rpcBaseUrl: str
httpBaseUrl: str
maxGrpcMessageSizeInBytes: int
grpcHttpClientTimeout: timedelta

def __init__(self, client_as_string: str):
client = json.loads(client_as_string)

self.taskHubName = client.get("taskHubName", "")
self.connectionName = client.get("connectionName", "")
self.creationUrls = client.get("creationUrls", {})
self.managementUrls = client.get("managementUrls", {})
self.baseUrl = client.get("baseUrl", "")
self.requiredQueryStringParameters = client.get("requiredQueryStringParameters", "")
self.rpcBaseUrl = client.get("rpcBaseUrl", "")
self.httpBaseUrl = client.get("httpBaseUrl", "")
self.maxGrpcMessageSizeInBytes = client.get("maxGrpcMessageSizeInBytes", 0)
# TODO: convert the string value back to timedelta - annoying regex?
self.grpcHttpClientTimeout = client.get("grpcHttpClientTimeout", timedelta(seconds=30))
interceptors = [AzureFunctionsDefaultClientInterceptorImpl(self.taskHubName, self.requiredQueryStringParameters)]

# We pass in None for the metadata so we don't construct an additional interceptor in the parent class
# Since the parent class doesn't use anything metadata for anything else, we can set it as None
super().__init__(
host_address=self.rpcBaseUrl,
secure_channel=False,
metadata=None,
interceptors=interceptors)

def create_check_status_response(self, request: func.HttpRequest, instance_id: str) -> func.HttpResponse:
"""Creates an HTTP response for checking the status of a Durable Function instance.

Args:
request (func.HttpRequest): The incoming HTTP request.
instance_id (str): The ID of the Durable Function instance.
"""
raise NotImplementedError("This method is not implemented yet.")

def create_http_management_payload(self, instance_id: str) -> dict[str, str]:
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

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

[nitpick] Same PEP 585 type hint compatibility concern. The return type dict[str, str] requires Python 3.9+. Ensure this aligns with the minimum Python version requirement.

Copilot uses AI. Check for mistakes.
"""Creates an HTTP management payload for a Durable Function instance.

Args:
instance_id (str): The ID of the Durable Function instance.
"""
raise NotImplementedError("This method is not implemented yet.")

def read_entity_state(
self,
entity_id: EntityInstanceId,
task_hub_name: Optional[str],
connection_name: Optional[str]
) -> tuple[bool, Any]:
"""Reads the state of a Durable Entity.

Args:
entity_id (str): The ID of the Durable Entity.
task_hub_name (Optional[str]): The name of the task hub.
connection_name (Optional[str]): The name of the connection.

Returns:
(bool, Any): A tuple containing a boolean indicating if the entity exists and its state.
"""
raise NotImplementedError("This method is not implemented yet.")
13 changes: 13 additions & 0 deletions durabletask-azurefunctions/durabletask/azurefunctions/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

"""Constants used to determine the local running context."""
# TODO: Remove unused constants after module is complete
DEFAULT_LOCAL_HOST: str = 'localhost:7071'
DEFAULT_LOCAL_ORIGIN: str = f'http://{DEFAULT_LOCAL_HOST}'
DATETIME_STRING_FORMAT = '%Y-%m-%dT%H:%M:%S.%fZ'
HTTP_ACTION_NAME = 'BuiltIn::HttpActivity'
ORCHESTRATION_TRIGGER = "orchestrationTrigger"
ACTIVITY_TRIGGER = "activityTrigger"
ENTITY_TRIGGER = "entityTrigger"
DURABLE_CLIENT = "durableClient"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

"""Durable Task SDK for Python entities component"""

import durabletask.azurefunctions.decorators.durable_app as durable_app
import durabletask.azurefunctions.decorators.metadata as metadata

__all__ = ["durable_app", "metadata"]

PACKAGE_NAME = "durabletask.azurefunctions.decorators"
Loading
Loading