I'm creating a very simple Azure Function with NET8.
public async Task Run(
[ServiceBusTrigger("wordvoice", Connection = "SBConnectionString")]
string message)
{
AudioServiceBusRequest request =
JsonSerializer.Deserialize<AudioServiceBusRequest>(message);
await ProcessService.ProcessAudio(request, processName, _logger);
}
In the service bus, I add a simple json like that
{
"wordId": 33,
"language": 1,
"word": "go"
}
I created a model to receive this json
public class AudioServiceBusRequest
{
[JsonPropertyName("wordId")]
public long? WordId { get; set; }
[JsonPropertyName("language")]
public string Language { get; set; }
[JsonPropertyName("word")]
public string Word { get; set; }
}
When the message is received by the Azure Function, I get at least 90 lines of errors starting with
Exception: System.AggregateException: One or more errors occurred. (The JSON value could not be converted to System.String. Path: $.language | LineNumber: 2 | BytePositionInLine: 17.)
---> System.Text.Json.JsonException: The JSON value could not be converted to System.String. Path: $.language | LineNumber: 2 | BytePositionInLine: 17.
---> System.InvalidOperationException: Cannot get the value of a token type 'Number' as a string.
I'm using the same json in an Azure Function built with NET6 and it is working.

