'How to subscribe to Azure Event Grid Topic using HTTP Webhook activity in Azure Logic App
I have a scenario in which I want to use Azure Logic App / Azure Power App to use the HTTP Webhook
activity to subscribe to Event Grid Topic. I have been using Azure Event Grid connector/activity to connect with Event Grid in the Logic App but now my manager wants to move from native connector to HTTP Webhook
activity. Surprisingly I have been look into this but I could not find any resource online which demonstrate/suggest how HTTP Webhook activity can be used.
I tried to use the below flow but I am getting this error
"Unauthorized","message":"The request authorization key is not authorized for EVENTGRIDNAME.NORTHEUROPE-1.EVENTGRID.AZURE.NET.
Solution 1:[1]
Though I have'nt done this yet myself, my first guess is that you manually need to verify your Endpoint first.
As per Code you get an Event of type "Microsoft.EventGrid.SubscriptionValidationEvent
". In this Event is a validationCode
included that you must send back to the EventGrid as Validation-Handshake.
https://docs.microsoft.com/en-us/azure/event-grid/receive-events#endpoint-validation
As soon as this has happended your Endpoint is usually seen as Authenticated.
Solution 2:[2]
The following is an example of using the Http Webhook Trigger for subscribing on the Azure Event Grid (AEG) Topic:
The Http Webhook Trigger has a responsibility to create an AEG subscription with a callback event handler destination endpoint during its subscribing process and also for deleting this subscription from the AEG (unsubscribing process). Based on the AEG REST APIs in my example:
Subscribe - Method:
PUT
Subscribe - URI:
https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxxxx/providers/Microsoft.EventGrid/topics/xxxxx/providers/Microsoft.EventGrid/eventSubscriptions/mySubscription123?api-version=2021-12-01
Subscribe - Body:
{
"properties": {
"destination": {
"endpointType": "WebHook",
"properties": {
"endpointUrl": @{listCallbackUrl()}
}
}
}
}
Subscribe - Headers:
Authorization Bearer eyJ0eXAiOiJKV1QiLCJ....
Unsubscribe - Method:
DELETE
Unsubscribe - URI:
https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxxxx/providers/Microsoft.EventGrid/topics/xxxxx/providers/Microsoft.EventGrid/eventSubscriptions/mySubscription123?api-version=2021-12-01
Unsubscribe - Headers:
Authorization Bearer eyJ0eXAiOiJKV1QiLCJ....
Note, that the Authorization header is required for using the AEG REST APIs.
Also, I do recommend to read the following docs:
https://docs.microsoft.com/en-us/azure/connectors/connectors-native-webhook
https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-create-api-app
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Tobi |
Solution 2 |