Hello @Maheshwaram Srikaran ,
you want to access the device twin on a device in the Azure IoT Hub.
There are several samples available on GitHub accessing the device twin, mostly about patching the desired properties.
But to show how to access individual desired properties (and reported properties also) I tweaked this sample.
Here I access the twin:
# Create IoTHubRegistryManager
registry_manager = IoTHubRegistryManager(CONNECTION_STRING)
twin = registry_manager.get_twin(DEVICE_ID)
print ( "Twin device id:" )
print ( twin.device_id )
print("Twin desired properties document:")
print("{}".format(twin.properties.desired))
print("Twin desired properties key and value:")
for key, value in twin.properties.desired.items():
print (key, value)
print("Twin reported properties key and value:")
for key, value in twin.properties.reported.items():
print (key, value)
The device twin of my device looks like this:
To run the code, I have to install this PIP package:
pip install azure.iot.hub
This is the result when I run the code:
As you can see, I can access both desired and reported properties.