Skip to content

Commit 0db93e8

Browse files
committed
Robin's edits
1 parent c0ed457 commit 0db93e8

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

articles/iot-hub/iot-hub-python-python-module-twin-getstarted.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ms.author: menchi
1515
[!INCLUDE [iot-hub-selector-module-twin-getstarted](../../includes/iot-hub-selector-module-twin-getstarted.md)]
1616

1717
> [!NOTE]
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.
18+
> [Module identities and module twins](iot-hub-devguide-module-twins.md) are similar to Azure IoT Hub device identities and device twins, but provide finer granularity. While Azure IoT Hub device identities and device twins enable a back-end application to configure a device and provide visibility on the device's conditions, module identities and module twins provide these capabilities for individual components of a device. On capable devices with multiple components, such as operating system based devices or firmware devices, they allow for isolated configuration and conditions for each component.
1919
>
2020
2121
At the end of this tutorial, you have three Python apps:
@@ -44,17 +44,23 @@ At the end of this tutorial, you have three Python apps:
4444

4545
## Create a device identity and a module identity in IoT Hub
4646

47-
In this section, you create a Python app that creates a device identity and a module identity in the identity registry in your IoT hub. A device or module can't connect to IoT hub unless it has an entry in the identity registry. For more information, see the [Identity registry section of the IoT Hub developer guide](iot-hub-devguide-identity-registry.md). When you run this console app, it generates a unique ID and key for both device and module. Your device and module use these values to identify itself when it sends device-to-cloud messages to IoT Hub. The IDs are case-sensitive.
47+
In this section, you create a Python service app that creates a device identity and a module identity in the identity registry in your IoT hub. A device or module can't connect to IoT hub unless it has an entry in the identity registry. For more information, see [Understand the identity registry in your IoT hub](iot-hub-devguide-identity-registry.md). When you run this console app, it generates a unique ID and key for both device and module. Your device and module use these values to identify itself when it sends device-to-cloud messages to IoT Hub. The IDs are case-sensitive.
4848

4949
1. At your command prompt, run the following command to install the **azure-iot-hub** package:
5050

5151
```cmd/sh
5252
pip install azure-iot-hub
5353
```
5454
55+
1. At your command prompt, run the following command to install the **msrest** package. You need this package to catch **HTTPOperationError** exceptions.
56+
57+
```cmd/sh
58+
pip install msrest
59+
```
60+
5561
1. Using a text editor, create a file named **CreateModule.py** in your working directory.
5662
57-
1. Add the following code to your Python file:
63+
1. Add the following code to your Python file. Replace *YourIoTHubConnectionString* with the connection string you copied in [Get the IoT hub connection string](#get-the-iot-hub-connection-string).
5864
5965
```python
6066
import sys
@@ -120,22 +126,22 @@ In this section, you create a Python app that creates a device identity and a mo
120126
This app creates a device identity with ID **myFirstDevice** and a module identity with ID **myFirstModule** under device **myFirstDevice**. (If the device or module ID already exists in the identity registry, the code simply retrieves the existing device or module information.) The app displays the ID and primary key for each identity.
121127
122128
> [!NOTE]
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).
129+
> 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 [Understand the identity registry in your IoT hub](iot-hub-devguide-identity-registry.md).
124130
>
125131
126132
## Update the module twin using Python service SDK
127133
128-
In this section, you create a Python app that updates the module twin desired properties.
134+
In this section, you create a Python service app that updates the module twin desired properties.
129135
130-
1. At your command prompt, run the following command to install the **azure-iot-hub** package:
136+
1. At your command prompt, run the following command to install the **azure-iot-hub** package. You can skip this step if you installed the **azure-iot-hub** package in the previous section.
131137
132138
```cmd/sh
133139
pip install azure-iot-hub
134140
```
135141
136142
1. Using a text editor, create a file named **UpdateModuleTwinDesiredProperties.py** in your working directory.
137143
138-
1. Add the following code to your Python file:
144+
1. Add the following code to your Python file. Replace *YourIoTHubConnectionString* with the connection string you copied in [Get the IoT hub connection string](#get-the-iot-hub-connection-string).
139145
140146
```python
141147
import sys
@@ -173,9 +179,9 @@ In this section, you create a Python app that updates the module twin desired pr
173179
174180
## Get updates on the device side
175181
176-
In this section, you create a Python app to get the module twin desired properties update on your device.
182+
In this section, you create a Python device app to get the module twin desired properties update on your device.
177183
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.
184+
1. Get your module connection string. In [Azure portal](https://portal.azure.com/), navigate to your IoT Hub and select **IoT devices** in 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.
179185
180186
![Azure portal module detail](./media/iot-hub-python-python-module-twin-getstarted/module-detail.png)
181187
@@ -187,7 +193,7 @@ In this section, you create a Python app to get the module twin desired properti
187193
188194
1. Using a text editor, create a file named **ReceiveModuleTwinDesiredPropertiesPatch.py** in your working directory.
189195
190-
1. Add the following code to your Python file:
196+
1. Add the following code to your Python file. Replace *YourModuleConnectionString* with the module connection string you copied in step 1.
191197
192198
```python
193199
import time

0 commit comments

Comments
 (0)