我们使用Azure创建资源组、物联网集线器和设备。
例如:
iotHubDescription = await iotHubClient.IotHubResource.CreateOrUpdateAsync(resourceGroupName, iotHubName,
iotHubDescription);或
var device = await registryManager.AddDeviceAsync(new Device(azureDevice.DeviceId));在创建物联网中心名称之前,我已经找到了如何验证它的方法:
var info = await iotHubClient.IotHubResource.CheckNameAvailabilityAsync(new OperationInputs(iotHubName));但无法找到如何验证设备id。
那么,问题是:如何从Azure SDK中验证物联网设备的id?
发布于 2019-12-17 09:20:04
你需要抓住使用Exception,
try
{
simulatedDevice = await registryManager.AddDeviceAsync(new Device(simulatedDeviceId));}
catch (DeviceAlreadyExistsException)
{
simulatedDevice = await registryManager.GetDeviceAsync(simulatedDeviceId);
Console.WriteLine("Retrieving existing device id");
}
}https://stackoverflow.com/questions/59370925
复制相似问题