Azure Logic Apps team announced an important feature on their YouTube webcast to support custom assemblies inside XSLTs. So we can go ahead and upload the dll of of the C# class library project to Azure Integration Account and we can refer the same inside the XSLTs. How cool!
Since we are having an immediate requirement on one of our projects to do a lookup during the transformation, I went ahead and gave it a try.
Please note that to utilize custom assemblies inside XSLTs, we will not be using the extension object XML to refer the dlls rather use <msxsl:assembly> to declare assemblies for use in script blocks.
What I did:
- Created a C# Class Library project and wrote a method inside it to concatenate first name and last name and return full name.
- Created an Integration Account project in Visual Studio 2015 and added two schemas (Input and Output), and a map to generate XSLTs.
- Input schema elements: FirstName and LastName
- Output schema element: FullName
- BizTalk Map: Input Schema to Output schema
- XSLT: Template that calls the assembly and does the transformation
I used Visual Studio 2015 for this development since Microsoft Azure Logic Apps Enterprise Integration Tools for Visual Studio 2017 is not available yet. This Tools add-on template helps generate BizTalk style (XML and flatfile) schemas and maps that can be uploaded to the Integration Account to be used inside Logic Apps for Flat file decoding/encoding, schema validation and XML transformations.
Here is the sample C# class library project:
public class XSLTHelper
public string ConcatenateNames(string firstName, string lastName)
return firstName + ” ” + lastName;
Integration Account artifacts:
Project creation in Visual Studio 2015:
File –> New –> Project
Right click on the Project and select Add New Item to add schemas and maps:
Map (only to generate xslts and unit testing in Visual Studio. Map cannot be uploaded to Integration Account):
<?xml version=”1.0″ encoding=”UTF-16″?>
exclude-result-prefixes=”msxsl var s0″ version=”1.0″
<xsl:output omit-xml-declaration=”yes” method=”xml” version=”1.0″ />
<xsl:apply-templates select=”/s0:Employee” />
<xsl:variable name=”firstName” select=”FirstName/text()”/>
<xsl:variable name=”lastName” select=”LastName/text()”/>
<xsl:value-of select=”user:Concatenate($firstName, $lastName)”/>
<msxsl:script language=”C#” implements-prefix=”user”>
<msxsl:assembly name=”MapHelper, Version=188.8.131.52, Culture=neutral, PublicKeyToken=92f92a6720d1e6ec” />
<msxsl:using namespace=”MapHelper” />
public string Concatenate(string a, string b)
XSLTHelper xsltHelper = new XSLTHelper();
return xsltHelper.ConcatenateNames(a, b);
If you are from BizTalk background, please note that we are not using Custom Extension object XML to refer the dlls inside the XSLT. When you refer the class library project dll, please add the fully qualified name of the assembly.
Once all done and unit tested successfully, please upload the Input schema, the XSLT and the custom assembly dll to Azure Integration Account:
Once done, associate the integration account to your new Logic App and refer the map to do the transformation.
The Logic App I created for this was exposed as a HTTP endpoint, and I used Postman to send the XML request payload (Input schema instance) to get the transformed XML (Output schema instance)
Logic App flow:
Postman request: Upon saving the logic app, you would get the callback uri. Copy it to call it from the Postman app. Please make sure you set the Content-Type to application/xml since so the XML payload would be passed over without any issues.
Hope this helps you if you are trying to utilize custom assemblies inside XSLTs to be used in the Logic Apps. However, if you are trying to port your existing XSLTs that are using Extension Object XMLs, you may not be able to port as-is. In other words, I am not sure how would you do that since there is not a way to export your Extension Object xml yet. You may want to explore Azure Functions or API Apps route. There is a nice post here for that.
Please feel free to reach out to me in case of any questions / comments.
Thanks to Logic Apps team for continuing to listen to the community and adding key features to make Logic Apps a robust Enterprise Integration Platform in the cloud.