Debatching using Azure Logic Apps

In Azure when we talk about Serverless technology, we think of Azure Logic Apps and Azure Functions. You use Azure Logic Apps to design serverless workflow. It’s basically designing an orchestration somewhat similar to one in Microsoft BizTalk Server.

The best part of Logic App is that you just pay for the resources you use. There are around 200 + connectors which can be used + custom connectors.

Why Serverless ?

  • No management of Architecture.
  • High Scale and Availability.
  • Automatic scaling.
  • Billing Based on use.

Today we are going to Debatch an XML using Logic Apps. Using BizTalk Server we can do de-batching in couple of different ways, within an Orchestration or using Pipeline etc.  De-batching is nothing but splitting a message into multiple individual messages. Let us looks at the below example,

Here we have a message which contains multiple book details, we would be splitting this message into individual book details using Logic Apps. The below sample message will be used through-out our demo.

XML Message.JPG

Scenario

You will receive an XML which contains a batch of Book Details in an XML. We will split this XML into group of Individual messages and send each message via email.

Connectors

connectors.JPG

Login to Azure Portal and Create a Logic App

logicAPp.JPG

Once the Logic App is created we would now be performing debatching using the below 2 methods,

  1. Using For-each (uses XPath)
  2. Using SplitOn (uses XPath)

USING FOR-EACH 

  • Drag when HTTP request is received.
  • Click on Plus sign and select For-each
  • Add an xpath query

@xpath(xml(triggerBody()), ‘//*[local-name()=\”BookDetails\” and namespace-uri()=\”http://InstallationCodesCHe.Books\”]’) ”

  • Add an action and select outlook 365 connector to send the message.
    • Configure your connector
  • Save the Logic APP and copy the HTTP POST URL of your Logic App

logicapp1.JPG

  • Now configure the POSTMAN application to post an XML message to our Logic App.

LogicApp2 (2)

  • After  a successfull run, you must receive 4 individual messages to your e-mail box. Each Book Details are splitted into individual messages.

LogicApp3.JPG

USING SPLITON

  • Drag when HTTP request is received.
  • Go to the code view,

Logicapp4.JPG

  • Add the key – splitOn and xpath value associated with it

logicapp5

  • Navigate to the designer view go to your shape “When a HTTP request is received” and click on settings tab. You will see a SplitOn property.

LogicApp6

  • Add the final connector, outlook 365 to send a message. Once you have set the necessary property trigger a message via Postman. You will receive 4 email messages as received above.

This is how we can Debatch messages using Azure Logic Apps.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s