任何人都知道到底可能会出现什么问题?
在adx
,由于未正确添加日期字段 /发送的消息是恒定 /线性的,因此未收到数据。确保正确发送遥测有效载荷。 below是发送遥测IoT消息的代码:
async def send_telemetry_from_thermostat(device_client, telemetry_msg):
msg = Message(json.dumps(telemetry_msg))
msg.custom_properties["iothub-creation-time-utc"] = datetime.now(timezone.utc).isoformat()
msg.content_encoding = "utf-8"
msg.content_type = "application/json"
print("Sent message")
await device_client.send_message(msg)
Microsoft文档将JSON形式的数据吸收到振动数据Explorer
.。
BELOW是我在ADX中创建的样本表:
输出:.create table sampleTable ( messageId: int, deviceId: string, temperature: decimal, humidity: decimal, temperatureAlert: string, IotHubDeviceId: string, IotHubEnqueuedTime: datetime )
贝洛是上表的样本流摄取和JSON映射:
.alter table sampleTable policy streamingingestion enable .create table sampleTable ingestion json mapping "JsonTelemetryMapping" '[' '{"Column": "messageId", "Properties": {"Path": "$.messageId"}},' '{"Column": "deviceId", "Properties": {"Path": "$.deviceId"}},' '{"Column": "temperature", "Properties": {"Path": "$.temperature"}},' '{"Column": "humidity", "Properties": {"Path": "$.humidity"}},' '{"Column": "temperatureAlert", "Properties": {"Path": "$.Properties.temperatureAlert"}},' '{"Column": "IotHubDeviceId", "Properties": {"Path": "$.iothub-connection-device-id"}},' '{"Column": "IotHubEnqueuedTime", "Properties": {"Path": "$.iothub-enqueuedtime"}}' ']'
to thisdocumentation tothisdocumentation
iothub.。
检查此Microsoft文档用于将IoT数据转换为事件Hubs
,然后将其导出到振应数据explorerhere