Azure Messaging Eventgrid (4.6.0) issue with JObject in data property
See original GitHub issueWe have been using Microsoft.Azure.Eventgrid 3.2.x package for quite a while now in our function projects to publish messages. When publishing, we use a JObject to fill the data property of the EventGridEvent, works like a charm as shown in the following example
var data = new JObject { {"fileId", fileId}, {"fileName", fileName} };
and later on this JObject is used as
var eventGridEvent = new EventGridEvent( Guid.NewGuid().ToString(), subject, **someJObject**, eventType, DateTime.Now, "1.0" );
Last week we saw that this nuget package has been deprecated and we needed to move to the new Azure Messaging Eventgrid 4.6.x nuget package so we did. When using empty JObjects in some cases (just sending a notification that something is ready for processing), we also use the above code, which breaks (new method signature isn’t reflected in above example). In run time, we get the error: The collection type ‘Newtonsoft.Json.Linq.JObject’ is not supported.
When we do some modifications to use a json string instead, all quotation marks get translated to unicode formatting (even when specifying the formatter to None). The Microsoft Docs example to use objects and serialize them might be an option, but requires quite some code changes.
In the end, this left us in a non working situation on production, where we had to rollback to the old package.
Any idea if JObject support for the data element will be back into support? Is this just some bug that needs to be resolved, or is this by design?
Awaiting your responses.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
Hi,
Thanks for your quick responses! I’ll check if the provided solution solves our issue.
@pakrym pointed out that in .NET 6.0 (which is still in preview), there is a JsonNode type being included in System.Text.Json which should have similar semantics to the JObject so swapping out those types would be a third option.