无法将 webhook 订阅添加到 Azure 事件网格

Not able to add webhook subscription to the Azure Event Grid

我无法在 Azure 事件网格中添加新的 WebHook 订阅。有人可以帮忙吗?添加 webhook 端点时出现以下错误。

{
  "status": "Failed",
  "error": {
    "code": "ResourceDeploymentFailure",
    "message": "The resource operation completed with terminal provisioning state 'Failed'.",
    "details": [
      {
        "code": "Url validation",
        "message": "The attempt to validate the provided endpoint https://webapplication120180427035159.azurewebsites.net/api/values?id=AMif5RXS+Bs0bgsbHnNP8RUcn8ZacH8ETUzHXZ5YlNM= failed. For more details, visit https://aka.ms/esvalidation."
      }
    ]
  }

向 Azure 事件网格注册 webhook 时,您的代码必须处理 validation call. You can follow this sample 显示如何接收验证码并回复以确保订阅者正确注册。

目前,这是通过处理所有常规(非验证)事件的代码执行验证的唯一方法。

如果您使用的是 Azure Functions,则可以使用 EventGridTrigger instead of HttpTrigger. It will handle validation handshake 让您的 Function 仅专注于 "normal" 事件。