This post was originally published here
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.