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-edge/how-to-auto-provision-simulated-device-linux.md
+57-48Lines changed: 57 additions & 48 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,21 +13,28 @@ ms.custom: seodec18
13
13
14
14
# Create and provision an IoT Edge device with a virtual TPM on a Linux virtual machine
15
15
16
-
Azure IoT Edge devices can be automatically provisioned using the [Device Provisioning Service](../iot-dps/index.yml). If you're unfamiliar with the process of autoprovisioning, review the [autoprovisioning concepts](../iot-dps/concepts-auto-provisioning.md) before continuing.
16
+
Azure IoT Edge devices can be automatically provisioned using the [Device Provisioning Service](../iot-dps/index.yml). If you're unfamiliar with the process of auto-provisioning, review the [auto-provisioning concepts](../iot-dps/concepts-auto-provisioning.md) before continuing.
17
17
18
-
This article shows you how to test autoprovisioning on a simulated IoT Edge device with the following steps:
18
+
This article shows you how to test auto-provisioning on a simulated IoT Edge device with the following steps:
19
19
20
20
* Create a Linux virtual machine (VM) in Hyper-V with a simulated Trusted Platform Module (TPM) for hardware security.
21
21
* Create an instance of IoT Hub Device Provisioning Service (DPS).
22
22
* Create an individual enrollment for the device
23
23
* Install the IoT Edge runtime and connect the device to IoT Hub
24
24
25
-
The steps in this article are meant for testing purposes.
25
+
> [!NOTE]
26
+
> TPM 2.0 is required when using TPM attestation with DPS and can only be used to create individual, not group, enrollments.
27
+
28
+
> [!TIP]
29
+
> This article describes how to test DPS provisioning using a TPM simulator, but much of it applies to physical TPM hardware such as the [Infineon OPTIGA™ TPM](https://catalog.azureiotsolutions.com/details?title=OPTIGA-TPM-SLB-9670-Iridium-Board), an Azure Certified for IoT device.
30
+
>
31
+
> If you're using a physical device, you can skip ahead to the [Retrieve provisioning information from a physical device](#retrieve-provisioning-information-from-a-physical-device) section in this article.
26
32
27
33
## Prerequisites
28
34
29
-
* A Windows development machine with [Hyper-V enabled](https://docs.microsoft.com/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v). This article uses Windows 10 running an Ubuntu Server VM.
30
-
* An active IoT Hub.
35
+
* A Windows development machine with [Hyper-V enabled](https://docs.microsoft.com/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v). This article uses Windows 10 running an Ubuntu Server VM.
36
+
* An active IoT Hub.
37
+
* If using a simulated TPM, [Visual Studio](https://visualstudio.microsoft.com/vs/) 2015 or later with the ['Desktop development with C++'](https://www.visualstudio.com/vs/support/selecting-workloads-visual-studio-2017/) workload enabled.
31
38
32
39
## Create a Linux virtual machine with a virtual TPM
33
40
@@ -67,7 +74,7 @@ It may take a few minutes to create the new VM.
67
74
68
75
### Enable virtual TPM
69
76
70
-
Once your VM is created, open its settings to enable the virtual trusted platform module (TPM) that lets you autoprovision the device.
77
+
Once your VM is created, open its settings to enable the virtual trusted platform module (TPM) that lets you auto-provision the device.
71
78
72
79
1. Select the virtual machine, then open its **Settings**.
73
80
@@ -81,18 +88,48 @@ Once your VM is created, open its settings to enable the virtual trusted platfor
81
88
82
89
### Start the virtual machine and collect TPM data
83
90
84
-
In the virtual machine, build a C SDK tool that you can use to retrieve the device's **Registration ID** and **Endorsement Key**.
91
+
In the virtual machine, build a tool that you can use to retrieve the device's **Registration ID** and **Endorsement key**.
85
92
86
93
1. Start your virtual machine and connect to it.
87
94
88
-
2. Follow the prompts within the virtual machine to finish the installation process and reboot the machine.
95
+
1. Follow the prompts within the virtual machine to finish the installation process and reboot the machine.
89
96
90
-
3. Sign in to your VM, then follow the steps in [Set up a Linux development environment](https://github.com/Azure/azure-iot-sdk-c/blob/master/doc/devbox_setup.md#linux) to install and build the Azure IoT device SDK for C.
97
+
1. Sign in to your VM, then follow the steps in [Set up a Linux development environment](https://github.com/Azure/azure-iot-sdk-c/blob/master/doc/devbox_setup.md#linux) to install and build the Azure IoT device SDK for C.
91
98
92
99
>[!TIP]
93
-
>In the course of this article, you'll copy to and paste from the virtual machine, which is not easy through the Hyper-V Manager connection application. You may want to connect to virtual machine through Hyper-V Manager once to retrieve its IP address: `ifconfig`. Then, you can use the IP address to connect through SSH: `ssh <username>@<ipaddress>`.
100
+
>In the course of this article, you'll copy to and paste from the virtual machine, which is not easy through the Hyper-V Manager connection application. You may want to connect to the virtual machine through Hyper-V Manager once to retrieve its IP address: `ifconfig`. Then, you can use the IP address to connect through SSH: `ssh <username>@<ipaddress>`.
94
101
95
-
4. Run the following commands to build an C SDK tool that retrieves your device provisioning information.
102
+
1. Run the following commands to build the SDK tool that retrieves your device provisioning information from the TPM simulator.
1. From a command window, navigate to the `azure-iot-sdk-c` directory and run the TPM simulator. It listens over a socket on ports 2321 and 2322. Do not close this command window; you will need to keep this simulator running.
113
+
114
+
From the `azure-iot-sdk-c` directory, run the following command to start the simulator:
1. Using Visual Studio, open the solution generated in the `cmake` directory named `azure_iot_sdks.sln`, and build it using the **Build solution** command on the **Build** menu.
121
+
122
+
1. In the **Solution Explorer** pane in Visual Studio, navigate to the folder **Provision\_Tools**. Right-click the **tpm_device_provision** project and select **Set as Startup Project**.
123
+
124
+
1. Run the solution using either of the **Start** commands on the **Debug** menu. The output window displays the TPM simulator's **Registration ID** and the **Endorsement key**, which you should copy for use later when you create an individual enrollment for your device in You can close this window (with Registration ID and Endorsement key), but leave the TPM simulator window running.
125
+
126
+
## Retrieve provisioning information from a physical device
127
+
128
+
On your device, build a tool that you can use to retrieve the device's provisioning information.
129
+
130
+
1. Follow the steps in [Set up a Linux development environment](https://github.com/Azure/azure-iot-sdk-c/blob/master/doc/devbox_setup.md#linux) to install and build the Azure IoT device SDK for C.
131
+
132
+
1. Run the following commands to build the SDK tool that retrieves your device provisioning information from the TPM device.
96
133
97
134
```bash
98
135
cd azure-iot-sdk-c/cmake
@@ -101,10 +138,8 @@ In the virtual machine, build a C SDK tool that you can use to retrieve the devi
101
138
make
102
139
sudo ./tpm_device_provision
103
140
```
104
-
>[!TIP]
105
-
>If you are testing with TPM simulator, you'll need to put an extra parameter `-Duse_tpm_simulator:BOOL=ON` to enable it. The full command will be `cmake -Duse_prov_client:BOOL=ON -Duse_tpm_simulator:BOOL=ON ..`.
106
141
107
-
5. Copy the values for **Registration ID** and **Endorsement Key**. You use these values to create an individual enrollment for your device in DPS.
142
+
1. Copy the values for **Registration ID** and **Endorsement key**. You use these values to create an individual enrollment for your device in DPS.
108
143
109
144
## Set up the IoT Hub Device Provisioning Service
110
145
@@ -125,15 +160,18 @@ When you create an enrollment in DPS, you have the opportunity to declare an **I
125
160
3. Select **Add individual enrollment** then complete the following steps to configure the enrollment:
126
161
127
162
1. For **Mechanism**, select **TPM**.
128
-
163
+
129
164
2. Provide the **Endorsement key** and **Registration ID** that you copied from your virtual machine.
130
-
165
+
166
+
> [!TIP]
167
+
> If you're using a physical TPM device, you need to determine the **Endorsement key**, which is unique to each TPM chip and is obtained from the TPM chip manufacturer associated with it. You can derive a unique **Registration ID** for your TPM device by, for example, creating an SHA-256 hash of the endorsement key.
168
+
131
169
3. Select **True** to declare that this virtual machine is an IoT Edge device.
132
-
170
+
133
171
4. Choose the linked **IoT Hub** that you want to connect your device to. You can choose multiple hubs, and the device will be assigned to one of them according to the selected allocation policy.
134
-
172
+
135
173
5. Provide an ID for your device if you'd like. You can use device IDs to target an individual device for module deployment. If you don't provide a device ID, the registration ID is used.
136
-
174
+
137
175
6. Add a tag value to the **Initial Device Twin State** if you'd like. You can use tags to target groups of devices for module deployment. For example:
138
176
139
177
```json
@@ -212,35 +250,6 @@ You can give TPM access to the IoT Edge runtime by overriding the systemd settin
212
250
213
251
If you don't see that the correct permissions have been applied, try rebooting your machine to refresh udev.
214
252
215
-
8. Open the IoT Edge runtime overrides file.
216
-
217
-
```bash
218
-
sudo systemctl edit iotedge.service
219
-
```
220
-
221
-
9. Add the following code to establish a TPM environment variable.
222
-
223
-
```input
224
-
[Service]
225
-
Environment=IOTEDGE_USE_TPM_DEVICE=ON
226
-
```
227
-
228
-
10. Save and exit the file.
229
-
230
-
11. Verify that the override was successful.
231
-
232
-
```bash
233
-
sudo systemctl cat iotedge.service
234
-
```
235
-
236
-
Successful output displays the **iotedge** default service variables, and then shows the environment variable that you setin**override.conf**.
237
-
238
-
12. Reload the settings.
239
-
240
-
```bash
241
-
sudo systemctl daemon-reload
242
-
```
243
-
244
253
## Restart the IoT Edge runtime
245
254
246
255
Restart the IoT Edge runtime so that it picks up all the configuration changes that you made on the device.
Copy file name to clipboardExpand all lines: articles/iot-edge/how-to-auto-provision-simulated-device-windows.md
+44-10Lines changed: 44 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
---
2
-
title: Auto-provision Windows devices with DPS - Azure IoT Edge | Microsoft Docs
2
+
title: Automatically provision Windows devices with DPS - Azure IoT Edge | Microsoft Docs
3
3
description: Use a simulated device on your Windows machine to test automatic device provisioning for Azure IoT Edge with Device Provisioning Service
4
4
author: kgremban
5
5
manager: philmea
@@ -11,17 +11,23 @@ services: iot-edge
11
11
ms.custom: seodec18
12
12
---
13
13
14
-
# Create and provision a simulated TPM Edge device on Windows
14
+
# Create and provision a simulated IoT Edge device with a virtual TPM on Windows
15
15
16
16
Azure IoT Edge devices can be auto-provisioned using the [Device Provisioning Service](../iot-dps/index.yml) just like devices that are not edge-enabled. If you're unfamiliar with the process of auto-provisioning, review the [auto-provisioning concepts](../iot-dps/concepts-auto-provisioning.md) before continuing.
17
17
18
-
This article shows you how to test auto-provisioning on a simulated Edge device with the following steps:
18
+
This article shows you how to test auto-provisioning on a simulated IoT Edge device with the following steps:
19
19
20
20
* Create an instance of IoT Hub Device Provisioning Service (DPS).
21
21
* Create a simulated device on your Windows machine with a simulated Trusted Platform Module (TPM) for hardware security.
22
22
* Create an individual enrollment for the device.
23
23
* Install the IoT Edge runtime and connect the device to IoT Hub.
24
24
25
+
> [!NOTE]
26
+
> TPM 2.0 is required when using TPM attestation with DPS and can only be used to create individual, not group, enrollments.
27
+
28
+
> [!TIP]
29
+
> This article describes testing auto-provisioning by using TPM attestation on virtual devices, but much of it applies when using physical TPM hardware as well.
30
+
25
31
## Prerequisites
26
32
27
33
* A Windows development machine. This article uses Windows 10.
@@ -33,9 +39,14 @@ Create a new instance of the IoT Hub Device Provisioning Service in Azure, and l
33
39
34
40
After you have the Device Provisioning Service running, copy the value of **ID Scope** from the overview page. You use this value when you configure the IoT Edge runtime.
35
41
42
+
> [!TIP]
43
+
> If you're using a physical TPM device, you need to determine the **Endorsement key**, which is unique to each TPM chip and is obtained from the TPM chip manufacturer associated with it. You can derive a unique **Registration ID** for your TPM device by, for example, creating an SHA-256 hash of the endorsement key.
44
+
>
45
+
> Follow the instructions in the article [How to manage device enrollments with Azure Portal](../iot-dps/how-to-manage-enrollments.md) to create your enrollment in DPS and then proceed with the [Install the IoT Edge runtime](#install-the-iot-edge-runtime) section in this article to continue.
46
+
36
47
## Simulate a TPM device
37
48
38
-
Create a simulated TPM device on your Windows development machine. Retrieve the **Registration ID** and **Endorsement Key** for your device, and use them to create an individual enrollment entry in DPS.
49
+
Create a simulated TPM device on your Windows development machine. Retrieve the **Registration ID** and **Endorsement key** for your device, and use them to create an individual enrollment entry in DPS.
39
50
40
51
When you create an enrollment in DPS, you have the opportunity to declare an **Initial Device Twin State**. In the device twin you can set tags to group devices by any metric you need in your solution, like region, environment, location, or device type. These tags are used to create [automatic deployments](how-to-deploy-monitor.md).
41
52
@@ -55,15 +66,39 @@ After creating the individual enrollment, save the value of the **Registration I
55
66
56
67
## Install the IoT Edge runtime
57
68
58
-
After completing the previous section, you should see your new device listed as an IoT Edge device in your IoT Hub. Now, you need to install the IoT Edge runtime on your device.
69
+
The IoT Edge runtime is deployed on all IoT Edge devices. Its components run in containers, and allow you to deploy additional containers to the device so that you can run code at the edge.
70
+
71
+
You'll need the following information when provisioning your device:
72
+
73
+
* The DPS **ID Scope** value
74
+
* The device **Registration ID** you created
75
+
76
+
Install the IoT Edge runtime on the device that is running the simulated TPM. You'll configure the IoT Edge runtime for automatic, not manual, provisioning.
59
77
60
-
The IoT Edge runtime is deployed on all IoT Edge devices. Its components run in containers, and allow you to deploy additional containers to the device so that you can run code at the edge.
78
+
> [!TIP]
79
+
> Keep the window that's running the TPM simulator open during your installation and testing.
61
80
62
-
Follow the instructions to install the IoT Edge runtime on the device that is running the simulated TPM from the previous section. Make sure to configure the IoT Edge runtime for automatic, not manual, provisioning.
81
+
For more detailed information about installing IoT Edge on Windows, including prerequisites and instructions for tasks like managing containers and updating IoT Edge, see [Install the Azure IoT Edge runtime on Windows](how-to-install-iot-edge-windows.md).
63
82
64
-
Know your DPS **ID Scope** and device **Registration ID** before installing IoT Edge on your device.
83
+
1. Open a PowerShell window in administrator mode. Be sure to use an AMD64 session of PowerShell when installing IoT Edge, not PowerShell (x86).
65
84
66
-
[Install and automatically provision IoT Edge](how-to-install-iot-edge-windows.md#option-2-install-and-automatically-provision)
85
+
1. The **Deploy-IoTEdge** command checks that your Windows machine is on a supported version, turns on the containers feature, and then downloads the moby runtime and the IoT Edge runtime. The command defaults to using Windows containers.
1. At this point, IoT Core devices may restart automatically. Other Windows 10 or Windows Server devices may prompt you to restart. If so, restart your device now. Once your device is ready, run PowerShell as an administrator again.
93
+
94
+
1. The **Initialize-IoTEdge** command configures the IoT Edge runtime on your machine. The command defaults to manual provisioning with Windows containers. Use the `-Dps` flag to use the Device Provisioning Service instead of manual provisioning.
95
+
96
+
Replace the placeholder values for `{scope_id}` and `{registration_id}` with the data you collected earlier.
0 commit comments