Quickstart: Create a Service Bus namespace and a queue using an Azure Resource Manager template

This article shows how to use an Azure Resource Manager template that creates a Service Bus namespace and a queue within that namespace. The article explains how to specify which resources are deployed and how to define parameters that are specified when the deployment is executed. You can use this template for your own deployments, or customize it to meet your requirements.

Resource Manager template is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for your project. The template uses declarative syntax, which lets you state what you intend to deploy without having to write the sequence of programming commands to create it. If you want to learn more about developing Resource Manager templates, see Resource Manager documentation and the template reference.

If you don't have an Azure subscription, create a free account before you begin.

Prerequisites

None

Create a Service Bus namespace and a queue

Review the template

The template used in this quickstart is from Azure Quickstart templates.

{
 "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
 "contentVersion": "1.0.0.0",
 "parameters": {
   "serviceBusNamespaceName": {
     "type": "string",
     "metadata": {
       "description": "Name of the Service Bus namespace"
     }
   },
   "serviceBusQueueName": {
     "type": "string",
     "metadata": {
       "description": "Name of the Queue"
     }
   },
   "location": {
     "type": "string",
     "defaultValue": "[resourceGroup().location]",
     "metadata": {
       "description": "Location for all resources."
     }
   }
 },
 "variables": {
   "defaultSASKeyName": "RootManageSharedAccessKey",
   "authRuleResourceId": "[resourceId('Microsoft.ServiceBus/namespaces/authorizationRules', parameters('serviceBusNamespaceName'), variables('defaultSASKeyName'))]",
   "sbVersion": "2017-04-01"
 },
 "resources": [
   {
     "apiVersion": "2017-04-01",
     "name": "[parameters('serviceBusNamespaceName')]",
     "type": "Microsoft.ServiceBus/namespaces",
     "location": "[parameters('location')]",
     "sku": {
       "name": "Standard"
     },
     "properties": {},
     "resources": [
       {
         "apiVersion": "2017-04-01",
         "name": "[parameters('serviceBusQueueName')]",
         "type": "Queues",
         "dependsOn": [
           "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespaceName'))]"
         ],
         "properties": {
           "lockDuration": "PT5M",
           "maxSizeInMegabytes": "1024",
           "requiresDuplicateDetection": "false",
           "requiresSession": "false",
           "defaultMessageTimeToLive": "P10675199DT2H48M5.4775807S",
           "deadLetteringOnMessageExpiration": "false",
           "duplicateDetectionHistoryTimeWindow": "PT10M",
           "maxDeliveryCount": "10",
           "autoDeleteOnIdle": "P10675199DT2H48M5.4775807S",
           "enablePartitioning": "false",
           "enableExpress": "false"
         }
       }
     ]
   }
 ],
 "outputs": {
   "NamespaceConnectionString": {
     "type": "string",
     "value": "[listkeys(variables('authRuleResourceId'), variables('sbVersion')).primaryConnectionString]"
   },
   "SharedAccessPolicyPrimaryKey": {
     "type": "string",
     "value": "[listkeys(variables('authRuleResourceId'), variables('sbVersion')).primaryKey]"
   }
 }
}

The resources defined in the template include:

You can find more template from Azure Quickstart templates

Deploy the template

With this template, you deploy a Service Bus namespace with a queue.

Service Bus queues offer First In, First Out (FIFO) message delivery to one or more competing consumers.

To run the deployment automatically, click the following button: Create a new resource group for the deployment so that you can easily cleanup later.

Deploy to Azure

Verify the deployment

  1. Select Notifications at the top to see the status of the deployment. Wait until the deployment succeeds. Then, select Go to resource group in the notification message to navigate to the page for the resource group that contains the Service Bus namespace.

    Notification from deployment

  2. Confirm that you see your Service Bus namespace in the list of resources.

    Resource group - namespace

  3. Select the namespace from the list to see the Service Bus Namespace page.

Cleanup resources

  1. In the Azure portal, navigate to the Resource group page for your resource group.

  2. Select Delete resource group from the toolbar.

  3. Type the name of the resource group, and select Delete.

    Resource group - delete

Next steps

See the following topic that shows how to create an authorization rule for the namespace/queue:

Create a Service Bus authorization rule for namespace and queue using an Azure Resource Manager template

Learn how to manage these resources by viewing these articles: