问题
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 <
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:
Enabled "Managed Identity" on the Logic App.
Added Storage-Queue-Contributor permissions on the storage queue.
Used
utcnow('R')
to get this date format ("Tue, 08 Sep 2020 12:03:08 GMT") forx-ms-date
HTTP header (no doc from MS about this).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