2
votes

C# .NET Core Azure Functions v2; Microsoft.Azure.ServiceBus 3.2.0, Microsoft.Azure.WebJobs 3.0.2, Microsoft.Azure.WebJobs.Extensions.ServiceBus 3.0.1

We receive BrokeredMessages posted using the old ServiceBus packages (WindowsAzure.ServiceBus, Microsoft.ServiceBus), Content-Type: text/plain.

We use ServiceBusTrigger in the azure function to consume:

[ServiceBusTrigger("topic", "subscription", Connection = "appsetting")]Message message,

When attempting to consume from topic using new package

(microsoft.azure.servicebus) we encounter the following error:

System.Private.CoreLib: Exception while executing function: Function1. Microsoft.Azure.WebJobs.Host: Exception binding parameter 'message'. System.Private.CoreLib: Unable to translate bytes [99] at index 60 from specified code page to Unicode.

This error occurs even if we attempt to use other types instead of Message, such as string, byte[] and custom types.

The issue seems to be the Content-Type:

Content-Type: text/plain

Other BrokeredMessage combinations seem to work properly (where none is empty Content-Type); stream+none, stream+text/plain, string+none and string+text/plain;charset=unicode.

We may be able to circumvent this (untested) in our webjobs, as we can access MessageReceiver or other ServiceBus configurations at runtime to handle this, but so far we have been unable to find any solution or method to handle this for Azure Functions as the framework throws an error before we are inside the function.

Have anyone else encountered this error? Is my current approach wrong?

We are not in control of the message generation, so we are unable to easily change that.

Others have different issues with similar configuration: BrokeredMessage send and Message consumer in Azure Function v2

1
Did you get anywhere with this in the end? I am having the same problem right now - Jamie Peacock
@JamiePeacock I would comment on here github.com/Azure/Azure-Functions/issues/1052 so msft people can look into it - scorpion5211

1 Answers

1
votes

Have you tried to specify the encoding along with the content type? like: Content-Type: text/plain;charset=unicode