我有一个应用程序,它使用AzureFunction和EventGrid和NodeJS.我想在本地主机中调试一些事件触发器函数,但出于特殊原因,我不想使用Ngrok.没有Ngrok,还有其他方法可以实现EventGrid调试吗?

推荐答案

在本地运行Azure函数时,可以通过以下URL访问EventGridTrigger:

http://localhost:7071/runtime/webhooks/EventGrid?functionName={functionname}

例如,从postman (例如),您将需要以下附加标头:

  • Content-Type:application/json.
  • aeg-event-type:Notification.

完整的http请求如下所示

POST /runtime/webhooks/EventGrid?functionName={functionname}
Host: http://localhost:7071
Content-Type: application/json
aeg-event-type: Notification

{
  "topic": "/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/test/providers/Microsoft.EventHub/namespaces/test",
  "subject": "eventhubs/test",
  "eventType": "captureFileCreated",
  "eventTime": "2017-07-14T23:10:27.7689666Z",
  "id": "7b11c4ce-1c34-4416-848b-1730e766f126",
  "data": {
    "fileUrl": "https://test.blob.core.windows.net/debugging/testblob.txt",
    "fileType": "AzureBlockBlob",
    "partitionId": "1",
    "sizeInBytes": 0,
    "eventCount": 0,
    "firstSequenceNumber": -1,
    "lastSequenceNumber": -1,
    "firstEnqueueTime": "0001-01-01T00:00:00",
    "lastEnqueueTime": "0001-01-01T00:00:00"
  },
  "dataVersion": "",
  "metadataVersion": "1"
}

Calling Azure Function EventgridTrigger from Postman

VS Code debug - Azure Function EventgridTrigger

Node.js相关问答推荐

可以删除一个mongodb catch块

为高流量网站优化Node.js实时通知服务

如何使用Node.js、Express和Mongoose创建多个API

@nuxtjs/站点 map 错误提示:找不到包';NitroPack';

Express无法发布

验证器功能在mongoose 中不起作用

通过 Node js 中的 TBA 执行 netsuite REST upsert 操作出现 401 错误

使用 playwright 获取页面中同一 url 的所有响应

在对象数组中的数组中嵌套 $lookup - Mongodb

如何在mongoose 聚合中执行全文搜索

suppress AWS SDK v2 弃用消息

Fly.io 启动问题:无法从源获取图像或构建错误:构建错误:连接期间出错:发布...

node.js 中 pdfkit-tables 中的垂直线

提供静态文件到底是什么意思?

我可以通过 JNI 从 Node.js 调用 Java 吗?如何?

在多个文件 node.js 之间共享和修改变量

create-react-app,安装错误(找不到命令)

Node.JS 中的基本 HTTP 身份验证?

使用 pm2 编程 api 重命名进程

我可以有条件地将 where() 子句添加到我的 knex 查询吗?