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 methods AddQueue, AddTopic, and AddSubscription are 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 methods AddQueue, AddTopic, and AddSubscription were used to add resources to the Azure Service Bus.
var builder = DistributedApplication.CreateBuilder(args);
var serviceBus = builder.AddAzureServiceBus("messaging");
serviceBus.AddQueue("queueName");
serviceBus.AddTopic("topicName");
serviceBus.AddSubscription("topicName", "subscriptionName");
New behavior
The new methods use the AddServiceBus prefix. The Add prefix indicates that a child resource is created and returned, aligning with the intended usage.
var builder = DistributedApplication.CreateBuilder(args);
var serviceBus = builder.AddAzureServiceBus("messaging");
var queue = serviceBus.AddServiceBusQueue("queueName");
var topic = serviceBus.AddServiceBusTopic("topicName");
topic.AddServiceBusSubscription("subscriptionName");
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 serviceBus = builder.AddAzureServiceBus("messaging");
serviceBus.AddServiceBusQueue("queueName");
serviceBus.AddServiceBusTopic("topicName");
Affected APIs
Aspire.Hosting.AzureServiceBusExtensions.AddQueueAspire.Hosting.AzureServiceBusExtensions.AddTopicAspire.Hosting.AzureServiceBusExtensions.AddSubscription