Publishing Events
#
Publishing EventsWe provide support for publishing custom events to a custom Azure Event Grid Topics.
Import the following namespace into your project:
using Arcus.EventGrid.Publishing;
Next, create an EventGridPublisher
instance via the .Create()
method which requires the endpoint & authentication key of your custom topic endpoint.
var eventGridPublisher = EventGridPublisher.Create(topicEndpoint, endpointKey);
Publishing EventGridEvent's
Create your event that you want to publish
string licensePlate = "1-TOM-337";string eventSubject = $"/cars/{licensePlate}";string eventId = Guid.NewGuid().ToString();var @event = new NewCarRegistered(eventId, eventSubject, licensePlate);
await eventGridPublisher.Publish(eventSubject, eventType: "NewCarRegistered", data: new [] { @event }, id: eventId);