我正在使用 Azure IoT 中心。在 Azure 门户中,很容易看到队列中有多少云到设备的消息处于待处理状态。
我想使用 C# SDK 读取这个值
我终于找到了工作答案如下:
using Microsoft.Azure.Devices;
RegistryManager registryManager = RegistryManager.CreateFromConnectionString("registryreadconnectionstring");
Device device = await registryManager.GetDeviceAsync("device-id");
var count = device.CloudToDeviceMessageCount;
var device = new Microsoft.Azure.Devices.Device("device-id");
var cloudToDeviceMessageCount = device.CloudToDeviceMessageCount;