Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
In Aspire 9.1, the method AddEventHub is being obsoleted. This change introduces new methods that better reflect the intended usage and improve the API's clarity.
Version introduced
Aspire 9.1
Previous behavior
Previously, the method AddEventHub was used to add a hub to the Azure Event Hubs namespace.
var builder = DistributedApplication.CreateBuilder(args);
var eventHubs = builder.AddAzureEventHubs("hubs");
eventHubs.AddEventHub("myhub");
New behavior
The new method also uses the Add prefix. The Add prefix indicates that a child resource is created and returned, aligning with the intended usage.
var builder = DistributedApplication.CreateBuilder(args);
var eventHubs = builder.AddAzureEventHubs("hubs");
var myhub = eventHubs.AddHub("myhub");
Type of breaking change
This change is a source incompatible.
Reason for change
A better API is provided, as the names Add reflect that a child resource is created and returned. Add should be used when it returns the new resource (not the parent resource). For more information, see EventHubs, ServiceBus, and CosmosDB Hosting integrations should create Resources for children.
Recommended action
Replace any usage of the obsolete methods with the new methods.
var builder = DistributedApplication.CreateBuilder(args);
var eventHubs = builder.AddAzureEventHubs("hubs");
eventHubs.AddHub("myhub");
Affected APIs
Aspire.Hosting.AzureEventHubsExtensions.AddEventHub