Search code examples
azureazure-rm-templateazure-eventgridazure-webhooks

Event subscription of type WEBHOOK with static Header using ARM template


Problem area:

I tried creating a new event grid topic subscription using an ARM Template following the official documentation.

Script ran fine within PowerShell terminal but I couldn't find the event subscription being generated under the specified topic in the azure portal.

Sample JSON Template:

{
  "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [
    {
      "type": "Microsoft.EventGrid/eventSubscriptions",
      "apiVersion": "2021-06-01-preview",
      "name": "Subscription_1",
      "properties": {
        "destination": {
          "topic": "/subscriptions/{Subscription Id})/resourceGroups/{Resource group name}/providers/Microsoft.EventGrid/topics/{Topic name}}",
          "endpointType": "WebHook",
          "properties": {
              "endpointUrl": "{Endpoint URL}",
              "deliveryAttributeMappings": [
                  {
                      "name": "test",
                      "type": "Static",
                      "properties": {
                          "value": "test"
                      }
                  }
              ]
          }
        },
        "eventDeliverySchema": "EventGridSchema",
        "filter": {
          "advancedFilters": [],
          "enableAdvancedFilteringOnArrays": true
        },
        "labels": []      
      }
    }
  ]
}

Solution

  • Solution:

    Got this working by changing the 'type' and the 'naming convention' in the arm-template as below:

    "type": "Microsoft.EventGrid/topics/providers/eventSubscriptions",
    "apiVersion": "2021-06-01-preview",
    "name": "{Topic Name}/ Microsoft.EventGrid/ {Subsctription Name}",