0
votes

I have written an Azure function (2.0). I am trying to consume a queue message (brokered message) like below.

 FunctionName("ConsumeQueueMessage")]
     public static async Task InitiateQueueHandling([ServiceBusTrigger("queueName", Connection = "AzureServiceBus")]BrokeredMessage queueMessage, ILogger log)
     {
         log.LogInformation($"HTTP trigger function starting processing campaign seek request at : {DateTime.Now}.");

But when i run it locally I am getting an error like this

Microsoft.Azure.WebJobs.Host: Exception binding parameter 'queueMessage'. Microsoft.Azure.WebJobs.Host: Binding parameters to complex objects (such as 'BrokeredMessage') uses Json.NET serialization.

  1. Bind the parameter type as 'string' instead of 'BrokeredMessage' to get the raw values and avoid JSON deserialization, or
  2. Change the queue payload to be valid json. The JSON parser failed: Unexpected character encountered while parsing value: @. Path '', line 0, position 0.

Queue message is created as below

    var message = new BrokeredMessage(objWrapper);
             message.Properties["message"] = JsonConvert.SerializeObject(objWrapper.Message);
             message.Properties["messageType"] = objWrapper.Type.ToString();
1
Which version of the WebJobs SDK are you using? 'Cause it smells a lot like this: stackoverflow.com/questions/58028180/… - eli
Does this answer your question? Servicebustrigger deserialization fails - eli
Hey, @Arjun Menon, would you mind accept my reply as answer for others to refer? - Doris Lv
Hi , thanks for your quick answer. The object that is creating the queue message is running in .NET framework where as Azure function is in .NET core. will that be an issue? - Arjun Menon
Sorry for my slow reply, I didn't get this comment. And I don't think what you mentioned is an issue for your case. - Doris Lv

1 Answers

0
votes

You should notice this, and use Message rather than BrokeredMessage.

These parameter types are for Azure Functions version 1.x; for 2.x and higher, use Message instead of BrokeredMessage.