首页 > 解决方案 > How do I return JSON from my Azure Storage Queue?

问题描述

I have a logic app that puts JSON in a queue.

enter image description here

Couldn't be more simple. But then, when I use the trigger for new messages, the raw output shows this:

    "body": {
        "MessageId": "e705a261-f2c4",
        "InsertionTime": "Tue, 02 Apr 2019 14:22:24 GMT",
        "ExpirationTime": "Tue, 09 Apr 2019 14:22:24 GMT",
        "PopReceipt": "AgAAAAMAAAAAA=",
        "TimeNextVisible": "Tue, 02 Apr 2019 19:03:32 GMT",
        "DequeueCount": "69",
        "MessageText": "{\"etag\":\"\",\"ItemInternalId\":\"ab5c-4859-a755\",\"LastChangeDate\":\"2019-04-02T13:37:32.9638012Z\",\"is_current_employee\":true}"
    }

This is causing me a massive headache when I go to try and use the body, especially when I pipe that raw MessageText to my Liquid Template. I tried the expression json(triggerBody()) and that does not work, it fails because of the first "/". I tried to use the Parse JSON action, but that does not work because that is just designed to map the JSON to a schema and fails because MessageText is a string anyway.

I created a NodeJS Function to literally return a JSON.parse() with a JSON content type header. Which seems like a huge waste of resources.

EDIT: One solution I got working was to manually base64 encode when I add to queue and then @json(decodeBase64(triggerBody()?['MessageText'])) when I pull from queue. The result works but wont that encode twice under the hood?

标签: azure-logic-apps

解决方案


我也试图理解你的问题..我尝试将消息添加到队列并在逻辑中检索,但我没有看到任何此类问题..我错过了什么吗?

在此处输入图像描述

在逻辑应用中检索到的消息

在此处输入图像描述

我在电子邮件中得到这样的输出

{"ItemInternalId":"ab5c-4859-a755","LastChangeDate":"2019-04-02T13:37:32.9638012Z","is_current_employee":true}

推荐阅读