introduction to azure iot
play

Introduction to Azure IoT Pierre Cauchois, Senior Software Engineer, - PowerPoint PPT Presentation

Introduction to Azure IoT Pierre Cauchois, Senior Software Engineer, Microsoft h"p://sched.co/9n2a Agenda How is Microsoft making it easy for embedded systems engineers to connect their things to the cloud? What do


  1. Introduction to Azure IoT Pierre Cauchois, Senior Software Engineer, Microsoft h"p://sched.co/9n2a ¡ ¡

  2. Agenda How is Microsoft making it easy for embedded systems engineers to connect their “things” to “the cloud”? What do you do once the devices are connected?

  3. Part 1: Connecting Devices to the Cloud

  4. Azure ¡IoT ¡Hub ¡ IoT ¡Solu6on ¡& ¡Intelligence ¡ Event ¡processing ¡& ¡Analy6cs ¡ (hot ¡and ¡cold ¡path) ¡ Storage ¡/ ¡Big ¡Data ¡ Business ¡logic, ¡ Machine ¡Learning ¡ Protocol ¡Gateway ¡ Connec6vity ¡monitoring ¡ Dashboards ¡ Device ¡management, ¡provisioning ¡ ¡ and ¡authoriza6on ¡ Field ¡Gateway ¡

  5. Device-facing Endpoints Device ¡ Device ¡ Proper6es ¡ Twin ¡ Methods ¡ Device ¡ D2C ¡ C2D ¡ Twin ¡ Proper6es ¡ Methods ¡ Azure ¡IoT ¡Hub ¡

  6. Backend-Facing Endpoints Azure ¡IoT ¡Hub ¡ IoT ¡Hub ¡ management ¡ ¡ ¡ Telemetry ¡ Commands ¡ Command ¡ Devices ¡ ¡ Device ¡ Opera6ons ¡ (D2C) ¡receive ¡ (C2D) ¡send ¡ feedback ¡ ¡ Methods ¡ management ¡ Monitoring ¡ Twins ¡ Event ¡ ¡ Device ¡ processing ¡ provisioning ¡ ¡ Business ¡logic, ¡ (hot ¡and ¡cold ¡path) ¡ and ¡authoriza6on ¡ Connec6vity ¡monitoring ¡

  7. SDK Supported Platforms • STM32 ¡ ¡ • Android (Java or Xamarin) • TI ¡RTOS ¡ • Arduino • Ubilinux ¡(v3.0) ¡ • Debian Linux (v 7.5) • Ubuntu ¡Linux ¡(v ¡14.04) ¡ • ESP8266 • Windows ¡Desktop ¡(7, ¡8, ¡10) ¡ • Fedora Linux (v 20) • Windows ¡IoT ¡Core ¡(v ¡10) ¡ • FreeRTOS • Windows ¡Server ¡(v ¡2012 ¡R2) ¡ • iOS (Xamarin) • Yocto ¡Linux ¡(v ¡2.1) ¡ • mbed OS (v 2.0) • … ¡and ¡more ¡ • OpenWRT • Raspbian Linux (v 3.18)

  8. SDK Languages C library: Node.js library: Java library: • Microcontrollers ¡ • Node.js ¡(v ¡0.10+) ¡ • Java ¡(v ¡1.7+) ¡ • RTOS ¡ • Node-­‑RED ¡ • Android ¡ • Linux ¡ • Windows ¡ C# libraries supported: Python library: • Windows ¡Desktop ¡(7,8,10) ¡ • v ¡2.7.x ¡ • Universal ¡Windows ¡Plaeorm ¡ • v ¡3.5.x ¡ • Windows ¡10 ¡IoT ¡Core ¡ • Xamarin ¡(iOS, ¡Android) ¡

  9. Getting an SDK • Clone on Github • Look for it on your favoring package manager (npm, maven, nuget, apt … ) • Examples in this presentation will be node.js • https://github.com/azure/azure-iot-sdk-node

  10. Giving the device an identity • Device Identity == Identifier + Secret • Secret: • Symmetric keys stored in the Device Registry + Token generated from this key and used by the device (obviously, the key never travels on the wire) • x509 Certs/Keys on the Device + Certificate Thumbprints in the Device Registry • TPM Support to store secrets h"ps://github.com/Azure/azure-­‑iot-­‑hub-­‑vs-­‑cs/wiki/Device-­‑Provisioning-­‑with-­‑TPM ¡ ¡

  11. Managing Device Identities • Each identity supports 2 keys or 2 cert thumbprints for easy roll- over • Single-device and Bulk APIs to create, update or delete device identities

  12. Giving the Device an Identity Service Device var iothub = require('azure-iothub'); var Protocol = require('azure-iot-device-amqp').Amqp; var connectionString = '[IoT Connection String]'; var Client = require('azure-iot-device').Client; var registry = iothub.Registry.fromConnectionString(connectionString); var connectionString = 'HostName=<hub-name>.azure- devices.net;DeviceId=<some-device-id>;SharedAccessKey=<base64- var device = { /* device description */ }; key>'; registry.create(device, function(err, res) { /* do something with the result */ var client = Client.fromConnectionString(connectionString, Protocol);; }); /* update and delete work the same way */ /* Bulk APIs also available */

  13. Sending a Message (“Telemetry” scenario) Service Device var EventHubClient = require('azure-event-hubs').Client; var client = EventHubClient.fromConnectionString(connectionString); client.open() var message = new Message("foo"); .then(client.getPartitionIds.bind(client)) client.sendEvent(message, function (err, res) {/* deal with result */} ); .then(function (partitionIds) { return Promise.map(partitionIds, function (partitionId) { return client.createReceiver('$Default', partitionId).then(function(receiver) { receiver.on('message', printEvent); }); }); }); h"ps://docs.microsog.com/en-­‑us/azure/iot-­‑hub/iot-­‑hub-­‑devguide-­‑d2c-­‑guidance ¡ ¡

  14. Receiving a Message (“Command” scenario) Service Device var Client = require('azure-iothub').Client; client.on('message', function (msg) { /* do something with the command */ var connectionString = '[IoT Hub Connection String]'; client.complete(msg, function (err, res) { /* We could also “reject” or “abandon” the message */ var client = Client.fromConnectionString(connectionString); /* do something with the result */ client.send(<deviceId>, <message>, function (err, res) { }); /* do something with the result */ }); }); h"ps://docs.microsog.com/en-­‑us/azure/iot-­‑hub/iot-­‑hub-­‑node-­‑node-­‑c2d ¡ ¡

  15. Sending and Receiving Messages • MQTTS (and over Websockets) • AMQPS (and over Websockets) • HTTPS • Protocol Gateway: • https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-protocol-gateway • https://github.com/Azure/azure-iot-protocol-gateway

  16. Routing messages (new!) https://azure.microsoft.com/en-us/blog/azure-iot-hub-message-routing- enhances-device-telemetry-and-optimizes-iot-infrastructure-resources/

  17. Upload large amounts of data at once Service Device client.getFileNotificationReceiver(function(err, receiver) { client.uploadToBlob(<blob_name>,<file_stream>, <file_size>, function (err, result) { receiver.on('message', function(msg) { /* do something with the result */ /* msg contains the file location and a token to access it */ }); receiver.complete(msg, function(err, res) { /* do something */ }); }); }); • https://azure.microsoft.com/en-us/blog/upload-files-from-devices-with-azure-iot-hub/ • https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-file-upload

  18. Execute code on the device and return the result (“Device Methods”) Service Device var methodParams = { client.onDeviceMethod(<method_name>, function (request, response) { methodName: '<Method Name>', /* Do something with the content of the request */ payload: '[Method Payload]', response.send(<status_code>, <payload>, function(err, res) { responseTimeoutInSeconds: 30 //default /* do something with the result */ }; }); client.invokeDeviceMethod(<device_id>, methodParams, function (err, }); res) { /* deal with result */ }); h"ps://docs.microsog.com/en-­‑us/azure/iot-­‑hub/iot-­‑hub-­‑node-­‑node-­‑direct-­‑methods ¡ ¡

  19. Maintain a device state and metadata (“Device Twin”) Service Device registry.getTwin(deviceId, function(err, twin) { client.getTwin(function(err, twin) { var twinPatch = { twin.on('properties.desired', function(delta) { tags: { city: "Redmond“ }, /* Do something with the delta (new property values) */ properties: { desired: { telemetryInterval: 1000 } } }); }; twin.properties.reported.update(patch, function(err) { twin.update(twinPatch, function(err, twin) { /* Do something if that failed */ /* Do something */ }); }); }); }); h"ps://docs.microsog.com/en-­‑us/azure/iot-­‑hub/iot-­‑hub-­‑node-­‑node-­‑twin-­‑getstarted ¡ ¡

  20. Schedule tasks on devices Service Device var Protocol = require('azure-iot-device-amqp').Amqp; /* Same as desired properties update or device method call */ var Client = require('azure-iot-device').Client; var Message = require('azure-iot-device').Message; var client = Client.fromConnectionString(connectionString, Protocol); var message = new Message("foo"); client.sendEvent(message, function (err, res) {/* deal with result */} ); h"ps://docs.microsog.com/en-­‑us/azure/iot-­‑hub/iot-­‑hub-­‑node-­‑node-­‑schedule-­‑jobs ¡ ¡

  21. Query device twins var query = registry.createQuery('SELECT * FROM devices', 100); var onResults = function(err, results) { /* Do something with the results */ if (query.hasMoreResults) { query.nextAsTwin(onResults); } }; query.nextAsTwin(onResults); h"ps://docs.microsog.com/en-­‑us/azure/iot-­‑hub/iot-­‑hub-­‑devguide-­‑query-­‑language ¡ ¡

  22. Monitor Operations and Errors (Service) var EventHubClient = require('azure-event-hubs').Client; var client = EventHubClient.fromConnectionString(connectionString, '/messages/operationsMonitoringEvents/*'); client.open() .then(client.getPartitionIds.bind(client)) .then(function (partitionIds) { return Promise.map(partitionIds, function (partitionId) { return client.createReceiver('$Default', partitionId).then(function(receiver) { receiver.on('message', printEvent); }); }); }); h"ps://docs.microsog.com/en-­‑us/azure/iot-­‑hub/iot-­‑hub-­‑opera6ons-­‑monitoring ¡ ¡

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend