简体   繁体   中英

Iterating Through and Checking JSON Object Properties using Azure Logic Apps

I am attempting to write an Azure Logic App which will assist with me moving data from my Azure LogAnalytics Workspace and into Azure Table Storage. As I am performing this task, I continue to get the same error. Essentially, the LogAnalytics Data has some properties which are assigned null values, but the Azure Table Storage does not allow null values at all - so it simply throws a generic error:

Service Code: 400

"code": "PropertiesNeedValue"

"value": "The values are not specified for all properties in the entity.

So, in order to get the Azure Storage Table to accept the data from LogAnalytics, I need to convert any Null Valued properties into a different data type, such as an empty string. The issue here is, the data which is stored as JSON Objects, have hundreds of properties with any number of them being null.

I need to be able to iterate through the properties themselves, check if each is null, and then set the property to a different value/data type.

Is this possible using Azure Logic Apps?

How would this be implemented?

For the record I am familiar with LogicApps and understand how to use SetProperty(), RemoveProperty(), and how to use the ForEach Loops. Thank you!!

The solution for successful parsing is to modify the schema to allow nulls.

Modifying Existing schema It can be done in very simple step by modifying type of the object into array of types like shown below:

在此处输入图片说明

Execution that allow nulls to be parsed

在此处输入图片说明

在此处输入图片说明

We see that this time Logic app did not thrown an exception and would allow us to deal with this null value within our code.

Let's bear in mind that allowing nulls it is not always the best option.

There is also default values, that could be considered, but everything depends on the context your logic app operates in.

Hope it helps.

MV

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM