[Azure Blob Storage] How to decrypt blob storage json file body contents?

조영우 우짜 26 Reputation points
2022-07-13T01:57:24.627+00:00

Hi
I make up D2C endpoint message routing.
IoT Hub -> Azure Storage

I confirmed that the data was received as much as device sent.
It's nice but i couldn't recognize the body contents because it's encripted.

So how do i decrypt the message or check it's data on dashboard?
Should i change configuration to IoT Central or choose sql, cosmos db instead of blob storage?
Let me know as much as ways i could try220234-ss.png

Azure IoT
Azure IoT
A category of Azure services for internet of things devices.
399 questions
0 comments No comments
{count} vote

Accepted answer
  1. QuantumCache 20,266 Reputation points
    2022-07-13T03:57:44.53+00:00

    Hello @조영우 우짜

    We have to decode the message payload value from base64 format after the message is landed in Blob Storage (You can do this in multiple ways, like using Azure Functions)

    IoT Hub supports writing data to Azure Storage in the Apache Avro format and the JSON format. The default is AVRO. When using JSON encoding, you must set the contentType to application/json and contentEncoding to UTF-8 in the message system properties. Both of these values are case-insensitive. If the content encoding is not set, then IoT Hub will write the messages in base 64 encoded format.

    The IoT Device should follow the below instructions to send the message to Azure IoTHub ,

    // Set message body type and content encoding.   
        message.ContentEncoding = "utf-8";   
        message.ContentType = "application/json";   
    

    220246-image.png

    If looking for Message Routing to work:
    In order for IoT Hub to know whether the message can be routed based on its body contents, the message must contain specific headers which describe the content and encoding of its body. In particular, messages must have both these headers for routing on message body to work:

    1. Content type of "application/json"
    2. Content encoding must match one of:

    "utf-8"
    "utf-16"
    "utf-32"

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Steinberg, Lyle (GE Healthcare) 21 Reputation points
    2022-07-14T15:41:27.383+00:00

    This was my experience, as well, had to set the message formatting at the device. For MQTT, you can just stick the folling on the end of your topic:

    /$.ct=application%2Fjson&$.ce=utf-8

    4 people found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.