This will help as quick start hands-on for those seeking debatching pattern on Azure logic apps. Though there could be other ways to split the file like using JSON "
SplitOn" in the request, but I am using For Each loop to debatch it.
On premise, BizTalk developer or citizen integration developer who has no prior knowledge of BizTalk can start with Azure Logic app development. You must need Azure subscription to develop this and SOAP UI or Postman tool to test the solution.
Using the Code
To split the batch order file into individual order and send it to destination path.
For this scenario, I will use batch order file JSON formatted and destination path to Google Drive to send the debatched orders.
The batched JSON file sample is below. It has four orders in the batch. The expected output is four files to be written with their details into Google drive account folder.
"Qty": "1","Price": "700"}},
"Swimming Kit","ProductCategory": "Sports",
Steps to Develop the Logic Flow
I presume that you have Azure subscription and you understand how to navigate to create Logic App workflow.
- Create Logic Apps with Name. Select the subscription and you can either create new resource group or use an existing one, select the location and click on create button. It takes few moments to create in Azure.
- Go to Logic App dashboard and select the above logic app created in step 1. This will prompt a page to design the flow where you have the option to select “Blank Logic App” from template. On the designer, select HTTP connector with Trigger "When HTTP Request received". Click on the option "Use Sample Payload to Generate Schema". In the dialog box, copy the sample provided in the scenario section. Once click done, this will generate the JSON schema.
- Click on next Step below the first flow and go to option (More...) section to add For Each loop, then select the Order from dynamic content. This appears because the Schema structure is already defined.
- Click on the "Add Action" inside the For Each loop and select the Google drive Action for Creating a file. You can type search to find in the search option given. Once you select this option, it will ask you to provide the Google account details to authorize the logic apps to write files in your Google drive. You can create a separate folder in Google drive for this application to test your files.
Select the folder path by navigating to the folder picker icon and File Name = Set date time
To do this, click on File Name type box and it will pop up for Dynamic content and Expression. Select Expression and scroll down for Date time function to select
utcNow(). I have chosen this to keep each file different name with date time. There are various other functions you can explore to set specific File name with macros.
File Content value will be set in the next step.
- Go to code view mode of logic App designer to set the File Content value. You would see body value is empty at line # 18. See the highlighted screen for this.
Type the content for value --- ”
Line #18 will look like
- Go back to designer mode and expand the first shape HTTP Receive to set the Advance Option Method =POST and Copy the HTTP Post URL and save the project.
- Test it using any test tool like SOAP UI or Google Postman. I am using Postman to test it as per below screen. Use POST verb and url that you copied from Logic App designer HTTP receive first shape. Make sure you select raw body and use content type application/json. The same sample message given in scenario use for testing. After test, you would see your Google drive folder with four files written. You can view the content of the files as well.
Complete Developed Designer View
At a Glance View
View order files in Google drive and also you can track the transaction history in Logic apps Run history. See the images below for details.
Image From Google Drive:
Image from Logic App run history:
You can click on the transaction details for depth analysis.