What version of .NET does your existing project use?
.NET 6
What version of .NET are you attempting to target?
.NET 8
Description
Hi all!
I'm working on migration from Azure Function on .NET 6 in-process model to .NET 8 isolated process.
I have Service Bus queue trigger to listen queueA and after processing I want to put message to other queue queueB.
I have code like this:
[Function(nameof(HandleQueueA))]
[ServiceBusOutput(OutputQueueB, Connection = "ServiceBusConnection")]
public async Task<Envelope<JObject>> Run(
[ServiceBusTrigger(StartQueueA, Connection = "ServiceBusConnection")]
ServiceBusReceivedMessage message)
{
var eventData = JsonConvert.DeserializeObject<Envelope<JToken>>(message.Body);
// some logic here
return eventData;
}
Definition for Envelope class is like:
public class Envelope<T>
{
public string Id { get; set; }
public DateTimeEpoch CreatedAt { get; set; }
public string EventInstance { get; set; }
public T Content { get; set; }
}
In JObject content here I have some business attributed for event itself. And this works with no errors but at the end in queueB I can see not fully serialized message like:
If I'm trying to serialize eventData before returning from function, I can see correct data
If using Newtonsoft.Json.JsonConvert.SerializeObject(eventData):
"{\"Id\":\"<some-guid>\",\"createdAt\":{\"dateTime\":\"2024-07-30T15:40:12.5198266Z\",\"epoch\":1722354012},\"content\":{\"attribute1\":\"attribute1Value\",\"attribute2\":\"attribute2Value\",\"some-collection1\":{\"name\":\"name\",\"value\":\"value\"},\"collection2\":{\"name\":\"name\",\"value\":\"value\"}
I have the next global serialization settings:
JsonConvert.DefaultSettings = () => new JsonSerializerSettings()
{
DefaultValueHandling = DefaultValueHandling.Include,
NullValueHandling = NullValueHandling.Ignore,
ContractResolver = new CamelCasePropertyNamesContractResolver(),
Converters = new List<JsonConverter> { new StringEnumConverter(), new IsoDateTimeConverter() },
};
What version of .NET does your existing project use?
.NET 6
What version of .NET are you attempting to target?
.NET 8
Description
Hi all! I'm working on migration from Azure Function on .NET 6 in-process model to .NET 8 isolated process. I have Service Bus queue trigger to listen
queueA
and after processing I want to put message to other queuequeueB
.I have code like this:
Definition for Envelope class is like:
In JObject content here I have some business attributed for event itself. And this works with no errors but at the end in queueB I can see not fully serialized message like:
If I'm trying to serialize eventData before returning from function, I can see correct data
If using Newtonsoft.Json.JsonConvert.SerializeObject(eventData):
"{\"Id\":\"<some-guid>\",\"createdAt\":{\"dateTime\":\"2024-07-30T15:40:12.5198266Z\",\"epoch\":1722354012},\"content\":{\"attribute1\":\"attribute1Value\",\"attribute2\":\"attribute2Value\",\"some-collection1\":{\"name\":\"name\",\"value\":\"value\"},\"collection2\":{\"name\":\"name\",\"value\":\"value\"}
I have the next global serialization settings:I would appreviate any ideas what's wrong here :)
Thanks in advance!
Project configuration and dependencies
.NET 8 Microsoft.Azure.Functions.Worker 1.22.0 Microsoft.Azure.Functions.Worker.Extensions.ServiceBus 5.20.0 Microsoft.Azure.Functions.Worker.Sdk 1.17.4
Link to a repository that reproduces the issue
No response