Azure 事件网格使用来自与节点的混合连接的事件

Azure Event Grid consume events from Hybrid Connection with Node

有人能指出我正确的方向吗?我正在与一个希望让第 3 方从他们那里接收事件数据(创建的 blob 等)的客户合作。 C# 示例效果很好:

https://azure.microsoft.com/en-us/resources/samples/event-grid-dotnet-publish-consume-events/

但是,他们的一些客户正在使用 Node,我们在连接他们时遇到了问题。当存在 sender/listener 时,示例工作得很好,但侦听器实际上吞噬了事件网格事件,因为它们是使用 "request" 键发送的,而 sender/listener 事件是使用 "accept"键。

https://github.com/Azure/azure-relay/tree/master/samples/hybrid-connections/node

我可以直接指向每个节点示例(HybridConnectionWebSocktServer.js 等)中处理事件并随后忽略的行。

我也找到并尝试了这个函数示例,但未能成功在本地接收事件网格事件:

https://azure.microsoft.com/is-is/resources/samples/event-grid-node-publish-consume-events/

有更好的例子吗?有更好的方法吗?我们应该从另一个方向来解决这个问题吗?

任何正确方向的帮助、指导或推动将不胜感激。

我联系了所有可用的途径,试图快速解决我的问题。我想 post 在这里回答,以防其他人遇到和我一样的麻烦。

非常感谢那些能够为我指明正确方向并帮助我解决问题的 Microsoft 人员。

Event Grid is built exclusively on HTTP so it makes sense that you’re getting the events with a request gesture. Incase you haven’t found it, the doc on the interaction model for Hybrid Connections is available here.

The sample you’re looking at uses the hyco-ws package which is for websockets only. The package you want to be using is hyco-https which allows listening to HTTP messages. This sample shows how to use Hybrid Connections with HTTP.

我也试过这个例子,但没有看到(或不知道如何访问)事件数据。

再深入一点,我能够通过添加 req.on 行找到获取数据的方法:

        (req, res) => {
        console.log('request accepted: ' + req.method + ' on ' + req.url);

        req.on('data', function(chunk) {
            var bodydata = chunk.toString('utf8');
            console.log(bodydata);
        });

        res.setHeader('Content-Type', 'text/html');
        res.end('<html><head><title>Hey!</title></head><body>Relayed Node.js Server!</body></html>');
    });

这写出了我期望在控制台看到的事件。