Azure IotHub routing is not functioning

491 views Asked by At

I have the following routing query defined in Azure IotHub: $body.messageType="Test"

And using Microsoft.Azure.Devices.Client" SDK Version="1.28.0"

Here is my very simple C# code.

            var device = DeviceClient.CreateFromConnectionString(DeviceConnectionString);
       
            await device.OpenAsync();

            var obj = new
            {
                messageType = "Test"
            };

            var telemetryJson = JsonConvert.SerializeObject(obj);

            var message = new Message(Encoding.UTF8.GetBytes(telemetryJson));

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

            await device.SendEventAsync(message);

Message gets delivered to IotHub but routing is not applied! Any idea why?

3

There are 3 answers

0
Mori On BEST ANSWER

I noticed the IotHub resource's behavior was not normal at all. Different types of error messages started to appear like IotHub is not in an Active state whatsoever.

Deleting and recreating the resource resolved the issue.

0
Mirza On

I noticed at times after creating new route , IOTHUB takes some time before I start seeing messages on storage container. Just give it half an hour and check again

0
Helikaon On

Could you try it with single quotes like this $body.messageType='Test'?