DevSum'15 : Microsoft Azure and Things

34
#devsum15 Microsoft Azure and Things Thomas Conté Technical Evangelist, Microsoft Azure @tomconte [email protected]

Transcript of DevSum'15 : Microsoft Azure and Things

#devsum15

Microsoft Azure and ThingsThomas Conté

Technical Evangelist, Microsoft Azure

@tomconte [email protected]

Things are the new apps!

Easy development

Readymarket

Low-friction distribution

Enduring relationships

Introduction

Field Gateway

Device Connectivity & Management

IoT Device & Cloud PatternsD

evi

ces

RTO

S, L

inux,

Win

dow

s, A

ndro

id, i

OS

Cloud Gateway

Event Hubs

Field Gateway

Protocol Adaptation

Event Hubs• High scale telemetry ingestion

service• HTTP/AMQP protocol support• Each Event Hub supports

• 1 million publishers• 1GB/s ingress

• Generally available worldwide• 18 Billion messages per day• 60+ TB ingested per day

Field Gateway

Device Connectivity & Management

Analytics & Operationalized Insights

IoT Device & Cloud PatternsD

evi

ces

RTO

S, L

inux,

Win

dow

s, A

ndro

id, i

OS

Protocol Adaptation

Batch Analytics & Visualizations

Azure HDInsight, AzureML, Power BI,

Azure Data Factory

Hot Path Analytics

Azure Stream Analytics, Azure HDInsight Storm

Hot Path Business Logic

Service Fabric & Actor Framework

Cloud Gateway

Event Hubs&IoT Hub

Field Gateway

Protocol Adaptation

Find insights to• Power new services• Improve your

“things”

Operationalize your insights in real timeIoT Scale Object Models & Business Logic

Field Gateway

Device Connectivity & Management

Analytics & Operationalized Insights

Presentation & Business Connectivity

IoT Device & Cloud PatternsD

evi

ces

RTO

S, L

inux,

Win

dow

s, A

ndro

id, i

OS

Protocol Adaptation

Batch Analytics & Visualizations

Azure HDInsight, AzureML, Power BI,

Azure Data Factory

Hot Path Analytics

Azure Stream Analytics, Azure HDInsight Storm

Presentation &

Business Connectivity

App Service, Websites

Dynamics, BizTalk Services, Notification Hubs

Hot Path Business Logic

Service Fabric & Actor Framework

Cloud Gateway

Event Hubs&IoT Hub

Field Gateway

Protocol Adaptation

Microsoft Azure IoT services

Devices Device Connectivity Storage Analytics Presentation & Action

Event Hubs SQL Database Machine Learning App Service

Service Bus Table/Blob Storage

Stream Analytics Power BI

External Data Sources DocumentDB HDInsight Notification

Hubs

External Data Sources Data Factory Mobile

Services

BizTalk Services

{ }

• High scale data ingestion via Event Hub.

• High scale stream processing via Stream Analytics (or HDInsight /Storm)

• Storage for cold-path analytics

• Processing for hot-path analytics

Start the pipeline with Telemetry

Event HubStream Analytics

SQL Blob

• Real-time analytics for Internet of Things solutions• Stream millions of events per second• Mission critical reliability, performance and predictable

results• Rapid development with familiar SQL-based language

Event Hubs and Stream Analytics• Cloud-scale telemetry ingestion from websites, apps,

and devices• Compatible with more than a million publishers

supporting HTTP, AMQP and MQTT• Ingress millions of events per second • SAS based security, with unique token per publisher• Configurable data retention (1-30 days)• Low latency (<10 ms for volatile data)• Pluggable with other cloud services like Stream Analytics

Event Hub

Stream Analytics

IoT Sweet Spot $1000 PCs$400

Phones

• IoT capabilities are primarily value-add to other primary capabilities

• How much computer, storage, and networking circuitry can you add to the BOM for a $40-range retail product for that value-add?

• Tiny devices make awfully vulnerable network servers

Capability constrained devices

Cost

Computational Capabilities

Memory/Storage Capacity

Energy Consumption/Source

$1 Senso

r

$10000

Server

Component Quality

Service Assisted Communication (SAC)

(CG)NATFirewall

Router

Isolated Network

Service Gateway

Client

Port Mapping is automatic, outbound

Device does not actively listen for

unsolicited trafficNo inbound ports

open, attack surface is minimized

Public address, full and well

defendable server platform

Q

Q

Device Identity Registry/Direct

ory

Connections are device-initiated and

outbound

Non-IP

Field Gateway

Access Control Policies

Devices

• Simple MCU-based boards• Arduino Uno, Due ...

• Advanced (MCU-based) boards with networking• Tessel• Arduino Yun ...

• Full computing platform in embedded form factor• Raspberry Pi• BeagleBone Black …

• Back to simple MCU-based boards• Using a more powerful device as a field gateway

Different types of Devices

Simple MCU boards: Arduino

EthernetClient client;const char *server = "arduinouno.azure-mobile.net";if (client.connect(server, 80)) { sprintf(buffer, "POST /tables/%s HTTP/1.1", table_name); client.println(buffer); sprintf(buffer, "Host: %s", server); sprintf(buffer, "X-ZUMO-APPLICATION: %s", ams_key); client.println("Content-Type: application/json"); sprintf(buffer, "{\"value\": %d}", value); client.print("Content-Length: "); client.println(strlen(buffer)); client.println(); client.println(buffer);

Sending data to Azure Mobile Services

Demo

• Arduino Uno• Ethernet Shield• Photoresistor• Analog sound sensor• Send to Mobile Services• Plot using Highcharts

and OData endpoint

Advanced board: Arduino Yun

Process proc;void send_request(int value){ proc.begin("curl"); proc.addParameter("-k"); proc.addParameter("-X"); proc.addParameter("POST"); proc.addParameter("-H"); proc.addParameter("Content-Type:application/json"); proc.addParameter("-H"); proc.addParameter("Authorization:" + sas_key); proc.addParameter("-d"); proc.addParameter("{\"value\":" + String(value) + "}"); proc.addParameter("https://" + server + "/" + hub_name + \ "/publishers/" + device_name + "/messages"); proc.run();

Sending HTTPS data to Event Hubs using cURL

Demo

• Arduino Yun• Built-in Wi-Fi• Sparkfun Weather

Shield• Send telemetry data to

Event Hubs• Temperature• Humidity• Pressure• Light

• Over HTTPS using cURL

Advanced board: Tessel

Sending data to Event Hubs in JavaScript/Nodevar options = {

hostname: namespace + '.servicebus.windows.net', port: 443, path: '/' + hubname + '/publishers/' + devicename + '/messages', method: 'POST', headers: { 'Authorization': my_sas, 'Content-Length': payload.length, 'Content-Type': 'application/atom+xml;type=entry;charset=utf-8' } };   var req = https.request(options, function(res) { res.on('data', function(d) { process.stdout.write(d); }); });

Generating a SAS key

http://eventhubssasgenerator.azurewebsites.net

/

function create_sas_token(uri, key_name, key) { // Token expires in one hour var expiry = moment().add(1, 'hours').unix();   var string_to_sign = encodeURIComponent(uri) + '\n' + expiry; var hmac = crypto.createHmac('sha256', key); hmac.update(string_to_sign); var signature = hmac.digest('base64'); var token = 'SharedAccessSignature sr=' + \encodeURIComponent(uri) + '&sig=' + \encodeURIComponent(signature) + '&se=' \+ expiry + '&skn=' + key_name;   return token; }

Uploading picture directly to Azure Storagefunction upload_picture(name, image) {

var options = { hostname: blob_host, port: 443, path: '/' + blob_container + '/' + name + blob_sas, method: 'PUT', headers: { 'Content-Length' : image.length, 'x-ms-blob-type' : 'BlockBlob', 'Content-Type' : 'image/jpeg' } };   var req = https.request(options, function(res) { res.on('data', function(d) { process.stdout.write(d); }); });

Demo: Face Detection with Project Oxford• Tessel board• Camera module• Takes a picture every

5 sec• Upload the picture to

Azure Blob Storage• Query Project Oxford

Face API, send Blob link

• Get a response back with face attributes like gender and age!

Full board: Raspberry Pi 2

Windows 10 IoT Core preview available for Minnowboard Max and Raspberry Pi 2

Announcing!

www.windowsondevices.com

AMQP over SSL: Proton bindings in Pythonimport sys import commands from proton import *   address = "amqps://send:[email protected]/yun";   # Create Proton objects messenger = Messenger()   # Create AMQP message message = Message()   message.body = sys.argv[1]   message.address = address messenger.put(message) messenger.send()

Sending to Azure from Windows 10address = new Address(sbNamespace, 5671, keyName, keyValue);connection = new Connection(address);session = new Session(connection);sendLink = new SenderLink( session, "send-link:" + entity, entity);var messageValue = Encoding.UTF8.GetBytes(data);// AMQP supports 3 types of body, here we use Data.var message = new Message() { BodySection = \ new Data() { Binary = messageValue } };sendLink.Send(message);

Using AmqpNetLite: http://amqpnetlite.codeplex.com/

• IoT Labs• https://github.com/dx-ted-emea/iot-labs

• ConnectTheDots• https://github.com/MSOpenTech/connectthedots

• IoT samples for Windows 10 on Raspberry Pi 2• https://github.com/ms-iot/samples

• My Blog ;-)• http://hypernephelist.com/

Samples, code, etc.

Even more stuff

• A $50 Lumia 530 has $200 worth of sensors: accelerometer, compass, GPS, light sensor, camera…

• Use your Windows device like a stack of Shields

• Communicate via Bluetooth

• Universal App and sample Arduino sketches

Windows Virtual Shields for Arduino

https://github.com/ms-iot/virtual-shields-arduino/https://github.com/ms-iot/virtual-shields-universal

• Remote control Arduino GPIO, I2C via Bluetooth

• Based on Standard Firmata protocol, available in Arduino examples

• Client implementation for Windows 8, 8.1, 10

Windows Remote Arduino

https://github.com/ms-iot/remote-wiringhttps://github.com/ms-iot/windows-remote-arduino-samples

© 2015 Microsoft Corporation. All rights reserved.