title | description | author | ms.topic | ms.tgt_pltfrm | ms.date | ms.author | ms.custom | ms.devlang |
---|---|---|---|---|---|---|---|---|
Create a Service Bus authorization rule using an Azure template |
Create a Service Bus authorization rule for namespace and queue using Azure Resource Manager template |
spelluru |
article |
dotnet |
09/27/2021 |
spelluru |
devx-track-azurecli, devx-track-arm-template |
azurecli |
Create a Service Bus authorization rule for namespace and queue using an Azure Resource Manager template
This article shows how to use an Azure Resource Manager template that creates an authorization rule for a Service Bus namespace and queue. 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, please see Authoring Azure Resource Manager templates.
For the complete template, see the Service Bus authorization rule template on GitHub.
Note
The following Azure Resource Manager templates are available for download and deployment.
- Create a Service Bus namespace
- Create a Service Bus namespace with queue
- Create a Service Bus namespace with topic and subscription
- Create a Service Bus namespace with topic, subscription, and rule
To check for the latest templates, visit the Azure Quickstart Templates gallery and search for Service Bus.
[!INCLUDE updated-for-az]
With this template, you deploy a Service Bus authorization rule for a namespace and messaging entity (in this case, a queue).
This template uses Shared Access Signature (SAS) for authentication. SAS enables applications to authenticate to Service Bus using an access key configured on the namespace, or on the messaging entity (queue or topic) with which specific rights are associated. You can then use this key to generate a SAS token that clients can in turn use to authenticate to Service Bus.
To run the deployment automatically, click the following button:
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. You should define a parameter for those values that will vary based on the project you are deploying or based on the environment you are deploying to. Do not define parameters for values that will 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.
The name of the Service Bus namespace to create.
"serviceBusNamespaceName": {
"type": "string"
}
The name of the authorization rule for the namespace.
"namespaceAuthorizationRuleName ": {
"type": "string"
}
The name of the queue in the Service Bus namespace.
"serviceBusQueueName": {
"type": "string"
}
The Service Bus API version of the template.
"serviceBusApiVersion": {
"type": "string",
"defaultValue": "2017-04-01",
"metadata": {
"description": "Service Bus ApiVersion used by the template"
}
Creates a standard Service Bus namespace of type Messaging, and a Service Bus authorization rule for namespace and entity.
"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('serviceBusQueueName')]",
"type": "Queues",
"dependsOn": [
"[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespaceName'))]"
],
"properties": {
"path": "[parameters('serviceBusQueueName')]"
},
"resources": [
{
"apiVersion": "[variables('sbVersion')]",
"name": "[parameters('queueAuthorizationRuleName')]",
"type": "authorizationRules",
"dependsOn": [
"[parameters('serviceBusQueueName')]"
],
"properties": {
"Rights": ["Listen"]
}
}
]
}
]
}, {
"apiVersion": "[variables('sbVersion')]",
"name": "[variables('namespaceAuthRuleName')]",
"type": "Microsoft.ServiceBus/namespaces/authorizationRules",
"dependsOn": ["[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespaceName'))]"],
"location": "[resourceGroup().location]",
"properties": {
"Rights": ["Send"]
}
}
]
For JSON syntax and properties, see namespaces, queues, and AuthorizationRules.
[!INCLUDE app-service-deploy-commands]
New-AzResourceGroupDeployment -ResourceGroupName \<resource-group-name\> -TemplateFile <https://raw.githubusercontent.com/azure/azure-quickstart-templates/master/quickstarts/microsoft.servicebus/servicebus-create-authrule-namespace-and-queue/azuredeploy.json>
azure config mode arm
azure group deployment create \<my-resource-group\> \<my-deployment-name\> --template-uri <https://raw.githubusercontent.com/azure/azure-quickstart-templates/master/quickstarts/microsoft.servicebus/servicebus-create-authrule-namespace-and-queue/azuredeploy.json>
Now that you've created and deployed resources using Azure Resource Manager, learn how to manage these resources by viewing these articles: