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?
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.