Search code examples
azureazure-blob-storageazure-iot-hubazure-iot-central

Iot Central to Blob Storage Data encrypted telemetry data body


i have got a problem regarding saving telemetry data/json into a blob storage. The problem is that the saved data has sort of encrypted my valuable telemetry data.

{"EnqueuedTimeUtc":"2019-11-25T15:42:51.5340000Z","Properties":{},"SystemProperties":{"to":"/devices/device-08/messages/events","connectionDeviceId":"device-08","connectionAuthMethod":"{\"scope\":\"device\",\"type\":\"sas\",\"issuer\":\"iothub\",\"acceptingIpFilterRule\":null}","connectionDeviceGenerationId":"xxxxxxxxxxxxx","contentEncoding":"","enqueuedTime":"2019-11-25T15:42:51.5340000Z"},"Body":"eyJ0ZW1wIjo3LjM5LCJodW0iOjczLjUsInJzc2kiOi04OSwic25yIjo4Ljh9"}

I think the problem also lays within "contentEncoding":"" cause it should be"contentEncoding":"utf-8".

Does anyone know how to fix this :) thank you very much for your efforts!


Solution

  • Have a look at this document.

    Set the device message system properties such as the contentType to application/json and contentEncoding to UTF-8.

    In the case when your device is using the MQTT protocol directly, use the topic for passing the system properties, for example:

     devices/mydeviceId/messages/events/$.ct=application%2Fjson&$.ce=utf-8
    

    Update:

    The following screen snippets are showing an example of the quick test for Data export to the blob storage.

    1. Creating a IOT Central Application with a PnP device template (environmentalSensor) assigned to the device1 and Data Export to the blob storage:

    enter image description here

    1. Using an Azure IoT Hub Tester for simulation of the PnP device1 connected to the IoT Central directly via MQTT protocol:

    enter image description here

    As you can see, the published topic is

    devices/device1/messages/events/$.ct=application%2Fjson&$.ce=utf-8
    

    and 6 messages have been sent to the IoT Central.

    1. Showing a telemetry data on the IoT Central dashboard.

    enter image description here

    1. Using the Azure Storage Explorer for exploring a blob content:

    enter image description here

    As you can see, the body of each device message is not Base64 encoded json text.

    Note, that only contentType and contentEncoding of the device message will decide if the body is Base64 encoded or not.