Basics of Azure Logic Apps Schema and Codeview editing

Integrations using Logic App could be a fun exercise. Logic App provides a visual designer to model and automates your workflow process as a series of steps called as workflow designer UI,  for complex requirement Code view comes handy. In this blog, I will talk about the structure of logic app definition.

Let’s start with some basic components of Logic App.

    • Logic App Visual designer actually creates a JSON file with workflow definitions. JSON structure for Logic app

{
"$schema": "",
"contentVersion": "",
"parameters": { },
"triggers": [ { } ],
"actions": [ { } ],
"outputs": { }
}

$Schemacontent version and static values and are set to schema and version automatically.

Parameters are important as they help parameterize the logic app and assist with Deployments and change management. I will go more in-depth in my subsequent blog on Logic App and Change management/ALM.

Triggers: define the trigger criteria for the workflow. to access the output of trigger @triggerBody() could be used.

Actions: define the actions within the workflow, actions are nested and using runAfter you may define the dependent action or parallel action flow.

Outputs: refer to the response of the workflow post execution of all the actions. Most of our Integration scenario doesn’t use the output as we will have another action to consume the output.

 

Sample Logic App structure with nested actions:


{
    "$connections": {
        "value": {
            "ConnectionA": {
                "connectionId": "ID of Connection",
                "connectionName": "Connection Name",
                "id": "Connection Type"
            }
        }
    },
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Action B": {
                "inputs": {},
                "runAfter": {},
                "type": "ActionType"
            },
            "Action C": {
                "inputs": {},
                "runAfter": {
                    "Action B": [
                        "Succeeded"
                    ]
                },
                "type": "ApiConnection"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            }
        },
        "triggers": {
            "TriggerName": {
                "inputs": {},
                "recurrence": {
                    "frequency": "Minute",
                    "interval": 3
                },
                "splitOn": "@triggerBody()?['value']",
                "type": "ApiConnection"
            }
        }
    }
}

Key components for editing Logic App from code view:

  • Expressions: which needs to be evaluated at runtime are prefixed with @, as an example:
    • Evaluate action result status code
      "expression": "@equals(outputs('HTTP')['statusCode'], 409)"
    • Evaluate any parameter at runtime
      "name": "@parameters('registrationnumber')"
    • Evaluate a parameter as string at runtime
      "name": "@{parameters('registrationnumber')}"

For more details on Logic app Workflow, definition schema refer here.

Note: This post was originally posted on Kunal Tripathy's blog.  Kunal is the Technical Team Lead for Services Delivery with Adoxio Business Solutions.