Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Namespace: Microsoft.Azure.Workflows.Sdk
WorkflowFactory is the primary entry point for defining and registering Azure Logic Apps workflows. It creates stateful, stateless, and agent workflows from trigger-rooted graphs built with WorkflowTriggers, WorkflowActions, and OperationChain.
Usage
// Stateful workflow
var trigger = WorkflowTriggers.BuiltIn.CreateHttpTrigger();
trigger.Then(WorkflowActions.BuiltIn.Compose(inputs: () => "Hello").WithName("Greet"));
var stateful = WorkflowFactory.CreateStatefulWorkflow("MyStatefulFlow", trigger);
// Stateless workflow
var timer = WorkflowTriggers.BuiltIn.CreateRecurrenceTrigger();
timer.Then(WorkflowActions.BuiltIn.Compose(inputs: () => "Tick").WithName("Process"));
var stateless = WorkflowFactory.CreateStatelessWorkflow("MyStatelessFlow", timer);
// Agent workflow
var agentTrigger = WorkflowTriggers.BuiltIn.CreateConversationalAgentTrigger();
agentTrigger.Then(WorkflowActions.BuiltIn.Agent(
AgentModelType.OpenAI, "gpt-4", new AgentModelSettings(), "conn",
messages: () => new[] { new AgentPromptMessage { Role = "system", Content = "Hello" } }));
var agent = WorkflowFactory.CreateAgentWorkflow("MyAgentFlow", agentTrigger);
Methods
CreateStatefulWorkflow(String, IWorkflowTrigger)
Creates a durable stateful workflow from an IWorkflowTrigger. This overload throws InvalidOperationException if the supplied trigger is a ConversationalFlowTrigger.
public static FlowDefinition CreateStatefulWorkflow(string flowName, IWorkflowTrigger trigger)
| Name | Description | Type | Required |
|---|---|---|---|
| flowName | The unique workflow name. | string | Yes |
| trigger | The trigger that starts the workflow graph. | IWorkflowTrigger | Yes |
var trigger = WorkflowTriggers.BuiltIn.CreateHttpTrigger();
trigger.Then(WorkflowActions.BuiltIn.Compose(inputs: () => "Hello").WithName("Greet"));
var flow = WorkflowFactory.CreateStatefulWorkflow("MyStatefulFlow", trigger);
CreateStatefulWorkflow(String, OperationChain)
Creates a durable stateful workflow from an OperationChain. This overload extracts the trigger from the chain start and throws InvalidOperationException if the chain does not start with an IWorkflowTrigger or if that trigger is a ConversationalFlowTrigger.
public static FlowDefinition CreateStatefulWorkflow(string flowName, OperationChain chain)
| Name | Description | Type | Required |
|---|---|---|---|
| flowName | The unique workflow name. | string | Yes |
| chain | The operation chain whose start node must be a trigger. | OperationChain | Yes |
var trigger = WorkflowTriggers.BuiltIn.CreateHttpTrigger();
var chain = trigger
.Then(WorkflowActions.BuiltIn.Compose(inputs: () => "Step 1").WithName("Step1"))
.Then(WorkflowActions.BuiltIn.Compose(inputs: () => "Step 2").WithName("Step2"));
var flow = WorkflowFactory.CreateStatefulWorkflow("MyStatefulFlow", chain);
CreateStatelessWorkflow(String, IWorkflowTrigger)
Creates a lightweight stateless workflow from an IWorkflowTrigger. This overload throws InvalidOperationException if the supplied trigger is a ConversationalFlowTrigger.
public static FlowDefinition CreateStatelessWorkflow(string flowName, IWorkflowTrigger trigger)
| Name | Description | Type | Required |
|---|---|---|---|
| flowName | The unique workflow name. | string | Yes |
| trigger | The trigger that starts the workflow graph. | IWorkflowTrigger | Yes |
var timer = WorkflowTriggers.BuiltIn.CreateRecurrenceTrigger();
timer.Then(WorkflowActions.BuiltIn.Compose(inputs: () => "Tick").WithName("Process"));
var flow = WorkflowFactory.CreateStatelessWorkflow("MyStatelessFlow", timer);
CreateStatelessWorkflow(String, OperationChain)
Creates a lightweight stateless workflow from an OperationChain. This overload extracts the trigger from the chain start and throws InvalidOperationException if the chain does not start with an IWorkflowTrigger or if that trigger is a ConversationalFlowTrigger.
public static FlowDefinition CreateStatelessWorkflow(string flowName, OperationChain chain)
| Name | Description | Type | Required |
|---|---|---|---|
| flowName | The unique workflow name. | string | Yes |
| chain | The operation chain whose start node must be a trigger. | OperationChain | Yes |
var timer = WorkflowTriggers.BuiltIn.CreateRecurrenceTrigger();
var chain = timer.Then(WorkflowActions.BuiltIn.Compose(inputs: () => "Tick").WithName("Process"));
var flow = WorkflowFactory.CreateStatelessWorkflow("MyStatelessFlow", chain);
CreateAgentWorkflow(String, ConversationalFlowTrigger)
Creates an agent workflow from a ConversationalFlowTrigger. Agent workflows require a conversational trigger and cannot be created from standard HTTP or recurrence triggers.
public static FlowDefinition CreateAgentWorkflow(string flowName, ConversationalFlowTrigger trigger)
| Name | Description | Type | Required |
|---|---|---|---|
| flowName | The unique workflow name. | string | Yes |
| trigger | The conversational trigger that starts the agent workflow. | ConversationalFlowTrigger | Yes |
var agentTrigger = WorkflowTriggers.BuiltIn.CreateConversationalAgentTrigger();
agentTrigger.Then(WorkflowActions.BuiltIn.Agent(
AgentModelType.OpenAI,
"gpt-4",
new AgentModelSettings(),
"conn",
messages: () => new[] { new AgentPromptMessage { Role = "system", Content = "Hello" } }));
var flow = WorkflowFactory.CreateAgentWorkflow("MyAgentFlow", agentTrigger);
CreateAgentWorkflow(String, OperationChain)
Creates an agent workflow from an OperationChain. This overload extracts the trigger from the chain start and requires that the start node be a ConversationalFlowTrigger.
public static FlowDefinition CreateAgentWorkflow(string flowName, OperationChain chain)
| Name | Description | Type | Required |
|---|---|---|---|
| flowName | The unique workflow name. | string | Yes |
| chain | The operation chain whose start node must be a conversational trigger. | OperationChain | Yes |
var agentTrigger = WorkflowTriggers.BuiltIn.CreateConversationalAgentTrigger();
var chain = agentTrigger.Then(WorkflowActions.BuiltIn.Agent(
AgentModelType.OpenAI,
"gpt-4",
new AgentModelSettings(),
"conn",
messages: () => new[] { new AgentPromptMessage { Role = "system", Content = "Hello" } }));
var flow = WorkflowFactory.CreateAgentWorkflow("MyAgentFlow", chain);
ConfigureServices
Registers the Logic Apps SDK runtime services in an IServiceCollection, including the workflow initialization infrastructure and required runtime services.
public static void ConfigureServices(IServiceCollection services)
| Name | Description | Type | Required |
|---|---|---|---|
| services | The dependency injection service collection to configure. | IServiceCollection | Yes |
IServiceCollection services = new ServiceCollection();
WorkflowFactory.ConfigureServices(services);
Related Content
- AgentToolContext Class Definition
- IChainableNode Interface Definition
- IVariableWorkflowAction Interface Definition
- IWorkflowAction Interface Definition
- IWorkflowOperation Interface Definition
- IWorkflowProvider Interface Definition
- IWorkflowTrigger Interface Definition
- OperationChain Class Definition
- Typed Workflow Action Interfaces Definition
- Typed Workflow Trigger Interfaces Definition
- WorkflowActionBase Class Definition
- WorkflowActions Class Definition
- WorkflowBuiltInActions Class Definition
- WorkflowBuiltInTriggers Class Definition
- WorkflowContext Class Definition
- WorkflowControlActions Class Definition
- WorkflowManagedActions Class Definition
- WorkflowManagedTriggers Class Definition
- WorkflowProviderExtensions Class Definition
- WorkflowTriggerBase Class Definition
- WorkflowTriggers Class Definition
- WorkflowVariableActions Class Definition