即使使用正确的?正文和HTTP状态代码200,将Blobcreated Webhook的订户添加到事件网格也会失败

问题描述

我正在尝试根据javascript文档将订阅者添加到Azure事件网格。在本地和针对从docker映像运行的Azure Web App服务进行测试时,在使用curl / postman与虚拟验证消息进行测试时,响应似乎是正确的(?),但是Event Grid无法添加Azure Web App订户-我知道我在做什么错吗?

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)."}

代码,基本上是从文档中粘贴的副本。

     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
            }
        }
    }

使用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

回复

{"validationResponse":"512d38b6-c7b8-40c8-89fe-f46f9e9622b6"} | statusCode= 200

与邮递员

HTTP状态为200 OK

enter image description here

{
    "validationResponse": "512d38b6-c7b8-40c8-89fe-f46f9e9622b6"
}

解决方法

好吧,显然这只是天蓝色了。在发布了这个问题之后,再次尝试,然后成功了。 #生活。 yeye希望以后可以帮助其他人

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...