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/tutorial-machine-learning-edge-02-prepare-environment.md
+71-83Lines changed: 71 additions & 83 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,24 +4,23 @@ description: 'Tutorial: Prepare your environment for development and deployment
4
4
author: kgremban
5
5
manager: philmea
6
6
ms.author: kgremban
7
-
ms.date: 11/11/2019
7
+
ms.date: 1/23/2020
8
8
ms.topic: tutorial
9
9
ms.service: iot-edge
10
10
services: iot-edge
11
11
---
12
-
13
12
# Tutorial: Set up an environment for machine learning on IoT Edge
14
13
15
14
> [!NOTE]
16
15
> This article is part of a series for a tutorial about using Azure Machine Learning on IoT Edge. If you have arrived at this article directly, we encourage you to begin with the [first article](tutorial-machine-learning-edge-01-intro.md) in the series for the best results.
17
16
18
-
This article from the end-to-end Azure Machine Learning on IoT Edge tutorial helps you prepare your environment for development and deployment. First, set up a development machine with all the tools you need. Then, create the necessary cloud resources in Azure.
17
+
This article helps you prepare your environment for development and deployment. First, set up a development machine with all the tools you need. Then, create the necessary cloud resources in Azure.
19
18
20
-
## Set up a development machine
19
+
## Set up the development VM
21
20
22
21
This step is typically performed by a cloud developer. Some of the software may also be helpful for a data scientist.
23
22
24
-
Over the course of this article we perform various developer tasks including coding, compiling, configuring, and deploying IoT Edge modules and IoT devices. For ease of use, we created a PowerShell script that creates an Azure virtual machine with many of the prerequisites already configured. The VM that we create needs to be able to handle [nested virtualization](https://docs.microsoft.com/azure/virtual-machines/windows/nested-virtualization), which is why we chose a [Standard_D8s_v3](../virtual-machines/windows/sizes-general.md#dsv3-series-1) machine size.
23
+
We created a PowerShell script that creates an Azure virtual machine with many of the prerequisites already configured. The VM that we create needs to be able to handle [nested virtualization](https://docs.microsoft.com/azure/virtual-machines/windows/nested-virtualization), which is why we chose a [Standard_D8s_v3](../virtual-machines/windows/sizes-general.md#dsv3-series-1) machine size.
25
24
26
25
The development VM will be set up with:
27
26
@@ -45,102 +44,95 @@ The developer VM is not strictly necessary – all the development tools can be
45
44
46
45
It takes about 30 minutes to create and configure the virtual machine.
47
46
48
-
### Get the script
49
-
50
-
Clone or download the PowerShell script from the [Machine Learning and IoT Edge](https://github.com/Azure-Samples/IoTEdgeAndMlSample) sample repository.
51
-
52
-
### Create an Azure virtual machine
47
+
1. Clone or download the [Machine Learning and IoT Edge](https://github.com/Azure-Samples/IoTEdgeAndMlSample) sample repository to your local computer.
53
48
54
-
The DevVM directory contains the files needed to create an Azure virtual machine appropriate for completing this tutorial.
55
-
56
-
1. Open Powershell as an administrator and navigate to the directory where you downloaded the code. We will refer to the root directory for your source as `<srcdir>`.
49
+
1. Open Powershell as an administrator and navigate to the **\IoTEdgeAndMlSample\DevVM** directory located under the root directory where you downloaded the code. We will refer to the root directory for your source as `srcdir`.
57
50
58
51
```powershell
59
-
cd <srcdir>\IoTEdgeAndMlSample\DevVM
52
+
cd c:\srcdir\IoTEdgeAndMlSample\DevVM
60
53
```
61
54
62
-
2. Run the following command to allow execution of scripts. Choose **Yes to All** when prompted.
55
+
The DevVM directory contains the files needed to create an Azure virtual machine appropriate for completing this tutorial.
56
+
57
+
1. Run the following command to allow execution of scripts. Choose **Yes to All** when prompted.
63
58
64
59
```powershell
65
60
Set-ExecutionPolicy Bypass -Scope Process
66
61
```
67
62
68
-
3. Run Create-AzureDevVM.ps1 from this directory.
63
+
1. Run Create-AzureDevVM.ps1.
69
64
70
65
```powershell
71
66
.\Create-AzureDevVm.ps1
72
67
```
73
68
74
-
* When prompted, provide the following information:
75
-
* **Azure Subscription ID**: Your subscription ID, which can be found in the Azure portal
76
-
* **Resource Group Name**: The name of a new or existing resource group in Azure
77
-
* **Location**: Choose an Azure location where the virtual machine will be created. For example, westus2 or northeurope. For more information, see [Azure locations](https://azure.microsoft.com/global-infrastructure/locations/).
78
-
* **AdminUsername**: Provide a memorable name for the admin account you want to create and use on the virtual machine.
79
-
* **AdminPassword**: Set a password for the admin account on the virtual machine.
69
+
When prompted, provide the following information:
80
70
81
-
* If you do not have Azure PowerShell installed, the script will install [Azure PowerShell Az module](https://docs.microsoft.com/powershell/azure/new-azureps-module-az?view=azps-1.1.0)
71
+
* **Azure Subscription ID**: Your subscription ID, which can be found in [Azure Subscriptions](https://ms.portal.azure.com/#blade/Microsoft_Azure_Billing/SubscriptionsBlade) in portal.
72
+
* **Resource Group Name**: The name of a new or existing resource group in Azure.
73
+
* **Location**: Choose an Azure location where the virtual machine will be created. For example, 'West US 2' or 'North Europe'. For more information, see [Azure locations](https://azure.microsoft.com/global-infrastructure/locations/).
74
+
* **Username**: Provide a memorable name for the administrator account for the VM.
75
+
* **Password**: Set a password for the administrator account for the VM.
82
76
83
-
* You will be prompted to sign in to Azure.
84
-
85
-
* The script confirms the information for the creation of your VM. Press `y` or `Enter` to continue.
77
+
The script runs for several minutes as it executes the following steps:
86
78
87
-
The script runs for several minutes as it executes the following steps:
79
+
1. Installs the [Azure PowerShell Az module](https://docs.microsoft.com/powershell/azure/new-azureps-module-az?view=azps-1.1.0).
80
+
1. Prompts you to sign in to Azure.
81
+
1. Confirms the information for the creation of your VM. Press **y** or **Enter** to continue.
82
+
1. Creates the resource group if it does not exist.
83
+
1. Deploys the virtual machine.
84
+
1. Enables Hyper-V on the VM.
85
+
1. Installs software need for development and clone the sample repository.
86
+
1. Restarts the VM.
87
+
1. Creates an RDP file on your desktop for connecting to the VM.
88
88
89
-
* Create the resource group if it does not exist
90
-
* Deploy the virtual machine
91
-
* Enable Hyper-V on the VM
92
-
* Install software need for development and clone the sample repository
93
-
* Restart the VM
94
-
* Create an RDP file on your desktop for connecting to the VM
89
+
If you are prompted for the name of the VM to restart it, you can copy its name from the script output. The output also shows the path to the RDP file for connecting to the VM.
95
90
96
91
### Set auto-shutdown schedule
97
92
98
-
To help you reduce cost, the VM has been created with an automatic shutdown schedule that is set to 1900 PST. You may need to update this timing depending on your location and schedule. To update the shutdown
99
-
schedule:
93
+
To help you reduce cost, the development VM has been created with an automatic shutdown schedule that is set to 1900 PST. You may need to update this setting depending on your location and schedule. To update the shutdown schedule:
100
94
101
-
1. Sign in to the [Azure portal](https://portal.azure.com).
95
+
1. In the Azure portal, navigate to the VM that the script created.
102
96
103
-
2. Navigate to your virtual machine in the resource group that you provided in the previous section.
97
+
1. From the left pane menu, under **Operations**, select **Auto-shutdown**.
104
98
105
-
3. Select **Auto-shutdown** on the side navigator.
99
+
1. Adjust the **Scheduled shutdown** and **Time zone** as desired and select **Save**.
106
100
107
-
4. Enter a new shutdown time in **Scheduled shutdown** or change the **Time zone** then click **Save**.
108
-
109
-
### Connect and configure development machine
101
+
## Connect to the development VM
110
102
111
103
Now that we have created a VM we need to finish installing the software needed to complete the tutorial.
112
104
113
-
#### Start a remote desktop session
114
-
115
-
1. The VM creation script created an RDP file on your desktop.
105
+
1. Double-click on the RDP file that the script created on your desktop.
116
106
117
-
2. Double-click on the file with the name **\<Azure VM name\>.rdp**.
107
+
1. You will be presented with a dialog saying the publisher of the remote connection is unknown. This is acceptable, so select **Connect**.
118
108
119
-
3. You will be presented with a dialog saying the publisher of the remote connection is unknown. Click the **Don’t ask me again for connections to this computer** checkbox then select **Connect**.
109
+
1. Provide the administrator password that you provided to create the VM and click **OK**.
120
110
121
-
4. When prompted, provide the AdminPassword that you used when running the script to set up the VM and click **OK**.
111
+
1. You will be prompted to accept the certificate for the VM. Select **Yes**.
122
112
123
-
5. You will be prompted to accept the certificate for the VM. Select **Don’t ask me again for connections to this computer** and choose **Yes**.
124
-
125
-
#### Install Visual Studio Code extensions
113
+
## Install Visual Studio Code extensions
126
114
127
115
Now that you have connected to the development machine, add some useful extensions to Visual Studio Code to make the development experience easier.
128
116
129
-
1. In a PowerShell window, navigate to **C:\\source\\IoTEdgeAndMlSample\\DevVM**.
117
+
1. Connect to the development VM, open a PowerShell window, and navigate to the **C:\source\IoTEdgeAndMlSample\DevVM** directory. This directory was created by the script that created the VM.
130
118
131
-
2. Allow scripts to be executed on the virtual machine by typing.
119
+
```powershell
120
+
cd C:\source\IoTEdgeAndMlSample\DevVM
121
+
```
122
+
123
+
1. Run the following command to allow execution of scripts. Choose **Yes to All** when prompted.
4. The script will run for a few minutes installing VS code extensions:
135
+
1. The script will run for a few minutes installing VS code extensions:
144
136
145
137
* Azure IoT Tools
146
138
* Python
@@ -152,19 +144,15 @@ Now that you have connected to the development machine, add some useful extensio
152
144
153
145
These steps are typically performed by a cloud developer.
154
146
155
-
Azure IoT Hub is the heart of any IoT application. It handles secure communication between IoT devices and the cloud. It is the main coordination point for the operation of the IoT Edge machine learning solution.
147
+
Azure IoT Hub is the heart of any IoT application as it handles secure communication between IoT devices and the cloud. It is the main coordination point for the operation of the IoT Edge machine learning solution.
156
148
157
-
* IoT Hub uses routes to direct incoming data from IoT devices to other downstream services. We will take advantage of IoT Hub routes to send device data to Azure Storage where it can be consumed by Azure Machine Learning to train our remaining useful life (RUL) classifier.
149
+
* IoT Hub uses routes to direct incoming data from IoT devices to other downstream services. We will take advantage of IoT Hub routes to send device data to Azure Storage. In Azure Storage, the device data is consumed by Azure Machine Learning to train our remaining useful life (RUL) classifier.
158
150
159
151
* Later in the tutorial, we will use IoT Hub to configure and manage our Azure IoT Edge device.
160
152
161
-
In this section, you use a script to create an Azure IoT hub and an Azure Storage account. Then, you configure a route that forwards data received by the hub to an Azure Storage Blob container using the Azure portal. These steps take about 10 minutes to complete.
153
+
In this section, you use a script to create an Azure IoT hub and an Azure Storage account. Then in the Azure portal, you configure a route that forwards data received by the hub to an Azure Storage container. These steps take about 10 minutes to complete.
162
154
163
-
### Create cloud resources
164
-
165
-
1. On your development machine, open a PowerShell window.
166
-
167
-
1. Change to the IoTHub directory.
155
+
1. Connect to the development VM, open a PowerShell window, and navigate to the **IoTHub** directory.
168
156
169
157
```powershell
170
158
cd C:\source\IoTEdgeAndMlSample\IoTHub
@@ -173,50 +161,50 @@ In this section, you use a script to create an Azure IoT hub and an Azure Storag
173
161
1. Run the creation script. Use the same values for subscription ID, location, and resource group as you did when creating the development VM.
* The script confirms the information for the creation of your Hub and Storage account. Press `y` or `Enter` to continue.
168
+
* The script confirms the information for the creation of your Hub and Storage account. Press **y** or **Enter** to continue.
182
169
183
-
The script takes about two minutes to run. Once complete, the script outputs the name of the hub and the storage account.
170
+
The script takes about two minutes to run. Once complete, the script outputs the name of the IoT hub and the storage account.
184
171
185
-
### Review route to storage in IoT Hub
172
+
## Review route to storage in IoT Hub
186
173
187
-
As part of creating the IoT hub, the script that we ran in the previous section also created a custom endpoint and a route. IoT Hub routes consist of a query expression and an endpoint. If a message matches the expression, the data is sent along the route to the associated endpoint. Endpoints can be Event Hubs, Service Bus Queues, and Topics. In this case, the endpoint is a Blob container in a storage account. Let’s use the Azure portal to review the route created by our script.
174
+
As part of creating the IoT hub, the script that we ran in the previous section also created a custom endpoint and a route. IoT Hub routes consist of a query expression and an endpoint. If a message matches the expression, the data is sent along the route to the associated endpoint. Endpoints can be Event Hubs, Service Bus Queues, and Topics. In this case, the endpoint is a blob container in a storage account. Let’s use the Azure portal to review the route created by our script.
188
175
189
-
1. Open the [Azure portal](https://portal.azure.com).
176
+
1. Open the [Azure portal](https://portal.azure.com) and go to the resource group you're using for this tutorial.
190
177
191
-
1. Choose all services from the left navigator, type IoT in the search box, and select **IoT Hub**.
178
+
1. In the list of resources, select the IoT Hub that the script created. It will have a name ending with random characters such as `IotEdgeAndMlHub-jrujej6de6i7w`.
192
179
193
-
1. Choose the IoT Hub created in the previous step.
180
+
1. From the left pane menu, under **Messaging**, select **Message routing**.
194
181
195
-
1. In the IoT Hub side navigator, choose **Message routing**.
182
+
1. On the **Message routing** page, select the **Custom endpoints** tab.
196
183
197
-
1. The message routing page has two tabs, **Routes** and **Custom endpoints**. Select the **Custom endpoints** tab.
184
+
1. Expand the **Storage** section:
198
185
199
-
1. Under **Blob storage**, select **turbofanDeviceStorage**.
186
+

200
187
201
-
1. Note that this endpoint points to a blob container called **devicedata** in the storage account created in the last step, which is named **iotedgeandml\<unique suffix\>**.
188
+
We see **turbofandevicestorage** is in the custom endpoints list. Note the following characteristics about this endpoint:
202
189
203
-
1. Also note the **Blob file name format** has been changed from the default format to instead place the partition as the last element in the name. We find this format is more convenient for the file operations we will do with Azure Notebooks later in the tutorial.
204
-
205
-
1. Close the endpoint details blade to return to the **Message routing** page.
190
+
* It points to the blob storage container you created named `devicedata` as indicated by **Container name**.
191
+
* Its **Filename format** has partition as the last element in the name. We find this format is more convenient for the file operations we will do with Azure Notebooks later in the tutorial.
206
192
207
193
1. Select the **Routes** tab.
208
194
209
195
1. Select the route named **turbofanDeviceDataToStorage**.
210
196
211
-
1. Note that the route’s endpoint is the **turbofanDeviceStorage** custom endpoint.
197
+
1. On the **Routes details** page, note that the route’s endpoint is the **turbofanDeviceStorage** endpoint.
198
+
199
+

212
200
213
-
1. Look at the routing query, which is set to **true**. This means that all device telemetry messages will match this route and therefore all messages will be sent to the **turbofanDeviceStorage** endpoint.
201
+
1. Look at the **Routing query**, which is set to **true**. This setting means that all device telemetry messages will match this route; and therefore all messages will be sent to the **turbofanDeviceStorage** endpoint.
214
202
215
-
1. Close the route details.
203
+
1. Since no edits were made, just close this page.
216
204
217
205
## Next steps
218
206
219
-
In this article, we created an IoT Hub and configured a route to an Azure Storage account. In the next article, we will send data from a set of simulated devices through the IoT Hub into the storage account. Later in the tutorial, after we have configured our IoT Edge device and modules, we will revisit routes and look a little more at the routing query.
207
+
In this article, we created an IoT Hub and configured a route to an Azure Storage account. Next, we will send data from a set of simulated devices through the IoT Hub into the storage account. Later in the tutorial, after we have configured our IoT Edge device and modules, we will revisit routes and look a little more at the routing query.
220
208
221
209
For more information about the steps covered in this portion of the Machine Learning on IoT Edge tutorial, see:
0 commit comments