-
Hello, Is it possible/recommended to start an orchestration trigger from another one. I would like to chain them without sub orchestrating them. I have 2 different non-static classes, I need the context from the first orchestrator in the next orchestrator that triggers activities. <TargetFramework>netcoreapp3.1</TargetFramework> public class A
{
[FunctionName(nameof(ProvCalloutOrchestrator))]
public async Task ProvCalloutOrchestrator(
[OrchestrationTrigger] IDurableOrchestrationContext ctx,
ILogger log)
{
var result = await new B(some params).DoSomething(ctx, log);
//here I use the result and the context populated with all the results of the activities triggered
}
}
public class B
{
[FunctionName(nameof(DoSubscriptionProvisioning))]
public async Task<Response> DoSomething(
[OrchestrationTrigger] IDurableOrchestrationContext ctx,
ILogger log)
{
//here I need the context sent as parameter, not a new one
//call another orchestration trigger with ctx as param and that orchestration trigger will fire activities
//the results from the activities will be populated in the context
}
} Thank you for your advices! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It's not possible to directly chain orchestrations like this. Can you explain why you want to chain them without sub-orchestrations? Or do you simply want to refactor your code into multiple methods? You can certainly pass the context object to other methods if you want. The runtime doesn't care how you factor your code - it will still be interpreted as a single orchestration. For example, you can do this: public class A
{
[FunctionName(nameof(ProvCalloutOrchestrator))]
public async Task ProvCalloutOrchestrator(
[OrchestrationTrigger] IDurableOrchestrationContext ctx,
ILogger log)
{
var result = await new B(some params).DoSomething(ctx, log);
//here I use the result and the context populated with all the results of the activities triggered
}
}
public class B
{
// NOTE: This is not a function. It's just a regular C# method.
public async Task<Response> DoSomething(
IDurableOrchestrationContext ctx,
ILogger log)
{
return await ctx.CallActivityAsync<Response>("GetResponse", null);
}
} |
Beta Was this translation helpful? Give feedback.
It's not possible to directly chain orchestrations like this. Can you explain why you want to chain them without sub-orchestrations?
Or do you simply want to refactor your code into multiple methods? You can certainly pass the context object to other methods if you want. The runtime doesn't care how you factor your code - it will still be interpreted as a single orchestration. For example, you can do this: