Reputation: 3935
I am trying to fetch device twin properties within an IoT Edge module, and while I am already connected with a module client (aka IoTHubModuleClient
), I've found a method called get_twin()
in the documentation that says that we can grab device or module twin properties. However, I am getting "empty" properties, here's the result:
{'desired': {'$version': 1}, 'reported': {'$version': 1}}
Which is not what I configured in the azure portal in device twin section. But using the IotHubDeviceClient
with a device connection string (that's why I don't want to use that client), I am able to get the right device twin properties.
The code is pretty basic:
client = IoTHubModuleClient.create_from_edge_environment()
twin_properties = await client.get_twin()
logger.debug(f'Twin properties: {twin_properties}')
Upvotes: 2
Views: 1403
Reputation: 61
That is correct Mehdi, when you use the IoTHubModuleClient's get_twin method you are getting the module twin properties, you can add/modify/delete module twin properties independently of device twin properties.
Please take a look of this article
Upvotes: 2