Azure Service Bus hosting integration obsolete APIs
In .NET 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.
.NET Aspire 9.1
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");
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");
This change is a source incompatible.
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.
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");
Aspire.Hosting.AzureServiceBusExtensions.AddQueue
Aspire.Hosting.AzureServiceBusExtensions.AddTopic
Aspire.Hosting.AzureServiceBusExtensions.AddSubscription
.NET Aspire प्रतिक्रिया
.NET Aspire एक ओपन सोर्स प्रोजेक्ट है. प्रतिक्रिया प्रदान करने के लिए लिंक का चयन करें: