Search code examples
azureazure-iot-hubazure-iot-edgeazure-iot-sdk

How to fetch DeviceScope using iot-service-client java


I am trying to fetch the deviceScope of the deviceTwin. However, the deviceScope is not returned in the DeviceTwinDevice.

String iotHubConnectionString  = "xxx";

DeviceTwin twinClient = DeviceTwin.createFromConnectionString(iotHubConnectionString);

SqlQuery sqlQuery = SqlQuery.createSqlQuery("*",SqlQuery.FromType.DEVICES,"capabilities.iotEdge=false",null);
Query twinQuery = twinClient.queryTwin(sqlQuery.getQuery());
            
DeviceTwinDevice d = twinClient.getNextDeviceTwin(twinQuery);

Solution

  • Thanks to https://github.com/Azure/azure-iot-sdk-java/issues/1157. Have to use registerManager