| title | description | services | keywords | author | manager | ms.author | ms.date | ms.topic | ms.service |
|---|---|---|---|---|---|---|---|---|---|
Quickstart Azure IoT Edge + Linux | Microsoft Docs |
Try out Azure IoT Edge by running analytics on a simulated edge device |
iot-edge |
kgremban |
timlt |
kgremban |
01/11/2018 |
article |
iot-edge |
Azure IoT Edge moves the power of the cloud to your Internet of Things devices. In this topic, learn how to use the cloud interface to deploy prebuilt code remotely to an IoT Edge device.
If you don't have an active Azure subscription, create a free account before you begin.
This quickstart uses your computer or virtual machine like an Internet of Things device. To turn your machine into an IoT Edge device, the following services are required:
- Python pip, to install the IoT Edge runtime.
- Linux:
sudo apt-get install python-pip. - MacOS:
sudo easy_install pip.
- Linux:
- Docker, to run the IoT Edge modules
- Install Docker for Linux and make sure that it's running.
- Install Docker for Mac and make sure that it's running.
Create an IoT hub in your Azure subscription. The free level of IoT Hub works for this quickstart. If you've used IoT Hub in the past and already have a free hub created, you can skip this section and go on to Register an IoT Edge device. Each subscription can only have one free IoT hub.
-
Sign in to the Azure portal.
-
Select the Cloud Shell button.
-
Create a resource group. The following code creates a resource group called IoTEdge in the West US region:
az group create --name IoTEdge --location westus -
Create an IoT hub in your new resource group. The following code creates a free F1 hub called MyIotHub in the resource group IoTEdge:
az iot hub create --resource-group IoTEdge --name MyIotHub --sku F1
Create a device identity for your simulated device so that it can communicate with your IoT hub. Since IoT Edge devices behave and can be managed differently than typical IoT devices, you declare this to be an IoT Edge device from the beginning.
- In the Azure portal, navigate to your IoT hub.
- Select IoT Edge (preview).
- Select Add IoT Edge device.
- Give your simulated device a unique device ID.
- Select Save to add your device.
- Select your new device from the list of devices.
- Copy the value for Connection string--primary key and save it. You'll use this value to configure the IoT Edge runtime in the next section.
The IoT Edge runtime is deployed on all IoT Edge devices. It comprises two modules. First, the IoT Edge agent facilitates deployment and monitoring of modules on the IoT Edge device. Second, the IoT Edge hub manages communications between modules on the IoT Edge device, and between the device and IoT Hub.
On the machine where you'll run the IoT Edge device, download the IoT Edge control script:
sudo pip install -U azure-iot-edge-runtime-ctlConfigure the runtime with your IoT Edge device connection string from the previous section:
sudo iotedgectl setup --connection-string "{device connection string}" --auto-cert-gen-force-no-passwordsStart the runtime:
sudo iotedgectl startCheck Docker to see that the IoT Edge agent is running as a module:
sudo docker ps[!INCLUDE iot-edge-deploy-module]
In this quickstart, you created a new IoT Edge device and installed the IoT Edge runtime on it. Then, you used the Azure portal to push an IoT Edge module to run on the device without having to make changes to the device itself. In this case, the module that you pushed creates environmental data that you can use for the tutorials.
Open the command prompt on the computer running your simulated device again. Confirm that the module deployed from the cloud is running on your IoT Edge device:
sudo docker psView the messages being sent from the tempSensor module to the cloud:
sudo docker logs -f tempSensorYou can also view the telemetry the device is sending by using the IoT Hub explorer tool.
When you no longer need the IoT Hub you created, you can use the az iot hub delete command to remove the resource and any devices associated with it:
az iot hub delete --name {your iot hub name} --resource-group {your resource group name}
You learned how to deploy an IoT Edge module to an IoT Edge device. Now try deploying different types of Azure services as modules, so that you can analyze data at the edge.



