Quickstart: Create a Service Bus namespace and a queue using an ARM template

This article shows how to use an Azure Resource Manager template (ARM 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.

An Azure Resource Manager template is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for your project. The template uses declarative syntax. You describe your intended deployment without writing the sequence of programming commands to create the deployment.

If your environment meets the prerequisites and you're familiar with using ARM templates, select the Deploy to Azure button. The template will open in the Azure portal.

Button to deploy the Resource Manager template to Azure.

Prerequisites

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

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",
  "metadata": {
    "_generator": {
      "name": "bicep",
      "version": "0.9.1.41621",
      "templateHash": "724589808436302889"
    }
  },
  "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."
      }
    }
  },
  "resources": [
    {
      "type": "Microsoft.ServiceBus/namespaces",
      "apiVersion": "2022-01-01-preview",
      "name": "[parameters('serviceBusNamespaceName')]",
      "location": "[parameters('location')]",
      "sku": {
        "name": "Standard"
      },
      "properties": {}
    },
    {
      "type": "Microsoft.ServiceBus/namespaces/queues",
      "apiVersion": "2022-01-01-preview",
      "name": "[format('{0}/{1}', parameters('serviceBusNamespaceName'), parameters('serviceBusQueueName'))]",
      "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
      },
      "dependsOn": [
        "[resourceId('Microsoft.ServiceBus/namespaces', parameters('serviceBusNamespaceName'))]"
      ]
    }
  ]
}

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 clean up later.

Button to deploy the Resource Manager template to Azure.

Validate 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.

Clean up 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 ARM template

Learn how to manage these resources by viewing these articles: