Getting content from service bus in logic apps

纵饮孤独 提交于 2019-12-04 15:01:44

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

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);

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

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

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

My precise setup to decrypt the base 64 message using the interface. Easy enough to type into the expression builder.

json(base64ToString(triggerBody()?['ContentData']))

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