You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/iot-hub/iot-hub-python-python-module-twin-getstarted.md
+73-57Lines changed: 73 additions & 57 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,11 +18,13 @@ ms.author: menchi
18
18
> [Module identities and module twins](iot-hub-devguide-module-twins.md) are similar to Azure IoT Hub device identity and device twin, but provide finer granularity. While Azure IoT Hub device identity and device twin enable the back-end application to configure a device and provides visibility on the device's conditions, a module identity and module twin provide these capabilities for individual components of a device. On capable devices with multiple components, such as operating system based devices or firmware devices, it allows for isolated configuration and conditions for each component.
19
19
>
20
20
21
-
At the end of this tutorial, you have two Python apps:
21
+
At the end of this tutorial, you have three Python apps:
22
22
23
23
***CreateIdentities**, which creates a device identity, a module identity and associated security key to connect your device and module clients.
24
24
25
-
***UpdateModuleTwinReportedProperties**, which sends updated module twin reported properties to your IoT Hub.
25
+
***UpdateModuleTwinDesiredProperties**, which sends updated module twin desired properties to your IoT Hub.
@@ -50,16 +52,16 @@ In this section, you create a Python app that creates a device identity and a mo
50
52
pip install azure-iot-hub
51
53
```
52
54
53
-
2. Using a text editor, create a file named **CreateModule.py** in your working directory.
55
+
1. Using a text editor, create a file named **CreateModule.py** in your working directory.
54
56
55
-
3. Add the following code to your Python file:
57
+
1. Add the following code to your Python file:
56
58
57
59
```python
58
60
import sys
59
61
from msrest.exceptions import HttpOperationError
60
62
from azure.iot.hub import IoTHubRegistryManager
61
63
62
-
CONNECTION_STRING = "YourConnString"
64
+
CONNECTION_STRING = "YourIotHubConnectionString"
63
65
DEVICE_ID = "myFirstDevice"
64
66
MODULE_ID = "myFirstModule"
65
67
@@ -109,7 +111,7 @@ In this section, you create a Python app that creates a device identity and a mo
109
111
print("IoTHubRegistryManager sample stopped")
110
112
```
111
113
112
-
4. At your command prompt, run the following command:
114
+
1. At your command prompt, run the following command:
113
115
114
116
```cmd/sh
115
117
python AddModule.py
@@ -121,94 +123,108 @@ This app creates a device identity with ID **myFirstDevice** and a module identi
121
123
> The IoT Hub identity registry only stores device and module identities to enable secure access to the IoT hub. The identity registry stores device IDs and keys to use as security credentials. The identity registry also stores an enabled/disabled flag for each device that you can use to disable access for that device. If your application needs to store other device-specific metadata, it should use an application-specific store. There is no enabled/disabled flag for module identities. For more information, see [IoT Hub developer guide](iot-hub-devguide-identity-registry.md).
122
124
>
123
125
124
-
## Update the module twin using Python device SDK
125
-
126
-
In this section, you create a Python app on your simulated device that updates the module twin reported properties.
127
-
128
-
1. Get your module connection string. In [Azure portal](https://portal.azure.com/), navigate to your IoT Hub and select **IoT devices** on the left pane. Select **myFirstDevice** from the list of devices and open it. Under **Module identities** select **myFirstModule**. Copy the module connection string. You need it in a following step.
126
+
## Update the module twin using Python service SDK
In addition to the above code, you can use the following code to get the twin update message on your device.
176
+
You can use the following code to get the module twin update patch on your device.
177
+
178
+
1. Get your module connection string. In [Azure portal](https://portal.azure.com/), navigate to your IoT Hub and select **IoT devices** on the left pane. Select **myFirstDevice** from the list of devices and open it. Under **Module identities** select **myFirstModule**. Copy the module connection string. You need it in a following step.
0 commit comments