Azure IoT Hub Message Routing Encoding

SoonJoo@Genting 241 Reputation points
2024-04-17T07:02:16.32+00:00

Hi, I have setup an IoT Hub account, and configure my device to send data to the IoT hub, I am redirecting the message to storage.

When I monitor the device data using Azure IoT Explorer, I am receiving data in JSON format like below:

{
  "body": {
    "state": {
      "reported": {
        "4": 0,
        "16": 99198,
        "21": 4,
        "66": 12549,
        "67": 3972,
        "68": 0,
        "69": 2,
        "72": 209,
        "73": 210,
        "76": "0xA03CA3F64973BE28",
        "77": "0xA63C73F649F8C228",
        "181": 0,
        "182": 0,
        "200": 0,
        "239": 1,
        "240": 0,
        "241": 50219,
        "ts": 1713336761000,
        "pr": 0,
        "latlng": "0.000000,0.000000",
        "alt": 0,
        "ang": 0,
        "sat": 0,
        "sp": 0,
        "evt": 0
      }
    }
  },
  "enqueuedTime": "Wed Apr 17 2024 14:53:46 GMT+0800 (Singapore Standard Time)"
}

But When I check the files created in the storage when I re-route the message in the storage, I am getting the following format. I wonder how can I receive the original message format instead of the encoded format?

{"EnqueuedTimeUtc":"2024-04-17T06:49:17.8780000Z","Properties":{},"SystemProperties":{"connectionDeviceId":"1234567890","connectionAuthMethod":"{\"scope\":\"hub\",\"type\":\"sas\",\"issuer\":\"iothub\",\"acceptingIpFilterRule\":null}","connectionDeviceGenerationId":"638487721780314648","enqueuedTime":"2024-04-17T06:49:17.8780000Z"},"Body":"eyJzdGF0ZSI6eyJyZXBvcnRlZCI6eyJ0cyI6MTcxMzMzNjQ5MTAwMCwicHIiOjAsImxhdGxuZyI6IjAuMDAwMDAwLDAuMDAwMDAwIiwiYWx0IjowLCJhbmciOjAsInNhdCI6MCwic3AiOjAsImV2dCI6MCwiMjM5IjoxLCIyNDAiOjAsIjIxIjo0LCIyMDAiOjAsIjY5IjoyLCIxODEiOjAsIjE4MiI6MCwiNjYiOjEyNDk0LCI2NyI6Mzk2OSwiNjgiOjAsIjI0MSI6NTAyMTksIjE2Ijo5OTE5OCwiNzIiOjIxMCwiNzMiOjIxMSwiNCI6MCwiNzYiOiIweEEwM0NBM0Y2NDk3M0JFMjgiLCI3NyI6IjB4QTYzQzczRjY0OUY4QzIyOCJ9fX0="}

Thanks for any input for my queries.

Best regards,

Yap

Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,120 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sander van de Velde 28,546 Reputation points MVP
    2024-04-17T08:58:36.3633333+00:00

    Hello @SoonJoo@Genting ,

    welcome to this moderated Azure community forum.

    The content of your message body is encoded as Base64 in the storage account.

    It can be decoded with any Base64 decoder as seen with this online version:

    User's image

    Keep in mind, this is done to make your messages human readable inside the storage files, the message will be 'fly' as Json through Azure.


    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.


0 additional answers

Sort by: Most helpful