Melbourne Azure Meetup presentation 1r4 July 2016
- Windows 10 IoT-Core details
- Internet of Things features
- Azure IoT Hub details
- Into to Azure IoT Suite and SDKs
5. Windows 10
Phone Small Tablet
2-in-1s
(Tablet or Laptop)
Desktops
& All-in-OnesPhablet Large Tablet
Classic
Laptop
Xbox
IoT
Surface Hub
Holographic
6. One Core OS
Base OS
App and Device platform
Runtimes and frameworks
Windows
for …
Form factor–appropriate
shell experience
Device-specific scenario
support
Windows
for phones
Familiar mobile shell
Rich telephony
Windows phone app
compatibility
Windows
for PCs
Familiar desktop shell
Broad hardware ecosystem
Windows desktop application
compatibility
Windows
on Xbox
10’ shell experience
Shared gaming experiences
Xbox One
game and app compatibility
7.
8.
9.
10. 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
12. 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.
13. 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.
15. 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
16. 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.
17. 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.
18. 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
19. 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
20. 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.
21. IoT-Core Supported Devices
• ARM
• Raspberry Pi 2b and Raspberry PI 3
• Dragonboard 410C
• X86
• Minnowboard Max
• Others (not directly supported by Microsoft)
• Toradex Colibri T30 (Nvidia COU)
Is Certified for IoT though
22. 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/supportedinterfaces
23. FEZ HAT
GrovePi+ Board
DHT11 temperature
and humidity sensor
IoT Sensor
Boards
Grove Starter Kit for 96Boards
(Dragonboard 410c)
24. 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
26. 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.
27.
28. 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
29. 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
30.
31.
32.
33.
34.
35.
36.
37.
38.
39. IoT Systems , what we want:
• Simplicity
• Manageability
• Deployment & Updates
• Monitoring and fixes
• Scalability
• Extensibility
• Reliability
• Analytics
• Security
40. 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
41. 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
42. 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
46. IoT Hub
Azure 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 platforms
Ref: What is IoT Hub?
47.
48. 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
49. 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
50. 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.
51.
52. 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):
53. 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 KB
S1 $63.69 400,000 4 KB
S2 $636.85 6,000,000 4 KB
S3 $6,368.50 300,000,000 4 KB
See number of Hubs per subscription later: Eg Free = 1
55. 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.
58. Service Bus Consumer Group
• Allows several applications to independently read data from an IoT
Hub
59. Service Bus Messaging:
Queue v Topic Patterns
Ref: http://microsoftintegration.guru/2015/03/03/azure-event-hubs-vs-azure-messaging/
60. 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/
61. 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
69. 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
70. 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
75. 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)
76. 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);
}
80. 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
devices
83. 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
84. 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
85. Azure IoT services in Azure IoT Suite
The 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
86. 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/