Skip to content
LambogeniusDocs

Compose using Liquid for Azure Logic Apps

Quick start

Install the package, add the connection and a template, and run a workflow locally.

Service provider/serviceProviders/lamboLiquidComposeOperation ComposeLiquid, shown in the designer as Compose using Liquid.

Map an order in five steps

  1. 1
    Get the package

    from Downloads, save it in a folder such as packages/, and make that folder a package source:

    <configuration>
      <packageSources>
        <add key="liquid-compose" value="packages" />   <!-- the folder holding the downloaded .nupkg -->
        <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
      </packageSources>
    </configuration>
  2. 2
    Reference it

    in a NuGet-based Logic Apps Standard project:

    <ItemGroup>
      <PackageReference Include="Microsoft.Azure.Workflows.WebJobs.Extension" Version="1.170.91" />
      <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.5.0" />
      <PackageReference Include="Lambogenius.LiquidCompose.LogicApps" Version="0.1.1" />
    </ItemGroup>

    The package's build targets copy the worker to lambogenius-liquid-worker/ in the build and publish output. The host.json the runtime reads must not have an extensionBundle section, or the runtime ignores the project's packages; the samples remove it from the build and publish copies.

  3. 3
    Add the connection and the settings.

    Keep "templateFolder": "": the runtime refuses an empty parameterValues.

    {
      "serviceProviderConnections": {
        "lamboLiquidCompose": {
          "displayName": "Liquid Compose (Lambogenius)",
          "serviceProvider": { "id": "/serviceProviders/lamboLiquidCompose" },
          "parameterValues": { "templateFolder": "" }
        }
      }
    }
    {
      "IsEncrypted": false,
      "Values": {
        "AzureWebJobsStorage": "UseDevelopmentStorage=true",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet",
        "APP_KIND": "workflowApp",
        "FUNCTIONS_INPROC_NET8_ENABLED": "1"
      }
    }
  4. 4
    Add a template

    as Artifacts/LiquidTemplates/order-to-sales-order.liquid:

    {
      "orderNumber": {{ content.order.number | Upcase | ToJson }},
      "currency": {{ parameters.currency | ToJson }},
      "lines": [
        {% for line in content.order.lines %}
        { "sku": {{ line.sku | ToJson }}, "quantity": {{ line.quantity | ToJson }} }{% unless forloop.last %},{% endunless %}
        {% endfor %}
      ]
    }
  5. 5
    Create the workflow and run it.
    {
      "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "contentVersion": "1.0.0.0",
        "triggers": {
          "When_an_HTTP_request_is_received": { "type": "Request", "kind": "Http", "inputs": {} }
        },
        "actions": {
          "Compose_using_Liquid": {
            "type": "ServiceProvider",
            "runAfter": {},
            "inputs": {
              "parameters": {
                "inputFormat": "json",
                "outputFormat": "json",
                "content": "@triggerBody()",
                "templateSource": "deployed",
                "templateName": "order-to-sales-order.liquid",
                "parameters": { "currency": "CAD" }
              },
              "serviceProviderConfiguration": {
                "connectionName": "lamboLiquidCompose",
                "operationId": "ComposeLiquid",
                "serviceProviderId": "/serviceProviders/lamboLiquidCompose"
              },
              "retryPolicy": { "type": "none" }
            }
          },
          "Response": {
            "type": "Response",
            "kind": "Http",
            "runAfter": { "Compose_using_Liquid": [ "Succeeded" ] },
            "inputs": { "statusCode": 200, "body": "@body('Compose_using_Liquid')?['result']" }
          }
        },
        "outputs": {}
      },
      "kind": "Stateful"
    }

    Run dotnet build, then func start in bin/Debug/net8.0, and POST an order as JSON to the trigger URL.

Faster: start from a sample

The samples repository has eight ready-made Logic Apps. ./run.ps1 builds and starts one, and ./demo.ps1 calls every workflow and checks the answers.