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

标签 visual-studio azure azureservicebus azure-resource-manager azure-servicebus-topics

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

  • 模板部署返回以下错误: 15:28:14 - 15:28:13 - 资源 Microsoft.ServiceBus/namespaces “########” 失败,并显示消息 '{ 15:28:14 - “错误”:{ 15:28:14 - “message”:“命名空间更新因后端冲突而失败。CorrelationId:3c155444-2c1e-525d-943f-8b25d0a1da7e”, 15:28:14 - “代码”:“冲突” 15:28:14 - }

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

最佳答案

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]"
    }
  }
}

关于visual-studio - Azure 服务总线 - ARM 模板(更新现有主题参数),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56966945/

相关文章:

c# - 有没有办法将 VS 与只能通过 sftp 访问的远程站点一起使用?

windows - 将默认的 git 源添加到 visual studio?

c# - 了解 eventhub 中的检查点

multithreading - Azure 服务 TopicClient 线程安全且可重用吗?

visual-studio - 有没有一种方法可以有条件地运行Visual Studio生成后步骤

visual-studio - 有没有办法最大化 Visual Studio 中的当前选项卡?

session - 共置缓存在 Web 角色中不起作用

c# - 如何取消 Azure 主题中的预定消息

Azure 应用服务 WebApp 正常关闭/重新启动

python - qpid 质子 url 用于接收来自给定订阅(主题)的消息