We send servicebus messages with an old library via Microsoft.ServiceBus.Messaging which is available in the nuget-package 'ServiceBus.v1_1' and want to receive and parse the message with the newest service bus client: Azure.Messaging.ServiceBus.
[FunctionName("FunctionHandler")]
public async Task RunFunction(
[ServiceBusTrigger("%ServiceBusQueueName%", Connection = ApFunctionDefaults.ServiceBusNames.ServiceBusConnectionString)]
ServiceBusReceivedMessage queueMessage)
{
var jsonSettings = KnownTypesBinder.GetSerializerSettings(KnownTypeProvider.GetKnownTypes());
command = JsonConvert.DeserializeObject<MyDto>(Encoding.UTF8.GetString(queueMessage.Body), jsonSettings); // <- throws an exception
}
The body of the message queueMessage.Body has some value like that:
@\u000eCommandMessage\bUhttp://schemas.datacontract.org/2004/07/ ...more payload here... a\u0001"
With JsonConvert.DeserializeObject, we get an format exception.
How do we deserialize a message which was send by Microsoft.ServiceBus.Messaging (Nuget-Package: ServiceBus.v1_1) with Azure.Messaging.ServiceBus?