'How do I parse a JSON from Azure Blob Storage file in Logic App?

I have a JSON file in Azure Blob storage that I need to parse and insert rows into SQL using the Logic App.

I am using the "Get Blob Content" and my first attempt was to then pass to "Parse JSON". It returns and error": InvalidTemplate. Unable to process template language expressions in action 'Parse_JSON' inputs at line '1' and column '2856'"

I found some discussion that indicated that the content needs to be converted to a string so I used "Compose" and edited the code as suggested to "inputs": "@base64ToString(body('Get_blob_content').$content)"

This works but then the InvalidTemplate issue gets pushed to the Parse function and I get the InvalidTemplate error there. I have tried wrapping the output in JSON expression and a few other things but I just can't get it to parse.

If I take a sample or even the entire JSON and put it into the INPUT of the Parse function it works without issue but it will not accept the blob content as JSON.

The only thing I have been able to do successfully from blob content is to take it as a string and update a row in SQL to later use the OPENJSON in SQL...but I run into an issue there that is for another post.

I am at a loss of what to do.



Solution 1:[1]

You don't post much information about your logic app actions, so maybe you could refer to my flow design. I test with a json data with array.

The below is my flow picture. I'm not using compose action, and use decodeBase64(body('Get_blob_content')['$content']) as the Parse Json content.

enter image description here

And if select property from the json, you need set the array index. I set a variable to get a value 'body('Parse_JSON')1['name']'.

enter image description here

you could have a try with this, if still fail, please provide more information or some sample to let us have a test.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 George Chen