【问题标题】:How do I properly write an ARM template for topic and subscription如何正确编写主题和订阅的 ARM 模板
【发布时间】:2019-12-08 10:46:31
【问题描述】:

我有以下代码:

// Create event topics and listeners
    {
        "comments": "Service Bus Topic - clusterprocessingcompletedevent",
        "type": "Microsoft.ServiceBus/namespaces/topics",
        "name": "[concat(variables('resource_names').service_bus_namespaces.core, '/clusterprocessingcompletedevent')]",
        "apiVersion": "2017-04-01",
        "location": "[resourceGroup().location]",
        "dependsOn": [
            "[resourceId('Microsoft.ServiceBus/namespaces', variables('resource_names').service_bus_namespaces.core)]"
        ],
        "resources": [
            {
                "comments": "Service Bus Topic Subscription - notification.clusterprocessingcompletedevent",
                "apiVersion": "2017-04-01",
                "name": "[concat(variables('resource_names').service_bus_namespaces.core, '/clusterprocessingcompletedevent', '/notification.clusterprocessingcompletedevent')]",
                "type": "Microsoft.ServiceBus/namespaces/topics/subscriptions",
                "dependsOn": [
                    "[resourceId('Microsoft.ServiceBus/namespaces/topics', variables('resource_names').service_bus_namespaces.core, '/clusterprocessingcompletedevent')]"
                ]
            }
        ]
    }

当尝试使用它时,我得到这个错误:

无法评估模板语言函数“resourceId”:函数 只需要一个多段参数,它必须是资源 类型包括资源提供者命名空间

我该如何解决?

【问题讨论】:

  • @GauravMantri 是的,我确实看过它。如果可能,我不想定义参数“serviceBusTopicName”。有什么办法可以避免这样做吗?订阅资源中的“dependsOn”参数似乎是问题所在。

标签: json azure azure-resource-manager


【解决方案1】:

我认为这是问题所在:

"dependsOn": [
    "[resourceId('Microsoft.ServiceBus/namespaces/topics', variables('resource_names').service_bus_namespaces.core, 'clusterprocessingcompletedevent')]"
]

所以主题名称中有一个额外的/。这同样适用于:variables('resource_names').service_bus_namespaces.core。它应该是命名空间的名称,其中不包含/

【讨论】:

    猜你喜欢
    • 2020-03-27
    • 1970-01-01
    • 2017-03-28
    • 1970-01-01
    • 2020-05-29
    • 2021-02-19
    • 1970-01-01
    • 2019-11-05
    • 1970-01-01
    相关资源
    最近更新 更多