James Wood James Wood - 4 years ago 297
JSON Question

How to transform JSON in Azure Logic Apps?

I'm trying to create an Azure Logic App that broadly does the following:


  1. Use a HTTP call to a REST service, the REST service will return JSON with Ids. This is working fine, the resulting JSON looks a bit like this:
    "workItems" : [ { "id": 118, }, { "id": 119, }, etc ]

  2. I need to extract all the Ids, and put them into a comma separated string, e.g.
    118, 119, etc
    .

  3. The comma separated string will then be used as part of another HTTP REST call.



However I'm struggling at point 2. I cant see where I can write some script or code (without building a custom logic app component) to do this transformation.

At the moment I've tried using the BizTalk Apps to convert the JSON to XML, then use XPath, then hopefully get that back into a string at some point - but this whole process seems overly complicated.

I realise I could write a custom app, but if I did that then I might as well just do all the work in the custom app as well. Be nice to use the native features of Azure if possible.

I'm afraid I might be missing something obvious. Suggestions would be appreciated.

Answer Source

WebJobs Webhooks are now deprecated. Use Azure Functions Generic Webhooks instead - they have direct integration support with Logic Apps.

One option is to use a WebJob Webhook and do the transformation/filter there. I have an example on GitHub of using this to filter posts to Slack. If you already have a Web/Mobile/API app up and running, it's easy to have a WebJob hosted on it so you don't need additional resources, necessarily.

Your other option, you highlighted. Deploy an API App which will do the xform for you.

If you want to go down the WebJob route and need any help, let me know and I'll be glad to assist.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download