Custom headers for event grid using ARM template

Anonymous
2021-07-19T15:59:01.367+00:00

Recently Azure had introduced a feature to add custom headers to events delivered via Event Grid. It seems that it can be done only via the Azure portal, is there a way this can be done using ARM templates or the REST API?

Link for feature: https://learn.microsoft.com/en-us/azure/event-grid/delivery-properties

Thanks.

Azure Event Grid
Azure Event Grid
An Azure event routing service designed for high availability, consistent performance, and dynamic scale.
382 questions
0 comments No comments
{count} votes

Accepted answer
  1. MayankBargali-MSFT 70,451 Reputation points
    2021-07-20T03:30:39.163+00:00

    Hi @Anonymous

    You can leverage the Event Subscription - Create Or Update API 2020-10-15-preview API to update the delivery properties.
    You need to define properties.deliveryAttributeMappings for the different endpoints that you have configured. Please refer to Create Or Update document for the usage.

    For your reference below was the REST body call for webhook endpoint. You can see the properties deliveryAttributeMappings

    {  
       "id":"/subscriptions/{subscriptionID}/resourceGroups/{resourcegroup}/providers/Microsoft.EventGrid/topics/{mytopic}/providers/Microsoft.EventGrid/eventSubscriptions/{myeventgridsubscription}",  
       "name":"myeventgridsub",  
       "type":"Microsoft.EventGrid/eventSubscriptions",  
       "properties":{  
          "topic":"/subscriptions/{subscriptionID}/resourceGroups/{resourcegroup}/providers/Microsoft.EventGrid/topics/{mytopic}",  
          "destination":{  
             "endpointType":"WebHook",  
             "properties":{  
                "endpointUrl":"mywebhookendpoint",  
                "maxEventsPerBatch":1,  
                "preferredBatchSizeInKilobytes":64,  
                "deliveryAttributeMappings":[  
                   {  
                      "name":"mycustomheader",  
                      "type":"Static",  
                      "properties":{  
                         "value":"mycustomheaderValue",  
                         "isSecret":false  
                      }  
                   },  
                   {  
                      "name":"mycustomheader1",  
                      "type":"Static",  
                      "properties":{  
                         "value":"mycustomheaderValue2",  
                         "isSecret":false,  
                         "sourceField":""  
                      }  
                   }  
                ]  
             }  
          },  
          "filter":{  
             "advancedFilters":[  
                  
             ],  
             "enableAdvancedFilteringOnArrays":true  
          },  
          "eventDeliverySchema":"EventGridSchema",  
          "labels":[  
               
          ],  
          "retryPolicy":{  
             "maxDeliveryAttempts":30,  
             "eventTimeToLiveInMinutes":1440  
          }  
       }  
    }  
    

    As per the ARM document for Microsoft.EventGrid eventSubscriptions I don't see the api version as 2020-10-15-preview or newer yet that can help you with the ARM deployment which has deliveryAttributeMappings property that can be define to achieve the same.

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.