【发布时间】:2018-02-27 16:47:54
【问题描述】:
使用 Azure IOT,我的设备端点指向 Azure Blob 存储。数据被发送到 Blob,但我得到非 ascii 字符,并被告知文件扩展名不正确。示例 Blob 数据为
Objavro.codecnullavro.schemaÐ{"type":"record","name":"Message","namespace":"Microsoft.Azure.Devices","fields":[{"name":"EnqueuedTimeUtc","type":"string"},{"name":"Properties","type":{"type":"map","values":"string"}},{"name":"SystemProperties","type":{"type":"map","values":"string"}},{"name":"Body","type":["null","bytes"]}]} ±¡RëZË8耑,¡…$•
à82018-02-20T15:12:16.1060000Z $connectionDeviceIdLane4Free(connectionAuthMethodœ{"scope":"device","type":"sas","issuer":"iothub","acceptingIpFilterRule":null}8connectionDeviceGenerationId$636543931333384343enqueuedTime82018-02-20T15:12:16.1060000Z d{"deviceId": "myPythonDevice","PinsCCC": 302.00,\}82018-02-20T15:12:16.2000000Z
Azure IOT 文档说格式是 Apache Avro,但我找不到任何关于如何解码非 ascii 字符的信息。我看不到在哪里指定 json 扩展名。
【问题讨论】:
-
如何发送数据?
-
这是我使用的 Python 代码。 -- message = IoTHubMessage((msg_txt_formatted)) --- message.ContentEncoding = "utf-8"; --- message.ContentType = "应用程序/json" ---; client.send_event_async(message, send_confirmation_callback, message_counter)
-
重新格式化 - 这是使用 MQTT 的 Python 代码。
message =IoTHubMessage((msg_txt_formatted))message.ContentEncoding = "utf-8";message.ContentType = "application/json" ;`client.send_event_async(message, send_confirmation_callback, message_counter)``