我在Azure IotHub中定义了以下路由查询:
$body.messageType="Test"
并使用Microsoft.Azure.Devices.Client"
SDK Version="1.28.0"
这是我非常简单的C#代码。
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);
消息已传递到IotHub,但未应用路由!知道为什么吗?
答案 0 :(得分:0)
您可以尝试使用$body.messageType='Test'
这样的单引号吗?
答案 1 :(得分:0)
我注意到IotHub资源的行为根本不正常。各种错误消息开始以IotHub is not in an Active state
的形式出现。
删除并重新创建资源即可解决此问题。