我正在寻找一种解决方案,将数据从 Azure IoT 中心获取到同样托管在 Azure 中的 Web 应用程序的后端,该应用程序是用 ASP.NET 4.6 编写的。 最好尽快接收原始 Json 字符串。
我发现其他人建议使用 Webhooks 或 Azure 函数来实现类似的目的,但这些解决方案带来的延迟确实令人无法接受。 最好直接连接到物联网端点并获取收到的每条消息。任何人都可以为我指出正确的方向吗?
最佳答案
您只需在 Web 应用程序中使用 EventHub .NET SDK,连接到 EventHub-compatible endpoint IoT 中心的并直接使用应用程序中的事件。这具有最小的延迟并且不涉及额外的组件。
如何指导(.NET core,但同样适用于.NET Framework):https://learn.microsoft.com/en-us/azure/event-hubs/event-hubs-dotnet-standard-getstarted-send#receive-events
var eventProcessorHost = new EventProcessorHost(
EventHubName,
PartitionReceiver.DefaultConsumerGroupName,
EventHubConnectionString,
StorageConnectionString,
StorageContainerName);
// Registers the Event Processor Host and starts receiving messages
await eventProcessorHost.RegisterEventProcessorAsync<SimpleEventProcessor>();
关于asp.net - Azure - 将数据从 IoT 中心发送到 Web 应用程序后端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57031694/