Edit

WorkflowVariableActions class

Namespace: Microsoft.Azure.Workflows.Sdk

Provides factory methods for creating variable manipulation actions in Logic Apps workflows. Access this class through WorkflowBuiltInActions by using WorkflowActions.BuiltIn.Variables.

Usage

// Variable actions are accessed via WorkflowActions.BuiltIn.Variables
var trigger = WorkflowTriggers.BuiltIn.CreateHttpTrigger();

var init = WorkflowActions.BuiltIn.Variables.InitializeVariable<int>(
    name: () => "counter", value: () => 0).WithName("InitCounter");
var increment = WorkflowActions.BuiltIn.Variables.IncrementVariable<int>(
    name: () => "counter", value: () => 1).WithName("AddOne");

trigger.Then(init).Then(increment);
WorkflowFactory.CreateStatefulWorkflow("VariableExample", trigger);

Methods

InitializeVariable<T>(Expression<Func<string>> name, Expression<Func<T>> value)

Creates an IVariableWorkflowAction that declares a workflow variable with its initial value.

IVariableWorkflowAction InitializeVariable<T>(Expression<Func<string>> name, Expression<Func<T>> value)
Name Description Type Required
name Expression for the variable name. Expression<Func<string>> Yes
value Expression for the initial value. Expression<Func<T>> Yes
var initVar = WorkflowActions.BuiltIn.Variables.InitializeVariable<string>(
    name: () => "greeting",
    value: () => "Hello").WithName("InitGreeting");

SetVariable<T>(Expression<Func<string>> name, Expression<Func<T>> value)

Creates an IVariableWorkflowAction that assigns a new value to an existing workflow variable.

IVariableWorkflowAction SetVariable<T>(Expression<Func<string>> name, Expression<Func<T>> value)
Name Description Type Required
name Expression for the variable name. Expression<Func<string>> Yes
value Expression for the new value. Expression<Func<T>> Yes
var setVar = WorkflowActions.BuiltIn.Variables.SetVariable<string>(
    name: () => "greeting",
    value: () => "Updated greeting").WithName("UpdateGreeting");

IncrementVariable<T>(Expression<Func<string>> name, Expression<Func<T>> value)

Creates an IVariableWorkflowAction that increments a numeric variable.

IVariableWorkflowAction IncrementVariable<T>(Expression<Func<string>> name, Expression<Func<T>> value)
Name Description Type Required
name Expression for the variable name. Expression<Func<string>> Yes
value Expression for the increment value. Expression<Func<T>> Yes
var increment = WorkflowActions.BuiltIn.Variables.IncrementVariable<int>(
    name: () => "counter",
    value: () => 1).WithName("IncrementCounter");

DecrementVariable<T>(Expression<Func<string>> name, Expression<Func<T>> value)

Creates an IVariableWorkflowAction that decrements a numeric variable.

IVariableWorkflowAction DecrementVariable<T>(Expression<Func<string>> name, Expression<Func<T>> value)
Name Description Type Required
name Expression for the variable name. Expression<Func<string>> Yes
value Expression for the decrement value. Expression<Func<T>> Yes
var decrement = WorkflowActions.BuiltIn.Variables.DecrementVariable<int>(
    name: () => "counter",
    value: () => 1).WithName("DecrementCounter");

AppendToStringVariable

Creates an IVariableWorkflowAction that appends text to a string variable.

IVariableWorkflowAction AppendToStringVariable(Expression<Func<string>> name, Expression<Func<string>> value)
Name Description Type Required
name Expression for the variable name. Expression<Func<string>> Yes
value Expression for the string to append. Expression<Func<string>> Yes
var append = WorkflowActions.BuiltIn.Variables.AppendToStringVariable(
    name: () => "log",
    value: () => " new entry").WithName("AppendLog");

AppendToArrayVariable<T>(Expression<Func<string>> name, Expression<Func<T>> value)

Creates an IVariableWorkflowAction that appends a value to an array variable.

IVariableWorkflowAction AppendToArrayVariable<T>(Expression<Func<string>> name, Expression<Func<T>> value)
Name Description Type Required
name Expression for the variable name. Expression<Func<string>> Yes
value Expression for the value to append. Expression<Func<T>> Yes
var appendArray = WorkflowActions.BuiltIn.Variables.AppendToArrayVariable<string>(
    name: () => "items",
    value: () => "new item").WithName("AddItem");