Put/Post JSON message to Azure Storage Queue via Logic App

我与影子孤独终老i 提交于 2021-01-29 17:03:00

问题


I want to be able to use Logic Apps to put/post messages in an Azure Storage Queue, because I want to make use of the Managed Identity option that HTTP Logic App acion provides.

I have a Logic App that uses HTTP action to post XML messages to the queue and I have a "Put a message on a queue" action that puts JSON message to the queue for debugging purposes.

My ultimate goal is to be able to use the HTTP action with Managed Identity as Authentication but be able to post JSON messages to the queue like the "Put a message on a queue" action is able to.


回答1:


You can certainly send JSON as message body. In fact you can send any text. You just have to ensure that the text you're sending as message body must be XML safe e.g. replace < with &lt; etc. Generally Base64 encoded string messages are sent to ensure this.

From the REST API documentation:

A message must be in a format that can be included in an XML request with UTF-8 encoding. To include markup in the message, the contents of the message must either be XML-escaped or Base64-encode. Any XML markup in the message that is not escaped or encoded will be removed before the message is added to the queue.




回答2:


Here is what worked for me:

  1. Enabled "Managed Identity" on the Logic App.

  2. Added Storage-Queue-Contributor permissions on the storage queue.

  3. Used utcnow('R') to get this date format ("Tue, 08 Sep 2020 12:03:08 GMT") for x-ms-date HTTP header (no doc from MS about this).

  4. Inserted JSON data inside

    <QueueMessage> 
        <MessageText>
        {
          "car": "Audi",
          "year": 1983
        }
       </MessageText>  
    </QueueMessage>
    

Final result in Logic App designer:



来源:https://stackoverflow.com/questions/62173016/put-post-json-message-to-azure-storage-queue-via-logic-app

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