-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Ux study feedback #16124
Ux study feedback #16124
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -38,26 +38,39 @@ In order to interact with the Event Grid service, you will need to create an ins | |||||||||||||
A **topic_hostname** and **credential** are necessary to instantiate the client object. | ||||||||||||||
|
||||||||||||||
#### Looking up the endpoint | ||||||||||||||
You can find the endpoint and the hostname on the Azure portal. | ||||||||||||||
You can find the topic endpoint within the Event Grid Topic resource on the Azure portal. This will look like: | ||||||||||||||
`"https://<event-grid-topic-name>.<topic-location>.eventgrid.azure.net/api/events"` | ||||||||||||||
The topic hostname is the URL host component of this endpoint, which will be in the format: | ||||||||||||||
`"https://<event-grid-topic-name>.<topic-location>.eventgrid.azure.net"` | ||||||||||||||
|
||||||||||||||
#### Create the client with AzureKeyCredential | ||||||||||||||
|
||||||||||||||
To use an API key as the `credential` parameter, | ||||||||||||||
To use an Access Key as the `credential` parameter, | ||||||||||||||
pass the key as a string into an instance of [AzureKeyCredential][azure-key-credential]. | ||||||||||||||
|
||||||||||||||
> **Note:** The Access Key may be found in the azure portal in the "Access Keys" menu of the Event Grid Topic resource. They may also be obtained via the azure CLI, or the `azure-mgmt-eventgrid` library. A guide for getting access keys can be found [here](https://docs.microsoft.com/azure/event-grid/get-access-keys). | ||||||||||||||
|
||||||||||||||
```python | ||||||||||||||
from azure.core.credentials import AzureKeyCredential | ||||||||||||||
from azure.eventgrid import EventGridPublisherClient | ||||||||||||||
|
||||||||||||||
topic_hostname = "https://<name>.<region>.eventgrid.azure.net" | ||||||||||||||
credential = AzureKeyCredential("<api_key>") | ||||||||||||||
credential = AzureKeyCredential("<access_key>") | ||||||||||||||
eg_publisher_client = EventGridPublisherClient(topic_hostname, credential) | ||||||||||||||
``` | ||||||||||||||
|
||||||||||||||
> **Note:** A client may also be authenticated via SAS signature, using the `EventGridSharedAccessSignatureCredential`. A sample demonstrating this, as well as how to generate that signature utilizing `generate_shared_access_signature` is available [here][python-eg-sample-publish-sas-signature]. | ||||||||||||||
|
||||||||||||||
## Key concepts | ||||||||||||||
|
||||||||||||||
Information about the key concepts on Event Grid, see [Concepts in Azure Event Grid][publisher-service-doc] | ||||||||||||||
|
||||||||||||||
### Topic | ||||||||||||||
A channel within the EventGrid service to send events. Must be of [CloudEvent](https://docs.microsoft.com/azure/event-grid/cloud-event-schema) or [EventGridEvent](https://docs.microsoft.com/azure/event-grid/event-schema) schema, (decided at creation time) and the corresponding event type must be used. | ||||||||||||||
|
||||||||||||||
### Domain Topic | ||||||||||||||
A domain exists to rout arbitrary named topics within it. Topics must not exist beforehand if using a domain, topic name can be provided at send time. Simply provide the domain endpoint at client construction instead of topic endpoint. | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A little unclear on what is meant by Might be worthwhile to make it more clear how a domain topic works in comparison to other topics + to include things from this doc (https://docs.microsoft.com/en-us/azure/event-grid/event-domains) including the following:
Links + typo + something like this?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as @swathipil mentioned, echoing words from the service doc is good. also I'm feeling that as it is the |
||||||||||||||
|
||||||||||||||
### 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. | ||||||||||||||
|
@@ -71,12 +84,14 @@ The following sections provide several code snippets covering some of the most c | |||||||||||||
|
||||||||||||||
* [Send an Event Grid Event](#send-an-event-grid-event) | ||||||||||||||
* [Send a Cloud Event](#send-a-cloud-event) | ||||||||||||||
* [Send to a Domain](#send-to-a-domain) | ||||||||||||||
* [Consume an eventgrid Event](#consume-an-event-grid-event) | ||||||||||||||
* [Consume a cloud Event](#consume-a-cloud-event) | ||||||||||||||
|
||||||||||||||
### Send an Event Grid Event | ||||||||||||||
|
||||||||||||||
This example publishes an Event Grid event. | ||||||||||||||
> **Note:** It is important to know if your topic supports Cloud or EventGrid events beforehand, otherwise send() will throw an exception. | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Small, potential change, for clarity. Something like:
Suggested change
|
||||||||||||||
|
||||||||||||||
```Python | ||||||||||||||
import os | ||||||||||||||
|
@@ -97,11 +112,13 @@ credential = AzureKeyCredential(key) | |||||||||||||
client = EventGridPublisherClient(topic_hostname, credential) | ||||||||||||||
|
||||||||||||||
client.send(event) | ||||||||||||||
# Note: Events may also be sent as a list, e.g: client.send([event]) | ||||||||||||||
``` | ||||||||||||||
|
||||||||||||||
### Send a Cloud Event | ||||||||||||||
|
||||||||||||||
This example publishes a Cloud event. | ||||||||||||||
> **Note:** It is important to know if your topic supports Cloud or EventGrid events beforehand, otherwise send() will throw an exception. | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as 92 |
||||||||||||||
|
||||||||||||||
```Python | ||||||||||||||
import os | ||||||||||||||
|
@@ -121,6 +138,32 @@ credential = AzureKeyCredential(key) | |||||||||||||
client = EventGridPublisherClient(topic_hostname, credential) | ||||||||||||||
|
||||||||||||||
client.send(event) | ||||||||||||||
# Note: Events may also be sent as a list, e.g: client.send([event]) | ||||||||||||||
``` | ||||||||||||||
|
||||||||||||||
### Send to a Domain | ||||||||||||||
|
||||||||||||||
This example illustrates sending to a Domain, whereas the earlier samples sent to a Topic. | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may add a little more clarity?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why custom? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||
|
||||||||||||||
The primary difference is that for `EventGridEvents` a topic must be defined in the event being sent, such that it can be routed within the Domain. | ||||||||||||||
|
||||||||||||||
```Python | ||||||||||||||
import os | ||||||||||||||
from azure.core.credentials import AzureKeyCredential | ||||||||||||||
from azure.eventgrid import EventGridPublisherClient, EventGridEvent | ||||||||||||||
key = os.environ["EG_ACCESS_KEY"] | ||||||||||||||
domain_hostname = os.environ["EG_DOMAIN_HOSTNAME"] | ||||||||||||||
event = EventGridEvent( | ||||||||||||||
subject="Door1", | ||||||||||||||
data={"team": "azure-sdk"}, | ||||||||||||||
event_type="Azure.Sdk.Demo", | ||||||||||||||
data_version="2.0", | ||||||||||||||
topic="test" | ||||||||||||||
) | ||||||||||||||
credential = AzureKeyCredential(key) | ||||||||||||||
client = EventGridPublisherClient(domain_hostname, credential) | ||||||||||||||
client.send(event) | ||||||||||||||
# Note: Events may also be sent as a list, e.g: client.send([event]) | ||||||||||||||
``` | ||||||||||||||
|
||||||||||||||
### Consume an Event Grid Event | ||||||||||||||
|
@@ -143,7 +186,7 @@ eg_storage_dict = { | |||||||||||||
"dataVersion":"2.0", | ||||||||||||||
"metadataVersion":"1", | ||||||||||||||
"eventTime":"2020-08-07T02:28:23.867525Z", | ||||||||||||||
"topic":"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/topics/eventgridegsub" | ||||||||||||||
"topic":"/subscriptions/fake-subscription-id/resourceGroups/fake-resource-group/providers/Microsoft.EventGrid/topics/eventgridegsub" | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason for changing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's more clear according to some users in the ux study |
||||||||||||||
} | ||||||||||||||
|
||||||||||||||
deserialized_event = consumer.decode_eventgrid_event(eg_storage_dict) | ||||||||||||||
|
@@ -164,7 +207,7 @@ consumer = EventGridConsumer() | |||||||||||||
|
||||||||||||||
cloud_storage_dict = { | ||||||||||||||
"id":"a0517898-9fa4-4e70-b4a3-afda1dd68672", | ||||||||||||||
"source":"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.Storage/storageAccounts/{storage-account}", | ||||||||||||||
"source":"/subscriptions/fake-subscription-id/resourceGroups/fake-resource-group/providers/Microsoft.Storage/storageAccounts/fake-storage-account", | ||||||||||||||
"data":{ | ||||||||||||||
"api":"PutBlockList", | ||||||||||||||
}, | ||||||||||||||
|
@@ -251,6 +294,7 @@ This project has adopted the [Microsoft Open Source Code of Conduct][code_of_con | |||||||||||||
[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/azure/event-grid/concepts | ||||||||||||||
[python-eg-sample-publish-sas-signature]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/eventgrid/azure-eventgrid/samples/publish_samples/publish_with_shared_access_signature_sample.py | ||||||||||||||
|
||||||||||||||
[cla]: https://cla.microsoft.com | ||||||||||||||
[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/ | ||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -49,11 +49,14 @@ def _from_json(event, encode): | |||||||||
|
||||||||||
class CloudEvent(EventMixin): #pylint:disable=too-many-instance-attributes | ||||||||||
"""Properties of an event published to an Event Grid topic using the CloudEvent 1.0 Schema. | ||||||||||
Note: CloudEvents can only be sent to a topic of CloudEvent schema. | ||||||||||
For EventGrid schema, use EventGridEvent. | ||||||||||
|
||||||||||
All required parameters must be populated in order to send to Azure. | ||||||||||
|
||||||||||
:param source: Required. Identifies the context in which an event happened. The combination of id and source must | ||||||||||
be unique for each distinct event. If publishing to a domain topic, source must be the domain name. | ||||||||||
be unique for each distinct event, and otherwise can be any user-defined string. | ||||||||||
If publishing to a domain topic, source must be the domain name. | ||||||||||
Comment on lines
+58
to
+59
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indentation
Suggested change
|
||||||||||
:type source: str | ||||||||||
:param data: Event data specific to the event type. | ||||||||||
:type data: object | ||||||||||
|
@@ -131,19 +134,24 @@ def _to_generated(self, **kwargs): | |||||||||
|
||||||||||
class EventGridEvent(InternalEventGridEvent, EventMixin): | ||||||||||
"""Properties of an event published to an Event Grid topic using the EventGrid Schema. | ||||||||||
Note: EventGridEvents can only be sent to a topic of EventGridEvent schema. | ||||||||||
For CloudEvent schema, use CloudEvent. | ||||||||||
|
||||||||||
Variables are only populated by the server, and will be ignored when sending a request. | ||||||||||
|
||||||||||
All required parameters must be populated in order to send to Azure. | ||||||||||
|
||||||||||
:param topic: The resource path of the event source. If not provided, Event Grid will stamp onto the event. | ||||||||||
Is required for Domain topics, and a domain topic may be specified which doesn't yet exist. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so if I send the event to a domain topic which doesn't exist yet, the EventGrid would create a new domain topic for me? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also, it seems over indented, not sure it would cause rendering issue
Suggested change
|
||||||||||
:type topic: str | ||||||||||
:param subject: Required. A resource path relative to the topic path. | ||||||||||
:param subject: Required. A resource path relative to the topic path. Can be any user-defined string. | ||||||||||
:type subject: str | ||||||||||
:param data: Event data specific to the event type. | ||||||||||
:type data: object | ||||||||||
:param event_type: Required. The type of the event that occurred. | ||||||||||
:param event_type: Required. The type of the event that occurred. Can be any user-defined string. | ||||||||||
:type event_type: str | ||||||||||
:param data_version: Required. The schema version of the data object. Can be any user-defined string. | ||||||||||
:type data_version: str | ||||||||||
:ivar metadata_version: The schema version of the event metadata. If provided, must match Event Grid Schema exactly. | ||||||||||
If not provided, EventGrid will stamp onto event. | ||||||||||
:vartype metadata_version: str | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a bit clarity on the second half, feel free to tweak my words.