An Azure service that provides an event-driven serverless compute platform.
Thanks for your replies @SurferOnWww and @AgaveJoe .
BTW @SurferOnWww you are correct on what you pointed out, but is just that when I pasted here the code I altered a bit the names to not use exactly the working code, just a version of it here and then I missed that renamed, but thank you for spotting it.
The application sending the event to the EventGrid was making a double serialization of the object within the EventgridEvent.Data. This was happening because as the object was instantiated when added to the EventGridEvent it was serialized to Json, but when the event is publish using Azure.Messaging.EventGrid; there is an additional Json serialization. The object in Data was been serialized twice. Ultra confusing because when the event is received at the function, and is deserialized during the triggering and binding for the function, the Data object is seem as a properly formed Json object, when in fact is being Serialized twice and the string contains the UTF8 scape characters.
My solution was going back to the source application publishing the event, removing the double json serialization, just leaving the Json serialization executed when the event is published and that was the fixed. The deserialization of the EventGridEvent.Data worked at the function receiving side.
thanks for your suggestion of the console app @AgaveJoe , when I was setting up a new console I came up with the idea of going back to strip the publishing application, so your suggestion actually led me to find the issue.
One thing to note is that the double serialization was being properly Deserialized when using .NET6 and Newtonsoft 13.0.1 which is part of the packages used by the azure-function Microsoft.NET.SDK.Functions 4.1.0. but failing with a very confusing generic error message when using same code with .NET8 sdks Microsoft.Azure.Functions.Worker.Sdk 1.16.4 with the underlying Azure.Core 1.36.0 which uses System.Text.Json 4.7.2