0

Ok.

I'm writing a POC (Proof of Concept) Logic App.

The logic app has a Service Bus connector wired to a queue.

I'm using peek/complete/abandon.

I wrote a client app (dotnet c# console app) that writes messages to the queue (nothing really to do with the logic app part).

I'm setting the Content Type to "text/plain".

string payLoad = @"{ ""myid"": ""1000"", ""mymessage"": ""1000 is great"" , ""myboolean"" : ""true"" }";
QueueClient queueClient = /* not seen here */;
brokeredMsg = new BrokeredMessage(payLoad) { ContentType = System.Net.Mime.MediaTypeNames.Text.Plain };
queueClient.Send(brokeredMsg);

Now I use Service Bus Explorer (4.0.104), and I see the message in the queue

enter image description here

The issue is that when my Logic App runs, its not seeing plain-text/json.

enter image description here

You can see it picked up the content-type.

But it garbly gooks the content itself.

Is there a way to get raw-text with this trigger?

Note, the documentation says:

let's look at the two Content-Types that don't require conversion or casting that you can use in a logic app: application/json and text/plain.

from : https://learn.microsoft.com/en-us/azure/logic-apps/logic-apps-content-type

https://learn.microsoft.com/en-us/azure/connectors/connectors-create-api-servicebus

My C# console app packages.config (nothing to do with Logic Apps, but including for completeness)

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.1.0" targetFramework="net45" />
  <package id="WindowsAzure.ServiceBus" version="2.1.4.0" targetFramework="net45" />
</packages>

APPEND:

I needed to do two thing to get it to work

One:

I had to change the "sender" code slightly.

QueueClient queueClient = /* not seen here */;

string ct = System.Net.Mime.MediaTypeNames.Text.Plain;
/* see https://social.msdn.microsoft.com/Forums/en-US/8fbf2391-8440-46db-bb47-648daccf46fd/servicebus-output-json-is-being-wrapped-in-a-xml-header-in-logic-app?forum=azurelogicapps and https://abhishekrlal.com/2012/03/30/formatting-the-content-for-service-bus-messages/ */

string payLoad = @"{ ""myid"": ""1000"", ""mymessage"": ""1000 is great"" , ""myboolean"" : ""true"" }";
brokeredMsg = new BrokeredMessage(new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(Convert.ToString(payLoad))), true) { ContentType = ct };

queueClient.Send(brokeredMsg);

And I used the hint Derek Li gave me.

I've accepted his answer as the-answer, but PLEASE NOTE I had to do slightly more than he suggested. The code above has the urls for the reason I changed the sender code.

In a nutshell, the constructor for BrokeredMessage that I was using was choosing a specific serializer for me.

BrokeredMessage(Object) Initializes a new instance of the BrokeredMessage class from a given object by using DataContractSerializer with a binary XmlDictionaryWriter.

https://learn.microsoft.com/en-us/dotnet/api/microsoft.servicebus.messaging.brokeredmessage.-ctor?view=azureservicebus-4.1.1#Microsoft_ServiceBus_Messaging_BrokeredMessage__ctor

and after I figured out the answer, I found this SOF answer:

Azure Service Bus Serialization Type

granadaCoder
  • 26,328
  • 10
  • 113
  • 146

1 Answers1

1

You can use expression @base64ToString(triggerBody()?['ContentData'])" to convert it to string.

Derek Li
  • 3,089
  • 2
  • 25
  • 38
  • 1
    This got me half way there. I'm figuring out the second part now. @string3http://schemas.microsoft.com/2003/10/Serialization/�M{ "myid": "1000", "mymessage": "1000 is great", "myboolean" : "true" } – granadaCoder Oct 16 '17 at 19:28
  • I've appended my answer to show what I needed to do IN ADDITION to this answer. (Emphasized for future readers) – granadaCoder Oct 16 '17 at 19:52