Azure Function to Apply Liquid Transformations

After the release of our Azure Function to Apply XSLT Transformations, it is now time for another Azure Function under the same context: an Azure Function to Apply Liquid Transformations.

As in the previous transformation function, you can ask the same questions: Can we accomplish the same with default capabilities inside Logic Apps or Azure API Management?

Using Azure Integration Services, we can easily apply liquid transformations: 

  • If we are using Logic App Consumption we can use in conjugation with an Integration Account the following actions associated with the Liquid connector:
    • Transform JSON to JSON
    • Transform JSON to TEXT
    • Transform XML to JSON
    • Transform XML to TEXT
  • If we are using Logic App Standard it already provides out-of-the-box support for applying Liquid transformations (using the same Liquid connector) without the Integration Account need.
  • Or, if you are using API Management, we can make use of the set-body policy to apply a Liquid transformation (any input format to any input format) in the request or response body.
<set-body template="liquid" xsi-nil="blank | null">
    new body value as text
</set-body>

Once again, our main objective in creating this function was to use it inside Logic Apps Consumption to avoid needing an Integration Account. But that we will address later on in another blog post.

What does this Azure Function do?

The ApplyLiquidTransformation function allows you to execute Liquid transformations using DotLiquid to dynamically convert a payload into another payload format. To use this function, you must set up an Azure Storage Account and a container to store the liquid files. The following transformation types are supported:

  • Apply the following transformations on JSON payloads
    • JSON to JSON
    • JSON to XML
    • JSON to CSV
    • JSON to plain text
    • and so on
  • Apply the following transformations on XML payloads
    • XML to JSON
    • XML to XML
    • XML to CSV
    • XML to plain text
    • and so on
  • Apply the following transformations on CSV messages
    • CSV to JSON
    • CSV to XML
    • CSV to CSV
    • CSV to plain text
    • and so on

To trigger this function, you need to:

  • In the Body, send one of the following payloads: JSON, XML, or CSV.
  • You should specify the following mandatory headers:
    • Content-Type as text/xml (or application/xml), application/json or text/csv.
    • LiquidFileName with the name of the liquid file present in the storage account.
  • Optionally, you can set the following header:
    • Output-Content-Type: this will specify the outcome (response) content-type. The default value is application/json.
    • CSVDelimiterChar: If you specify the Content-Type header as text/csv, then you need to specify the delimiter char of the CSV file. For example: ;

Once again, our main objective in creating this function was to use it inside Logic Apps Consumption to avoid needing an Integration Account. But that we will address later on in another blog post. However, it can be used in other scenarios.

Where can I download it?

You can download the complete Azure Functions source code here:


Hope you find this helpful! So, if you liked the content or found it useful and want to help me write more, you can buy (or help me buy) my son a Star Wars Lego! 

Thanks to my team member Luís Rigueira for helping me realize and implement this idea.

Credits also to these two projects and authors:

Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc. He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community.

Leave a Reply

Your email address will not be published. Required fields are marked *

turbo360

Back to Top