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
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 Add-AzureAccount # 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 &amp;lt;namespace&amp;gt; &amp;lt;region&amp;gt;
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 &amp;lt;username&amp;gt; # create Azure Service Bus Namespace azure sb namespace create &amp;lt;namespace&amp;gt; &amp;lt;region&amp;gt;
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.