title | description | services | keywords | author | manager | ms.author | ms.date | ms.topic | ms.service |
---|---|---|---|---|---|---|---|---|---|
Deploy Azure Machine Learning with Azure IoT Edge | Microsoft Docs |
Deploy Azure Machine Learning as a module to an edge device |
iot-edge |
kgremban |
timlt |
kgremban |
11/15/2017 |
article |
iot-edge |
You can use IoT Edge modules to deploy code that implements your business logic directly to your IoT Edge devices. This tutorial walks you through deploying an Azure Machine Learning module that predicts when a device fails based on sensor data on the simulated IoT Edge device that you created in the Deploy Azure IoT Edge on a simulated device on Windows or Linux tutorials. You learn how to:
[!div class="checklist"]
- Deploy an Azure Machine Learning module to your IoT Edge device
- View generated data
When you want to use your own Azure Machine Learning model in your solution you will deploy a model for IoT Edge and host it in a container registry like Azure Container Registry or Docker.
- The Azure IoT Edge device that you created in the quickstart or first tutorial.
- The IoT Hub connection string for the IoT hub that your IoT Edge device connects to.
- The Azure ML container
To create your Azure ML container, follow the instructions in the AI toolkit for Azure IoT Edge.
-
On the Azure portal, navigate to your IoT hub.
-
Go to IoT Edge (preview) and select your IoT Edge device.
-
Select Set modules.
-
Select Add IoT Edge module.
-
In the Name field, enter
tempSensor
. -
In the Image URI field, enter
microsoft/azureiotedge-simulated-temperature-sensor:1.0-preview
. -
Leave the other settings unchanged and select Save.
-
Still on the Add Modules step, select Add IoT Edge module again.
-
In the Name field, enter the name of the container you made in the previous section. Refer to the AI toolkit for Azure IoT Edge for help finding the name.
-
In the Image field, enter the image URI of the container that you made in the previous section. Refer to the AI toolkit for Azure IoT Edge for help finding the image.
-
Click Save.
-
Back in the Add Modules step, click Next.
-
Update routes for your module:
-
In the Specify Routes step, copy the JSON below into the text box. Modules publish all messages to the Edge runtime. Declarative rules in the runtime define where those messages flow. In this tutorial you need two routes. The first route transports messages from the temperature sensor to the machine learning module via the "mlInput" endpoint, which is the endpoint that all Azure Machine Learning modules use. The second route transports messages from the machine learning module to IoT Hub. In this route, ''mlOutput'' is the endput that all Azure Machine Learning modules use to output data, and ''upstream'' is a special destination that tells Edge Hub to send messages to IoT Hub.
{ "routes": { "sensorToMachineLearning":"FROM /messages/modules/tempSensor/outputs/temperatureOutput INTO BrokeredEndpoint(\"/modules/machinelearningmodule/inputs/amlInput\")", "machineLearningToIoTHub": "FROM /messages/modules/machinelearningmodule/outputs/amlOutput INTO $upstream" } }
-
Click Next.
-
In the ''Review Template'' step, click ''Submit''.
-
Return to the device details page and click ''Refresh.'' You should see the new ''machinelearningmodule'' running along with the ''tempSensor module'' and the ''IoT Edge runtime''.
In VS Code, use the View | Command Palette... | IoT: Start Monitoring D2C Messages menu command to monitor data arriving in the IoT Hub.
In this tutorial, you deployed an IoT Edge module powered by Azure Machine Learning. You can continue on to any of the other tutorials to learn about other ways that Azure IoT Edge can help you turn data into business insights at the edge.
[!div class="nextstepaction"] Deploy an Azure Function as a module