【发布时间】:2021-07-13 14:43:25
【问题描述】:
我正在尝试创建从 IoT 中心到 Power BI 的流分析作业,但我的输入数据接缝无效。开始作业后,我收到此错误代码: InputDeserializerError.InvalidData 。我的事件序列化格式是 JSON。 我通过 azure shell 监控了我的消息,它们看起来像这样:
"event": {
"origin": "Projektpi",
"module": "",
"interface": "",
"component": "",
"payload": "{\"Time\": 19/04/2021, 13:22:33, \"Critical vibration\": No, \"Temperature\": 20.812, \"RPM\": 0.0}"
}
每 11 秒我通过此代码从我的 pi 发送消息:
client = IoTHubDeviceClient.create_from_connection_string(CONNECTION_STRING)
async def send_to_azure(payload):
# await internet connection
awaitConnection()
# payload looks like this: payload = '{{"Time": {now}, "Critical vibration": {azurevibration}, "Temperature": {azuretemp}, "RPM": {azurerpm}}}'
message = Message(payload)
# Send a message to the IoT hub
print(f"Sending message: {message}")
try:
print('Status: Trying to send data to Azure IoT Hub...')
await client.connect()
await client.send_message(message)
print('Status: Data sent ...')
except:
print('Status: Problem sending data to Azure IoT Hub...')
如何更改我的代码,以便流分析作业可以使用我的 pi 传感器数据作为输入? 如果您知道 python 教程等,那就太好了。 总的来说,我对 azure 和编程很陌生,所以非常感谢您的帮助!
【问题讨论】:
标签: azure azure-iot-hub azure-stream-analytics