Azure IotHub 路由无法正常工作

问题描述 投票:0回答:3

我在 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,但未应用路由!知道为什么吗?

azure-iot-hub azure-iot-sdk azure-iot-hub-device-management
3个回答
0
投票

你能尝试用这样的单引号吗

$body.messageType='Test'


0
投票

我注意到 IotHub 资源的行为根本不正常。不同类型的错误消息开始出现,例如

IotHub is not in an Active state

删除并重新创建资源解决了该问题。


0
投票

我有时注意到创建新路由后,IOTHUB 需要一些时间才能开始在存储容器上看到消息。等半个小时再检查一下吧

© www.soinside.com 2019 - 2024. All rights reserved.