windows 10 iot-core to azure iot suite

89
Windows 10 IoT-Core to Azure IoT Suite David Jones MVP

Upload: david-jones

Post on 16-Jan-2017

407 views

Category:

Technology


5 download

TRANSCRIPT

Page 1: Windows 10 IoT-Core to Azure IoT Suite

Windows 10 IoT-CoretoAzure IoT Suite

David JonesMVP

Page 2: Windows 10 IoT-Core to Azure IoT Suite

[email protected]

@CEDriverWizhttp://embedded101.com/blogs/David-JonesMVP

Page 3: Windows 10 IoT-Core to Azure IoT Suite

Agenda• One Windows • Azure• Windows 10 IoT-Core• Internet of Things• Azure IoT• IoT Hub, Service Bus etc

• Azure IoT Suite

A work in progress

Page 4: Windows 10 IoT-Core to Azure IoT Suite

The journey to one Windows…

IoTHoloLens

Surface Hub

Windows Desktop

Windows Phone

Xbox

ONE CORE OSONE APP PLATFORMONE STOREWindows 10

Page 5: Windows 10 IoT-Core to Azure IoT Suite

on a full range of devices…

Windows 10

Phone Small Tablet2-in-1s

(Tablet or Laptop)Desktops

& All-in-OnesPhablet Large TabletClassic Laptop

XboxIoT

Surface Hub

Holographic

Page 6: Windows 10 IoT-Core to Azure IoT Suite

tuned to each form factor…

One Core OSBase OS

App and Device platformRuntimes and frameworks

Windows for …

Form factor–appropriateshell experience

Device-specific scenario support

Windows for phones

Familiar mobile shellRich telephony

Windows phone app compatibility

Windows for PCs

Familiar desktop shellBroad hardware ecosystem

Windows desktop application compatibility

Windows on Xbox

10’ shell experienceShared gaming experiences

Xbox Onegame and app compatibility

Page 7: Windows 10 IoT-Core to Azure IoT Suite
Page 8: Windows 10 IoT-Core to Azure IoT Suite
Page 9: Windows 10 IoT-Core to Azure IoT Suite
Page 10: Windows 10 IoT-Core to Azure IoT Suite

Windows 10• There is Core functionality

• You just need the Windows 10 SDK• You build a “generic” Universal Windows Platform (UWP) App

and it will run all Windows 10 devices.

• Then there are Platform (SDK) Extensions:• Desktop• Mobile• IoT-Core• Team• Others:

• Xbox• HoloLens

Page 11: Windows 10 IoT-Core to Azure IoT Suite

Add a reference to a Platform Extension SDK

Page 12: Windows 10 IoT-Core to Azure IoT Suite

Platform Extension Runtime Checks• You can provide checks in code when using Extension APIs that

conditionally run code if that platform is present.• “Windows.Foundation.Metadata.ApiInformation” that contains the

following interfaces:• IsApiContractPresent.• IsEnumNameValuePresent.• IsEventPresent.• IsMethodPresent.• IsPropertyPresent.• IsTypePresent.• IsWritablePropertyPresent.

Page 13: Windows 10 IoT-Core to Azure IoT Suite

Validation Code for GPIO

using Windows.Foundation.Metadata;

……if (ApiInformation.IsApiContractPresent

("Windows.Devices.DevicesLowLevelContract", 1)){ //doing something with GPIO}

• Other available contracts :• Windows.Foundation.FoundationContract.• Windows.Foundation.UniversalApiContract.• Windows.Foundation.RemoveFromThisBadContract.

Page 14: Windows 10 IoT-Core to Azure IoT Suite

Windows 10 IoT-Core

Page 15: Windows 10 IoT-Core to Azure IoT Suite

IoT-Core Capabilities and Requirements• Windows 10 IoT has a subset of functionality from Windows 10 desktop but has extra

IO features: • GPIO, Interrupts• I2C, SPI, RS232• Ethernet, WiFi, Bluetooth• There is a set of validated USB devices • There is a reduction in the requirements for storage and memory with 4GB and

512MB/256MB: • Recommended 8G storage (eg on SDCard)• Systems can be headless:

• Headed requires 512MB (Generally uses HDMI or LCD) • Headless only requires 256MB

Page 16: Windows 10 IoT-Core to Azure IoT Suite

IoT-Core App Technology• The main application technology is Universal Apps: • In the headed mode, the standard UAP UI stack is available for fully

interactive apps. • In headless mode, there is no UI stack available and apps are not interactive.

Headless mode apps can be thought of as services.

Page 17: Windows 10 IoT-Core to Azure IoT Suite

IoT-Core Apps• Only one startup app is permitted which becomes the UI. There is no

shell: • The startup app IS the shell.

• Background tasks are supported. • Console apps are supported but without UI and a subset of the

existing Win32API.• There is a tool for checking existing Console Win32 apps for Win32 API

requirements against those available in Win 10 IoT.

Page 18: Windows 10 IoT-Core to Azure IoT Suite

IoT-Core Command line utilities• There is a set of command line OS utilities, for example shutdown.

https://developer.microsoft.com/en-us/windows/iot/win10/tools/commandlineutils• Examples:

• Task scheduler:• To view the current list of scheduled tasks, use the schtasks.exe command. You can create new tasks with the /create switch or

run on-demand tasks with the /run switch. For a full list of supported parameters, use schtasks.exe /?• Device drivers:

• The device console utility is useful in identifying and managing installed devices and drivers. For a full list of parameters, use devcon.exe /?

• Registry Access:• If you need to access the registry to view or modify settings, use the reg.exe /? Command for the full list of supported parameters

• In the default startup app there a command line pane• Requires enabling

• Can be actioned remotely• We want large scale manageability though

Page 19: Windows 10 IoT-Core to Azure IoT Suite

IoT-Core Remote Access• Can access remotely to action command line utilities.

• PowerShell• SSH not Telnet• Windows 10 IoT Remote Client (Like Remote Desktop)

• Use the Command line pane

• Device Manager• This is available for most Windows 10 devices• Is a web service on the device for remote management• Note for IoT-Core uses port 8080. eg http://minwinpc:8080

• Also• Remote File Share• FTP

Page 20: Windows 10 IoT-Core to Azure IoT Suite

IoT-Core Unavailable APIs• Many APIs are not available because• Hardware would not be on these devices: eg Phone functionality• To complex• Doesn’t make sense for a dedicated, single purpose device• Just isn’t available, eg Popups

• See• For universal code need to make these API calls conditional on not

being an IoT device• Eg Popups were originally just ignored, whereas in the public release they

generate an error.

Page 22: Windows 10 IoT-Core to Azure IoT Suite

IoT-Core Supported Peripherals• A broad subset of Windows 10 desktop peripherals• If it runs on the desktop it possibly runs under IoT-Core

• Though might need ARM driver version ( cf x86)

• The are some Iot-Core specific peripherals that are supported (eg Sensors)• Lost of “Hats”

• Also others can be added if compatible using the devcon utility.• https://developer.microsoft.com/en-us/windows/iot/win10/supporte

dinterfaces

Page 23: Windows 10 IoT-Core to Azure IoT Suite

FEZ HATGrovePi+ Board

DHT11 temperature and humidity sensor

IoT Sensor Boards

Grove Starter Kit for 96Boards(Dragonboard 410c)

Page 24: Windows 10 IoT-Core to Azure IoT Suite

Developing for Windows 10 IoT-Core• Visual Studio 2015 with latest Update (2 or 3)

• Community Edition is OK• Windows 10 SDK (Latest)• OS Image installed on device (Latest)

• Windows 10 IoT Dashboard• Window 10 IoT Remote Client

• Getting started:• https://developer.microsoft.com/en-us/windows/iot

• Docs:• https://developer.microsoft.com/en-us/windows/iot/Docs

• Samples on GitHub• https://github.com/ms-iot/samples

Page 25: Windows 10 IoT-Core to Azure IoT Suite

Internet of ThingsIoT

Page 26: Windows 10 IoT-Core to Azure IoT Suite

What is the Internet of Things?• The seamless interconnection of spatially spread heterogeneous

devices via the cloud• Devices collect and transmit data.• The cloud stores, analyzes and disseminates the raw and processed data• Devices respond to the data.

• Other• Heterogeneous connectivity/protocols• Heterogeneous device OSs.

Page 27: Windows 10 IoT-Core to Azure IoT Suite
Page 28: Windows 10 IoT-Core to Azure IoT Suite

IoT Device Communication Patterns

1:N 1:N

CLOUD

Telemetry

Information flowing from device to system

conveying device state

Commands

Commands from system to a device or

device group to perform specific

action

Rules

Simple if then conditional command

sequences that provide edge intelligence to

devices and gateways

Alarms

State based notifications from

devices or cloud sent back to devices

Page 29: Windows 10 IoT-Core to Azure IoT Suite

IoT: Extracting insights thru Analytics

Descriptive analytics

• Summarize and tell what happened

• Starts with Exploratory Data Analysis (usually creates more questions than answers)

• Descriptive statistics (i.e. counts, sums, averages, percentages, min, max and simple arithmetic: + − × ÷)

• Summarizes certain groupings or filtered versions of data

Predictive analytics

• Summarize and tell what could happen

• Focused on using data you have to predict data that you don’t have

• Predictive analytics are not limited to the time domain ( e.g. fraud detection)

Prescriptive analytics

• Summarize predictions of what will happen based on a model

• Ability to take actions based on the predicted outcome of the model (usually in an automated way)

• Has a feedback system that collects data for each type of action

Page 30: Windows 10 IoT-Core to Azure IoT Suite
Page 31: Windows 10 IoT-Core to Azure IoT Suite
Page 32: Windows 10 IoT-Core to Azure IoT Suite
Page 33: Windows 10 IoT-Core to Azure IoT Suite
Page 34: Windows 10 IoT-Core to Azure IoT Suite
Page 35: Windows 10 IoT-Core to Azure IoT Suite
Page 36: Windows 10 IoT-Core to Azure IoT Suite
Page 37: Windows 10 IoT-Core to Azure IoT Suite
Page 38: Windows 10 IoT-Core to Azure IoT Suite
Page 39: Windows 10 IoT-Core to Azure IoT Suite

IoT Systems , what we want:• Simplicity• Manageability• Deployment & Updates• Monitoring and fixes

• Scalability• Extensibility• Reliability• Analytics• Security

Page 40: Windows 10 IoT-Core to Azure IoT Suite

The Cloud: Azure• Devices direct data to and consume data from the cloud.• Sensors and actuators

• Use• SQL data bases hosted on Azure directly• Azure Web Services etc• Azure Storage• Azure Mobile Services• Azure Cloud Services• etc

Page 41: Windows 10 IoT-Core to Azure IoT Suite

Single Device: Azure Mobile Services• Arduino device uploading sensor data to Azure Mobile Service V1&2

• https://ardjson.codeplex.com/• Windows Embedded Compact Version: https://cejson.codeplex.com/

• Mobile Service 1&2 • 1 uses integer ID, 2 uses Guid ID• Simple as you pass data as JSON• Has a backend SQL database• But a Mobile Service uses unstructured tables

• If a new field is present in a record, it just adds it to the table’s fields• Can add some service side scripts to process data coming in and out

• Eg Add a DateTime stamp• Hard to do any complex processing

• Azure App Services are now recommended

Page 42: Windows 10 IoT-Core to Azure IoT Suite

Single Device: Azure Mobile Services• Arduino device uploading sensor data to Azure Mobile Service V1&2

• https://ardjson.codeplex.com/• Windows Embedded Compact Version: https://cejson.codeplex.com/

• Mobile Service 1&2 • 1 uses integer ID, 2 uses Guid ID• Simple as you pass data as JSON• Has a backend SQL database• But a Mobile Service uses unstructured tables

• If a new field is present in a record, it just adds it to the table’s fields• Can add some service side scripts to process data coming in and out

• Eg Add a DateTime stamp• Hard to do any complex processing

• Azure App Services are now recommendedLim

ited scalability

,

manageability ..

Page 43: Windows 10 IoT-Core to Azure IoT Suite

Azure IoT

Page 44: Windows 10 IoT-Core to Azure IoT Suite
Page 45: Windows 10 IoT-Core to Azure IoT Suite

Azure IoT Hub

Page 46: Windows 10 IoT-Core to Azure IoT Suite

IoT HubAzure IoT Hub is a fully managed service that enables reliable and secure bidirectional communications between millions of IoT devices and a solution back end. Azure IoT Hub:• Provides reliable device-to-cloud and cloud-to-device messaging at scale.• Enables secure communications using per-device security credentials and

access control.• Provides extensive monitoring for device connectivity and device identity

management events.• Includes device libraries for the most popular languages and platformsRef: What is IoT Hub?

Page 47: Windows 10 IoT-Core to Azure IoT Suite
Page 48: Windows 10 IoT-Core to Azure IoT Suite

IoT Hub Features• Per-device authentication and secure connectivity..• Monitoring of device connectivity operations..• An extensive set of device libraries.

• Azure IoT device SDKs • Variety of languages and platforms• Managed languages, such as C#, Java, and JavaScript.

• Scalability• Azure IoT Hub scales to millions of simultaneously connected devices• And millions of events per second.

• IoT protocols and extensibility. • Use the device libraries, • Enables devices to natively use the MQTT v3.1.1, HTTP 1.1, or AMQP 1.0 • Can extend IoT Hub to provide support for custom protocols using Gateways

Page 49: Windows 10 IoT-Core to Azure IoT Suite

Communication Patterns• Event-based device-to-cloud.

• Can process events immediately• Store for analysis• Retains event data for up to 7 days

• Reliable cloud-to-device messaging (or commands). The solution back end • Can use IoT Hub to send messages with an at-least-once delivery guarantee to individual

devices. • Time-to-live setting• Back end can request both delivery and expiration receipts.

• Upload files and cached sensor data to the cloud. • Devices can upload files to Azure Storage using by IoT Hub.• The Hub can generate notifications when files arrive in the cloud to enable the back end to

process them

Page 50: Windows 10 IoT-Core to Azure IoT Suite

Gateways• Protocol Gateway• In cloud• Convert between devices’ protocols and that of the Hub

• Eg MQTT to AMQP

• Field Gateway• Locally in region of devices• Run analytics on the edge• Make time-sensitive decisions that can reduce latency• Provide device management services• Enforce security and privacy constraints• Can also perform protocol translation.

Page 51: Windows 10 IoT-Core to Azure IoT Suite
Page 52: Windows 10 IoT-Core to Azure IoT Suite

Microsoft Azure IoT Hub S3 edition generally available Pricing | Azure IoT Hub webpage Microsoft Azure IoT Hub S3 addresses enterprise scenarios where you have a large number of devices that generate large amounts of data and must transmit messages frequently. Each unit of the S3 edition lets you transmit up to 300 million messages per day. Azure IoT Hub S3 is the fourth edition in the Azure IoT Hub family; the others are Free, S1, and S2.

Announcement (7/7/16):

Page 53: Windows 10 IoT-Core to Azure IoT Suite

Azure IoT Hub Pricing ($A US East Coast)

Edition Type Price (per month) Total number of Messages/day Message meter size

Free Free 8,000 0.5 KBS1 $63.69 400,000 4 KBS2 $636.85 6,000,000 4 KBS3 $6,368.50 300,000,000 4 KB

See number of Hubs per subscription later: Eg Free = 1

Page 54: Windows 10 IoT-Core to Azure IoT Suite

Azure Service Bus

Page 55: Windows 10 IoT-Core to Azure IoT Suite

Service Bus Communication Mechanisms• Queues

• one-directional communication. • Each queue acts as an intermediary (sometimes called a broker) • Stores sent messages until they are received. • Each message is received by a single recipient.

• Topics, • One-directional communication • Using subscriptions-a single topic can have multiple subscriptions. • Like a queue, a topic acts as a broker, but each subscription• Can optionally use a filter to receive only messages that match specific criteria.

• Relays, which provide • Bi-directional communication. Unlike queues and topics, a relay • Doesn't store in-flight messages-it's not a broker. • Just passes them on to the destination application.

• Event Hubs• Provide event and telemetry ingress to the cloud at massive scale• Low latency and high reliability.

Page 56: Windows 10 IoT-Core to Azure IoT Suite
Page 57: Windows 10 IoT-Core to Azure IoT Suite

Relay

Queue Topic

Page 58: Windows 10 IoT-Core to Azure IoT Suite

Service Bus Consumer Group• Allows several applications to independently read data from an IoT

Hub

Page 59: Windows 10 IoT-Core to Azure IoT Suite

Service Bus Messaging:Queue v Topic Patterns

Ref: http://microsoftintegration.guru/2015/03/03/azure-event-hubs-vs-azure-messaging/

Page 60: Windows 10 IoT-Core to Azure IoT Suite

Service Bus Event Hub• Multiple Consumers• Read at own rate

• Ie. at different parts of stream

Ref: http://microsoftintegration.guru/2015/03/03/azure-event-hubs-vs-azure-messaging/

Page 61: Windows 10 IoT-Core to Azure IoT Suite

Event Hubs v Service Bus Messaging• Message Retention

• SB Messaging: Live until it is consumed, expires and the queue exists• Event Hub: All messages are live for 7 days

• Messaging: • Peek/lock/delete

• Event Hub:• Receiver does not remove messages from the stream • Manages its own pointer to where it is reading in the queue

• Scale up in SB Messaging by having competing Consumer groups.• One group will consume the msg• With Event Hub have multiple partitions with one processor per partition

• Messaging: • Can replay messages as they aren’t removed from stream when “consumed”• Event Hub: You can randomly change index of msg being examined

• Errant msgs can be removed by an agent in SB Messaging • Not in Event Hub• Replay will give it again

Page 62: Windows 10 IoT-Core to Azure IoT Suite

Provisioning IoT Hub

Page 63: Windows 10 IoT-Core to Azure IoT Suite
Page 64: Windows 10 IoT-Core to Azure IoT Suite

The Uri

Page 65: Windows 10 IoT-Core to Azure IoT Suite
Page 66: Windows 10 IoT-Core to Azure IoT Suite
Page 67: Windows 10 IoT-Core to Azure IoT Suite

Provision a Consumer Group:powerbi

Page 68: Windows 10 IoT-Core to Azure IoT Suite

Registering a Device

Page 69: Windows 10 IoT-Core to Azure IoT Suite

Device Registration• A Device needs to be registered to communicate with IoT Hub

• To authenticate the device• To communicate securely

• Can be done in a number of ways:• Using Device Explorer• Command Line iothub-explorer• Using Device Portal• (Coming) IoT Dashboard (New version later this month, Sh!)• Connected Service for Azure IoT Hub: Visual Studio Add-In

• Can be implemented in two ways• Using Connection String and Device ID

• Embedded in application• Using TPM

• An API to get credentials on device

Page 70: Windows 10 IoT-Core to Azure IoT Suite

Using Device Explorer• Manage devices connecting to your IoT hub.

• Can register a device with your IoT hub, • Monitor messages devices• Send messages to devices

• UI Version:• Prebuilt:

https://github.com/Azure/azure-iot-sdks/releases/download/2016-06-30/SetupDeviceExplorer.msi• Source: https://github.com/Azure/azure-iot-sdks/tree/master/tools/DeviceExplorer• Command line version discussion here:

• https://blogs.windows.com/buildingapps/2015/12/09/windows-iot-core-and-azure-iot-hub-putting-the-i-in-iot/

• On Management tab you Create a new Device Registration• You create the Device ID

• You want the Connection string and Primary Key• Collect all data and save to Notepad (Right click

Page 71: Windows 10 IoT-Core to Azure IoT Suite

Using Device Explorer

Page 72: Windows 10 IoT-Core to Azure IoT Suite

Command line: iothub-explorer• Run admin command prompt after installediothub-explorer <Hub connection string> create <deviceID

Page 73: Windows 10 IoT-Core to Azure IoT Suite

Using Device Portal• Only works on latest

versions of IoT-Core• Run web browser

http://minwinpc:8080• Choose TPM tab

Page 74: Windows 10 IoT-Core to Azure IoT Suite

Using IoT Dashboard (Coming)

Page 75: Windows 10 IoT-Core to Azure IoT Suite

Connected Services Option• Create a new UWP project.• Right click on Services• Selected add Connected Service• Choose Azure IoT Hub• Adds AzureIoTHub class with two methods:

• To send messages to the IoT Hub • SendDeviceToCloudMessageAsync()

• To start listening to messages from the IoT Hub• ReceiveCloudToDeviceMessageAsync()

• When creating service have two options• Use connection string• Use TPM (AzureIoTHub method on next page was for TPM)

Page 76: Windows 10 IoT-Core to Azure IoT Suite

public static async Task SendDeviceToCloudMessageAsync() { TpmDevice myDevice = new TpmDevice(0); //Use logical device 0 on the TPM string hubUri = myDevice.GetHostName(); string deviceId = myDevice.GetDeviceId(); string sasToken = myDevice.GetSASToken();

var deviceClient = DeviceClient.Create( hubUri, AuthenticationMethodFactory. CreateAuthenticationWithToken(

deviceId, sasToken), TransportType.Amqp);

var str = "Hello, Cloud from a secure C# app!";var message = new Message(Encoding.ASCII.GetBytes(str));

await deviceClient.SendEventAsync(message); }

Page 77: Windows 10 IoT-Core to Azure IoT Suite

Hub Registered Devices on Azure Portal

Page 78: Windows 10 IoT-Core to Azure IoT Suite

Demo: UWP Hub Registered App

https://github.com/djaus2/AzureHubRegisterIoT

Page 79: Windows 10 IoT-Core to Azure IoT Suite

Stream Analytics

Page 80: Windows 10 IoT-Core to Azure IoT Suite

Stream Analytics• You stream data to hub as Json or CSV data• You create a new Stream Analytics Job (In Classic Portal ??)• This includes creating an SQL query for the data stream• Get started with Azure Stream Analytics to process data from IoT de

vices

Page 81: Windows 10 IoT-Core to Azure IoT Suite

PowerBICan consume the Stream

Page 82: Windows 10 IoT-Core to Azure IoT Suite

Azure IoT Suite

Page 83: Windows 10 IoT-Core to Azure IoT Suite

About• You can bolt together your IoT solution

• Using custom devices,

• Creating:• IoT Hubs• Service Buses• Stream Analytics• PowerBI etc.

• Engineering your own• Deployment• Monitoring• Maintainence• Scalabilty etc.

• Or use a preconfigured solution: Azure IoT Suite

Page 84: Windows 10 IoT-Core to Azure IoT Suite

Azure IoT Suite• Collect data from devices• Analyse data streams in-motion• Store and query large data sets• Visualize both real-time and historical data• Integrate with back-office systems

Azure IoT Suite packages together Azure IoT services with preconfigured solutions. These preconfigured solutions

Page 85: Windows 10 IoT-Core to Azure IoT Suite

Azure IoT services in Azure IoT SuiteThe preconfigured solutions typically use the following services:• Azure IoT Hub service (the core)

• Provides the device-to-cloud and cloud-to-device messaging capabilities and acts as the gateway to the cloud and the other key IoT Suite services. The service enables you to receive messages from your devices at scale, and send commands to your devices.

• •Azure Stream Analytics • provides in-motion data analysis. IoT Suite leverages this service to process incoming telemetry, perform aggregation, and

detect events. The preconfigured solutions also use stream analytics to process informational messages that contain data such as metadata or command responses from devices. The solutions use Stream Analytics to process the messages from your devices and deliver those messages to other services.

• Azure Storage and Azure DocumentDB • Provide the data storage capabilities. The preconfigured solutions use blob storage to store telemetry and to make it

available for analysis. The solutions use DocumentDB to store device metadata and enable the device management capabilities of the solutions.

• Azure Web Apps and Microsoft Power BI• Provide the data visualization capabilities. The flexibility of Power BI enables you to quickly build your own interactive

dashboards that use IoT Suite data

Page 86: Windows 10 IoT-Core to Azure IoT Suite

IoT Suite Preconfigured Solutions• Predictive maintenance• Anticipate maintenance needs and avoid unscheduled downtime by

connecting and monitoring your devices for predictive maintenance

• Remote monitoring• Connect and monitor your devices to analyse untapped data and improve

business outcomes by automating processes.

• https://www.azureiotsuite.com/

Page 87: Windows 10 IoT-Core to Azure IoT Suite
Page 88: Windows 10 IoT-Core to Azure IoT Suite

Coming

Page 89: Windows 10 IoT-Core to Azure IoT Suite

[email protected]

@CEDriverWizhttp://embedded101.com/blogs/David-JonesMVP