From 5e7332ce7b01a4debf06fa497e974980c1e78e60 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Tue, 1 Sep 2020 11:03:37 -0700 Subject: [PATCH 1/7] Read me + docstrings --- sdk/eventgrid/azure-eventgrid/CHANGELOG.md | 4 +- sdk/eventgrid/azure-eventgrid/README.md | 125 ++++++++++++++++-- .../azure/eventgrid/_consumer.py | 4 +- .../azure/eventgrid/_publisher_client.py | 6 +- .../eventgrid/aio/_publisher_client_async.py | 6 +- 5 files changed, 124 insertions(+), 21 deletions(-) diff --git a/sdk/eventgrid/azure-eventgrid/CHANGELOG.md b/sdk/eventgrid/azure-eventgrid/CHANGELOG.md index a4a05abba5b4..94765d992733 100644 --- a/sdk/eventgrid/azure-eventgrid/CHANGELOG.md +++ b/sdk/eventgrid/azure-eventgrid/CHANGELOG.md @@ -2,7 +2,9 @@ ## 2.0.0b1 (Unreleased) - - Placeholder - NEEDS TO BE CHANGED + - Version (2.0.0b1) is the first preview of our efforts to create a user-friendly and Pythonic client library for AzureEventGrid. + + For more information about this, and preview releases of other Azure SDK libraries, please visit https://azure.github.io/azure-sdk/releases/latest/python.html. ## 1.3.0 (2019-05-20) diff --git a/sdk/eventgrid/azure-eventgrid/README.md b/sdk/eventgrid/azure-eventgrid/README.md index 67a40b44a789..bdc0b92bdc50 100644 --- a/sdk/eventgrid/azure-eventgrid/README.md +++ b/sdk/eventgrid/azure-eventgrid/README.md @@ -1,21 +1,122 @@ -# Microsoft Azure SDK for Python +# Azure EventGrid client library for Python -This is the Microsoft Azure Event Grid Client Library. -This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. -For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). +Azure Event Grid is a fully-managed intelligent event routing service that allows for uniform event consumption using a publish-subscribe model. +[Source code][python-eg-src] | [Package (PyPI)][python-eg-pypi] | [API reference documentation][python-eg-ref-docs]| [Product documentation][python-eg-product-docs] | [Samples][python-eg-samples] -# Usage +## Getting started -For code examples, see [Event Grid](https://docs.microsoft.com/python/api/overview/azure/event-grid) -on docs.microsoft.com. +### Prerequisites +* Python 2.7, or 3.5 or later is required to use this package. +* You must have an [Azure subscription][azure_subscription] and an EventGrid Topic resource to use this package. +### Install the package +Install the Azure EventGrid client library for Python with [pip][pip]: -# Provide Feedback +```bash +pip install azure-eventgrid +``` -If you encounter any bugs or have suggestions, please file an issue in the -[Issues](https://github.com/Azure/azure-sdk-for-python/issues) -section of the project. +#### Create an EventGrid Topic +You can create the resource using [Azure Portal][azure_portal_create_EG_resource] +### Authenticate the client +In order to interact with the Eventgrid service, you will need to create an instance of a client. +A **topic_hostname** and **credential** are necessary to instantiate the client object. -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-eventgrid%2FREADME.png) +#### Looking up the endpoint +You can find the endpoint and the hostname on the Azure portal. + +#### Create the client with AzureKeyCredential + +To use an API key as the `credential` parameter, +pass the key as a string into an instance of [AzureKeyCredential][azure-key-credential]. + +```python +from azure.core.credentials import AzureKeyCredential +from azure.eventgrid import EventGridPublisherClient + +topic_hostname = "https://..eventgrid.azure.net/api/events" +credential = AzureKeyCredential("") +eg_publisher_client = EventGridPublisherClient(topic_hostname, credential) +``` + +## Key concepts + +### EventGridPublisherClient +`EventGridPublisherClient` provides operations to send event data to topic hostname specified during client initialization. +Either a list or a single instance of CloudEvent/EventGridEvent/CustomEvent can be sent. + +### EventGridConsumer +`EventGridConsumer` is used to desrialize an event received. + +## Troubleshooting + +### General +Eventgrid client library will raise exceptions defined in [Azure Core][azure_core_exceptions]. + +### Logging +This library uses the standard +[logging][python_logging] library for logging. +Basic information about HTTP sessions (URLs, headers, etc.) is logged at INFO +level. + +### Optional Configuration + +Optional keyword arguments can be passed in at the client and per-operation level. +The azure-core [reference documentation][azure_core_ref_docs] +describes available configurations for retries, logging, transport protocols, and more. + +## Next steps + +The following section provides several code snippets illustrating common patterns used in the EventGrid Python API. + +### More sample code + +These code samples show common champion scenario operations with the Azure Eventgrid client library. + +* Publish Custom Events to a topic: [cs1_publish_custom_events_to_a_topic.py][python-eg-sample-customevent] +* Publish Custom events to a domain topic: [cs2_publish_custom_events_to_a_domain_topic.py][python-eg-sample-customevent-to-domain] +* Deserialize a System Event: [cs3_consume_system_events.py][python-eg-sample-consume-systemevent] +* Deserialize a Custom Event: [cs4_consume_custom_events.py][python-eg-sample-consume-customevent] +* Deserialize a Cloud Event: [cs5_consume_events_using_cloud_events_1.0_schema.py][python-eg-sample-consume-cloudevent] +* Publish a Cloud Event: [cs6_publish_events_using_cloud_events_1.0_schema.py][python-eg-sample-send-cloudevent] + +More samples can be found [here][python-eg-samples]. + +### Additional documentation + +For more extensive documentation on Azure EventGrid, see the [Eventgrid documentation][python-eg-product-docs] on docs.microsoft.com. + +## Contributing +This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit [cla.microsoft.com][cla]. + +When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct][code_of_conduct]. For more information see the [Code of Conduct FAQ][coc_faq] or contact [opencode@microsoft.com][coc_contact] with any additional questions or comments. + + + +[python-eg-src]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/eventgrid/azure-eventgrid/ +[python-eg-pypi]: https://pypi.org/project/azure-eventgrid +[python-eg-product-docs]: https://docs.microsoft.com/en-us/azure/event-grid/overview +[python-eg-ref-docs]: https://aka.ms/azsdk/python/eventgrid/docs +[python-eg-samples]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/eventgrid/azure-eventgrid/samples + +[azure_portal_create_EG_resource]: https://ms.portal.azure.com/#blade/HubsExtension/BrowseResource/resourceType/Microsoft.EventGrid%2Ftopics +[azure-key-credential]: https://aka.ms/azsdk/python/core/azurekeycredential +[azure_core_exceptions]: https://aka.ms/azsdk/python/core/docs#module-azure.core.exceptions +[python_logging]: https://docs.python.org/3/library/logging.html +[azure_core_ref_docs]: https://aka.ms/azsdk/python/core/docs + +[python-eg-sample-customevent]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/eventgrid/azure-eventgrid/samples/champion_scenarios/cs1_publish_custom_events_to_a_topic.py +[python-eg-sample-customevent-to-domain]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/eventgrid/azure-eventgrid/samples/champion_scenarios/cs2_publish_custom_events_to_a_domain_topic.py +[python-eg-sample-consume-systemevent]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/eventgrid/azure-eventgrid/samples/champion_scenarios/cs3_consume_system_events.py +[python-eg-sample-consume-customevent]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/eventgrid/azure-eventgrid/samples/champion_scenarios/cs4_consume_custom_events.py +[python-eg-sample-send-cloudevent]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/eventgrid/azure-eventgrid/samples/champion_scenarios/cs5_publish_events_using_cloud_events_1.0_schema.py +[python-eg-sample-consume-cloudevent]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/eventgrid/azure-eventgrid/samples/champion_scenarios/cs6_consume_events_using_cloud_events_1.0_schema.py + +[cla]: https://cla.microsoft.com +[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ +[coc_contact]: mailto:opencode@microsoft.com diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_consumer.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_consumer.py index def40ea69c4b..80cf18d9c859 100644 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_consumer.py +++ b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_consumer.py @@ -32,9 +32,9 @@ def deserialize_event(self, event, **kwargs): """Single event following CloudEvent/EventGridEvent schema will be parsed and returned as DeserializedEvent. :param event: The event to be deserialized. :type event: Union[str, dict, bytes] + :keyword str encoding: The encoding that should be used. Defaults to 'utf-8' :rtype: models.DeserializedEvent - - :raise: :class:`ValueError`, when events do not follow CloudEvent or EventGridEvent schema. + :raises: :class:`ValueError`, when events do not follow CloudEvent or EventGridEvent schema. """ encode = kwargs.pop('encoding', 'utf-8') try: diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_publisher_client.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_publisher_client.py index a0e5ff7e62c8..7e06364f4668 100644 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_publisher_client.py +++ b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_publisher_client.py @@ -51,12 +51,12 @@ def send(self, events, **kwargs): # type: (SendType, Any) -> None """Sends event data to topic hostname specified during client initialization. - :param events: A list of CloudEvent/EventGridEvent/CustomEvent to be sent. - :type events: Union[List[models.CloudEvent], List[models.EventGridEvent], List[models.CustomEvent]] + :param events: A list or an instance of CloudEvent/EventGridEvent/CustomEvent to be sent. + :type events: SendType :keyword str content_type: The type of content to be used to send the events. Has default value "application/json; charset=utf-8" for EventGridEvents, with "cloudevents-batch+json" for CloudEvents :rtype: None - :raise: :class:`ValueError`, when events do not follow specified SendType. + :raises: :class:`ValueError`, when events do not follow specified SendType. """ if not isinstance(events, list): events = [events] diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py index f4b552b0882e..48c5df022af8 100644 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py +++ b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py @@ -52,12 +52,12 @@ async def send(self, events, **kwargs): # type: (SendType) -> None """Sends event data to topic hostname specified during client initialization. - :param events: A list of CloudEvent/EventGridEvent/CustomEvent to be sent. - :type events: Union[List[models.CloudEvent], List[models.EventGridEvent], List[models.CustomEvent]] + :param events: A list or an instance of CloudEvent/EventGridEvent/CustomEvent to be sent. + :type events: SendType :keyword str content_type: The type of content to be used to send the events. Has default value "application/json; charset=utf-8" for EventGridEvents, with "cloudevents-batch+json" for CloudEvents :rtype: None - :raise: :class:`ValueError`, when events do not follow specified SendType. + :raises: :class:`ValueError`, when events do not follow specified SendType. """ if not isinstance(events, list): events = [events] From 2d077f23eeace98e8545e029612077da1b445de3 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Tue, 1 Sep 2020 11:07:46 -0700 Subject: [PATCH 2/7] Update sdk/eventgrid/azure-eventgrid/CHANGELOG.md --- sdk/eventgrid/azure-eventgrid/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/eventgrid/azure-eventgrid/CHANGELOG.md b/sdk/eventgrid/azure-eventgrid/CHANGELOG.md index 94765d992733..db65d2d56296 100644 --- a/sdk/eventgrid/azure-eventgrid/CHANGELOG.md +++ b/sdk/eventgrid/azure-eventgrid/CHANGELOG.md @@ -2,7 +2,7 @@ ## 2.0.0b1 (Unreleased) - - Version (2.0.0b1) is the first preview of our efforts to create a user-friendly and Pythonic client library for AzureEventGrid. + - Version (2.0.0b1) is the first preview of our efforts to create a user-friendly and Pythonic client library for Azure EventGrid. For more information about this, and preview releases of other Azure SDK libraries, please visit https://azure.github.io/azure-sdk/releases/latest/python.html. From 631766fdb5af344251af7a8e515d0ddabd073e26 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Tue, 1 Sep 2020 12:08:16 -0700 Subject: [PATCH 3/7] comments --- sdk/eventgrid/azure-eventgrid/CHANGELOG.md | 7 +- sdk/eventgrid/azure-eventgrid/README.md | 123 ++++++++++++++++++++- 2 files changed, 127 insertions(+), 3 deletions(-) diff --git a/sdk/eventgrid/azure-eventgrid/CHANGELOG.md b/sdk/eventgrid/azure-eventgrid/CHANGELOG.md index db65d2d56296..3a42bae4144a 100644 --- a/sdk/eventgrid/azure-eventgrid/CHANGELOG.md +++ b/sdk/eventgrid/azure-eventgrid/CHANGELOG.md @@ -1,11 +1,16 @@ # Release History -## 2.0.0b1 (Unreleased) +## 2.0.0b1 (2020-09-08) - Version (2.0.0b1) is the first preview of our efforts to create a user-friendly and Pythonic client library for Azure EventGrid. For more information about this, and preview releases of other Azure SDK libraries, please visit https://azure.github.io/azure-sdk/releases/latest/python.html. + **Breaking Changes** + + - Implements the `EventGridPublisherCloent` for the publish flow for EventGrid Events, CloudEvents and CustomEvents. + - Implements the `EventGridConsumer` for the consume flow of the events. + ## 1.3.0 (2019-05-20) - Event Schemas for new event types from IotHub, Media Services, diff --git a/sdk/eventgrid/azure-eventgrid/README.md b/sdk/eventgrid/azure-eventgrid/README.md index bdc0b92bdc50..84b48721b672 100644 --- a/sdk/eventgrid/azure-eventgrid/README.md +++ b/sdk/eventgrid/azure-eventgrid/README.md @@ -2,7 +2,7 @@ Azure Event Grid is a fully-managed intelligent event routing service that allows for uniform event consumption using a publish-subscribe model. -[Source code][python-eg-src] | [Package (PyPI)][python-eg-pypi] | [API reference documentation][python-eg-ref-docs]| [Product documentation][python-eg-product-docs] | [Samples][python-eg-samples] +[Source code][python-eg-src] | [Package (PyPI)][python-eg-pypi] | [API reference documentation][python-eg-ref-docs]| [Product documentation][python-eg-product-docs] | [Samples][python-eg-samples]| [Changelog][python-eg-changelog] ## Getting started @@ -36,7 +36,7 @@ pass the key as a string into an instance of [AzureKeyCredential][azure-key-cred from azure.core.credentials import AzureKeyCredential from azure.eventgrid import EventGridPublisherClient -topic_hostname = "https://..eventgrid.azure.net/api/events" +topic_hostname = "https://..eventgrid.azure.net" credential = AzureKeyCredential("") eg_publisher_client = EventGridPublisherClient(topic_hostname, credential) ``` @@ -50,8 +50,126 @@ Either a list or a single instance of CloudEvent/EventGridEvent/CustomEvent can ### EventGridConsumer `EventGridConsumer` is used to desrialize an event received. +## Examples + +The following sections provide several code snippets covering some of the most common EventGrid tasks, including: + +* [Send an EventGrid Event](#send-an-eventgrid-event) +* [Send a Cloud Event](#send-a-cloud-event) +* [Consume an eventgrid Event](#consume-an-eventgrid-event) +* [Consume a cloud Event](#consume-a-cloud-event) + +### Send an EventGrid Event + +This example publishes an EventGrid event. + +```Python +import os +from azure.core.credentials import AzureKeyCredential +from azure.eventgrid import EventGridPublisherClient, EventGridEvent + +key = os.environ["EG_ACCESS_KEY"] +topic_hostname = os.environ["EG_TOPIC_HOSTNAME"] + +event = EventGridEvent( + subject="Door1", + data={"team": "azure-sdk"}, + event_type="Azure.Sdk.Demo", + data_version="2.0" +) + +credential = AzureKeyCredential(key) +client = EventGridPublisherClient(topic_hostname, credential) + +client.send(event) +``` + +### Send a Cloud Event + +This example publishes a Cloud event. + +```Python +import os +from azure.core.credentials import AzureKeyCredential +from azure.eventgrid import EventGridPublisherClient, CloudEvent + +key = os.environ["CLOUD_ACCESS_KEY"] +topic_hostname = os.environ["CLOUD_TOPIC_HOSTNAME"] + +event = CloudEvent( + type="Azure.Sdk.Sample", + source="https://egsample.dev/sampleevent", + data={"team": "azure-sdk"} +) + +credential = AzureKeyCredential(key) +client = EventGridPublisherClient(topic_hostname, credential) + +client.send(event) +``` + +### Consume an eventgrid Event + +This example demonstrates consuming and deserializing an eventgrid event. + +```Python +import os +from azure.eventgrid import EventGridConsumer + +consumer = EventGridConsumer() + +eg_storage_dict = { + "id":"bbab6625-dc56-4b22-abeb-afcc72e5290c", + "subject":"/blobServices/default/containers/oc2d2817345i200097container/blobs/oc2d2817345i20002296blob", + "data":{ + "api":"PutBlockList", + }, + "eventType":"Microsoft.Storage.BlobCreated", + "dataVersion":"2.0", + "metadataVersion":"1", + "eventTime":"2020-08-07T02:28:23.867525Z", + "topic":"/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/t-swpill-test/providers/Microsoft.EventGrid/topics/eventgridegsub" +} + +deserialized_event = consumer.decode_eventgrid_event(eg_storage_dict) + +# both allow access to raw properties as strings +time_string = deserialized_event.time +time_string = deserialized_event["time"] +``` + +### Consume a Cloud Event + +This example demonstrates consuming and deserializing a cloud event. + +```Python +import os +from azure.eventgrid import EventGridConsumer + +consumer = EventGridConsumer() + +cloud_storage_dict = { + "id":"a0517898-9fa4-4e70-b4a3-afda1dd68672", + "source":"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.Storage/storageAccounts/{storage-account}", + "data":{ + "api":"PutBlockList", + }, + "type":"Microsoft.Storage.BlobCreated", + "time":"2020-08-07T01:11:49.765846Z", + "specversion":"1.0" +} + +deserialized_event = consumer.decode_cloud_event(cloud_storage_dict) + +# both allow access to raw properties as strings +time_string = deserialized_event.time +time_string = deserialized_event["time"] +``` + ## Troubleshooting +- Enable `azure.eventgrid` logger to collect traces from the library. + ### General Eventgrid client library will raise exceptions defined in [Azure Core][azure_core_exceptions]. @@ -102,6 +220,7 @@ This project has adopted the [Microsoft Open Source Code of Conduct][code_of_con [python-eg-product-docs]: https://docs.microsoft.com/en-us/azure/event-grid/overview [python-eg-ref-docs]: https://aka.ms/azsdk/python/eventgrid/docs [python-eg-samples]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/eventgrid/azure-eventgrid/samples +[python-eg-changelog]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/eventgrid/azure-eventgrid/CHANGELOG.md [azure_portal_create_EG_resource]: https://ms.portal.azure.com/#blade/HubsExtension/BrowseResource/resourceType/Microsoft.EventGrid%2Ftopics [azure-key-credential]: https://aka.ms/azsdk/python/core/azurekeycredential From db2d2fb32402ed91a057596152e08b45068522c7 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Tue, 1 Sep 2020 12:43:08 -0700 Subject: [PATCH 4/7] comment --- sdk/eventgrid/azure-eventgrid/CHANGELOG.md | 7 ++----- sdk/eventgrid/azure-eventgrid/README.md | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/sdk/eventgrid/azure-eventgrid/CHANGELOG.md b/sdk/eventgrid/azure-eventgrid/CHANGELOG.md index 3a42bae4144a..d44b57ff8e4b 100644 --- a/sdk/eventgrid/azure-eventgrid/CHANGELOG.md +++ b/sdk/eventgrid/azure-eventgrid/CHANGELOG.md @@ -2,13 +2,10 @@ ## 2.0.0b1 (2020-09-08) + **Features** - Version (2.0.0b1) is the first preview of our efforts to create a user-friendly and Pythonic client library for Azure EventGrid. - For more information about this, and preview releases of other Azure SDK libraries, please visit https://azure.github.io/azure-sdk/releases/latest/python.html. - - **Breaking Changes** - - - Implements the `EventGridPublisherCloent` for the publish flow for EventGrid Events, CloudEvents and CustomEvents. + - Implements the `EventGridPublisherClient` for the publish flow for EventGrid Events, CloudEvents and CustomEvents. - Implements the `EventGridConsumer` for the consume flow of the events. ## 1.3.0 (2019-05-20) diff --git a/sdk/eventgrid/azure-eventgrid/README.md b/sdk/eventgrid/azure-eventgrid/README.md index 84b48721b672..cf89f08a3cd4 100644 --- a/sdk/eventgrid/azure-eventgrid/README.md +++ b/sdk/eventgrid/azure-eventgrid/README.md @@ -108,7 +108,7 @@ client = EventGridPublisherClient(topic_hostname, credential) client.send(event) ``` -### Consume an eventgrid Event +### Consume an EventGrid Event This example demonstrates consuming and deserializing an eventgrid event. From 8fafd082dc27527f2c04b58ec642b1535aabe43e Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Tue, 1 Sep 2020 12:44:55 -0700 Subject: [PATCH 5/7] one more --- sdk/eventgrid/azure-eventgrid/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/eventgrid/azure-eventgrid/README.md b/sdk/eventgrid/azure-eventgrid/README.md index cf89f08a3cd4..1916a005aa6d 100644 --- a/sdk/eventgrid/azure-eventgrid/README.md +++ b/sdk/eventgrid/azure-eventgrid/README.md @@ -119,7 +119,7 @@ from azure.eventgrid import EventGridConsumer consumer = EventGridConsumer() eg_storage_dict = { - "id":"bbab6625-dc56-4b22-abeb-afcc72e5290c", + "id":"bbab625-dc56-4b22-abeb-afcc72e5290c", "subject":"/blobServices/default/containers/oc2d2817345i200097container/blobs/oc2d2817345i20002296blob", "data":{ "api":"PutBlockList", @@ -128,7 +128,7 @@ eg_storage_dict = { "dataVersion":"2.0", "metadataVersion":"1", "eventTime":"2020-08-07T02:28:23.867525Z", - "topic":"/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/t-swpill-test/providers/Microsoft.EventGrid/topics/eventgridegsub" + "topic":"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/topics/eventgridegsub" } deserialized_event = consumer.decode_eventgrid_event(eg_storage_dict) From 6b99e3fa7716889a187412576d8b1d7bda4acb49 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Tue, 1 Sep 2020 13:07:27 -0700 Subject: [PATCH 6/7] add one more line --- sdk/eventgrid/azure-eventgrid/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sdk/eventgrid/azure-eventgrid/README.md b/sdk/eventgrid/azure-eventgrid/README.md index 1916a005aa6d..c6cc38c9b0a7 100644 --- a/sdk/eventgrid/azure-eventgrid/README.md +++ b/sdk/eventgrid/azure-eventgrid/README.md @@ -50,6 +50,8 @@ Either a list or a single instance of CloudEvent/EventGridEvent/CustomEvent can ### EventGridConsumer `EventGridConsumer` is used to desrialize an event received. +For more information about the key concepts on EventGrid, see [Concepts in Azure Event Grid][publisher-service-doc] + ## Examples The following sections provide several code snippets covering some of the most common EventGrid tasks, including: @@ -234,6 +236,7 @@ This project has adopted the [Microsoft Open Source Code of Conduct][code_of_con [python-eg-sample-consume-customevent]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/eventgrid/azure-eventgrid/samples/champion_scenarios/cs4_consume_custom_events.py [python-eg-sample-send-cloudevent]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/eventgrid/azure-eventgrid/samples/champion_scenarios/cs5_publish_events_using_cloud_events_1.0_schema.py [python-eg-sample-consume-cloudevent]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/eventgrid/azure-eventgrid/samples/champion_scenarios/cs6_consume_events_using_cloud_events_1.0_schema.py +[publisher-service-doc]: https://docs.microsoft.com/en-us/azure/event-grid/concepts [cla]: https://cla.microsoft.com [code_of_conduct]: https://opensource.microsoft.com/codeofconduct/ From df3a689e66e3d3209dc3a8d6a69991f53778df49 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Tue, 1 Sep 2020 14:00:36 -0700 Subject: [PATCH 7/7] nti --- sdk/eventgrid/azure-eventgrid/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/eventgrid/azure-eventgrid/README.md b/sdk/eventgrid/azure-eventgrid/README.md index c6cc38c9b0a7..bb507a877135 100644 --- a/sdk/eventgrid/azure-eventgrid/README.md +++ b/sdk/eventgrid/azure-eventgrid/README.md @@ -43,6 +43,8 @@ eg_publisher_client = EventGridPublisherClient(topic_hostname, credential) ## Key concepts +Information about the key concepts on EventGrid, see [Concepts in Azure Event Grid][publisher-service-doc] + ### EventGridPublisherClient `EventGridPublisherClient` provides operations to send event data to topic hostname specified during client initialization. Either a list or a single instance of CloudEvent/EventGridEvent/CustomEvent can be sent. @@ -50,8 +52,6 @@ Either a list or a single instance of CloudEvent/EventGridEvent/CustomEvent can ### EventGridConsumer `EventGridConsumer` is used to desrialize an event received. -For more information about the key concepts on EventGrid, see [Concepts in Azure Event Grid][publisher-service-doc] - ## Examples The following sections provide several code snippets covering some of the most common EventGrid tasks, including: