Edit

WorkflowBuiltInActions class

Namespace: Microsoft.Azure.Workflows.Sdk

Provides factory methods for creating built-in workflow actions that run directly in the Logic Apps runtime. Access this class through WorkflowActions by using WorkflowActions.BuiltIn to create data transformation, HTTP, response, nested workflow, custom code, and agent actions.

Usage

// Built-in actions are accessed via WorkflowActions.BuiltIn
var compose = WorkflowActions.BuiltIn.Compose(inputs: () => "Hello").WithName("Greet");
var http = WorkflowActions.BuiltIn.HttpAction(
    uri: () => new Uri("https://api.example.com"),
    method: () => HttpMethod.Post,
    requestBody: () => new { message = "test" }).WithName("PostData");
var response = WorkflowActions.BuiltIn.Response(
    responseBody: () => $"{http.Body}").WithName("Reply");

// Chain actions in a workflow
var trigger = WorkflowTriggers.BuiltIn.CreateHttpTrigger();
trigger.Then(compose).Then(http).Then(response);

Properties

Name Description Type Required
Control Gets the factory for control flow actions such as Scope, Condition, ForEach, Until, Switch, and Terminate. WorkflowControlActions No
Variables Gets the factory for variable actions such as initialize, set, increment, decrement, and append operations. WorkflowVariableActions No

Methods

Compose

Creates a Compose action and returns an IOutputWorkflowAction<JToken> whose output can be referenced by later actions.

IOutputWorkflowAction<JToken> Compose(Expression<Func<string>> inputs)
Name Description Type Required
inputs Expression for the inputs to compose. Expression<Func<string>> Yes
var compose = WorkflowActions.BuiltIn.Compose(inputs: () => "Hello World").WithName("Greet");

Compose<T>(Expression<Func<T>> input)

Creates a typed Compose action and returns an IOutputWorkflowAction<T> for strongly typed output references.

IOutputWorkflowAction<T> Compose<T>(Expression<Func<T>> input)
Name Description Type Required
input Expression for the typed input to compose. Expression<Func<T>> Yes
var typed = WorkflowActions.BuiltIn.Compose<int>(input: () => 42).WithName("Answer");

HttpAction

Creates an HTTP action and returns an IBodyWorkflowAction<JToken> for calling external endpoints.

IBodyWorkflowAction<JToken> HttpAction(Expression<Func<Uri>> uri, Expression<Func<HttpMethod>> method, Expression<Func<object>> requestBody = null, Expression<Func<Dictionary<string, string>>> queries = null, Expression<Func<Dictionary<string, string>>> headers = null)
Name Description Type Required
uri Expression for the request URI. Expression<Func<Uri>> Yes
method Expression for the HTTP method. Expression<Func<HttpMethod>> Yes
requestBody Expression for the request body. Expression<Func<object>> No
queries Expression for query parameters. Expression<Func<Dictionary<string, string>>> No
headers Expression for request headers. Expression<Func<Dictionary<string, string>>> No
var http = WorkflowActions.BuiltIn.HttpAction(
    uri: () => new Uri("https://api.example.com/data"),
    method: () => HttpMethod.Get,
    headers: () => new Dictionary<string, string> { ["Authorization"] = "Bearer token" })
    .WithName("CallAPI");

Response

Creates a response action and returns an IBodyWorkflowAction<JToken> for sending an HTTP response from a request workflow.

IBodyWorkflowAction<JToken> Response(Expression<Func<HttpStatusCode>> statusCode = null, Expression<Func<object>> responseBody = null, Expression<Func<Dictionary<string, string>>> headers = null, Expression<Func<JToken>> schema = null)
Name Description Type Required
statusCode Expression for the HTTP status code. Expression<Func<HttpStatusCode>> No
responseBody Expression for the response body. Expression<Func<object>> No
headers Expression for response headers. Expression<Func<Dictionary<string, string>>> No
schema Expression for the response schema. Expression<Func<JToken>> No
var response = WorkflowActions.BuiltIn.Response(
    statusCode: () => HttpStatusCode.OK,
    responseBody: () => "Success").WithName("SendResponse");

CustomCode<T>(Func<WorkflowContext, Task<T>> callback)

Creates a custom code action and returns an IBodyWorkflowAction<T> that executes inline C# against a WorkflowContext.

IBodyWorkflowAction<T> CustomCode<T>(Func<WorkflowContext, Task<T>> callback)
Name Description Type Required
callback The async callback to execute. Func<WorkflowContext, Task<T>> Yes
var custom = WorkflowActions.BuiltIn.CustomCode<string>(async (context) =>
{
    var result = await context.GetTriggerResults();
    return "Processed";
}).WithName("RunCode");

NestedWorkflow

Creates a nested workflow action and returns an IBodyWorkflowAction<JToken> that invokes another workflow by reference name.

IBodyWorkflowAction<JToken> NestedWorkflow(Expression<Func<string>> workflowReferenceName, Expression<Func<object>> requestBody = null, Expression<Func<Dictionary<string, string>>> headers = null)
Name Description Type Required
workflowReferenceName Reference name of the child workflow. Expression<Func<string>> Yes
requestBody Request body for the child workflow. Expression<Func<object>> No
headers Request headers for the child workflow. Expression<Func<Dictionary<string, string>>> No
var nested = WorkflowActions.BuiltIn.NestedWorkflow(
    workflowReferenceName: () => "ChildWorkflow",
    requestBody: () => new { name = "test" }).WithName("CallChild");

Agent

Creates an AgentAction that sends prompt messages to an AI model configured for an agent workflow.

AgentAction Agent(AgentModelType agentModelType, string deploymentId, AgentModelSettings agentModelSettings, string connectionName, Expression<Func<AgentPromptMessage[]>> messages)
Name Description Type Required
agentModelType The AI model type, such as OpenAI. AgentModelType Yes
deploymentId The model deployment identifier. string Yes
agentModelSettings Configuration for the agent model. AgentModelSettings Yes
connectionName The connection name for the AI service. string Yes
messages Expression for the prompt messages array. Expression<Func<AgentPromptMessage[]>> Yes
var agent = WorkflowActions.BuiltIn.Agent(
    agentModelType: AgentModelType.OpenAI,
    deploymentId: "gpt-4",
    agentModelSettings: new AgentModelSettings(),
    connectionName: "openai-connection",
    messages: () => new[] { new AgentPromptMessage { Role = "system", Content = "You are helpful" } });