首页 > 解决方案 > ARM 隐式创建事件网格系统主题。事件网格订阅如何附加到自定义事件网格主题

问题描述

我在通过 ARM 部署资源时遇到问题。我有 2 个查询。

查询 1。为什么下面这个 Linked ARM 隐式创建了 Event Grid System Topic 这个 Linked ARM 仅用于获取 azure function { "$schema": "https://schema.management.azure.com/schemas/2015-01-01 的触发 URL /deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "functionAppName": { "type": "String" } }, "variables": { "sitesWebApiVersion": "2016-08 -01" }, "resources": [], "outputs": { "triggerUrl": { "type": "String", "value": "[listsecrets(resourceId('Microsoft.Web/sites/functions',参数('functionAppName')、'NPEventGridDataProcessor')、变量('sitesWebApiVersion')).trigger_url]" } } }

Query2 在 ARM 中,我如何创建附加到显式创建的自定义事件主题的事件订阅。如以下主要 ARM 代码片段所示,事件订阅附加到事件网格系统主题中不需要。但我想将它添加到自定义事件网格主题。

{ "apiVersion": "2020-06-01", "scope": "[format('Microsoft.EventGrid/topics/{0}', variables('eventGridName'))]", "name": "[variables ('eventGridSubwebhookName')]", "type": "Microsoft.EventGrid/eventSubscriptions", "tags": { "displayName": "Webhook Subscription" }, "dependsOn": ["[resourceId('Microsoft.EventGrid/topics /', variables('eventGridName'))]", "[resourceId('Microsoft.Resources/deployments/', variables('hackForGettingTriggerUrl'))]" ], "properties": { "destination": { "endpointType" :“WebHook”,“属性”:{“endpointUrl”:“[参考(变量('hackForGettingTriggerUrl'))。输出.triggerUrl.value]" } } } } ]

标签: azure-eventgrid

解决方案


如果您想为自定义主题创建事件网格订阅,请参考以下模板

"resources": [
    {
      "type": "Microsoft.EventGrid/topics",
      "apiVersion": "2020-06-01",
      "name": "[parameters('eventGridTopicName')]",
      "location": "[parameters('location')]"
    },
    {
      "type": "Microsoft.EventGrid/eventSubscriptions",
      "apiVersion": "2020-06-01",
      "scope": "[format('Microsoft.EventGrid/topics/{0}', parameters('eventGridTopicName'))]",
      "name": "[parameters('eventGridSubscriptionName')]",
      "properties": {
        "destination": {
          "endpointType": "WebHook",
          "properties": {
            "endpointUrl": "[parameters('eventGridSubscriptionUrl')]"
          }
        }
      },
      "dependsOn": [
        "[resourceId('Microsoft.EventGrid/topics', parameters('eventGridTopicName'))]"
      ]
    }
  ],

推荐阅读