Publishing messages to Azure Event Hubs
To use Azure Event Hubs, we’ll implement the game APIs service so that we can publish events.
Defining app-model for Event Hubs
To use Azure Event Hubs with the AppHost project, the Aspire.Hosting.Azure.EventHubs
NuGet package is required.
Here, Event Hubs needs to be added to the app model:
Codebreaker.AppHost/Program.cs
var eventHub = builder.AddAzureEventHubs("codebreakerevents") .AddEventHub("games"); // code removed for brevity
The AddAzureEventHubs
method, adds an Azure Event Hubs namespace, AddEventHub
, as an event hub. A namespace is a management container with network endpoints and access control. The default Event Hub namespace that’s created is in the Standard tier. For development, you can change this to the Basic tier. Event hubs are created within namespaces. For scalability, event hubs use one or more partitions. By default, the event hub is...