question

SundaraParipoorananC-9460 avatar image
0 Votes"
SundaraParipoorananC-9460 asked MayankBargali-MSFT commented

Custom headers for event grid using ARM template

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://docs.microsoft.com/en-us/azure/event-grid/delivery-properties

Thanks.

azure-event-grid
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

MayankBargali-MSFT avatar image
0 Votes"
MayankBargali-MSFT answered MayankBargali-MSFT commented

Hi @SundaraParipoorananC-9460

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.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks a lot for this. I basically used the same schema and changed the api version in the eventgrid resource to 2020-10-15-preview, and now this works with the arm template!

0 Votes 0 ·
MayankBargali-MSFT avatar image MayankBargali-MSFT SundaraParipoorananC-9460 ·

@SundaraParipoorananC-9460 Glad to know that specifying the api as " 2020-10-15-preview" with the same schema has helped you. Looks like this preview API document is not yet published for the ARM template.

0 Votes 0 ·