How do I send a list to Azure Durable Functions

Viewed 59

I have an architecture with two python functions: listcreator() and activity(). The listcreator() function is triggered by an http trigger and generates a list of strings. I want to pass this list of strings to an orchestrator function and call the activity() function multiple times.

How do I pass this to the orchestrator? Do I also need a starter function as desribed in the microsoft documents? https://docs.microsoft.com/nl-nl/azure/azure-functions/durable/quickstart-python-vscode

An oversimplified version of my code looks like this:

listcreator():

import azure.functions as func

def main(req: func.HttpRequest) -> func.HttpResponse
     mylist=['helo','world']
1 Answers

probably the best solution is to use your listcreator() function as Client function (the function you called as starter function). From the listcreator(), you can generate the list and pass it to the orchestrator. Finally from the orchestrator, pass the list to the activity function and run it.

A sketch of code:

# inside the client function call the orchestrato
client = df.DurableOrchestrationClient(starter)
instance_id = await client.start_new("yourorchestrator", None,  [1,2,3,4])

#inside orchestrator
data = context.get_input()
context.call_activity("activity", data)
Related