You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sdk/eventgrid/azure-eventgrid/migration_guide.md
+24-1
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ The modern Event Grid client library also provides the ability to share in some
36
36
The v2.x major version comes with support for [CloudEvents](https://github.com/cloudevents/spec). Now the cloud native Cloud Events can be directly published using the `CloudEvent` constructor or as a dictionary as follows:
37
37
38
38
```Python
39
-
from azure.eventgridimport CloudEvent
39
+
from azure.core.messagingimport CloudEvent
40
40
41
41
cloud_event = CloudEvent(
42
42
type="Contoso.Items.ItemReceived",
@@ -73,6 +73,29 @@ The `publish_events` API is replaced with `send` in v2.0. Additionally, `send` A
73
73
|---|---|---|
74
74
|`EventGridClient(credentials).publish_events(topic_hostname, events)`|`EventGridPublisherClient(endpoint, credential).send(events)`|[Sample for client construction](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/eventgrid/azure-eventgrid/samples/sync_samples/sample_publish_events_using_cloud_events_1.0_schema.py)|
75
75
76
+
### Consuming Events
77
+
78
+
The v2.x major version supports deserializing dictionaries into strongly typed objects. The `from_dict` methods in the `CloudEvent` and `EventGridEvent` models can be used for the same.
79
+
80
+
This example consumes a payload message received from ServiceBus and deserializes it to an EventGridEvent object.
81
+
82
+
```Python
83
+
from azure.eventgrid import EventGridEvent
84
+
from azure.servicebus import ServiceBusClient
85
+
import os
86
+
import json
87
+
88
+
# all types of EventGridEvents below produce same DeserializedEvent
Copy file name to clipboardExpand all lines: sdk/eventgrid/azure-eventgrid/samples/async_samples/sample_publish_events_using_cloud_events_1.0_schema_async.py
0 commit comments