An Microsoft Azure Service Bus Namespace can certainly be managed through the Azure Management Portal. However easy that is for a user to do manually, it definitely can be useful to create and manage Azure Service Bus Namespaces using other more automated methods. Fortunately, there is support for this using the PowerShell and X-plat CLI SDKs.

Below are examples using both the PowerShell and X-plat CLI (command-line) SDKs to create a new Azure Service Bus Namespace.

Azure PowerShell cmdlets

Creating an Azure Service Bus Namespace with the Azure PowerShell SDK is fairly simple using the New-AzureSBNamespace cmdlet.

Explicitly define parameters:

New-AzureSBNamespace -name SuperNamespace -Location North Central US

Implicitly define parameters:

New-AzureSBNamespace SuperNamespace 'North Central US'

Before you run the New-AzureSBNamespace cmdlet to create the Azure Service Bus Namespace, you need to import the Azure cmdlets and login to your Azure subscription. Here’s a short, full example of doing this:

# import Azure cmdlets
Import-Module Azure

# Login to Azure

# Create Namespace on the Azure Subscription that was logged into
New-AzureSBNamespace SuperNamespace "North Central US"

Note: The Add-AzureAccount cmdlet will open up a window for the user to enter their Microsoft Account credentials to login to the Azure Subscription.

Azure CLI 1.0

The biggest benefit of the X-plat CLI is that is runs on Mac OS and Linux. Since PowerShell doesn’t run on non-Windows operating system, this is extremely useful for anyone using Microsoft Azure without Windows.

Creating an Azure Service Bus Namespace can be done using the X-plat CLI using the following command.

azure sb namespace create <namespace> <region>

Before you can create the Azure Service Bus Namespace, you’ll need to login to your Azure subscription. Below is a short example that includes this:

#log into Azure account
azure login -u <username>

# create Azure Service Bus Namespace
azure sb namespace create <namespace> <region>

Note: The azure login command specifies the username to login with, but it then prompts the user to enter the password.

PowerShell vs Xplat-CLI

Both the PowerShell SDK and the Xplat-CLI SDK contain the same features. The Azure team does a good job at keeping both of these SDK’s in good parity. They both contain a huge amount of functionality for automating Azure resource management.

Additionally, both SDKs are Open Source and hosted on GitHub.

Microsoft MVP

Chris Pietschmann is a Microsoft MVP, HashiCorp Ambassador, and Microsoft Certified Trainer (MCT) with 20+ years of experience designing and building Cloud & Enterprise systems. He has worked with companies of all sizes from startups to large enterprises. He has a passion for technology and sharing what he learns with others to help enable them to learn faster and be more productive.
HashiCorp Ambassador Microsoft Certified Trainer (MCT) Microsoft Certified: Azure Solutions Architect