EventGridPublisherClient Class

EventGridPublisherClient publishes events to an EventGrid topic or domain. It can be used to publish either an EventGridEvent, a CloudEvent or a Custom Schema.

Inheritance
builtins.object
EventGridPublisherClient

Constructor

EventGridPublisherClient(endpoint: str, credential: Union[AzureKeyCredential, AzureSasCredential, TokenCredential], **kwargs: Any)

Parameters

endpoint
str
Required

The topic endpoint to send the events to.

credential
AzureKeyCredential or AzureSasCredential or TokenCredential
Required

The credential object used for authentication which implements SAS key authentication or SAS token authentication or a TokenCredential.

Methods

close

Close the EventGridPublisherClient session.

send

Sends events to a topic or a domain specified during the client initialization.

A single instance or a list of dictionaries, CloudEvents or EventGridEvents are accepted.

Dict representation of respective serialized models is accepted as CloudEvent(s) or EventGridEvent(s) apart from the strongly typed objects.

When publishing a Custom Schema Event(s), dict-like representation is accepted. Either a single dictionary or a list of dictionaries can be passed.

WARNING: When sending a list of multiple events at one time, iterating over and sending each event will not result in optimal performance. For best performance, it is highly recommended to send a list of events.

close

Close the EventGridPublisherClient session.

close() -> None

send

Sends events to a topic or a domain specified during the client initialization.

A single instance or a list of dictionaries, CloudEvents or EventGridEvents are accepted.

Dict representation of respective serialized models is accepted as CloudEvent(s) or EventGridEvent(s) apart from the strongly typed objects.

When publishing a Custom Schema Event(s), dict-like representation is accepted. Either a single dictionary or a list of dictionaries can be passed.

WARNING: When sending a list of multiple events at one time, iterating over and sending each event will not result in optimal performance. For best performance, it is highly recommended to send a list of events.

send(events: Union[azure.core.messaging.CloudEvent, azure.eventgrid._models.EventGridEvent, Dict, List[azure.core.messaging.CloudEvent], List[azure.eventgrid._models.EventGridEvent], List[Dict]], *, channel_name: Optional[str] = None, **kwargs: Any) -> None

Parameters

events
CloudEvent or EventGridEvent or dict or <xref:List>[CloudEvent] or <xref:List>[EventGridEvent] or <xref:List>[dict]
Required

A single instance or a list of dictionaries/CloudEvent/EventGridEvent to be sent.

content_type
str

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

channel_name
str or <xref:<xref:Nonenamespaces with partner topic. For more details>, visithttps://docs.microsoft.com/azure/event-grid/partner-events-overview>

Optional. Used to specify the name of event channel when publishing to partner.

Return type