Code Monkey home page Code Monkey logo

azure-iot-edge-hol-linux's Introduction

Azure IoT Edge Hands On Labs

Created and maintained by the Microsoft Azure IoT Global Black Belts

Overview

This hands-on lab demonstrates setting up, configuring, and developing modules for Azure IoT Edge. The intent of these labs is not to cover exhaustively every IoT Edge topic, but rather cover a scenario that allows the student to learn and understand the basics of IoT Edge, develop modules and Edge ASA jobs, and perform Edge configuration, all in a pseudo-realistic use case.

These labs were originally developed to be delivered in-person by the Azure IoT GBBs to customers, however, they are available for any customers or partners to leverage, to play, or to learn. Over time, they will evolve past this original use to incorporate other use cases.

Edge "Device"

For simplicity of setup, for our "Edge Device", we will actually be using an Ubuntu Linux VM hosted in Azure. However, the principals are the same and the functionality is exactly the same as a Linux Edge Device on-premises would be.

NOTE that the point of using a VM in Azure is so that the lab student doesn't have to install anything (other than putty) on their local machine. There are a lot of nice features in Visual Studio Code for developing IoT Edge modules, however, because of the goal of installing nothing on the student's desktop, we will do it the "old fashion way" using native editors and tools.

In this workshop you will:

  • Setup and configure a simple IoT Deviceto simply (and dumbly) send temperature over the serial port every 3 seconds. This module will intentionally send the data in a "proprietary" format (comma separated)
  • create an IoT Edge module that read the simple CSV temp/humidity data from the device and converts to JSON and passes the message along
  • create an Azure Stream Analytics module that a) aggregates the "every 3 seconds" data to a 30 second frequency to send to IoT Hub in the cloud and b) looks for temperatures above a certain threshold. Then a threshold violation occurs, the module will drop an "alert" message on Edge
  • create an IoT Edge module that reads the "alert" message from ASA and sends a Direct Method call to the IoT Device to turn ON or OFF an "alert"

The labs are broken up into the following modules:

  • Module 1 - Prerequisites and IoT Edge setup
  • Module 2 - Setup and program the "IoT Device"
  • Module 3 - Develop "Formatter" module
  • Module 4 - Azure Stream Analytics Edge job
  • Module 5 - Develop "Alert" module

If you have questions or issues for the lab, check out our troubleshooting guide!

Below is a conceptual flow for the labs to help visualize what is taking place and how the data is flowing through the system ("T/H" is short for "temperature and humidity)

conceptual drawing

Let's get started!!

azure-iot-edge-hol-linux's People

Stargazers

Kannan Rajagopalan avatar Sebastian avatar Sachin Sinha avatar Scott Stout avatar Simon J.K. Pedersen avatar  avatar  avatar Josh Quintana avatar Nik Sachdeva avatar Abhijeet Bhatikar avatar HL Drew avatar

Watchers

James Cloos avatar Chris Han avatar Clark MacDonald avatar HL Drew avatar Steve Busby avatar Qing Wei avatar  avatar Ansley avatar  avatar

azure-iot-edge-hol-linux's Issues

Alertmodule - message serialization

Hello - Thanks for the very best IoT end to end implementation guideline. Learnt a lot.

While working on module 5 to setup a alert module, i found that below is line
---- BEGIN ORIGINAL CODE
var alertMsg = JsonConvert.DeserializeObject<Alert[]>(messageString)[0];
---- END
This was causing an deserialization error - reporting that the input messagestring is not a Json Array.
When i replaced it with the below correction, IT WORKED FINE so was wondering may be you had a setting where in messagestring was a Json array ??
--- BEGIN MODIFIED CODE
var alertMsg = JsonConvert.DeserializeObject < Alert >(messageString);
-- END

How to implement DPS X.509 for leaf device?

Hi,

I have solution where python module is communicating with HW and getting data over serial communication and passing the data to Azure Edge module using GatewayHostName.

Can you please help me to implement DPS with leaf device. How will i handle GatewayHostName to transfer data to Azure IoT Edge module.

Here we are appending GatewayHostName in connection string but in DPS we don't require Connection String.

Thanks,
Prateek

Unable built and Push Azure IoT Edge by Azure devops pipeline

Hi,
I am trying to built and push azure edge solution using Azure DevOps

  • My code is for Running in Windows container ( Windows-amd64)
  • My code is in azure repository

As my code is in azure Pipeline , so while Building I have selected the Azure Pipelines in the agent pool

  • Like bellow -->

Screenshot 2019-09-26 at 12 53 58 PM

Now for agent i Have Used "win1803" in the first and build the solution , now for release

I have created a tasks -->

Screenshot 2019-09-26 at 12 53 58 PM

This is the settings for the " IoT Edge Build" -->

Screenshot 2019-09-26 at 12 53 58 PM

Now getting error while i release the solution and in that in the " Build module images" i got the bellow error -->

  • when i used " Windows 1803" Microsoft hosted agent while building -->

Screenshot 2019-09-26 at 12 28 05 PM

  • when i used " vs2017-win2016 " i got the bellow error -->

https://textuploader.com/108xh

Unable to Built the Python SDK

I was trying this transparent gateway implementation

while cloning python SDK, I noticed it's updated, the "build_all" folder is not there,
however, I had a back up of old python SDK that I copied in the device,
but when I was building the "setup.sh" I was getting the bellow error

edge001@EdgeDevice:~/azure-iot-sdk-python/build_all/linux$ sudo ./setup.sh
[sudo] password for edge001: 
sudo: ./setup.sh: command not found

Then I added the Permission and then re-ran the script

edge001@EdgeDevice:~/azure-iot-sdk-python/build_all/linux$ sudo chmod 777 setup.sh
edge001@EdgeDevice:~/azure-iot-sdk-python/build_all/linux$ sudo ./setup.sh
./setup.sh: line 13: ./c/build_all/linux/setup.sh: Permission denied

I have done this previously never faced this issue, how to fix this ?

@stevebus

Device Twin not working if appending GatewayHostName in connection string

Hi,

I am using transparent gateway implementation with Azure IoT Edge for one of our client.
Transparent gateway is reading data over serial and passing the data to Azure Edge Hub using ';GatewayHostName=mygateway.local'. I am able to get data on Edge module.

But i have implemented Device twin on transparent gateway. Invoking method on Azure platform and receiving on transparent gateway. I am able to invoke method using device twin on leaf device and able to report properties back, if i don't append ';GatewayHostName=mygateway.local' with connection string.

If i append ';GatewayHostName=mygateway.local' with connection string then i can invoke method ~one or two times max during the start of script. Later it never get invoked. Using below link for implementation-
https://github.com/AzureIoTGBB/azure-iot-edge-hol-linux/tree/master/module2

Python Code is not working in the above link. Can you please help me on this.

Regards,
Prateek

Are we adding host file entry to the IoT Edge Device, clarification?

Hi @stevebus.

I'm following through your Hands on Lab (this tutorial should be the reference for the main IoT Edge as a Transparent Gateway documentation as it's so good) and I'm not clear what adding the entry to the /etc/hosts is for?

https://github.com/AzureIoTGBB/azure-iot-edge-hol-linux/tree/master/module1#additional-miscellaneous-setup

The docs state:
'There are a few final steps needed to set up our specific lab scenario. We are using our Edge device as a gateway, so we need
a) our IoT Device to be able to find it and
b) to have valid certificates so the IoT Device will open a successful TLS connection to the Edge

Add a host file entry for our Edge device -- this will let our "IoT Device" resolve and find our Edge gateway. To do this:

run 'sudo nano /etc/hosts'
add a row at the bottom with the following
127.0.0.1 mygateway.local
save and close the file (CTRL-O, CTRL-X)
confirm you can successfully "ping mygateway.local"
'

In my case I'm going to have maybe 50 Android "leaf" downstream devices that connect through IoT Edge as a transparent gateway.

Questions:

  1. Are these instructions stating that we should add this entry to the "leaf" downstream device for their /etc/hosts entry or for adding this to the IoT Edge Gateway Device?

  2. Why the 127.0.0.1 mygateway.local? I will give the IoT Edge Gateway Device as DNS name in the Azure Portal. Should I enter the DNS name here or what you have indicated 'mygateway.local'?

Thanks,

Chris

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.