-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support strongly typed event data #11
Comments
Is there anything like this planned? |
We just use the EventGrid .net SDK to surface the trigger so it’s likely a better ask for the event grid SDK team. If the SDK supported it functions would “inherit” that functionality. I’ll ping them on this ask and reference the discussion. |
@jeffhollan Can you give us an update on this? Also, I'd like to see enums for |
An update would be highly appreciated, @jeffhollan. |
Sure let me send this to the Event Grid team and see if any thoughts on what would be required here and if something that can be committed |
Hello there. Any updates on this topic? |
+1 Nice to have this feature |
So the EventGrid client library (NuGet: "Microsoft.Azure.EventGrid") has a EventGridSubscriber that supports the ability to add custom mappings that will be used during deserialization. With this you can then Cast the Data property to the type you are interested in. While not exactly what is being asked for this might provide the insight to someone more familiar with the inner working of Azure functions and how the EventGridTrigger works. public void Example(System.IO.Stream inbound)
{
var eventGridSubscriber = new Microsoft.Azure.EventGrid.EventGridSubscriber();
eventGridSubscriber.AddOrUpdateCustomEventMapping(
typeof(MyEvent).FullName,
typeof(MyEvent));
var events = eventGridSubscriber.DeserializeEventGridEvents(inbound);
var myEvent = (MyEvent)events.First().Data;
} NOTE: The Microsoft.Azure.EventGrid package has been deprecated in favor of Azure.Messaging.EventGrid however I think Azure functions are still using the Microsoft.Azure.EventGrid package Additional reference material: |
This is available in the new version of bindings (3.x), reference here. |
Currently
EventGridEvent
is designed with itsData
property as aJObject
which will force everyone downstream to get into dealing with converting that into their own strong types using the JSON.NET APIs themselves.I propose supporting an
EventGridEvent<T>
where theData
property would now beT
. This would allow people to use a parameter such asEventGridEvent<CustomerProfileUpdated>
and it would "just work". Simultaneously we can keep the existing, defaultEventGridEvent
by simply changing it to be a subclass ofEventGridEvent<JObject>
that effectively locks it intoJObject
for people who might choose to work with that model instead.The text was updated successfully, but these errors were encountered: