You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用ARM模板创建带静态Header的WEBHOOK类事件订阅后门户无记录

问题根因及解决方案
  • 资源作用域配置错误:你当前定义的Microsoft.EventGrid/eventSubscriptions属于Azure订阅级/资源组级的全局事件订阅资源,并非指定Event Grid主题下的子资源,因此即使部署显示成功,订阅也不会出现在目标主题的订阅列表中。
  • 资源结构逻辑错误:你错误将事件源(目标Event Grid主题)写入了destination字段,该字段仅用于配置事件投递的目标(即你使用的WebHook相关配置),事件源需要通过子资源关联或scope字段声明。
  • 语法拼写错误:模板中填写的主题资源ID存在多余符号:{Subscription Id})多了一个右括号、{Topic name}}多了一个右大括号,会导致资源匹配失效。
修正后的ARM模板示例

要创建指定主题下的事件订阅,需要将订阅定义为对应主题的子资源,修正后的模板如下:

{
  "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "topicName": {
      "type": "string",
      "defaultValue": "{替换为实际主题名}"
    },
    "subscriptionName": {
      "type": "string",
      "defaultValue": "Subscription_1"
    },
    "endpointUrl": {
      "type": "string",
      "defaultValue": "{替换为实际WebHook地址}"
    }
  },
  "resources": [
    {
      "type": "Microsoft.EventGrid/topics/eventSubscriptions",
      "apiVersion": "2021-06-01-preview",
      // 名称必须为「父主题名/订阅名」格式,完成与父主题的关联
      "name": "[concat(parameters('topicName'), '/', parameters('subscriptionName'))]",
      "properties": {
        "destination": {
          "endpointType": "WebHook",
          "properties": {
              "endpointUrl": "[parameters('endpointUrl')]",
              "deliveryAttributeMappings": [
                  {
                      "name": "test",
                      "type": "Static",
                      "properties": {
                          "value": "test"
                      }
                  }
              ]
          }
        },
        "eventDeliverySchema": "EventGridSchema",
        "filter": {
          "advancedFilters": [],
          "enableAdvancedFilteringOnArrays": true
        },
        "labels": []      
      }
    }
  ]
}
验证方式

部署完成后可直接在PowerShell执行如下命令验证创建结果,返回正常则说明订阅创建成功,刷新Azure门户即可在对应主题下看到:
Get-AzEventGridSubscription -ResourceGroupName {替换为实际资源组名} -TopicName {替换为实际主题名} -SubscriptionName Subscription_1

内容的提问来源于stack exchange,提问作者Anurag Chugh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.25 04:45:03