成功完成了“Connect Raspberry Pi to Azure IoT Hub (Python) " and " Use iothub-explorer to send and receive messages between your device and IoT Hub”教程,设置了将模拟数据发送到 Cloud 端的Raspberry Pi .
使用iot-explorer我可以看到一切都运行良好,消息从Pi发送到 Cloud 端,iot-explorer监视器正在拉动并显示它们,完美!
但是,现在我已经尝试了“Visualize real-time sensor data from your Azure IoT hub by using the Web Apps feature of Azure App Service”教程,并且一切都很顺利,除非我加载网页时根本没有数据显示在图表上 .
Pi正在运行并发送消息,我可以在Azure门户和iot-explorer监视器中看到,但图中没有显示任何内容 .
什么想法可能是错的?
1 回答
您可以在iot-explorer监视器中看到消息指示消息正在成功发送到Azure IoT Hub的内置 endpoints 消息/事件 .
如果您在图表中看不到任何数据,则它是一个如下空白图:
这意味着Web应用程序已成功部署和运行,但Web应用程序中没有数据到达 .
那么您需要检查的是Web应用程序设置:
使用你设置正确的 IoT Hub connection string . 它具有以下格式:
HostName=[YOUR HUB NAME].azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=[KEY]
. 您可以在IoT Hub - >设置 - >共享访问策略 - > iothubowner - >连接字符串 - 主键中找到它 .设置在本教程的this step中创建的 consumer group .
启用 WebSocket .
Web App中的设置将是这样的:
Azure IoT Hub中的设置(使用者组):
如果它还没有工作,请随时告诉我 .