Creating a Logic App that showcases the use of all variable types

Creating a Logic App that demonstrates the usage of all variable types (string, integer, boolean, array, float, and object) involves initializing, manipulating, and using these variables within the workflow.

Steps to Create a Logic App with All Variable Types

  1. Create a Logic App:
    • Go to the Azure portal.
    • Click on “Create a resource” and search for “Logic App”.
    • Follow the prompts to create a new Logic App.
  2. Add a Trigger:
    • Open the Logic App in the designer.
    • Add a trigger to start the workflow. For example, use an HTTP Request trigger to start the workflow manually.
  3. Initialize Variables:
    • Add actions to initialize variables of different types:
      • String: A text variable.
      • Integer: A numeric variable.
      • Boolean: A true/false variable.
      • Array: A list of items.
      • Object: A JSON object.
      • Float: A decimal variable.
  4. Manipulate Variables:
    • Add actions to modify or use the variables:
      • Append to a string.
      • Increment an integer.
      • Toggle a boolean.
      • Add items to an array.
      • Update properties of an object.
      • Decrement an decimal.
  5. Output Variables:
    • Use the Response action to return the final values of all variables.

Example Workflow

Trigger:

  • Use a HTTP Request trigger to run the workflow manually.

2. Initialize Variables:

  • Add an Initialize variable action for each variable type:
    • String Variable:
      • Name: myString
      • Type: String
      • Value: "Hello,"
    • Integer Variable:
      • Name: myInteger
      • Type: Integer
      • Value: 10
    • Boolean Variable:
      • Name: myBoolean
      • Type: Boolean
      • Value: true
    • Array Variable:
      • Name: myArray
      • Type: Array
      • Value: ["Apple", "Banana", "Cherry"]
    • Object Variable:
      • Name: myObject
      • Type: Object
      • Value: { "name": "John", "age": 30, "isActive": true }
    • Float Variable:
      • Name: myFloat
      • Type: Float
      • Value: 12.34

3. Manipulate Variables:

  • Append to String:
    • Use the Append to string variable action to append text to myString:
      • Name: myString
      • Value: "World!"
  • Increment Integer:
    • Use the Increment variable action to increment myInteger:
      • Name: myInteger
      • Value: 5
  • Toggle Boolean:
    • Use the Set variable action to toggle myBoolean:
      • Name: myBoolean
      • Value: false
  • Add to Array:
    • Use the Append to array variable action to add an item to myArray:
      • Name: myArray
      • Value: "Date"
  • Update Object:
      • Use the Compose action to update myObject:
        • Inputs: @json(concat('{ "name": "', variables('myObject')?['name'], '", "age": ', add(variables('myObject')?['age'], 1), ',}'))
  • Decrement Integer:
    • Use the Decrement variable action to decrement myFloat:
      • Name: myFloat
      • Value: 2.12

4. Output Variables:

  • Use the Response action to return the final values of all variables:
    • Status Code: 200
    • Body:
      {
        "myString": "@{variables('myString')}",
        "myInteger": "@{variables('myInteger')}",
        "myBoolean": "@{variables('myBoolean')}",
        "myArray": "@{variables('myArray')}",
        "myObject": "@{variables('myObject')}"
        "myFloat": "@{variables('myFloat')}"
      }
Here's how Logic App should look:
estudy247-la-test-variables-08

Key Points

  • Variables are used to store and manipulate data during the workflow execution.
  • Each variable type (string, integer, boolean, array, object, float) is initialized and modified using appropriate actions.
  • The final values of the variables are returned in the response.

This Logic App demonstrates the usage of all variable types in a single workflow. You can customize it further based on your requirements.

You can download the logic app template from the estudy247 GitHub repository – la-test-variables-08 

Post a comment

Leave a Comment

Scroll to Top