In my project there are around 6 azure functions which are required to run in a sequence based on some JSON configuration.
The Configuration looks like this
{
"configurations": [
{
"Name": "Function1",
"Sequence": 1
},
{
"Name": "Function2",
"Sequence": 2
},
{
"Name": "Function3",
"Sequence": 2
},
{
"Name": "Function4",
"Sequence": 3
},
{
"Name": "Function5",
"Sequence": 4
},
{
"Name": "Function6",
"Sequence": 5
}
]
}
Which means, first it should trigger function1, then function2 and function3. when both function2 and 3 completed function 4 should execute.. then 5,6
I know for chaining in orchestration function it is like this
[FunctionName(nameof(FunctionChaining))]
public static async Task<List<string>> FunctionChainingRunOrchestrator(
[OrchestrationTrigger]
IDurableOrchestrationContext context)
{
// Serial calls
await context.CallActivityAsync<string>(
nameof(Function1), "param1");
await context.CallActivityAsync<string>(
nameof(Function2), "param2");
await context.CallActivityAsync<string>(
nameof(Function3), "param3");
}
and for parallel calls
[FunctionName(nameof(parallelcalls))]
public static async Task<List<string>> ParallelOrchestrator(
[OrchestrationTrigger]
IDurableOrchestrationContext context)
{
// Parallel calls
var tasks = new List<Task<string>>();
tasks.Add(context.CallActivityAsync<string>(
nameof(Function2),
"param1"));
tasks.Add(context.CallActivityAsync<string>(
nameof(Function3),
"param2"));
await Task.WhenAll(tasks);
}
So I need to fire function1 then when it completes 2 & 3 together when await Task.WhenAll(tasks);, I need to fire function 4 and 5 as just chaining
But I really dont know how to make it like a workflow based on my configuration. I am with durable function just for a day...
Please help