8

Listing all topics and subscriptions in an Azure Service Bus Namespace

 2 years ago
source link: https://www.pmichaels.net/2022/08/21/listing-all-topics-and-subscriptions-in-an-azure-service-bus-namespace/?utm_campaign=listing-all-topics-and-subscriptions-in-an-azure-service-bus-namespace
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Listing all topics and subscriptions in an Azure Service Bus Namespace

For anyone that follows this blog, you’ll notice that Azure Service Bus is one of my favourite topics. In this post, we’re going to see how you can list all subscriptions to all topics within a namespace.

var serviceBusClient = new ServiceBusClient(connectionString);
var serviceBusAdminClient = new ServiceBusAdministrationClient(connectionString);
var topics = serviceBusAdminClient.GetTopicsAsync();
await foreach (var topic in topics)
{
var subs = serviceBusAdminClient.GetSubscriptionsAsync(topic.Name);
await foreach (var sub in subs)
{
Console.WriteLine($"{sub.TopicName}: {sub.SubscriptionName}");
}
}

We’re using the latest service bus library, and the ServiceBusAdministrationClient, which lets us traverse the topics, and the subscriptions within them.

References

https://www.pmichaels.net/2021/06/26/receiving-a-message-using-azure-messaging-servicebus/

This entry was posted in .Net, Azure, Azure Service Bus, C# and tagged Azure Service Bus, List Subscriptions, List Topics, Message Broker, Service Bus on August 21, 2022.

Post navigation

← Introduction to Unit Tests (with examples in .Net) – Part 4 – Mocking (Including fakes and stubs)

You must log in to post a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK