Rediģēt

Kopīgot, izmantojot


Quickstart: Create a Service Bus namespace with topic and subscription 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 topic and subscription 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

For more information about creating templates, see Authoring Azure Resource Manager templates.

For the complete template, see the Service Bus namespace with topic and subscription template.

Note

The following Azure Resource Manager templates are available for download and deployment.

To check for the latest templates, visit the Azure Quickstart Templates gallery and search for Service Bus.

What do you deploy?

With this template, you deploy a Service Bus namespace with topic and subscription.

Service Bus topics and subscriptions provide a one-to-many form of communication, in a publish/subscribe pattern.

To run the deployment automatically, click the following button:

Deploy to Azure

Parameters

With Azure Resource Manager, you define parameters for values you want to specify when the template is deployed. The template includes a section called Parameters that contains all of the parameter values. Define a parameter for those values that vary based on the project you're deploying or based on the environment you're deploying to. Do not define parameters for values that always stay the same. Each parameter value is used in the template to define the resources that are deployed.

The template defines the following parameters:

serviceBusNamespaceName

The name of the Service Bus namespace to create.

"serviceBusNamespaceName": {
"type": "string"
}

serviceBusTopicName

The name of the topic created in the Service Bus namespace.

"serviceBusTopicName": {
"type": "string"
}

serviceBusSubscriptionName

The name of the subscription created in the Service Bus namespace.

"serviceBusSubscriptionName": {
"type": "string"
}

serviceBusApiVersion

The Service Bus API version of the template.

"serviceBusApiVersion": {
       "type": "string",
       "defaultValue": "2017-04-01",
       "metadata": {
           "description": "Service Bus ApiVersion used by the template"
       }

Resources to deploy

Creates a standard Service Bus namespace of type Messaging, with topic and subscription.

"resources": [{
        "apiVersion": "[variables('sbVersion')]",
        "name": "[parameters('serviceBusNamespaceName')]",
        "type": "Microsoft.ServiceBus/Namespaces",
        "location": "[variables('location')]",
        "kind": "Messaging",
        "sku": {
            "name": "Standard",
        },
        "resources": [{
            "apiVersion": "[variables('sbVersion')]",
            "name": "[parameters('serviceBusTopicName')]",
            "type": "Topics",
            "dependsOn": [
                "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespaceName'))]"
            ],
            "properties": {
                "path": "[parameters('serviceBusTopicName')]",
            },
            "resources": [{
                "apiVersion": "[variables('sbVersion')]",
                "name": "[parameters('serviceBusSubscriptionName')]",
                "type": "Subscriptions",
                "dependsOn": [
                    "[parameters('serviceBusTopicName')]"
                ],
                "properties": {}
            }]
        }]
    }]

For JSON syntax and properties, see namespaces, topics, and subscriptions.

Commands to run deployment

To deploy the resources to Azure, you must be signed in to your Azure account and you must use the Azure Resource Manager module. To learn about using Azure Resource Manager with either Azure PowerShell or Azure CLI, see:

The following examples assume you already have a resource group in your account with the specified name.

PowerShell

New-AzureResourceGroupDeployment -Name \<deployment-name\> -ResourceGroupName \<resource-group-name\> -TemplateUri <https://raw.githubusercontent.com/azure/azure-quickstart-templates/master/quickstarts/microsoft.servicebus/servicebus-create-topic-and-subscription/azuredeploy.json>

Azure CLI

az deployment group create \<my-resource-group\> --name \<my-deployment-name\> --template-uri <https://raw.githubusercontent.com/azure/azure-quickstart-templates/master/quickstarts/microsoft.servicebus/servicebus-create-topic-and-subscription/azuredeploy.json>

Next steps

Now that you've created and deployed resources using Azure Resource Manager, learn how to manage these resources by viewing these articles: