不同资源组中自定义主题的 Azure 事件网格订阅
Azure Event Grid Subscriptions on custom topic in different resource group
我正在尝试订阅存在于不同资源组中的自定义事件网格主题。例如,如果我在资源组 publisher-group
中有一个自定义事件网格主题 my-custom-topic
。如何从资源组 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"
]
}
}
}
]
}
如果我将 name
更改为主题的完整路径(例如 subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx/resourceGroups/publisher-group/providers/Microsoft.EventGrid/topics/my-custom-topic),那么模板会抱怨我有太多片段
我原以为这是一个非常常见的用例,在不同的资源组中有主题和订阅,但我找不到这方面的具体示例
如何创建 ARM 模板以订阅不同资源组上的事件网格主题?
这是不可能的 - 事件网格主题和订阅必须在同一个资源组中。
我建议创建一个单独的资源组,仅用于包含您的事件网格主题及其所有订阅。
从逻辑上讲,您不应将单个事件发布者视为拥有它发布到的事件网格主题 - 而是将主题视为许多发布者和订阅者所依赖的共享资源。
我正在尝试订阅存在于不同资源组中的自定义事件网格主题。例如,如果我在资源组 publisher-group
中有一个自定义事件网格主题 my-custom-topic
。如何从资源组 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"
]
}
}
}
]
}
如果我将 name
更改为主题的完整路径(例如 subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx/resourceGroups/publisher-group/providers/Microsoft.EventGrid/topics/my-custom-topic),那么模板会抱怨我有太多片段
我原以为这是一个非常常见的用例,在不同的资源组中有主题和订阅,但我找不到这方面的具体示例
如何创建 ARM 模板以订阅不同资源组上的事件网格主题?
这是不可能的 - 事件网格主题和订阅必须在同一个资源组中。
我建议创建一个单独的资源组,仅用于包含您的事件网格主题及其所有订阅。
从逻辑上讲,您不应将单个事件发布者视为拥有它发布到的事件网格主题 - 而是将主题视为许多发布者和订阅者所依赖的共享资源。