如何确定 Azure Function App 未被 webhook 触发的原因

How to determine why an Azure Function App is not triggered by a webhook

我有:

我的目标是 Azure Functions URL 从软件的 webhook 接收通知并执行操作。 Azure 逻辑应用仅用于测试。

什么有效

什么不起作用

Azure 函数的 URL

这来自获取函数URL > 默认(功能键).

https://<app_name>.azurewebsites.net/api/content?code=<api_key>

其他 Azure 函数配置设置

JSON 我相信会通过 webhook

{
  "headers": {
    "Expect": "100-continue",
    "Host": "redacted",
    "X-Telligent-Webhook-Sender": "redacted",
    "Content-Length": "16908",
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "events": [{
      "TypeId": "ec9da4f4-0703-4029-b01e-7ca9c9ed6c85",
      "DateOccurred": "2018-12-17T22:55:37.7846546Z",
      "EventData": {
        "ActorUserId": 9999,
        "ContentId": "redacted",
        "ContentTypeId": "redacted",
        "ForumReplyId": 9999,
        "ForumThreadId": 9999,
        "ForumId": 9999
      }
    }]
  }
}

我也尝试使用以下测试代码获得相同的结果。它与软件公司提供的示例负载数据更接近:

我试过的

{
  "events": [{
    "TypeId": "ec9da4f4-0703-4029-b01e-7ca9c9ed6c85",
    "DateOccurred": "2018-12-17T22:55:37.7846546Z",
    "EventData": {
      "ActorUserId": 9999,
      "ContentId": "redacted",
      "ContentTypeId": "redacted",
      "ForumReplyId": 9999,
      "ForumThreadId": 9999,
      "ForumId": 9999
    }
  }]
}

Sample payload data

{
  "events": [
    {
      "TypeId": "407ad3bc-8269-493e-ac56-9127656527df",
      "DateOccurred": "2015-12-04T16:31:55.5383926Z",
      "EventData": {
        "ActorUserId": 2100,
        "ContentId": "4c792b81-6f09-4a45-be8c-476198ba47be"
      }
    },
    {
      "TypeId": "3b75c5b9-4705-4a97-93f5-a4941dc69bc9",
      "DateOccurred": "2015-12-04T16:48:03.7343926Z",
      "EventData": {
        "ActorUserId": 2100,
        "ContentId": "4c792b81-6f09-4a45-be8c-476198ba47be"
      }
    }
  ]
}

我不知道如何确定为什么 Azure Function 没有被 webhook 触发。该软件的 API documentation 似乎没有提供查看通过 webhook 发送的 JSON 的方法,尽管以我的经验不足,我可能是错的。

Azure、Postman 或其他工具中是否有一种机制可以让我查看 JSON 通过 webhook 发送的内容?或者是否有其他方法可以确定问题的原因?

感谢您的帮助。

这就是我从 Azure 警报中获取 JSON 文件的方式。

  1. 在服务器上安装Ruby
  2. 使用以下命令安装 Sinatra gem install sinatra
  3. 创建文件 webhook.rb 并粘贴下面的代码
require 'sinatra'

set :port, 80
set :bind, '0.0.0.0'

post '/event' do
  status 204 #successful request with no body content

  request.body.rewind
  request_payload = JSON.parse(request.body.read)

  #append the payload to a file
  File.open("events.txt", "a") do |f|
    f.puts(request_payload)
  end
end
  1. 运行 使用命令 ruby webhook.rb
  2. 的 Web 服务
  3. JSON 填写写入文件events.txt