question

AshokPeddakotla-MSFT avatar image
1 Vote"
AshokPeddakotla-MSFT asked SatishBoddu-MSFT edited

Messages route to storage

Starting with IoT Hub for a small project and I'm stuck for 1 day in the following issue:

  • I've created the IoT Hub and one device

  • I've created the route to a storage container (JSON settings not AVRO)

  • I'm sending messages successfully, viewing them in Azure portal, Device explorer..., json messages like {temperature:50}

But when i'm viewing the blob data all the time I'm seeing something like:

 {"EnqueuedTimeUtc":"2020-04-05T08:33:42.7200000Z","Properties":{"temperatureAlert":"false"},"SystemProperties":{"connectionDeviceId":"ESP1","connectionAuthMethod":"\"scope\":\"hub\",\"type\":\"sas\",\"issuer\":\"iothub\",\"acceptingIpFilterRule\":null}","connectionDeviceGenerationId":"637137426272917278","enqueuedTime":"2020-04-05T08:33:42.7200000Z"},"Body":"eyJtZXNzYWdlSWQiOjAsInRlbXBlcmF0dXJlIjoyNCwiaHVtaWRpdHkiOjY0fQ=="} 

meaning the Body is something not recognizable and is the same for every message.

What could be the issue.

[Note: As we migrate from MSDN, this question has been posted by an Azure Cloud Engineer as a frequently asked question] Source: MSDN



azure-iot-hub
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

SatishBoddu-MSFT avatar image
0 Votes"
SatishBoddu-MSFT answered SatishBoddu-MSFT edited

The data can be written to blob storage in either the Apache Avro format, which is the default, or JSON (preview).

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:

Content type of "application/json" Content encoding must match one of: "utf-8" "utf-16" "utf-32"

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

contentType="application/json" 

contentEncoding=" UTF-8"

if yes, then the body should be in the json formatted text:

 {"messageId":0,"temperature":24,"humidity":64}

For more details, refer Message routing query based on message properties

Also, note that the capability to encode JSON format is in preview in all regions in which IoT Hub is available, except East US, West US and West Europe. The encoding format can be only set at the time the blob storage endpoint is configured. The format cannot be changed for an endpoint that has already been set up. When using JSON encoding, you must set the contentType to JSON and the contentEncoding to UTF-8 in the message system properties.

For more detailed information about using a blob storage endpoint, please see guidance on routing to storage.

Source: MSDN







5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.