Azure 服务总线 - ARM 模板(更新现有主题参数)

Azure Service Bus - ARM Template (Update existing Topic parameters)

我需要有关 Azure 服务总线服务的帮助。我需要使用 Visual Studio 在现有服务总线服务中创建一个新主题,有什么方法可以实现这一点。因为当我尝试这样做时,出现以下错误:

任何帮助都会对我很有帮助。

Microsoft.Resources/deployments 模板允许您update an existing resource

修改快速入门模板以允许更新看起来像这样(我确实删除了订阅部署以使其更短)。请记住,某些参数(如分区)无法修改 - 您必须删除资源并重新部署才能更改它们。

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "service_BusNamespace_Name": {
      "type": "String",
      "metadata": {
        "description": "Name of the Service Bus namespace"
      }
    },
    "serviceBusTopicName": {
      "type": "String",
      "metadata": {
        "description": "Name of the Topic"
      }
    },
    "serviceBusSubscriptionName": {
      "type": "String",
      "metadata": {
        "description": "Name of the Subscription"
      }
    },
    "location": {
      "defaultValue": "[resourceGroup().location]",
      "type": "String",
      "metadata": {
        "description": "Location for all resources."
      }
    }
  },
  "variables": {
    "defaultSASKey_Name": "RootManageSharedAccessKey",
    "authRuleResource_Id": "[resourceId('Microsoft.ServiceBus/namespaces/authorizationRules', parameters('service_BusNamespace_Name'), variables('defaultSASKey_Name'))]",
    "sbVersion": "2017-04-01"
  },
  "resources": [
    {
      "type": "Microsoft.Resources/deployments",
      "apiVersion": "2015-01-01",
      "name": "updateTopic",
      "properties": {
        "mode": "Incremental",
        "parameters": {},
        "template": {
          "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
          "contentVersion": "1.0.0.0",
          "parameters": {},
          "variables": {},
          "resources": [
            {
              "apiVersion": "2017-04-01",
              "name": "[parameters('service_BusNamespace_Name')]",
              "type": "Microsoft.ServiceBus/namespaces",
              "location": "[parameters('location')]",
              "sku": {
                "name": "Standard"
              },
              "resources": [
                {
                  "apiVersion": "2017-04-01",
                  "name": "[parameters('serviceBusTopicName')]",
                  "type": "Topics",
                  "dependsOn": [
                    "[concat('Microsoft.ServiceBus/namespaces/', parameters('service_BusNamespace_Name'))]"
                  ],
                  "properties": {
                    "defaultMessageTimeToLive": "P10675199DT2H48M5.4775807S",
                    "maxSizeInMegabytes": "1024",
                    "requiresDuplicateDetection": "false",
                    "duplicateDetectionHistoryTimeWindow": "PT10M",
                    "enableBatchedOperations": "false",
                    "supportOrdering": "false",
                    "autoDeleteOnIdle": "P10675199DT2H48M5.4775807S",
                    "enablePartitioning": "false",
                    "enableExpress": "false"
                  }
                }
              ]
            }
          ]
        }
      }
    }
  ],
  "outputs": {
    "NamespaceConnectionString": {
      "type": "String",
      "value": "[listkeys(variables('authRuleResource_Id'), variables('sbVersion')).primaryConnectionString]"
    },
    "SharedAccessPolicyPrimaryKey": {
      "type": "String",
      "value": "[listkeys(variables('authRuleResource_Id'), variables('sbVersion')).primaryKey]"
    }
  }
}

当您请求资源当前状态不允许的操作时,通常会出现 "conflict in backend" 错误。

例如,将服务总线升级到标准后,如果它尝试降级到基本,部署将失败。

实际上,针对这些情况的唯一解决方案是从头开始重新配置资源。