我在 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,但未应用路由!知道为什么吗?
你能尝试用这样的单引号吗
$body.messageType='Test'
?
我注意到 IotHub 资源的行为根本不正常。不同类型的错误消息开始出现,例如
IotHub is not in an Active state
。
删除并重新创建资源解决了该问题。
我有时注意到创建新路由后,IOTHUB 需要一些时间才能开始在存储容器上看到消息。等半个小时再检查一下吧