Reputation: 93
Im trying to add a subscriber to Azure Event Grid as per documentation for javascript. When testing both locally and against Azure Web App service running from a docker image the response seems correct(?) when testing with curl/postman with dummy validation message however Event Grid fails on adding Azure web app subscriber - Any ideas what Im doing wrong?
Deployment has failed with the following error: {"code":"Url validation","message":"Webhook validation handshake failed for https://blablablba.azurewebsites.net/event. Http POST request retuned 2XX response with response body {\"validationResponse\":\"BF3F55BB-862E-447F-8C49-8D7538D60484\". When a validation request is accepted without validation code in the response body, Http GET is expected on the validation url included in the validation event(within 10 minutes). For troublehooting, visit https://aka.ms/esvalidation. Activity id:blablalba-7c10-4002-a5ea-c2e7a1701d04, timestamp: 11/8/2020 9:45:33 PM (UTC)."}
Code, basically copy pasted from docs..
eventHook: function(req, res) {
var validationEventType = "Microsoft.EventGrid.SubscriptionValidationEvent";
var storageBlobCreatedEvent = "Microsoft.Storage.BlobCreated";
for (var events in req.body) {
var body = req.body[events];
if (body.data && body.eventType == validationEventType) {
var code = body.data.validationCode;
res.status(200).send({
"validationResponse": code
});
}
else if (body.data && body.eventType == storageBlobCreatedEvent) {
var blobCreatedEventData = body.data;
//Handle blob created event
}
}
}
Testing with Curl
curl -w " | statusCode= %{http_code} \n" -X POST -d '[{"id": "2d1781af-3a4c-4d7c-bd0c-e34b19da4e66","topic": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","subject": "","data": {"validationCode": "512d38b6-c7b8-40c8-89fe-f46f9e9622b6"},"eventType": "Microsoft.EventGrid.SubscriptionValidationEvent","eventTime": "2018-01-25T22:12:19.4556811Z", "metadataVersion": "1","dataVersion": "1"}]' -H 'Content-Type: application/json' https://blablablba.azurewebsites.net/event
Response
{"validationResponse":"512d38b6-c7b8-40c8-89fe-f46f9e9622b6"} | statusCode= 200
With Postman
{
"validationResponse": "512d38b6-c7b8-40c8-89fe-f46f9e9622b6"
}
Upvotes: 1
Views: 821
Reputation: 93
Well, apparently it was just azure being azure.. tried again after posting this question obviously and then it worked. #life. yeye hope it can help someone else later
Upvotes: 1