Friday Fact: It is possible to create an XML first-class experience inside Logic Apps.

  • Sandro Pereira
  • Apr 12, 2024
  • 2 min read

By default, Logic Apps provides a good first-class experience for JSON, which means when we receive a JSON message, we can tokenize the elements by using a JSON schema inside, for example, a Parse JSON action:

Parse JSON

This will basically create shortcuts or pointers to the fields of the message that we can easily use in other actions without worrying about the query path to each field:

Parse JSON tokens

These tokens or points are, in fact, shortcuts to the query path of those fields, providing a good first-class experience:

  • body(‘Parse_JSON’)?[‘firstName’]
  • body(‘Parse_JSON’)?[‘lastName’]

These two are simple, but they can be a little bit more complex:

  • outputs(‘Compose_Response_JSON’)[‘Result’][‘Address’][‘PostalCode’])

📝 One-Minute Brief

Create a first‑class XML experience in Azure Logic Apps by converting XML messages into JSON with built‑in expressions, enabling tokenization, easier access, and cleaner workflows.

Many developers point out that Logic Apps don’t offer the same first‑class experience for XML messages. That feedback is fair. By default, accessing XML fields is less intuitive than working with JSON.

However, this limitation does not mean that a first‑class XML experience is impossible. A simple and effective workaround is to use the json() expression to convert XML into its JSON equivalent. You can learn how to apply this approach in detail here: Logic App Best Practices, Tips, and Tricks: #41 How to convert XML into JSON inside Logic Apps.

For example, if we have the following XML message:

<Person>
	  <Firstname>Sandro</Firstname>
	  <Lastname>Pereira</Lastname>
</Person>

We can use the following expression to convert the XML message to JSON:

  • json(xml(outputs(‘Compose_XML’)))
json expression

Of course, then we need to provide a JSON Schema that corresponds to that message. and that will allow you to have a first-class experience for that XML message

Just a simple trick that can help you in many processes.

To lazy to read? We’ve got you covered! Check out our video version of this content!

Join us next Friday for another Friday Fact!

Hope you find this helpful! If you enjoyed the content or found it useful and wish to support our efforts to create more, you can contribute towards purchasing a Star Wars Lego for my son!

Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc. He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community.

Leave a Reply

Your email address will not be published. Required fields are marked *

The Ultimate Cloud
Management Platform for Azure

Supercharge your Azure Cost Saving

Learn More
Turbo360 Widget

Back to Top