Reputation: 1351
I am statrting new with Azure Durable functions, and I followed the tutorials and was able to run it without any error. As I see, my requirement will be to take output from one of the activity function and use as an input to other activity function, also the other activity function shouldnt start, unless the previous activity function has been completed. How can I do this?
Here is the code which runs: I would like "Hello" activity function return value which is src_client should be used as an input to activity function "Goodbye"
import logging
import json
import azure.functions as func
import azure.durable_functions as df
def orchestrator_function(context: df.DurableOrchestrationContext):
result1 = yield context.call_activity('Hello', "bestday-demo")
result2 = yield context.call_activity('Goodbye', "Seattle")
result3 = yield context.call_activity('Hello', "London")
return [result1, result2, result3]
main = df.Orchestrator.create(orchestrator_function)
and this is my activity function "Hello"
import logging
from myownsdk import myClient
def main(projectname: str) -> str:
SRC_PROJECT_DAY = projectname
src_client = myClient(
api_key= "Myapikey",
client_name= "Proj-DEMO_CLIENT",
project = SRC_PROJECT_DAY,
debug=False
)
return f"{src_client}"
and this is my activity function "Goodbye". This returns "Goodbye Seattle", but I would like to pass my src_client from Hello activity function and use that to get some more results.
import logging
from myownsdk import myClient
def main(name: str) -> str:
return f"GoodBye {name}!"
Also how can i make sure, Goodbye runs only when Hello has been exceuted and completed. Thanks for help.
Upvotes: 1
Views: 1840
Reputation: 2440
This is because you are calling goodbye function and the string Seattle in result2 and there is no way the orchestration is happening.
I observe that your orchestrator function isn't same when compared to original document So please make sure that you are calling it in a right way , As per the below code try to make changes in your code.
import azure.functions as func
import azure.durable_functions as df
def orchestrator_function(context: df.DurableOrchestrationContext):
result1 = yield context.call_activity('Hello', "bestday-demo")
result2 = yield context.call_activity('Goodbye', result1)
result3 = yield context.call_activity('Hello', result2)
return result3
main = df.Orchestrator.create(orchestrator_function)
Also, try to make changes in your Good Bye Activity Function.
import logging
from myownsdk import myClient
def main(name: str) -> str:
return f"GoodBye seattle {name}!"
Upvotes: 3