1+ import logging
2+ import azure .functions as func
3+ import azure .durable_functions as df
4+
5+ # To learn more about blueprints in the Python prog model V2,
6+ # see: https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-python?tabs=asgi%2Capplication-level&pivots=python-mode-decorators#blueprints
7+
8+ # Note, the `func` namespace does not contain Durable Functions triggers and bindings, so to register blueprints of
9+ # DF we need to use the `df` package's version of blueprints.
10+ bp = df .Blueprint ()
11+
12+ # We define a standard function-chaining DF pattern
13+
14+ @bp .route (route = "startOrchestrator" )
15+ @bp .durable_client_input (client_name = "client" )
16+ async def start_orchestrator (req : func .HttpRequest , client ):
17+ instance_id = await client .start_new ("my_orchestrator" )
18+
19+ logging .info (f"Started orchestration with ID = '{ instance_id } '." )
20+ return client .create_check_status_response (req , instance_id )
21+
22+ @bp .orchestration_trigger (context_name = "context" )
23+ def my_orchestrator (context : df .DurableOrchestrationContext ):
24+ result1 = yield context .call_activity ('say_hello' , "Tokyo" )
25+ result2 = yield context .call_activity ('say_hello' , "Seattle" )
26+ result3 = yield context .call_activity ('say_hello' , "London" )
27+ return [result1 , result2 , result3 ]
28+
29+ @bp .activity_trigger (input_name = "city" )
30+ def say_hello (city : str ) -> str :
31+ return f"Hello { city } !"
0 commit comments