不同资源组中自定义主题的 Azure 事件网格订阅

Ale*_*lex 5 azure-eventgrid

我正在尝试订阅存在于不同资源组上的自定义事件网格主题。例如,如果我my-custom-topic在资源组中有一个自定义事件网格主题publisher-group。如何从资源组中创建对我的主题的事件网格订阅subscriber-group

仅当以下 ARM 模板my-custom-topic与我应用该模板位于同一资源组中时才有效

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "eventGridSubscriptionName": {
            "type": "String",
            "metadata": {
                "description": "The name of the Event Grid custom topic's subscription."
            }
        },
        "location": {
            "defaultValue": "[resourceGroup().location]",
            "type": "String",
            "metadata": {
                "description": "The location in which the Event Grid resources should be deployed."
            }
        }
    },
    "resources": [
        {
            "type": "Microsoft.EventGrid/topics/providers/eventSubscriptions",
            "apiVersion": "2018-01-01",
            "name": "[concat('my-custom-topic', '/Microsoft.EventGrid/', parameters('eventGridSubscriptionName'))]",
            "location": "[parameters('location')]",
            "properties": {
                "destination": {
                    "endpointType": "EventHub",
                    "properties": {
                        "resourceId": "..."
                    }
                },
                "filter": {
                    "includedEventTypes": [
                        "All"
                    ]
                }
            }
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

如果我更改name为主题的完整路径(例如,subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx/resourceGroups/publisher-group/providers/Microsoft.EventGrid/topics/my-custom-topic),则模板会抱怨我的段太多了

我本以为这是一个非常常见的用例,在不同的资源组中具有主题和订阅,但我无法找到具体的示例

如何创建 ARM 模板来订阅不同资源组上的事件网格主题?

Phi*_*ris 1

这是不可能的 - 事件网格主题和订阅必须位于同一资源组中。

我建议创建一个单独的资源组,仅用于包含您的事件网格主题及其所有订阅。

从逻辑上讲,您不应将单个事件发布者视为拥有其发布到的事件网格主题,而应将主题视为许多发布者和订阅者所依赖的共享资源。