azure iot workshop

Post on 22-Jan-2018

322 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Azure IoT Workshop– 13.10.2017

Azure IoT Workshop@marco_parenzan

Azure IoT Workshop– 13.10.2017

@marco_parenzan

◇.NET, JavaScript,Azure ad IoT Developer, Trainer and Consultant

◇Microsoft MVP 2017 for Azure

◇Book Author @ Packt, LSWR

◇Community Lead per 1nn0va

Azure IoT Workshop– 13.10.2017

Azure IoT Workshop– 13.10.2017

Things

IoT Solutions Have a Common Pattern

Insights ActionsCloud

Gateway

Azure IoT Hub

Azure IoT Workshop– 13.10.2017

IoT Scenario

IoT Hub

(Events and Devices)

Function

(Process)

Function

(Alerts)

Storage

(Storage)

Azure IoT Workshop– 13.10.2017

Azure IoT Workshop– 13.10.2017

Azure IoT Workshop– 13.10.2017

Azure IoT Workshop– 13.10.2017

Azure IoT Workshop– 13.10.2017

Azure IoT Workshop– 13.10.2017

Azure IoT Workshop– 13.10.2017

Disclaimer

◇This is not an electronic course!

◇You are not an electronic geek!

◇I’m not an electronic geek!

◇You cannot avoid these skills in your team

Azure IoT Workshop– 13.10.2017

Warning! We cannot avoid…

Electronic engineers

Process engineers

Industrialization

process

Azure IoT Workshop– 13.10.2017

Warning! We are not saying…

Software engineers can create devices

Azure IoT Workshop– 13.10.2017

We are just saying…

Embedded world is no

more a niche

Software engineers can

contribute

Azure IoT Workshop– 13.10.2017

It is no more a niche

Proprietary Hardware and

toolsObsolete tools

No software rules and

quality

Azure IoT Workshop– 13.10.2017

Software engineers can contribute

Methodologies Patterns(Cloud)

Infrastructure

“Openness” Tools Languages

Azure IoT Workshop– 13.10.2017

Tools

Up to date compilers

Modern IDEsSDK (Libraries and Drivers)

Debuggers Simulators

Azure IoT Workshop– 13.10.2017

Languages

CProcessin

gNode.js

Python Java C#

Azure IoT Workshop– 13.10.2017

Software Developer Role

Develop and test the process and

the cloud infrastructure

Develop and test the device

software design

Cannot test sensors and

actuators

Work with fake/random data

Azure IoT Workshop– 13.10.2017

Azure IoT Workshop– 13.10.2017

Contesto

◇Azienda di Produzione Industriale■10-50M EURO

◇Presenza world-wide

◇Mercato Pro■Più sensibili al servizi

■E poi discutiamo del privato

◇Su commessa■Assorbe I costi iniziali

■E poi discutiamo della serie

10M€

Azure IoT Workshop– 13.10.2017

Industial Stainless Steel Kitchen Applications

Azure IoT Workshop– 13.10.2017

Scenario: resistor performance loss

◇Reference temperature is no more reachable

◇Example■fry-top: 400°C 300°C ■human cannot verify the temperature

■Mechanical thermostat shows only reference temperature, not current temperature

◇Effects■Longer cooking

■“Bad” cooking

■Customer impact

■Prelude to break

Azure IoT Workshop– 13.10.2017

Scenario: resistor break

◇Typically after a loose of performances, resistor elements break (days/weeks)

◇Effects■Appliance break

■Kitchen mainly slow down (few cooking appliances)

○Kitched typically don’t stop | Many elements in cooking blocks can supply loss of other elements

■Long time in assistance (no SLA discussed)

■Stop can vary from hours to days

■Final customer impact/reputation

Azure IoT Workshop– 13.10.2017

Required solution

◇Telemetry in industrial cooking plants

◇Intelligent appliances that sends status/operational data

◇Collect data world wide

◇Group by■Appliances

■Temperature range

■Daily/Seasonal data

■Kitchen/Plant

◇Apply data analysis algorithms■Final analysis (analyze costs)

■Forecast analysis (prevent uncontrolled failures, manage “planned” failures)

Azure IoT Workshop– 13.10.2017

Proposizione

◇Assolvere ad una esigenza «immediata»■Manutenzione predittiva

■Manutenzione preventiva

■Abbattere i costi della manutenzione

◇Assolvere ad una esigenza «a lungo termine»■Offrire nuovi servizi alle aziende

■Permettettere alle aziende di offrire nuovi servizi

■Nuovo modello di business (CAPEXOPEX)

Azure IoT Workshop– 13.10.2017

Industria 4.0

http://www.slideshare.net/alexcurti/piano-industria-40-68702177

Azure IoT Workshop– 13.10.2017

Benefici attesi dall’ Industria 4.0

Azure IoT Workshop– 13.10.2017

Tecnologie abilitanti Industria 4.0

Azure IoT Workshop– 13.10.2017

Azure IoT Workshop– 13.10.2017

Embedded

◇È la tecnologia che rende intelligente un elemento prodotto

◇Permette di creare azione ed interazione LOCALE

◇Usa microprocessori o microcontrollori

◇Microcrontrollori: I/O oriented, Atmel ATmeg328, ESP8266 ■I/O, realtime

■GPIO (5V, 3,3V)

◇Microprocessori: ARM Cortex, Intel Quark, Intel Atom■Gateway

◇Elementi tecnologici di riferimento■Consumo energetico

◇Si parla spesso di SOC: System On Chip■Integrazione cost effective

◇Può essere realtime

Azure IoT Workshop– 13.10.2017

I progetti Embedded IoT sono complessi

•conoscenzeIncompatibile con la infrastruttura

corrente

•conoscenzeTime consuming da avviare

•Infrastruttura complessa•Procedure

Difficile da mantenere

•Costi•Infrastruttura complessa

Difficile da scalare

Azure IoT Workshop– 13.10.2017

Makers

◇Board con microcontrolloreArduino

◇Board con microprocessoreRaspberry

◇Prototipazione■Verifichiamo che l’idea funzioni

◇Focus on:■Programming, Connecting

■…non sull’elettronica…

◇Non industrial-grade

◇Hanno cambiato il modo di interagire con il mondo embedded

◇Queste schede sono «naturalmente» connesse a Internet■Implementano sempre uno stack TCP/IP o almeno una connessione esterna evoluta (USB)

Azure IoT Workshop– 13.10.2017

Boards for makers

Arduino

Azure IoT Workshop– 13.10.2017

Industrial-grade Makers

Arduino

Raspberry

Olimex

Toradex

Azure IoT Workshop– 13.10.2017

Embedded Device

GPIO

Sensors

Actuators

Board

Edge/Local

Processing

State

Azure IoT Workshop– 13.10.2017

IoT Device=Embedded Device + Communication

GPIO Communication

Sensors

Actuators

Board

Edge/Local

Processing

State

Azure IoT Workshop– 13.10.2017

Non solo Raspberry…Industruino

Azure IoT Workshop– 13.10.2017

Energy ManagementVertical Cloud

MA DI CHI SONO I DATI?

Azure IoT Workshop– 13.10.2017

Azure IoT Workshop– 13.10.2017

Alternatives

Costs

Performances

Azure IoT Workshop– 13.10.2017

Performance of Arduino class devices

◇- The absolute performance power of Arduino device is low■Arduino is a microcontroller-based architecture

■Raspberry Pi is a microprocessor-based architecture

◇+ Pro: Arduino has a light set of running services, light OS

Azure IoT Workshop– 13.10.2017

Cost of Arduino class devices

• +Pro: Arduino cost LESS that Raspberry Pi devices

• - You have less resources and services

Azure IoT Workshop– 13.10.2017

Arduino language

◇Processing (the IDE - https://processing.org/)

◇JavaScript (inspiration of the language and for Processing)

◇C++ (object syntax, usage, not creation)

◇C (raw performance and binary)

Azure IoT Workshop– 13.10.2017

Arduino and Azure IoT Hub

◇Arduino can speak Http, MQTT and AMQP protocols

◇Porting of Azure IoTHub SDK for C

Azure IoT Workshop– 13.10.2017

Starting with Arduino

◇https://github.com/arduino/Arduino/

◇https://www.arduino.cc/en/main/software

◇https://azure.microsoft.com/en-us/develop/iot/starter-kits/

◇https://www.adafruit.com/azure

◇https://www.adafruit.com/product/3032

Azure IoT Workshop– 13.10.2017

Connecting the sensor

10K Ω

P2

+

-

+

-

Azure IoT Workshop– 13.10.2017

+

-

+

-

Connecting the leds

15

Anode (+

, longer)

56

56

13

Anode (+

, longer)

Azure IoT Workshop– 13.10.2017

The result

Azure IoT Workshop– 13.10.2017

Setup software per lo sviluppo in Azure

◇Git

◇Visual Studio Code

◇Python

◇Node.js

◇nom

Azure IoT Workshop– 13.10.2017

Setup software per Azure

◇Azure CLI 2.0[.19] (https://aka.ms/InstallAzureCliWindows)

◇npm install -g iothub-explorer [1.1.16]

Azure IoT Workshop– 13.10.2017

Setup software per Arduino

◇Arduino 1.8.x (1.8.5) da arduino.cc

◇CP210x USB to UART Bridge (COMx)https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers

Azure IoT Workshop– 13.10.2017

Setup Azure

◇Dashboard (Azure IoT Workshop)

◇Resource Group (AzureIoTWorkshop)

◇IoT Hub (AzureIoTWorkshop0000xy)

◇Azure Storage (azureiotworkshop00xy) in minuscolo!!!!

◇Function (azureiotworkshop00xy)

Azure IoT Workshop– 13.10.2017

Set current subscription

◇az login■https://aka.ms/devicelogin

■E incolla il codice

◇az account set --subscription “<subscription name>“

◇az show

Azure IoT Workshop– 13.10.2017

Create device from command line

◇Az iot hub list

◇az iot device create --hub-name azureiotworkshop00xy --device-id dev1

◇az iot device show-connection-string --hub-name azureiotworkshopproto --device-id dev1

Azure IoT Workshop– 13.10.2017

Una MCU programmabile Arduino con ESP8266

http://www.instructables.com/id/Programming-ESP8266-ESP-12E-NodeMCU-Using-Arduino-/

https://github.com/esp8266/Arduino/issues/584

Azure IoT Workshop– 13.10.2017

Resistenze, tanto per ricordarsi

Azure IoT Workshop– 13.10.2017

Rilevare la temperatura con un DHT 11

◇https://learn.adafruit.com/dht

Azure IoT Workshop– 13.10.2017

Azure IoT Workshop– 13.10.2017

IoT Scenario

IoT Hub

(Events and Devices)

Function

(Process)

Function

(Alerts)

Storage

(Storage)

Azure IoT Workshop– 13.10.2017

Configuring Azure Services

◇Three functional services■Azure Blob Storage

■Azure Function App

■Azure IoT Hub

◇One non functional service■Azure Resource Group

Azure IoT Workshop– 13.10.2017

Why IoT Hub?

◇Devices registration

◇Notification abstraction from implementation (web sockets/polling)

◇Eterogeneus devices implementation simplified by SDK support

◇Cons■External tool to manage device registration

Azure IoT Workshop– 13.10.2017

Alternatives to IoT Hub

◇API Apps (App Services)

◇Why not■Manual registry implementation

■Manual two way communication implementation (with web sockets)

■Manual scaling (at large)

Azure IoT Workshop– 13.10.2017

Why Azure Storage?

◇Persisted data handled as a blob in the storage■No query requirement

◇Native integration with Functions■Trigger

Azure IoT Workshop– 13.10.2017

Alternatives to Azure Storage

◇DocumentDb for Json support

◇Why yes■Native querying support

◇Why not■Blob support

Azure IoT Workshop– 13.10.2017

Why Azure Function?

◇Unfrequent access to the function■Subsecond billing

◇Event based solution■Http Request

■Blob storage

◇Better code organization■Simple Responsibility Principle: 1 function, 1 responsibility

Azure IoT Workshop– 13.10.2017

Alternatives to Azure Function

◇API Apps (App Services)

◇Why yes■Mature patterns on class-based development

■Mature ALM with API Apps (Visual Studio experience)

◇Why not■Classic hosting plan only

■Risk on responsibility coupling (too many responsibilities)

Azure IoT Workshop– 13.10.2017

Azure Resource Group

◇Mandatory service organization

◇Deployment opportunities■Agile deployment

■Transactional deployment

◇Cons■Not simple to learn (but full of advantages)

Azure IoT Workshop– 13.10.2017

Azure IoT Workshop– 13.10.2017

IP capable devices

Devices Data processing and analyticsMonitoring

Control

IT solution backend

Pre

se

nta

tion

an

dbu

sin

ess

co

nn

ectivity

Existing IoTdevices

Low power devices

Generic IoT RequirementsIp

C

ap

ab

leD

evic

es

Le

ga

cy,

Non

Ip

Cap

ab

leD

evic

es

??????

??????

??????

Azure IoT Workshop– 13.10.2017

IoTHub messaging protocols

Legacy Protocol

Low resource devices

Intermittent connection

Device location

Azure IoT Workshop– 13.10.2017

IP capable devices

FieldGatewa

y

Device connectivity Data processing and analytics

IT solution backend

Clo

ud

ga

tew

ay

Pre

se

nta

tion

an

dbu

sin

ess

co

nn

ectivity

Existing IoTdevices

Low power devices

Generic IoT Solution

DevicesMonitoring

Control

Azure IoT Workshop– 13.10.2017

IoT Hub

Device id

What is Azure IoTHub

Device

C2D queue

endpoint

D2C send

endpoint

Device …

Device …

Device…

IoT Hub management

Device identity management

D2C receive endpoint

Methods

endpoint

Twin

endpoint

Twins endpoint

Devices Methods endpoint

Custom endpoints

C2D send and feedback endpoints

Event processing(hot and cold path)

Event processing(hot path)

Device management, device business logic,Connectivity monitoring

Device provisioning and authorization

Field GW /Cloud GW

Azure IoT Workshop– 13.10.2017

IoT Hub features

Azure IoT Workshop– 13.10.2017

Azure IoT Workshop– 13.10.2017

Telemetry

sending, acquiring and measuring

data

Event

State (or state event) Message

Azure IoT Workshop– 13.10.2017

IoT Hub

Device id

Send/receive data

C2D queue

endpoint

D2C send

endpoint D2C receive endpoint

C2D send and feedback endpoints

Event processing(hot path)

Device

Client SDKs

• C

• Java

• C# (.Net

Standard

1.3)

• Python

Device management, device business logic,Connectivity monitoring

Client SDKs

• .Net

• Node

• Java

• Python

Azure IoT Workshop– 13.10.2017

Message

Opaque body Application Properties

System Properties

Azure IoT Workshop– 13.10.2017

IoT Hub Device Management

Device Twin Queries

Methods Jobs

Azure IoT Workshop– 13.10.2017

Azure IoT Workshop– 13.10.2017

Structured data

◇Device Twins■Last known state of device

■Desired state configuration

■Group devices

◇Device Direct Methods■Invoke method on device from Cloud

■“Immediate” response

Azure IoT Workshop– 13.10.2017

Azure IoT Workshop– 13.10.2017

Azure IoT Workshop– 13.10.2017

Azure IoT Workshop– 13.10.2017

Querying Device Twins

FROM WHERE

SELECT GROUP BY

Azure IoT Workshop– 13.10.2017

Sample queries

◇Devices located in the US configured to send telemetry less often that every minute

◇Devices which have wifi o wired connectivity

◇Devices where reported and desired properties do not match

Azure IoT Workshop– 13.10.2017

IoT Hub

Structured data

Device

Device management, device business logic,Connectivity monitoring

Device Twin

Properties

Tags

Desired

Reported

Properties

Desired

Reported

Method

Azure IoT Workshop– 13.10.2017

Azure IoT Workshop– 13.10.2017

Where does IoT Hub fit in?

Azure IoT Workshop– 13.10.2017

Functions «lifestyle»

◇Per event handling

◇Stateless processing

◇Binding approach

Azure IoT Workshop– 13.10.2017

IoTHub’s EventHub compatible endpoint

Namespace

Azure IoT Workshop– 13.10.2017

IoTHub’s Security Policies

Security Info

SharedAccessKeyName SharedAccessKey

Azure IoT Workshop– 13.10.2017

EventHub-like connection string

◇Endpoint=<EventHubNamespace>;SharedAccessKeyName=< SharedAccessKeyName>;SharedAccessKey=< SharedAccessKey>■Add EntityPath=<EventHub name> in case of EventHub Security Policy

Azure IoT Workshop– 13.10.2017

EventHub binding

ConnectionStringEventHub name

Azure IoT Workshop– 13.10.2017

Azure IoT Workshop– 13.10.2017

Azure IoT Workshop– 13.10.2017

Where storing a message

Azure Storage

Azure DocumentDb

Azure EventHub

Azure Queue

Azure Service Bus

Azure SQL Database

Azure IoT Workshop– 13.10.2017

Then?

◇The message is stored

◇Storage can be the end of the process

◇Or the beginning of the next step■Intermediate processing (a microservices approach)

■Control/Feedback

◇And you process again in the same way:■EventProcessor

■Azure Stream Analytics

■Azure Function

Azure IoT Workshop– 13.10.2017

Control the devices

◇Cloud-to-device messaging■As needed (twin, message, device method)

◇You need to invoke IoT Hub API■REST APIC# API

■Node.js API

◇Low frequency

◇Function is well suited for this

Azure IoT Workshop– 13.10.2017

Azure IoT Workshop– 13.10.2017

What I choose for my devices?

Azure IoT Workshop– 13.10.2017

Azure IoT Workshop– 13.10.2017

Generate the symmetric key

DEVICE IOT HUB

C:\>az iot device create –hub-name <hubname> --device-id <deviceId>

Azure IoT Workshop– 13.10.2017

All devices have different keys

Device Registry

Azure IoT Workshop– 13.10.2017

Authorization with encryption

Encrypt( , , )=

Azure IoT Workshop– 13.10.2017

Authenticated communication

◇Token based authentication

DEVICE IOT HUB

(TCP endpoint)

TCP Connection

Azure IoT Workshop– 13.10.2017

Key invalidation

DEVICE IOT HUB

Azure IoT Workshop– 13.10.2017

Wrap Up

top related