Azure Function to Apply XSLT Transformations

Another Azure Function? Can we accomplish the same with default capabilities inside Logic Apps or Azure API Management? These may be, once again, the questions that you are asking yourself at the moment. Because if we are using Azure Integration Services, we can easily use: 

  • If we are using Logic App Consumption we can use the Transform XML action in conjugation with an Integration Account.
  • If we are using Logic App Standard it already provides out-of-the-box support for applying XML transformations (using Transform XML action) without the Integration Account need.
  • Or, if you are using API Management, we can make use of the xsl-transform policy to apply an XSL transformation to XML in the request or response body.

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 ApplyXSLTTransformation allows you to dynamically convert an XML payload into another XML, JSON, or any other format using XLST. To use this function, you must set up an Azure Storage Account and a container to store the XSLT files.

To trigger this function, you need to:

  • In the Body, send an XML payload
  • You should specify the following mandatory headers:
    • Content-Type as text/xml, or application/xml.
    • XsltFileName with the name of the xslt 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 text/xml.

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.

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