如何使用 arm 模板在服务总线队列级别创建自定义共享访问策略
How to create custom shared access policies at service bus queue level using arm template
我使用 ARM 模板创建了一个 Azure 服务总线命名空间以及队列和主题。这是在我的服务总线模板中使用迭代概念创建队列的示例片段。
{
"apiVersion": "2017-04-01",
"name": "[concat(parameters('serviceBusNamespaceName'),'/', parameters('queueNames')[copyIndex()])]",
"type": "Microsoft.ServiceBus/namespaces/queues",
"copy": {
"name": "queuesCopy",
"count": "[length(parameters('queueNames'))]"
},
"dependsOn": [
"[resourceId('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespaceName'))]"
],
"properties": {
"lockDuration": "PT30S",
"maxSizeInMegabytes": 1024,
"requiresDuplicateDetection": false,
"requiresSession": false,
"defaultMessageTimeToLive": "P14D",
"deadLetteringOnMessageExpiration": false,
"duplicateDetectionHistoryTimeWindow": "PT10M",
"maxDeliveryCount": 10,
"autoDeleteOnIdle": "P10675199DT2H48M5.4775807S",
"enablePartitioning": false,
"enableExpress": false
},
}
如何在服务总线队列级别创建自定义共享访问策略?
您可以使用队列的子资源部分在队列级别创建自定义共享访问策略。
下面是一个与您的场景相似的示例 -
"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"]
}
}
]
请参考这个documentation。
我使用 ARM 模板创建了一个 Azure 服务总线命名空间以及队列和主题。这是在我的服务总线模板中使用迭代概念创建队列的示例片段。
{
"apiVersion": "2017-04-01",
"name": "[concat(parameters('serviceBusNamespaceName'),'/', parameters('queueNames')[copyIndex()])]",
"type": "Microsoft.ServiceBus/namespaces/queues",
"copy": {
"name": "queuesCopy",
"count": "[length(parameters('queueNames'))]"
},
"dependsOn": [
"[resourceId('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespaceName'))]"
],
"properties": {
"lockDuration": "PT30S",
"maxSizeInMegabytes": 1024,
"requiresDuplicateDetection": false,
"requiresSession": false,
"defaultMessageTimeToLive": "P14D",
"deadLetteringOnMessageExpiration": false,
"duplicateDetectionHistoryTimeWindow": "PT10M",
"maxDeliveryCount": 10,
"autoDeleteOnIdle": "P10675199DT2H48M5.4775807S",
"enablePartitioning": false,
"enableExpress": false
},
}
如何在服务总线队列级别创建自定义共享访问策略?
您可以使用队列的子资源部分在队列级别创建自定义共享访问策略。
下面是一个与您的场景相似的示例 -
"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"]
}
}
]
请参考这个documentation。