@@ -277,6 +277,42 @@ def __init__(self, *args, **kwargs):
277277 self ._function_builders : List [FunctionBuilder ] = []
278278 self ._app_script_file : str = SCRIPT_FILE_NAME
279279
280+ def _invoke_df_decorator (self , df_decorator ):
281+ """
282+ Invoke a Durable Functions decorator from the DF SDK, and store the
283+ resulting :class:`FunctionBuilder` object within the `DecoratorApi`.
284+
285+ """
286+
287+ @self ._configure_function_builder
288+ def wrap (fb ):
289+ def decorator ():
290+ function_builder = df_decorator (fb ._function ._func )
291+
292+ # remove old function builder from `self` and replace
293+ # it with the result of the DF decorator
294+ self ._function_builders .pop ()
295+ self ._function_builders .append (function_builder )
296+ return function_builder
297+ return decorator ()
298+ return wrap
299+
300+ def _get_durable_blueprint (self ):
301+ """Attempt to import the Durable Functions SDK from which DF decorators are
302+ implemented.
303+ """
304+
305+ try :
306+ import azure .durable_functions as df
307+ df_bp = df .Blueprint ()
308+ return df_bp
309+ except ImportError :
310+ error_message = "Attempted to use a Durable Functions decorator, " \
311+ "but the `azure-functions-durable` SDK package could not be " \
312+ "found. Please install `azure-functions-durable` to use " \
313+ "Durable Functions."
314+ raise Exception (error_message )
315+
280316 @property
281317 def app_script_file (self ) -> str :
282318 """Name of function app script file in which all the functions
@@ -443,6 +479,59 @@ def decorator():
443479
444480 return wrap
445481
482+ def orchestration_trigger (self , context_name : str ,
483+ orchestration : Optional [str ] = None ):
484+ """Register an Orchestrator Function.
485+
486+ Parameters
487+ ----------
488+ context_name: str
489+ Parameter name of the DurableOrchestrationContext object.
490+ orchestration: Optional[str]
491+ Name of Orchestrator Function.
492+ By default, the name of the method is used.
493+ """
494+ df_bp = self ._get_durable_blueprint ()
495+ df_decorator = df_bp .orchestration_trigger (context_name ,
496+ orchestration )
497+ result = self ._invoke_df_decorator (df_decorator )
498+ return result
499+
500+ def entity_trigger (self , context_name : str ,
501+ entity_name : Optional [str ] = None ):
502+ """Register an Entity Function.
503+
504+ Parameters
505+ ----------
506+ context_name: str
507+ Parameter name of the Entity input.
508+ entity_name: Optional[str]
509+ Name of Entity Function.
510+ """
511+
512+ df_bp = self ._get_durable_blueprint ()
513+ df_decorator = df_bp .entity_trigger (context_name ,
514+ entity_name )
515+ result = self ._invoke_df_decorator (df_decorator )
516+ return result
517+
518+ def activity_trigger (self , input_name : str ,
519+ activity : Optional [str ] = None ):
520+ """Register an Activity Function.
521+
522+ Parameters
523+ ----------
524+ input_name: str
525+ Parameter name of the Activity input.
526+ activity: Optional[str]
527+ Name of Activity Function.
528+ """
529+
530+ df_bp = self ._get_durable_blueprint ()
531+ df_decorator = df_bp .activity_trigger (input_name , activity )
532+ result = self ._invoke_df_decorator (df_decorator )
533+ return result
534+
446535 def timer_trigger (self ,
447536 arg_name : str ,
448537 schedule : str ,
@@ -1350,6 +1439,37 @@ def decorator():
13501439class BindingApi (DecoratorApi , ABC ):
13511440 """Interface to extend for using existing binding decorator functions."""
13521441
1442+ def durable_client_input (self ,
1443+ client_name : str ,
1444+ task_hub : Optional [str ] = None ,
1445+ connection_name : Optional [str ] = None
1446+ ):
1447+ """Register a Durable-client Function.
1448+
1449+ Parameters
1450+ ----------
1451+ client_name: str
1452+ Parameter name of durable client.
1453+ task_hub: Optional[str]
1454+ Used in scenarios where multiple function apps share the
1455+ same storage account but need to be isolated from each other.
1456+ If not specified, the default value from host.json is used.
1457+ This value must match the value used by the target
1458+ orchestrator functions.
1459+ connection_name: Optional[str]
1460+ The name of an app setting that contains a storage account
1461+ connection string. The storage account represented by this
1462+ connection string must be the same one used by the target
1463+ orchestrator functions. If not specified, the default storage
1464+ account connection string for the function app is used.
1465+ """
1466+ df_bp = self ._get_durable_blueprint ()
1467+ df_decorator = df_bp .durable_client_input (client_name ,
1468+ task_hub ,
1469+ connection_name )
1470+ result = self ._invoke_df_decorator (df_decorator )
1471+ return result
1472+
13531473 def service_bus_queue_output (self ,
13541474 arg_name : str ,
13551475 connection : str ,
0 commit comments