Hello Logic App!

During INTEGRATE 2014 last November in Seattle Microsoft gave a sneak preview of what today is known as API apps and Logic apps. Back then it was all fuzzy and no preview to play with. Right before the BizTalk Summit in Londen in April, Microsoft released the big news regarding their new App Service platform, including the existing Web apps (Azure websites) and Notification services, combined with the new API apps and Logic apps.

For us BizTalk developers the most interesting of all are the Logic apps. Although you can’t use Logic apps without having API apps, because they are (also) the new adapters to receive and send messages.

I was inspired by this blog post from the BizTalk360 team, in which is described how to read messages from one on-premise location and write them to another using Logic apps and hybrid connections. That blog post saved me from quite some research as there are some tricky things to know. At the end of the post I had the Logic app below.

FileConnectorBasic

For me that was the first step, but in a real BizTalk scenario there at least has to be one map! My scenario is to read from my local laptop ‘inbox’ folder, transform the message and write to the same laptop to an ‘output’ folder.

So I installed the Microsoft Azure BizTalk Services SDK to have mapping functionality in Visual Studio without the need for any BizTalk assembly. I created a small schema and a map to be used for the Logic app.

VisualStudioMap

Next step is to have an API app to perform the transform, because everything is an API on the platform. To create a new BizTalk Transform Service, you can also use this Azure documentation as reference.

NewTransformService

Select BizTalk Transform Service and click ‘Create’. The Azure portal start page will open and show the API app to be created. When the API app is created, click it to open the details. The next step is to add a map to the Transform Service.

TransformServiceMap

Now the BizTalk Transform API service is ready, we need to put it between the two file connectors in the existing Logic app. This is a challenge in itself, because currently it isn’t possible to re-organize the API apps within a Logic app. So just dragging the Transform Service in between the two file connectors is a no-go. I tried to add the Transform Service to the Logic app and then use the code view to re-organize but it appeared not to be that simple (although the design of the Logic app is described in a plain readable JSON file). This will be possible in the future, but for this case I removed the sending file connector, added the Transform Service and then added the file connector again. This results in the Logic app below.

BizTalkBasicScenario

The complexity at the moment is the expression you need to provide as parameter in the API apps. At the moment there is no validation, intellisense or syntax highlighting which complicates development. In the near future this will be possible, there is demand from the community for this as well.

Logic apps is in fact chaining API apps together and using (a part of) the output of one as the input for the next API app. For the BizTalk Transform Service we need to take the output of the first File Connector, which is the body of the message, as input for the map. We can use this expression for this: @triggers().outputs.body.Content

It is pretty easy to read: take the content of the body of the output of the previous API app.

Next is to take the output of the Transform Service and use that in the sending File Connector. To determine the file name to use for the File Connector we can use this: @concat(‘/Outbox/’, triggers().outputs.body.FileName)

The name is appended to the default folder. The content of the message is grabbed from the Transform Service, but has a different expression compared to the one used as input to the Transform Service: @body(‘transformservice’).OutputXml

Like a typical ‘hello world’ with BizTalk, I throw in this message in the Logic app:

<ns0:SourceSchema xmlns:ns0=”http://didago.nl/sourceschema”>
<ns0:FirstName>Indiana</ns0:FirstName>
<ns0:LastName>Jones</ns0:LastName>
</ns0:SourceSchema>

This is the output and as expected the map has been executed.

<?xml version=”1.0″ encoding=”utf-8″?>
<ns1:TargetSchema xmlns:ns0=”http://didago.nl/sourceschema” xmlns:ns1=”http://didago.nl/targetschema”>
<ns1:FullName>Indiana Jones</ns1:FullName>
</ns1:TargetSchema>

Hurray, my first Hello Logic app!

It was a very interesting exercise to play with these basic components of the App Service platform. Logic apps currently are certainly not a replacement for BizTalk and that is also not what it’s meant to be. Integration MVP Michael Stephenson has a nice blog post about it.

Currently the Logic apps are in preview and a lot still needs to be done before it is mature enough to build enterprise solutions. For example the entire ALM needs to be figured out and also the designer should be available in Visual Studio and not only via the browser. Microsoft is betting big on this so it will be a matter of time before these topics will be covered.

It is great playing with new stuff!