Edit

IChainableNode interface

Namespace: Microsoft.Azure.Workflows.Sdk

Defines the fluent chaining contract for composing workflow operations into sequential and parallel execution pipelines using the Then() method pattern. Both IWorkflowOperation and OperationChain implement this interface so you can compose linear and branched workflows fluently.

Usage

var trigger = WorkflowTriggers.BuiltIn.CreateHttpTrigger();
var compose = WorkflowActions.BuiltIn.Compose(inputs: () => "Hello").WithName("Greet");
var response = WorkflowActions.BuiltIn.Response(responseBody: () => $"{compose.Output}").WithName("Reply");

trigger
    .Then(compose)
    .Then(response);

Methods

Then(IWorkflowAction)

Chains a subsequent IWorkflowAction to run after the current node completes successfully. This is the standard overload for building sequential workflows.

OperationChain Then(IWorkflowAction action)
Name Description Type Required
action The action to append to the current chain. IWorkflowAction Yes
var trigger = WorkflowTriggers.BuiltIn.CreateHttpTrigger();
var compose = WorkflowActions.BuiltIn.Compose(inputs: () => "Hello").WithName("Greet");
var response = WorkflowActions.BuiltIn.Response(responseBody: () => $"{compose.Output}").WithName("Reply");

trigger
    .Then(compose)
    .Then(response);

Then(IWorkflowAction, FlowStatus[])

Chains a subsequent IWorkflowAction with explicit FlowStatus conditions. Use this overload when the appended action should run only after the previous action reaches one of the specified statuses.

OperationChain Then(IWorkflowAction action, FlowStatus[] runAfter)
Name Description Type Required
action The action to append to the current chain. IWorkflowAction Yes
runAfter The status values that allow the appended action to execute. FlowStatus[] Yes
var trigger = WorkflowTriggers.BuiltIn.CreateHttpTrigger();
var process = WorkflowActions.BuiltIn.Compose(inputs: () => "Process").WithName("Process");
var errorHandler = WorkflowActions.BuiltIn.Compose(inputs: () => "Error occurred").WithName("HandleError");

trigger
    .Then(process)
    .Then(errorHandler, runAfter: new[] { FlowStatus.Failed, FlowStatus.TimedOut });

Then(IWorkflowAction, RunAfter[])

Chains a subsequent IWorkflowAction with explicit per-predecessor RunAfter configuration. Use this overload in fan-in scenarios where the next action must wait for multiple predecessor chains.

OperationChain Then(IWorkflowAction action, RunAfter[] runAfter)
Name Description Type Required
action The action to append after the configured predecessors complete. IWorkflowAction Yes
runAfter The per-predecessor run-after definitions that control when the action executes. RunAfter[] Yes
var trigger = WorkflowTriggers.BuiltIn.CreateHttpTrigger();
var leftChain = trigger
    .Then(WorkflowActions.BuiltIn.Compose(inputs: () => "Left").WithName("Left"));
var rightChain = trigger
    .Then(WorkflowActions.BuiltIn.Compose(inputs: () => "Right").WithName("Right"));
var merged = WorkflowActions.BuiltIn.Compose(inputs: () => "Done").WithName("Merged");

leftChain
    .Join(rightChain)
    .Then(merged, runAfter: new[]
    {
        new RunAfter(leftChain, FlowStatus.Succeeded),
        new RunAfter(rightChain, FlowStatus.Succeeded),
    });

Then(Func<IChainableNode, OperationChain[]>)

Splits the current node into multiple parallel branches. The callback receives the current IChainableNode and must return OperationChain instances that share the same root node.

OperationChain Then(Func<IChainableNode, OperationChain[]> branches)
Name Description Type Required
branches A callback that creates one or more branches from the current node. Func<IChainableNode, OperationChain[]> Yes
var trigger = WorkflowTriggers.BuiltIn.CreateHttpTrigger();
var branch1 = WorkflowActions.BuiltIn.Compose(inputs: () => "Branch 1").WithName("Branch1");
var branch2 = WorkflowActions.BuiltIn.Compose(inputs: () => "Branch 2").WithName("Branch2");
var merged = WorkflowActions.BuiltIn.Compose(inputs: () => "Merged").WithName("Merged");

trigger
    .Then(parent => new[]
    {
        parent.Then(branch1),
        parent.Then(branch2),
    })
    .Then(merged);