Getting Azure Service Bus Namespace Information


Starting from version 3.3 of the .NET Standard client library for Azure Microsft Bus service, we can get programmatically its namespace information. In this blog post, I explain how to create a new vanilla Service Bus and how to get its namespace info using C#.


I used the following tools and libraries:

Azure Service Bus

One among my favorite Azure services is the Azure Service Bus. That's why I prefer to save it in my saved list. It's a shortcut for me to create a new Service Bus.

Azure Service Bus is a cloud-based messaging service providing queues and topics with publish/subscribe semantics and rich features. This fully managed service is available in multi or single tenant configurations with no servers to manage or licenses to buy.

We use Azure Service Bus in order to :

  • Build reliable and elastic cloud apps with messaging.
  • Protect our application from temporary peaks.
  • Distribute messages to multiple independent backend systems.
  • Decouple our applications from each other.
  • Scale out ordered messaging to multiple readers.

Namespace Creation

It is straightforward to create a new Service Bus. First, we create a namespace by entering its name, pricing tier, subscription, resource group, and location. The choice of the premium tier/SKU is on purpose.

It is highly recommended using premium tier namespaces to get features such as high availability because these features arenโ€™t available in the standard tier.

All customers should use the premium tier for production workloads. The shared environment of the standard tier simply isnโ€™t appropriate for anything but maybe for systems with very low message volumes or systems still in development.

We get the following neat dashboard to have an overview of messages, requests, and performance.

Namespace Info

Before the release of 3.3.0 SDK version, we used to configure manually the maximum message size. But since 3.3.0, we can use C# to configure it programmatically. In addition, we can know the type of tier/SKU also using C#.

Let's create a new .NET Core Console App using Visual Studio 2019 Preview and name it NamespaceInfoSample. Thanks to NuGet, we can grab easily the .NET Standard package Microsoft.Azure.ServiceBus. There is another popular nuget package WindowsAzure.ServiceBus with more than 16 million downloads which is compatible with .NET 4.5.2. I am using the first one.

I wrote the following asynchronous method to illustrate the new feature of Azure Service Bus .NET Standard package.

using Microsoft.Azure.ServiceBus.Management;
using System.Threading.Tasks;

namespace NamespaceInfoSample
    class Program
        static string ServiceBusConnectionString = "<your_connection_string>";
        static void Main(string[] args)

        static async Task<NamespaceInfo> MainAsync()
            var client = new ManagementClient(ServiceBusConnectionString);
            var taskOfNamespaceInfo = await client.GetNamespaceInfoAsync();
            return taskOfNamespaceInfo;

If we break point the return statement and quick watch the taskOfNamespaceInfo variable after running F5, we can get 2 valuable information among others about our Service Bus namespace: MessagingSku and MessagingUnits if the tier/SKU is premium.


The new added GetNamespaceInfoAsync API of .NET Standard client library for Azure Service Bus provides information related to the namespace including the type of namespace and the tier/SKU (basic/standard/premium), and the number of messaging units allocated for the namespace if its corresponding tier/SKU is premium. The Azure Service Bus Premium should be used for production workload and Basic SKU or Standard SKU should be used for testing or staging and never for production due to performance reasons.

azure Service Bus .NET Standard SKU Visual Studio NuGet

Hi, I'm Maher, Development Technologies MVP. I'm blogging about ASP.NET Core and Microsoft Azure.