Getting content from service bus in logic apps

2019-05-23 11:59发布

I am new to Azure logic apps. I have a service bus and pass a json object message to that service bus then I set up an action in logic apps to listen to my service bus. So everytime a new message come in to that service bus my logic apps will pick it upenter image description here and send it to http.

My question is how can I grab the property from the message in service bus and pass it to my http action. I tried this

“Id” : “@{json(triggerBody()[‘ContentData’]).id}”

but it's not working

3条回答
劫难
2楼-- · 2019-05-23 12:27

Who and how is sending the message on the queue?

I read a json message property (DestinationPath) in this way:

@{json(base64ToString(triggerBody()?['ContentData'])).DestinationPath}

Here is how my Logic App looks like enter image description here

and in my case the message is sent from an Azure webjob as a BrokeredMessage:

string jsonMessage = JsonConvert.SerializeObject(myObject);
Stream streamMessage = new MemoryStream(Encoding.UTF8.GetBytes(jsonMessage));
BrokeredMessage msg = new BrokeredMessage(streamMessage);

client.Send(msg);
查看更多
贪生不怕死
3楼-- · 2019-05-23 12:28

Logic app now has expressions to decode Base 64 encoded value.

My requirement was to decode the encoded ServiceBus message to an Azure Function. I solved this using Logic App Expression, decodeBase64() which can accept a dynamic content of type string, in this case the 'Content'- Content of the message, and returns the decoded json string. decodeBase64(triggerBody()?['ContentData'])

Find attached the screen shots for reference.

In the place holder for input to the action, include an expression and choose decodeBase64()

Get back to Dynamic Content tab to select 'Content' available from previous step, on hitting OK the expression would get generated

查看更多
做自己的国王
4楼-- · 2019-05-23 12:32

ContentData of Service Bus messages is Base64 encoded, so you need to decode it first, e.g.

“Id” : “@{json(base64ToString(triggerBody()?[‘ContentData’])).id}”
查看更多
登录 后发表回答