title | description | author | ms.topic | ms.tgt_pltfrm | ms.custom | ms.date | ms.author |
---|---|---|---|---|---|---|---|
Create an Azure Service Bus namespace using template |
Use Azure Resource Manager template to create a Service Bus Messaging namespace |
spelluru |
article |
dotnet |
devx-track-arm-template |
09/27/2021 |
spelluru |
Learn how to deploy an Azure Resource Manager template to create a Service Bus namespace. You can use this template for your own deployments, or customize it to meet your requirements. For more information about creating templates, see Azure Resource Manager documentation.
The following templates are also available for creating Service Bus namespaces:
- Create a Service Bus namespace with queue
- Create a Service Bus namespace with topic and subscription
- Create a Service Bus namespace with queue and authorization rule
- Create a Service Bus namespace with topic, subscription, and rule
[!INCLUDE updated-for-az]
If you don't have an Azure subscription, create a free account before you begin.
In this quickstart, you use an existing Resource Manager template from Azure Quickstart Templates:
[!code-jsoncreate-azure-service-bus-namespace]
To find more template samples, see Azure Quickstart Templates.
To create a service bus namespace by deploying a template:
-
Select Try it from the following code block, and then follow the instructions to sign in to the Azure Cloud shell.
$serviceBusNamespaceName = Read-Host -Prompt "Enter a name for the service bus namespace to be created" $location = Read-Host -Prompt "Enter the location (i.e. centralus)" $resourceGroupName = "${serviceBusNamespaceName}rg" $templateUri = "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.servicebus/servicebus-create-namespace/azuredeploy.json" New-AzResourceGroup -Name $resourceGroupName -Location $location New-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateUri $templateUri -serviceBusNamespaceName $serviceBusNamespaceName Write-Host "Press [ENTER] to continue ..."
The resource group name is the service bus namespace name with rg appended.
-
Select Copy to copy the PowerShell script.
-
Right-click the shell console, and then select Paste.
It takes a few moments to create an event hub.
To see the deployed service bus namespace, you can either open the resource group from the Azure portal, or use the following Azure PowerShell script. If the Cloud shell is still open, you don't need to copy/run the first and second lines of the following script.
$serviceBusNamespaceName = Read-Host -Prompt "Enter the same service bus namespace name used earlier"
$resourceGroupName = "${serviceBusNamespaceName}rg"
Get-AzServiceBusNamespace -ResourceGroupName $resourceGroupName -Name $serviceBusNamespaceName
Write-Host "Press [ENTER] to continue ..."
Azure PowerShell is used to deploy the template in this tutorial. For other template deployment methods, see:
When the Azure resources are no longer needed, clean up the resources you deployed by deleting the resource group. If the Cloud shell is still open, you don't need to copy/run the first and second lines of the following script.
$serviceBusNamespaceName = Read-Host -Prompt "Enter the same service bus namespace name used earlier"
$resourceGroupName = "${serviceBusNamespaceName}rg"
Remove-AzResourceGroup -ResourceGroupName $resourceGroupName
Write-Host "Press [ENTER] to continue ..."
In this article, you created a Service Bus namespace. See the other quickstarts to learn how to create queues, topics/subscriptions, and use them: