我已按照所有说明设置“下游设备”以通过在透明网关中运行的 IoT Edge 发送消息。我相信我的路由规则是正确的,但我的功能模块没有通过消息流接收任何消息。
这些是我遵循的指令: https ://docs.microsoft.com/en-us/azure/iot-edge/how-to-create-transparent-gateway-linux
我正在使用 2 个 Linxu 虚拟机(ubuntu 16.04.5)。
- IoT Edge 透明网关 VM 配置了正确设置、配置和验证的所有证书。我已经能够使用来自
openssl s_client -connect {my-gateway-machine-name-dns-name}.centralus.cloudapp.azure.com:8883 -CAfile /certs/certs/azure-iot-test-only.root.ca.cert.pem -演出证书
在安装并验证了证书的 Linux VM 上运行的下游设备。我的连接字符串如下:
HostName={IoTHubName}.azure-devices.net;DeviceId=TC51_EdgeDownStreamDevice01;SharedAccessKey={My-Shared-Access-Key}=GatewayHostName={my-gateway-machine-name-dns-name}.centralus.cloudapp.azure。 com
一个。我已经验证我使用 openssl 工具成功验证了 SSL 证书。湾。我在我的下游设备中使用以下内容来使用 NodeJS SDK 进行连接
var client = DeviceClient.fromConnectionString(connectionString, Mqtt); C。我可以看到消息显示在云中的 Azure IoT 中心,但我无法让我的模块在 IoT Edge 透明网关上运行以被命中。
- 这是我为 edgeHub 配置的路由规则,如示例文档页面中的“来自下游设备的路由消息”中指定的。
这是示例文档显示的内容: { "routes":{ "sensorToAIInsightsInput1":"FROM /messages/* WHERE NOT IS_DEFINED($connectionModuleId) INTO BrokeredEndpoint(\"/modules/ai_insights/inputs/input1\")", " AIInsightsToIoTHub":"FROM /messages/modules/ai_insights/outputs/output1 INTO $upstream" } }
这是我的路由配置设置为: "routes": { "downstreamBatterySensorToBatteryDataFunctionInput1": "FROM /* WHERE NOT IS_DEFINED($connectionModuleId) INTO BrokeredEndpoint(\"/modules/BatteryDataFunctionModule/inputs/input1\")", "BatteryDataFunctionModuleToIoTHub ": "从 /messages/modules/BatteryDataFunctionModule/outputs/* INTO $upstream" }
** 请注意,我使用了“FROM /* WHERE NOT IS_DEFINED”和“FROM /messages/* WHERE NOT IS_DEFINED”
- 我在 IoT Edge 上的模块设置为函数。当我使用开箱即用的示例时,其中模拟器设备是在 IoT Edge 上运行的另一个模块,然后我的函数被正确命中。只有当我尝试使用“下游设备”时才会触发模块。
我已启用在透明网关上运行的“IoT Edge 服务的调试日志记录”。
This is the basic Run method for the Function module:
#r "Microsoft.Azure.Devices.Client"
#r "Newtonsoft.Json"
using System.IO;
using Microsoft.Azure.Devices.Client;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
// Filter messages based on the temperature value in the body of the message and the temperature threshold value.
public static async Task Run(Message messageReceived, IAsyncCollector<Message> output, TraceWriter log)
{
我如何才能弄清楚如何让我的模块在 IoT Edge 中运行以从下游设备被点击/触发?