Logic apps is part of the new and awesome features Microsoft released in preview this spring. Focus on this type of functions are cloud integration! Both hybrid integrations that bring data to and from servers inside your network in a secure and easy way and also pure cloud integration.
Logic Apps is the application that is created in Azure as the workflowish application, I won’t explain more in this post but please read more here.
So the example I’ll take here is a classic one, I have a system that produces small and simple flat files on a local server and we want to bring that data in EDIFACT INVOIC format to a FTP server. Normally this would be solved via an integration platform like BizTalk but for this scenario we don’t have a BizTalk server that we can use so we try to solve this via Logic Apps instead.
Scenario:
Let’s jump right in into the portal, we need to start by setting up some connectors (File, FTP) and several API Apps from the marketplace will be used.
Preparations
SQL Databases
First off we need one SQL DB, you can use a previously created one but we need 2 empty instances, I did this in the “old” portal.
The 2 API apps are the following and in brackets you can se my database instance name.
Copy the connection strings and change the text {your_password_here} to your password so you can use it later.
Service Bus:
Create a Service Bus namespace for the File Connector.
Schemas:
Download the EDIFACT XSD schema here
Mapper:
Create a BizTalk Service mapper in Visual Studio 2012
Resulting in these 3 files for me (after downloading the EDIFACT schema)
Now when we are prepared let’s start creating the services
Creat and configure the API App’s instances.
In Web API section:
Create File Connector: We need a File Connector for picking up files on the onpremise server we need to provide the following information right away when we create the connector:
After creating this we can install it on the server, see the section about installing File Connector for more info.
Create FTP Connector: We need a FTP Connector to be able to send messages to the FTP server. For this we need to provide the following information right away when we create the connector:
Create BizTalk Flat File Encoder:
We need a BizTalk Flat File Encoder that will decode and encode of flatfile to/from XML. In our case it will be decode of flat file to XML
Installation is straight forward and you only need to apply name for the instance.
Configure BizTalk Flat File Encoder:
For the Flat File encoder to work we need to add one or more flatfile schemas. These schemas are the same that is used in BizTalk so you can easily reuse the once you have today. Go in to the instance we created (remeber the name of the instance) easiest way to find it is in the API apps list. (Browse -> API apps)
Create BizTalk Transform Service
We need a BizTalk Transform Service to be able to transform the xml instance of the flatfile to an xml instance of the EDIFACT schema. Creating this is quite straight forward just need to apply a name for the service.
Configure BizTalk Transform Service
After creation we need to some configuration, we basicly need to add the maps. Pick up the app as with the others, when you have found it do the following:
Create BizTalk Trading Partner Management
BizTalk Trading Partner Management is used to keep information about partners and setup agreements on AS2, EDIFACT and X12.
When creating we need to provide the connection string to the earlier created Database.
Configure BizTalk Trading Partner Management
When the Trading Partner Management is created we need to do some configurations. Mainly we need to create parties that are suppose to be used in the B2B flow and then connect them via agreements so we can say that partner A are exchanging messages with partner B.
First we need to create atleast 2 partners, go in to the instance (just like the others):
When the partners are created and we have added identities to them we can start creating agreements BUT to be able to create EDIFACT agreements we also need to provide the EDIFACT schemas that we want to use.
Now we can create the agreement:
Note! After Save write down the Agreement ID, we will use that later on in the Logic App
Create BizTalk EDIFACT
The BizTalk EDIFACT instance will do the hard work of encode or decode your EDIFACT message to XML or vice versa. When creating the instance we need the following:
There is no need to do some configuration since the EDIFACT instnace will use the configuration we did in the BizTalk Trading Partner Management instance when handling agreements and so on.
Now we are all set and the preparations are done, let’s start building the Logic Apps app.
Building the app looks easy and are smooth but there are some tricky parts that you will encounter since we will have some looping lists in this way of building the Logic App. (Building it this way so it’s easier to understand and test, quite bad though that if I need to change this later I have some serious remodeling to do, it’s easier to create a new flow.)
As I created it I focused on a flow that would be easy to demonstrate, so I added the fileconnector in a read mode of a folder, instead of the event mode that also is available. (With the read mode I can trigger it at any given time, perfect for demo or when we have need of manual runs).
So let’s start!
First of we pick up the files from the server.
Now we have this setup and we will start picking up files, eaither on the intervall or at the time we manually start the logic app.
Next section will be adding the BizTalk Flat File Encoder, transformation and the BizTalk EDIFACT component.
In my setup the files will not be deleted so I don’t need to redrop files over and over again. (If we want that behavior just add another File Connector at position 4 (marked as optinal in the setup) or change the whole setup so we use the trigger function in the File Connector that will keep track of new files and pick them up and afterwards delete the file in one step. The dissadvantage with that is when you want to demo since it’s not possible to manually trigger that flow via the start flow buttton.
Result will be, that we have a full functional flow that will pick up the flatfile and do all the handling that is needed to eventually end up as an EDIFACT file on the FTP server. Here is how the full flow look like for me:
Key Take Aways
Crashes:
This is a preview so don’t be afraid of crashes, I also learned that a lot of the time it was just the async GUI that had the problems especially if I used the Free tier. Then I quickly filled my quote and in combination with heavy traffic or high demand I was unable to work with it. But when I switched to Basic Tier almost all problems just disappeared =)
Updating the map
Strangely I couldn’t update the map, I had to delete it and upload it again.
Installing the File Connector:
To install the File Connector, find it in the portal (easiest way is to go via the Browse) and pick API Apps select the file connector.
You will notice that when loading the settings it will try to check if the connector is installed, click the link.
Next is to download the installer, click “Download and Configure” see image bellow
After downloading, copy and install the application on the prefered server. When you get promted for the connection string as bellow you should the Primary Configuration String (yellow marked in the image above).
Tips when using the File Connector
Finding the files and Installed content on your server:
After the micro service is installed it will be found in IIS
When browsing the file system we will find a folder containing some files that represents a web api:
Testing the installed API App locally with swagger on your server
Troubelshoothing the flow:
So when you get this red error and you have no idea what went wrong we need to start troubleshooting. In the editor it looks and feel so smooth to do things but there is not as easy finding the errors, specially not the first times. For us who has been in the business for some time we are use to troubleshoot and understand xml notations and layouts so this can be a little bit new since Logic App is building it’s settings, configuration and input/output on JSON notation, meaing no xpaths but a .(dot) notation instead.
First of all in an JSON object we use the [object}.{attribute} to access something so when looking at this example we will need the following notation in the field to get the value.
Check the error output messages, example bellow on error in EDIFACT service, reason is found under output.body.Exception
Other tips when working in the portal.
Watch out for portal related issues also, like when editing Partners in Trading Partner Management, make sure to wait for the green save signal before proceeding to fast to the next step. I found myself having trouble when I jumped to fast around in the portal.
Posted in: •Integration | Tagged: •AzureAPIApps •API Apps •EDIFACT •FileConnector •FlatFile •FTP •Logic Apps •Microsoft Azure