Sunday, January 8, 2017

Azure BizTalk FlatFile Decoder to XML Map

In the previous post we created the Flat File XML from the FlatFile decoder.
http://biztalkconnect.blogspot.no/2017/01/azure-biztalk-flatfile-decoder.html
Now we will map it to the XML Schema.

So first we need to create the map in Visual Studio.
Once the map is created( you can test it using the FlatFIle XML we got back in the last post).
Test map will not work with Flatfile in native format...it has to be XML Input...its buggy.

Once you have created the map you need to upload it to the Azure Portal(Integration Account).
Azure doenot support .btm file.
So you need to Debug the map and upload the .xsl file it creates to your (Integration Account).















So lets upload the .xsl file to Azure(Integration Account).




















Now we need to go to the Logic App we created last and Add the "Transform" shape to it where we will call this map to convert the FlatFile Xml to another mapped Xml Output.
Important here is to configure the map.
Content:  Input to Map: which will be output(XML) from Flat File Decoding.
Map:  Select the map we just uploaded to our Integration Account. It wil show in the dropdown window if the Integration Account is linked to the Logic App.




































Run the Logic App. It will show some Errors but dont worry all is well until now.



























Now we will test the map using Postman with the same Flat File input.
In the map I am concetenatiing FirstName and LastName.
Just a note: There are many BizTalk functoids like Database Functoids missing in the toolbox...seems Microsoft is still adding stuff to the map.

































Voila it works. The FullName contains the FirstName and LastName.
 I noticed Richard used some Azure Functions to call the maps.I did not needed any. Looks like I need to look into Azure functions or seems Microsoft has changed the Transform Shape recently.

Finally I have uploaded the Schemas/map/Test file out here.
Just download it and test it using Azure.
https://sites.google.com/site/knishtechweb/home/downloads/IntegrationAccount1.7z?attredirects=0&d=1



Saturday, January 7, 2017

Azure BizTalk FlatFile Decoder

Hi,
Recently one of my new probable customer wanted to convert CSV file to Xml.
So I recommended Biztalk but they dont have an On Premise Biztalk Server and dont plan one.
So I recommended using BizTalk in Auzre as a Service the so called "Enterprise Integration".
The only catch was I never worked with it so had no idea what it could offer.
So here we start looking into what challenges I faced.
I went through some good articles from Richard and Steve which pretty much gave me a head start but could not achieve what they achieved in the blog...thats why I am not an MVP ;) .
https://seroter.wordpress.com/2016/09/09/trying-out-standard-and-enterprise-templates-in-azure-logic-apps/
http://blogs.recneps.org/post/Processing-a-flat-file-with-Azure-Logic-Apps
https://docs.microsoft.com/en-us/azure/app-service-logic/app-service-logic-enterprise-integration-flatfile

So kepeing things short I will just show you few do's and dont's which you should be careful with.
So the scenario here is to first just convert a flat file to Xml.

1. First thing is to download the "Microsoft Azure Logic Apps Enterprise Integration Tools for Visual Studio 2015 2.0"
https://www.microsoft.com/en-us/download/details.aspx?id=53016

Here in Visual Studio -> New Project it looks similar to BizTalk but with only 3 options when you try to "Add New Items" after creating the project.




















As a BizTalker one clearly thinks of the Flat File wizard....yes we have it here.
The Flat File Schema is actually the Flat File Wizard.
Sandro has explained it better here
https://sandroaspbiztalkblog.wordpress.com/tag/flat-file-schema/

So i did next is created the Flat File Schema called EmpCsv.xsd

















If you want to can create the map and map the FF Schema to Xml schema also.
But I will not show the mapping in Azure in this blog post.










Very important

  1. Dont try to validate the FlatFile Schema.
  2. Dont try to Test the map using Flatfile csv input.

It fails as its buggy. 
So if you want to test the map you can test it using Flat file Xml as an input.
So how to get the Xml from the Schema?
Thats what I used 1 complete evening finding out.

So lets assume everything works and we are ready to deploy to Azure.
Remember I have not tested the map...I dont know if the Flat file validates against the Schema.

So now its Azure time.
1.Here we need to first create an "Integration Account" where we will add our Schemas and Map.





















2. We will add the Schemas and maps to the Integration Account


















3. Now we will create a new blank "Enterprise Integration" Logic App.












4. Associate the "Integration Account" to created Logic App.
You can go to properties of the Logic App created and link it.
















5. Now we start creating the Logic App in the Logic App Designer.
Add the Request Shape.














In the Request shape only the important thing is the makred in yellow(URL). Need to copy it later on when we want to send the flatfile for testing.
Nothing else need to be done here in body. Leave it blank.




























Click on the Next Step -> "Add an Action" and Add the "Flat file Decoder" Component.
We need to fill 2 boxes here
1. Content
    Click on the Content textbox it should popup the option as to use body(Output from the Request Step) as input .
2. Schema Name:
If the Integration Account is connected...it should show up the Schemas we added to the Integration Account.
Select the FlatFile Schema which we want to convert to Xml(Think of it as Flat file pipeline decoder stage: Select Schema and done converted to Xml).


























Click on the next Step and Add "Response" Shape which will return us the Flatfile in XML format.
We need to fill only the Body with output from Flat File Decoder.
























This is how it should look like.
Copy the URL from Request shape.

















2. Testing
Now we are ready to test.
Click "Run" on  the Logic App Menu to start the App.
It will show some error in the FlatFile decoder but dont worry it wont cause any problem.

You need to get a testing tool form here
https://www.getpostman.com/

I used Chrome addon.
So you need to paste the URL
Select "Post"
Click on "Body"
Click on "raw"
Paste the Flaltfile in the TextBox and Click Send.
The Response will be shown below.
































So we converted the FlatFile to Xml.
Finally I have uploaded the Schemas/map/Test file out here.
Just download it and test it using Azure.
https://sites.google.com/site/knishtechweb/home/downloads/IntegrationAccount1.7z?attredirects=0&d=1

In the next Post I will show how to map this FlatFile to a Xml file and return it.
http://biztalkconnect.blogspot.no/2017/01/azure-biztalk-flatfile-decoder-to-xml.html