Skip to content

Latest commit

 

History

History
224 lines (116 loc) · 5.42 KB

File metadata and controls

224 lines (116 loc) · 5.42 KB

Introduction to IoT Edge

Azure IoT Edge moves cloud analytics and custom business logic to devices so that your organization can focus on business insights instead of data management. Enable your solution to truly scale by configuring your IoT software, deploying it to devices via standard containers, and monitoring it all from the cloud.

Analytics drives business value in IoT solutions, but not all analytics needs to be in the cloud. If you want a device to respond to emergencies as quickly as possible, you can perform anomaly detection on the device itself. Similarly, if you want to reduce bandwidth costs and avoid transferring terabytes of raw data, you can perform data cleaning and aggregation locally. Then send the insights to the cloud.

In this lab you will learn about

  • Deploy a Linux machine and make it an edge device

  • Deploy Modules and learn how to create routes

Deploy IoT Edge on Ubuntu

In Azure portal click on Create a resource

Create Resource

Select Ubuntu Server

Ubuntu

Create server in its own resource group. You can delete the resource group after the lab is competed.

Create Ubuntu

Select DS1_V2 for VM Size

Ubuntu VM Size

Leave everything default

Ubuntu Storage

Click Create button

Ubuntu Create

Got To the Resource Group created for IoT Edge and select the VM. Click Connect button to get the ssh command to connect to the VM.

Ubuntu Connect

Copy the SSH command

Ubuntu SSH

Click on Cloud shell in the portal

Cloud Shell

Make sure you select Bash shell

Cloud Shell Login

Once logged into Cloud Shell type the command

$ ssh iotedgeadmin@ipaddress

You will be prompted to enter the password which you entered when creating the Ubuntu VM. Enter the password and press enter.

You will successfully login to Ubuntu VM

Cloud Shell Success

Change user to get root access by entering the following command

sudo su -

Check for Python version, you should have 2.7.X version.

python --version

Update the apt package index

apt install docker.io

Update the apt package index.

Check for docker version

docker --version

You should have a docker version installed.

Install IoT Edge Runtime

Install pip

sudo apt-get install python-pip

Install IoT Edge Runtime

sudo pip install -U azure-iot-edge-runtime-ctl

Check IoT Edge Runtime version

iotedgectl --version

Manage IoT Edge Devices using IoTHub

Create IoT Edge Device using IoT Hub. Click on IoT Edge from Azure Portal.

Devices

Click on + Add IoT Edge Device

Edge Device

Add new IoT Edge device and Click Save

device

New Edge Device is created. Click on the device

Device List

Copy primary connection string

Device Connection

Setup Device with the following command. Make sure replace device connection string with the primary connection string you copied.

iotedgectl setup --connection-string "{device connection string}" --nopass

Runtime Setup

Start the runtime with

iotedgectl start

Runtime running

Check Docker to see that the IoT Edge agent is running as a module

docker ps

Agent

Deploy a module

One of the key capabilities of Azure IoT Edge is being able to deploy modules to your IoT Edge devices from the cloud. An IoT Edge module is an executable package implemented as a container. In this section, you deploy a module that generates telemetry for your simulated device.

  • In 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.

Save Module

  • Back in the Add modules step, select Next.
  • In the Specify routes step, select Next.
  • In the Review template step, select Submit.
  • Return to the device details page and select Refresh. You should see the new tempSensor module running along the IoT Edge runtime.

Module Running

On the edge device type docker ps to list all the modules running. You should see tempSensor module running

docker ps

Module on Ubuntu

View logs of tempSensor module to see the data being sent to IoT Hub

docker logs -f tempSensor

Module Data