如何将一个服务总线的队列复制到另一个服务总线?

3

我有一个名为ServiceBus-Dev的服务总线,在开发阶段创建了许多队列。

我需要在ServiceBus-Prod上创建相同的队列。

是否有一种简单的方法可以从一个服务总线复制粘贴所有队列到另一个服务总线中?

目前我找到的唯一方法是使用az cli并编写一些脚本,例如:

  1. 从两个服务总线中获取所有队列ID az servicebus queue list
  2. 编写一些逻辑来识别在生产环境中缺失的队列
  3. 逐个创建缺少的队列 az servicebus queue create

是否有更简单的方法来实现相同的结果?

1个回答

1
有没有简单的方法来将一个服务总线中的所有队列复制粘贴到另一个服务总线中?
您可以使用 ARM 模板创建和部署基础结构。了解更多关于 ARM 模板的内容,请访问ARM 模板 1. 创建一个服务总线。 2. 创建队列。 3. 转到资源组并选择服务总线。 4. 点击右侧的三个点,选择导出模板。 5. ARM 模板导出。 6. ARM 模板 JSON。
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"namespaces_punitmt_name": {
"defaultValue": "punitmt",
"type": "String"
}

},
"variables": {},
"resources": [
{
"type": "Microsoft.ServiceBus/namespaces",
"apiVersion": "2022-01-01-preview",
"name": "[parameters('namespaces_punitmt_name')]",
"location": "East US",
"sku": {
"name": "Standard",
"tier": "Standard"
},

"properties": {
"minimumTlsVersion": "1.2",
"publicNetworkAccess": "Enabled",
"disableLocalAuth": false,
"zoneRedundant": false
}
},

{
"type": "Microsoft.ServiceBus/namespaces/AuthorizationRules",
"apiVersion": "2022-01-01-preview",
"name": "[concat(parameters('namespaces_punitmt_name'), '/RootManageSharedAccessKey')]",
"location": "East US",
"dependsOn": [
"[resourceId('Microsoft.ServiceBus/namespaces', parameters('namespaces_punitmt_name'))]"
],
"properties": {
"rights": [
"Listen",
"Manage",
"Send"
]
}
},
{
"type": "Microsoft.ServiceBus/namespaces/networkRuleSets",
"apiVersion": "2022-01-01-preview",
"name": "[concat(parameters('namespaces_punitmt_name'), '/default')]",
"location": "East US",
"dependsOn": [
"[resourceId('Microsoft.ServiceBus/namespaces', parameters('namespaces_punitmt_name'))]"
],
"properties": {
"publicNetworkAccess": "Enabled",
"defaultAction": "Allow",
"virtualNetworkRules": [],
"ipRules": []
}
},
{
"type": "Microsoft.ServiceBus/namespaces/queues",
"apiVersion": "2022-01-01-preview",
"name": "[concat(parameters('namespaces_punitmt_name'), '/message1')]",
"location": "eastus",
"dependsOn": [
"[resourceId('Microsoft.ServiceBus/namespaces', parameters('namespaces_punitmt_name'))]"
],
"properties": {
"maxMessageSizeInKilobytes": 256,
"lockDuration": "PT30S",
"maxSizeInMegabytes": 1024,
"requiresDuplicateDetection": false,
"requiresSession": false,
"defaultMessageTimeToLive": "P14D",
"deadLetteringOnMessageExpiration": false,
"enableBatchedOperations": true,
"duplicateDetectionHistoryTimeWindow": "PT10M",
"maxDeliveryCount": 10,
"status": "Active",
"autoDeleteOnIdle": "P10675199DT2H48M5.4775807S",
"enablePartitioning": false,
"enableExpress": false
}
},
{
"type": "Microsoft.ServiceBus/namespaces/queues",
"apiVersion": "2022-01-01-preview",
"name": "[concat(parameters('namespaces_punitmt_name'), '/message2')]",
"location": "eastus",
"dependsOn": [
"[resourceId('Microsoft.ServiceBus/namespaces', parameters('namespaces_punitmt_name'))]"
],
"properties": {
"maxMessageSizeInKilobytes": 256,
"lockDuration": "PT30S",
"maxSizeInMegabytes": 1024,
"requiresDuplicateDetection": false,
"requiresSession": false,
"defaultMessageTimeToLive": "P14D",
"deadLetteringOnMessageExpiration": false,
"enableBatchedOperations": true,
"duplicateDetectionHistoryTimeWindow": "PT10M",
"maxDeliveryCount": 10,
"status": "Active",
"autoDeleteOnIdle": "P10675199DT2H48M5.4775807S",
"enablePartitioning": false,
"enableExpress": false
}
}
]
}

您可以使用这些ARM模板来创建相同的内容。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接