Steven Edouard SDET, US - DX Audience West Microsoft … - Edouard-Terkaly.pdfBruno Terkaly...
Transcript of Steven Edouard SDET, US - DX Audience West Microsoft … - Edouard-Terkaly.pdfBruno Terkaly...
Bruno Terkaly – Principal Software Engineer - Microsoft
Steven Edouard – SDET, US - DX Audience West – Microsoft
Wafers
CPUs
Memory
The Internet
Mobile
Cloud
Social
(Twitter,
Facebook)
Big Data
IoT
Robotics
Machine Learning
Pro
gre
ss
Time
A prior project with Arduino
Arduino
Sprinkler
Controller
Home Network
Sprinkler
Valve
Linux Virtual
Machine
Python
Admin
WebSite
Background
Process
Mobile
Services
Azure Cloud
National
Weather
Service
http
Service BusData / State
Why Cloud?
Processing lots of
information (sensors,
cameras)
Limited Compute
Power
Limited Battery
Security Issues
Acoustic, sound,
vibration Automotive,
transportation
Chemical
Electric current,
electric
potential,
magnetic, radio
Environment,
weather,
moisture,
humidity
Flow, fluid
velocity
Ionizing
radiation,
subatomic
particles
Navigation
instruments
Position, angle,
displacement,
distance, speed,
acceleration
Optical, light,
imaging,
photon
Pressure
Force, density,
level
Thermal, heat,
temperature
Proximity,
presence
Sensor
technology
Let’s build our own device
Camera
Doorbell
Raspberry PI
Azure is the glue that binds these
devices together
iOS, Android, Windows Phone
You could have a common code base
with Xamarin
System board
A/C adapter
General purpose
input/output (GPIO)
breakout
Breadboard
Breadboard wires
Assorted resisters and
LEDs
One of the core components is the
GPIO breadboard.
The GPIO is a hardware circuit with
26 separate pins (numbered left to
right) that let you expand the
system to interact with other
devices.
Generally, these pins let you
connect such things as sensors,
actuators, LEDs and so on.
There are different types of pins,
though.
Understanding the GPIO
There are two pins providing a
power source for connected
devices, specifically a 3.3 volt and
a 5 volt.
There’s also a 0 volt pin that acts
as a ground, which is necessary
to define a circuit.
If you wish to perform
serial communications,
you’ll find TX and RX
pins (RS-232) for
transmitting and
receiving data.
The software that runs
on the device will need
to communicate with
these pins.
Section 3
SoftwareArchitecture
Queues
Service
Bus
Storage Raspberry
Linux
mono
JavaScript
Node.js
C#
What are the pieces
to the architecture?
Part Cloud,
Part Client Dev
Queues
Service Bus
Storage
Azure for cloud,
Linux for Raspberry
OS, Mono Runtime
Installed
Raspberry Linux
mono
Languages:
C#
JavaScript
Node.js
Service Bus Queues
Queues
MongoDB - MongoLabs
Azure Mobile Services Azure StorageAPI
Notification Hub
Mobile
Uploaded Images
Cloud is ideal for Real-Time
Analysis:
Finding relationships existing
between phenomena or things
or between mathematical or
statistical variables
Results in Alerting,
Limit Detection
Pre-emptive
troubleshooting
Pattern Detection
Behavior Prediction
Plausibility Analysis
Fraud Detection
Time-Series, Map/Reduce
Data Analytics, Machine
Learning
Power and scale of cloud computing
4 Patterns For
Devices To
Communicate With
Cloud
A client device sends data
(one way) to a cloud service.
A client device sends a query
to the cloud service and
receives a response.
A cloud service issues a
command to a client device
and the client device returns
a success or failure response.
A cloud service issues a one-
way out-of-band notification
to a client device that’s
important for the device’s
operation.
Telemetry
Notification
Inquiry
Command
Temperature
Maintenance
required
Turn on
cooling/heating
Go into wait
state
Network Compute Storage
Virtual Machine
Services (Windows,
Linux, etc)
VPN Cloud Storage SQL Hadoop/HDInsight
Web Sites Cloud Services Media Services Active Directory
Multi Factor Auth Mobile Services Service Bus Notification Hub
BizTalk Services
Traffic Manager,
Load Balancing,
Firewall
Node.js, Java, PHP,
Perl, Python, RubyNoSQL
Azure’s many capabilities
Azure Mobile Services
API
1Request SAS
key
Azure Storage
Uploaded Images
Camera
2Receive SAS key
Send SAS key and photo to Azure Storage
3DoorbellRaspberry PI
Linux and Mono
Getting connected directly to storage services
Key Point
Device can talk directly to storage with
HTTP
http ->
Service Bus Queues
Queues
Azure Storage
Uploaded Images Azure Mobile Services
API
Notification Hub
3rd Party Face Recognition API
MongoLab
1)
2)
3)
4) 5)
6)
Why are Service Bus Queues so powerful
Service Bus Queues expose a regular RESTful
API
Allows you to send and receive messages by
long polling
Long polling is an HTTP connection open for a
certain period of time
Long polling is a great technique for IoT
computing scenarios because it supports
timeouts
This allows devices to close the connections
until the next long poll
Provides relief to power consumption and
network resources
Data Storage In the Cloud
Types of data stores in NoSQL world
Key-value stores Azure tables, Redis, DynamoDB
Column Family stores Cassandra, HBASE
Document Store MongoDB, CouchDB
Graph store Neo4J
Various
languages
operate at
different speeds
on Raspberry PI.
We used C#
Python is fairly
slow and you
can’t use it in
scenarios where
speed is crucial
10hz is fast enough to
check if the doorbell
switch has pulled pin22
(connected to doorbell)
When pin22 is true, the
photo taking process starts
in TakeAndSendPicture
Client Code
Code running on Raspberry PI1. Take a photo2. Get the key so we can upload photo3. Upload photo4. Put a message on the queue
C# code running on Mono on Raspberry PI
Do a post to endpoint in cloud
Build “body” part of http post
Skip
Network Connectivity
For many
years, secure
connectivity
meant using
TCP/IP with
IPv4,
combined with
VPNs.
This worked
reasonably
well, but is
now showing
signs of age.
For starters, it’s difficult to
get a unique IP address
We’ve pretty much run out
of IP addresses
Diehard fans have an
answer
IPv6 will come to the rescue
The conventional wisdom is that if you give
the device a unique IP address, all your
difficult problems are solved
Unfortunately, this solves only a small part
of the overall problem
Giving each device its own unique IP
address is definitely not the silver bullet
many had hoped
Just to be clear, IPv6 and VPNs
are fraught with problems in a
crowded, connected-device
world.
Bandwidth, in particular, is a
challenge.
Chatty connectivity between
device and network can lead to
excessive traffic.
Using typical HTTP request/response
approaches for all messaging drains
battery life on many devices
Too many wasteful bytes are sent
This can get prohibitively expensive if
you’re supporting thousands of devices
Imagine your device has to send
temperature data every 5 seconds
The payload for the temperature data
is a generous 20 bytes
In a 24-hour period, the temperature
data by itself would transmit from the
device to the cloud about 350,000
bytes
Now add HTTP
request/response
envelope
HTTP introduces
an extra 800 bytes
This is a factor of
41
Sending more than
14MB to the cloud
instead of just the
350KB of
temperature data.
Not at all if this
device is part of a
VPN
How safe is this
device?
Because it is not under
your immediate
physical control
Once a single device is
breached, all devices
connected to the same
VPN are vulnerable
Using a VPN is largely
equivalent to having a
network adapter on that
network
IPv4, IPv6, and all
protocols that are built
upon them
What is the
preferred
solution?
Microsoft supports
Advanced Message
Queuing Protocol (AMQP)
1.0 was added first in
the Azure Service Bus
(middle of 2013)
AMQP is a binary and bi-
directional open protocol
with support for many
platforms, including
Embedded Linux.
Microsoft works
directly with the
Apache Foundation
contributing to
Apache QPid Proton
Provides message
orientation,
queuing, routing,
pubsub, reliability
and security.
It is very efficient
Advanced Message Queuing Protocol