Deploy Azure IoT Edge (preview) on a simulated device with Visual Studio Code
Azure IoT Edge enables you to perform analytics and data processing on your devices, instead of having to push all the data to the cloud. The IoT Edge tutorials demonstrate how to deploy different types of modules, built from Azure services or custom code, but first you need a device to test.
In this tutorial you learn how to:
- Create an IoT Hub
- Register an IoT Edge device
- Start the IoT Edge runtime
- Deploy a module
The simulated device that you create in this tutorial is a monitor on a wind turbine that generates temperature, humidity, and pressure data. You’re interested in this data because your turbines perform at different levels of efficiency depending on the weather conditions. The other Azure IoT Edge tutorials build upon the work you do here by deploying modules that analyze the data for business insights.
This tutorial assumes that you’re using a computer or virtual machine to simulate an Internet of Things device.
- Install Docker and make sure it’s running.
- Install Python and make sure you can use the pip command.
- Run the following command to download the IoT Edge control script.
1pip install -U azure-iot-edge-runtime-ctl
- Install Visual Studio Code
- Install Azure IoT Edge extension
Start the tutorial by creating your IoT Hub.
- In Visual Studio Code, select IoT Hub Devices.
- Select … then select Create IoT Hub from the menu.
- Select Subscription, Resource Group and fill in other required fields to create IoT Hub
Register an IoT Edge device with your newly created IoT Hub.
Configure and start the Azure IoT Edge runtime on your device.
- Right-click the Edge device in Device List and select Setup Edge
- In Command Palette, select Edge: Start Edge
Manage your Azure IoT Edge device in VS Code to deploy a module which will send telemetry data to IoT Hub.
- In Command Palette, select Edge: Generate Edge deployment manifest, save the deployment.json file.
- In the modules section of deployment.json, update SampleModule to tempSensor, update
- Right-click the Edge device in Device List and select Create deployment for Edge device, then select the deployment.json file to deploy the module.
Monitor device to cloud messages sent from your IoT Edge device to your IoT hub
- To monitor data arriving at the IoT hub, right-click the Edge device and select Start monitoring D2C message
- To stop monitoring data, right-click the Output Channel and select Stop monitoring D2C message
Expand the Edge device to view the status of each module
Now you have successfully deployed a pre-defined module on your IoT Edge device within Visual Studio Code. Besides that, you can build your own module as well. Please check out this tutorial for developing and deploying your own module.