Azure Logic App service bus message content

百般思念 提交于 2019-12-07 06:42:56

问题


I have logic app that is triggered by a service bus. The message content is not usable as it is just random characters. I suspect that perhaps it needs to be parsed but it is not clear how to do this.

I have the following: Not enough reputation to add an image - but screen shot from Azure

 "Insert_Entity": {
            "inputs": {
                "body": {
                    "PartitionKey": "deviceID",
                    "RowKey": "@variables('curDate')",
                    "content": "@triggerBody()?['ContentData']"
                },

When I look at the data that I am getting for the "content" coming from the "@triggerBody()?['ContentData']" it looks like this:

"W3sidHlwZSI6ImxvZyJ9LF...." I deleted most of this as it 100's of characters long.

I suspect that this needs to be parsed or something to look at the actual message body. I have checked this out but don't know where to insert code like this: Getting content from service bus in logic apps

Can you please explain how to see the message body.


回答1:


Can you please explain how to see the message body.

The string W3sidHlwZSI6ImxvZyJ9LF.... you mentioned is base64string. If we want to see the message body we need to convert the base64string to string

We could do that with base64ToString(triggerBody()?['ContentData']) details please refer to the screenshot.

Body info:




回答2:


After getting the value as Tom Sun solution, i had had to extract the json part of the result to be able to parse it, Logic App Expression :

substring(
variables('result'),sub(indexOf(variables('result'),'{'),1),
sub(lastIndexOf(variables('result'),'}'),indexOf(variables('result'),'{'))
)

Then use Parse JSON function to parse the result using the schema :

{
    "properties": {
        "data": {
            "type": "string" // Change As Required
        },
        "dataVersion": {
            "type": "string"
        },
        "eventTime": {
            "type": "string"
        },
        "eventType": {
            "type": "string"
        },
        "id": {
            "type": "string"
        },
        "metadataVersion": {
            "type": "string"
        },
        "subject": {
            "type": "string"
        },
        "topic": {
            "type": "string"
        }
    },
    "type": "object"
}


来源:https://stackoverflow.com/questions/47399765/azure-logic-app-service-bus-message-content

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!