2018 Ukraine
Device Twins, Digital Twins
and Device Shadow
Estelle Auberix
IT Consultant (Cloud, Cyber Security, IoT)
MS MVP Azure
2 0 1 8 U k r a i n e
@FollowEstelle
2018 Ukraine
About Speaker
• Estelle Auberix
• IT Consultant (Cloud, Cyber Security, IoT)
Practice Manager (Cyber Security / Robotic)
MVP Azure
• Contact
• @FollowEstelle
@FollowEstelle 2
2018 Ukraine
Agenda
• Device Twins
• Azure vs. AWS
• Resume
• New in Azure
• Back to the Future
Topic
Protocols
SDK
Security
Authentication
Communication
Pricing
@FollowEstelle 3
2018 Ukraine
1 - Device Twins
@FollowEstelle 4
2018 Ukraine
Device Twins
JSON documents
-> store device state information
including metadata, configurations, and conditions.
@FollowEstelle 5
2018 Ukraine
What for?
• Store device-specific metadata in the cloud
• Report current state information such as available capabilities and
conditions from your device app
• Synchronize the state of long-running workflows between device
app and back-end app
• Query your device metadata, configuration, or state
@FollowEstelle 6
2018 Ukraine
2 – Azure vs. AWS
@FollowEstelle 7
2018 Ukraine
Focus
• Azure IoT Hub
• AWS Device Shadows
@FollowEstelle 8
2018 Ukraine
Structure of the Device
• High Level Concept
• Device Description
• Device Model
• Properties
• Actions
• Events
• Serialization format
@FollowEstelle 9
2018 Ukraine
Microsoft Azure IoT Hub – Device Twins
• Microsoft’ Device Twin is an abstraction of a device state using properties and
a set of tags, containing metadata values
• Actions and events are not of the model, but are handled by application code
• Messages are rather lightweight and the content can be selected by the
application down to property level
• /! The format of the messages is defined by applications only
• The Device Twin model does not define a ‘template’ or a mechanism to
aggregate multiple devices into a combined device model
@FollowEstelle 10
2018 Ukraine
Microsoft Azure IoT Hub – Cloud
@FollowEstelle 11
2018 Ukraine
Microsost Azure IoT Hub – Edge/Cloud
@FollowEstelle 12
2018 Ukraine
AWS IoT Device Shadows
• Enable Internet-connected devices to connect to the AWS Cloud
and let application in the cloud interact with internet-connected
devices
• Devices report their state by publishing messages in JSON format
on MQTT topics
• /! Each MQTT topic has a hierarchical name that identifies the
device whose state is being updated
@FollowEstelle 13
2018 Ukraine
AWS IoT Device Shadows – Cloud
@FollowEstelle 14
2018 Ukraine
Microsoft’s Device Twin = JSON file
• Tags: a section where the solution back-end has access to
• Properties: Used to synchronize device configuration or conditions
• All property values can be of the following JSON type: Boolean,
number, string, object
• /! Arrays are not allowed in Azure but there are in AWS
@FollowEstelle 15
2018 Ukraine
3 kinds of properties
• Desired properties: can be set by the solution back-end and read
by the device app
• Reported properties: The device app can set reported properties
and the solution back-end can read and query them
• Device identity properties: The root of the Device Twin JSON file
contains the read-only properties from the corresponding device
identity stored in the identity registry
@FollowEstelle 16
2018 Ukraine
The AWS Thing is a Device Model
• AWS IoT provides a registry to manage Things
• A Thing is a representation of a specific device or logical entity
{
"version": 3,
"thingName": "MyLightBulb",
"defaultClientId": "MyLightBulb",
"thingTypeName": "LightBulb",
"attributes": {
"model": "123",
"wattage": "75"
}
}
@FollowEstelle 17
2018 Ukraine
AWS Thing types
• Thing types: store description and configuration information that
is common for all things associated with the same thing type
• Thing groups: allow to manage several things at once
• /! Groups can also contain groups
@FollowEstelle 18
2018 Ukraine
Actions (Microsoft & AWS)
Actions do not correspond
to a formal description in the JSON file, but are modelled
via posting of a payload to a ‘method’ endpoint
@FollowEstelle 19
2018 Ukraine
Events
There is no dedicated event mechanism.
@FollowEstelle 20
2018 Ukraine
Serialization formats Comparison
{
"deviceId": "devA",
"moduleId": "moduleA",
"etag": "AAAAAAAAAAc=",
"status": "enabled",
"statusReason": "provisioned",
"statusUpdateTime": "0001-01-
01T00:00:00",
"connectionState": "connected",
"lastActivityTime": "2015-02-
30T16:24:48.789Z",
"cloudToDeviceMessageCount": 0,
"authenticationType": "sas",
"x509Thumbprint": {
"primaryThumbprint": null,
"secondaryThumbprint": null
},
"version": 2,
"tags": {
"$etag": "123",
"deploymentLocation": {
"building": "43",
"floor": "1"
}
},
"properties": {
"desired": {
"telemetryConfig": {
"sendFrequency": "5m"
},
"$metadata" : {...},
"$version": 1
},
"reported": {
"telemetryConfig": {
"sendFrequency": "5m",
"status": "success"
}
"batteryLevel": 55,
"$metadata" : {...},
"$version": 4
}
}
}
{
"version": 3,
"thingName": "MyLightBulb",
"defaultClientId": "MyLightBulb",
"thingTypeName": "LightBulb",
"attributes": {
"model": "123",
"wattage": "75"
}
}
{
"state": {
"desired": {
"attribute1": integer2,
"attribute2": "string2",
...
"attributeN": boolean2
},
"reported": {
"attribute1": integer1,
"attribute2": "string1",
...
"attributeN": boolean1
}
}
"clientToken": "token",
"version": version
}
2018 Ukraine
SDKs
Azure
• IoT device SDKs (.NET, C, Java,
NodeJS, Python, iOS)
• IoT service SDKs (.NET, C, Java,
NodeJS, Python, iOS)
• Device provisioning SDKs (C, C#,
Java, NodeJS, Python)
-> GitHub
AWS
• AWS Mobile SDK for Android
• Arduino Yún SDK
• AWS IoT Device SDK for Embedded
C
• AWS IoT C++ Device SDK
• AWS Mobile SDK for iOS
• AWS IoT Device SDK for Java
• AWS IoT Device SDK for JavaScript
• AWS IoT Device SDK for Python
2018 Ukraine
Protocols in Azure
• AMQP 1.0 is already the official supported protocol for all Azure
services
• MQTT 3.1.1 but provides a simple programming model for building
protocol adapters for other protocols
• HTTPS
• additional protocols using the Azure IoT Protocol Gateway framework
• Look at the Microsoft partnerships
(PTC for useful connectors for example)
@FollowEstelle 23
2018 Ukraine
Protocols in AWS
• MQTT 3.1.1 is the official supported protocol
• /! The broker doesn’t support retained messages, persistent
sessions and QoS level 2
• HTTP protocol is supported but it’s limited to publish messages
using a REST API (POST method only)
@FollowEstelle 24
2018 Ukraine
Security in Azure
@FollowEstelle 25
2018 Ukraine
Microsost Azure IoT Hub – Edge/Cloud
@FollowEstelle 26
2018 Ukraine
AWS IoT Device Shadows – Cloud
@FollowEstelle 27
2018 Ukraine
Security in AWS
@FollowEstelle 28
2018 Ukraine
3 – Summary
@FollowEstelle 29
2018 Ukraine
Summary
• AWS and Azure only define a data model, no actions and events
• None of the serialization formats are uniformized
• None of the formats defines a protocol binding
• A device manufacturer, who wants to address these platforms, has
to create code for both diferrent environments
A unified device model will simplify the integration tasks across
different platforms and will accelerate IoT market adoption.
@FollowEstelle 30
2018 Ukraine
Summary
@FollowEstelle 31
Topic Azure IoT Hub Amazon AWS IoT
Protocols HTTPS, AMQP, MQTT, custom ones
(using protocol gateway)
HTTP, HTTPS, MQTT
SDKs .NET, UWP, Java, C, C#, NodeJS,
Python, iOS (CocoaPod)
C, NodeJS, Java, Python, iOS
Security TLS (Server authentication only) TLS (Mutual authentication)
Authentication Token bas (SAS) per device, X.509
device certificate
X.509 client authentication, IAM
service, Cognito Service
Communication Command based, telemetry Command based (state), telemetry
Pricing Per IoT Hub unit combined with
number of devices and messages
per day
Per number of messages (traffic)
to/from device
2018 Ukraine
4 – New in Azure
@FollowEstelle 32
2018 Ukraine
Azure Digital Twins
• Twin object models
• Spatial intelligence graph
• Advanced compute capabilities
• Data isolation via multi- and nested-tenancy capabilities
• Security through access control and Azure AD
• Integration with Microsoft services
@FollowEstelle 33
2018 Ukraine
Digital Twins object models
• Spaces
• Devices
• Sensors
• Users
Other categories:
Resources, Extended Types, Ontologies, Property Keys and Values,
Roles/Roles Assignments, Security Key Stores, UDFs, Matchers,
Endpoints
@FollowEstelle 34
2018 Ukraine
Spatial intelligence graph
• Managed with a collection of REST APIs
• Devices are provisioned with the Device API
• https://github.com/Azure-Samples/digital-twins-samples-csharp
@FollowEstelle 35
2018 Ukraine
Digital Twins
@FollowEstelle 36
2018 Ukraine
5 – Back to the Future
@FollowEstelle 37
2018 Ukraine @FollowEstelle 38
2018 Ukraine
Find ressources
@FollowEstelle 39
2018 Ukraine
Azure IoT
• https://code.visualstudio.com/download
• https://azure.microsoft.com/en-us/services/iot-hub/
• https://azure-samples.github.io/iot-devkit-web-simulator/
• https://azure-samples.github.io/raspberry-pi-web-simulator/#Getstarted
• https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-device-twins
• https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-node-node-twin-
getstarted
• https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-node-node-module-twin-
getstarted
• https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-node-node-device-
management-get-started
• https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/iot-hub/iot-
hub-devguide-device-twins.md
• https://docs.microsoft.com/en-us/azure/digital-twins/concepts-objectmodel-
spatialgraph
• https://docs.westcentralus.azuresmartspaces.net/management/swagger/ui/index
@FollowEstelle 40
2018 Ukraine @FollowEstelle 41
Where are the instructions?
https://aka.ms/ms-docs
 docs.microsoft.com is new the platform hosting Microsoft technical documentation
 Content is Open Source(*), Hosted on GitHub, Community-enabled + in your own
language!
 So YOU can help the community of users Worldwide to get a better experience by
improving the Docs, and grow your reputation online!!
Discover how here https://aka.ms/intldocs
2018 Ukraine
Help the Community to get them in your
language today!
VS Code SQL on Linux
Team Explorer Everywhere
… and more!
Do you like Open Source?
https://aka.ms/msossloc
2018 Ukraine
AWS IoT
• https://docs.aws.amazon.com/iot/latest/developerguide/what-is-
aws-iot.html
• https://hub.packtpub.com/build-an-iot-application-with-aws-iot-
tutorial/
• https://docs.aws.amazon.com/iot/latest/developerguide/iot-
device-shadows.html
• https://docs.sumerian.amazonaws.com/tutorials/create/intermedi
ate/iot-thing-shadow-script/
@FollowEstelle 43
2018 Ukraine
Thank you for your time
@FollowEstelle 44

Device Twins, Digital Twins and Device Shadow

  • 1.
    2018 Ukraine Device Twins,Digital Twins and Device Shadow Estelle Auberix IT Consultant (Cloud, Cyber Security, IoT) MS MVP Azure 2 0 1 8 U k r a i n e @FollowEstelle
  • 2.
    2018 Ukraine About Speaker •Estelle Auberix • IT Consultant (Cloud, Cyber Security, IoT) Practice Manager (Cyber Security / Robotic) MVP Azure • Contact • @FollowEstelle @FollowEstelle 2
  • 3.
    2018 Ukraine Agenda • DeviceTwins • Azure vs. AWS • Resume • New in Azure • Back to the Future Topic Protocols SDK Security Authentication Communication Pricing @FollowEstelle 3
  • 4.
    2018 Ukraine 1 -Device Twins @FollowEstelle 4
  • 5.
    2018 Ukraine Device Twins JSONdocuments -> store device state information including metadata, configurations, and conditions. @FollowEstelle 5
  • 6.
    2018 Ukraine What for? •Store device-specific metadata in the cloud • Report current state information such as available capabilities and conditions from your device app • Synchronize the state of long-running workflows between device app and back-end app • Query your device metadata, configuration, or state @FollowEstelle 6
  • 7.
    2018 Ukraine 2 –Azure vs. AWS @FollowEstelle 7
  • 8.
    2018 Ukraine Focus • AzureIoT Hub • AWS Device Shadows @FollowEstelle 8
  • 9.
    2018 Ukraine Structure ofthe Device • High Level Concept • Device Description • Device Model • Properties • Actions • Events • Serialization format @FollowEstelle 9
  • 10.
    2018 Ukraine Microsoft AzureIoT Hub – Device Twins • Microsoft’ Device Twin is an abstraction of a device state using properties and a set of tags, containing metadata values • Actions and events are not of the model, but are handled by application code • Messages are rather lightweight and the content can be selected by the application down to property level • /! The format of the messages is defined by applications only • The Device Twin model does not define a ‘template’ or a mechanism to aggregate multiple devices into a combined device model @FollowEstelle 10
  • 11.
    2018 Ukraine Microsoft AzureIoT Hub – Cloud @FollowEstelle 11
  • 12.
    2018 Ukraine Microsost AzureIoT Hub – Edge/Cloud @FollowEstelle 12
  • 13.
    2018 Ukraine AWS IoTDevice Shadows • Enable Internet-connected devices to connect to the AWS Cloud and let application in the cloud interact with internet-connected devices • Devices report their state by publishing messages in JSON format on MQTT topics • /! Each MQTT topic has a hierarchical name that identifies the device whose state is being updated @FollowEstelle 13
  • 14.
    2018 Ukraine AWS IoTDevice Shadows – Cloud @FollowEstelle 14
  • 15.
    2018 Ukraine Microsoft’s DeviceTwin = JSON file • Tags: a section where the solution back-end has access to • Properties: Used to synchronize device configuration or conditions • All property values can be of the following JSON type: Boolean, number, string, object • /! Arrays are not allowed in Azure but there are in AWS @FollowEstelle 15
  • 16.
    2018 Ukraine 3 kindsof properties • Desired properties: can be set by the solution back-end and read by the device app • Reported properties: The device app can set reported properties and the solution back-end can read and query them • Device identity properties: The root of the Device Twin JSON file contains the read-only properties from the corresponding device identity stored in the identity registry @FollowEstelle 16
  • 17.
    2018 Ukraine The AWSThing is a Device Model • AWS IoT provides a registry to manage Things • A Thing is a representation of a specific device or logical entity { "version": 3, "thingName": "MyLightBulb", "defaultClientId": "MyLightBulb", "thingTypeName": "LightBulb", "attributes": { "model": "123", "wattage": "75" } } @FollowEstelle 17
  • 18.
    2018 Ukraine AWS Thingtypes • Thing types: store description and configuration information that is common for all things associated with the same thing type • Thing groups: allow to manage several things at once • /! Groups can also contain groups @FollowEstelle 18
  • 19.
    2018 Ukraine Actions (Microsoft& AWS) Actions do not correspond to a formal description in the JSON file, but are modelled via posting of a payload to a ‘method’ endpoint @FollowEstelle 19
  • 20.
    2018 Ukraine Events There isno dedicated event mechanism. @FollowEstelle 20
  • 21.
    2018 Ukraine Serialization formatsComparison { "deviceId": "devA", "moduleId": "moduleA", "etag": "AAAAAAAAAAc=", "status": "enabled", "statusReason": "provisioned", "statusUpdateTime": "0001-01- 01T00:00:00", "connectionState": "connected", "lastActivityTime": "2015-02- 30T16:24:48.789Z", "cloudToDeviceMessageCount": 0, "authenticationType": "sas", "x509Thumbprint": { "primaryThumbprint": null, "secondaryThumbprint": null }, "version": 2, "tags": { "$etag": "123", "deploymentLocation": { "building": "43", "floor": "1" } }, "properties": { "desired": { "telemetryConfig": { "sendFrequency": "5m" }, "$metadata" : {...}, "$version": 1 }, "reported": { "telemetryConfig": { "sendFrequency": "5m", "status": "success" } "batteryLevel": 55, "$metadata" : {...}, "$version": 4 } } } { "version": 3, "thingName": "MyLightBulb", "defaultClientId": "MyLightBulb", "thingTypeName": "LightBulb", "attributes": { "model": "123", "wattage": "75" } } { "state": { "desired": { "attribute1": integer2, "attribute2": "string2", ... "attributeN": boolean2 }, "reported": { "attribute1": integer1, "attribute2": "string1", ... "attributeN": boolean1 } } "clientToken": "token", "version": version }
  • 22.
    2018 Ukraine SDKs Azure • IoTdevice SDKs (.NET, C, Java, NodeJS, Python, iOS) • IoT service SDKs (.NET, C, Java, NodeJS, Python, iOS) • Device provisioning SDKs (C, C#, Java, NodeJS, Python) -> GitHub AWS • AWS Mobile SDK for Android • Arduino Yún SDK • AWS IoT Device SDK for Embedded C • AWS IoT C++ Device SDK • AWS Mobile SDK for iOS • AWS IoT Device SDK for Java • AWS IoT Device SDK for JavaScript • AWS IoT Device SDK for Python
  • 23.
    2018 Ukraine Protocols inAzure • AMQP 1.0 is already the official supported protocol for all Azure services • MQTT 3.1.1 but provides a simple programming model for building protocol adapters for other protocols • HTTPS • additional protocols using the Azure IoT Protocol Gateway framework • Look at the Microsoft partnerships (PTC for useful connectors for example) @FollowEstelle 23
  • 24.
    2018 Ukraine Protocols inAWS • MQTT 3.1.1 is the official supported protocol • /! The broker doesn’t support retained messages, persistent sessions and QoS level 2 • HTTP protocol is supported but it’s limited to publish messages using a REST API (POST method only) @FollowEstelle 24
  • 25.
    2018 Ukraine Security inAzure @FollowEstelle 25
  • 26.
    2018 Ukraine Microsost AzureIoT Hub – Edge/Cloud @FollowEstelle 26
  • 27.
    2018 Ukraine AWS IoTDevice Shadows – Cloud @FollowEstelle 27
  • 28.
    2018 Ukraine Security inAWS @FollowEstelle 28
  • 29.
    2018 Ukraine 3 –Summary @FollowEstelle 29
  • 30.
    2018 Ukraine Summary • AWSand Azure only define a data model, no actions and events • None of the serialization formats are uniformized • None of the formats defines a protocol binding • A device manufacturer, who wants to address these platforms, has to create code for both diferrent environments A unified device model will simplify the integration tasks across different platforms and will accelerate IoT market adoption. @FollowEstelle 30
  • 31.
    2018 Ukraine Summary @FollowEstelle 31 TopicAzure IoT Hub Amazon AWS IoT Protocols HTTPS, AMQP, MQTT, custom ones (using protocol gateway) HTTP, HTTPS, MQTT SDKs .NET, UWP, Java, C, C#, NodeJS, Python, iOS (CocoaPod) C, NodeJS, Java, Python, iOS Security TLS (Server authentication only) TLS (Mutual authentication) Authentication Token bas (SAS) per device, X.509 device certificate X.509 client authentication, IAM service, Cognito Service Communication Command based, telemetry Command based (state), telemetry Pricing Per IoT Hub unit combined with number of devices and messages per day Per number of messages (traffic) to/from device
  • 32.
    2018 Ukraine 4 –New in Azure @FollowEstelle 32
  • 33.
    2018 Ukraine Azure DigitalTwins • Twin object models • Spatial intelligence graph • Advanced compute capabilities • Data isolation via multi- and nested-tenancy capabilities • Security through access control and Azure AD • Integration with Microsoft services @FollowEstelle 33
  • 34.
    2018 Ukraine Digital Twinsobject models • Spaces • Devices • Sensors • Users Other categories: Resources, Extended Types, Ontologies, Property Keys and Values, Roles/Roles Assignments, Security Key Stores, UDFs, Matchers, Endpoints @FollowEstelle 34
  • 35.
    2018 Ukraine Spatial intelligencegraph • Managed with a collection of REST APIs • Devices are provisioned with the Device API • https://github.com/Azure-Samples/digital-twins-samples-csharp @FollowEstelle 35
  • 36.
  • 37.
    2018 Ukraine 5 –Back to the Future @FollowEstelle 37
  • 38.
  • 39.
  • 40.
    2018 Ukraine Azure IoT •https://code.visualstudio.com/download • https://azure.microsoft.com/en-us/services/iot-hub/ • https://azure-samples.github.io/iot-devkit-web-simulator/ • https://azure-samples.github.io/raspberry-pi-web-simulator/#Getstarted • https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-device-twins • https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-node-node-twin- getstarted • https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-node-node-module-twin- getstarted • https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-node-node-device- management-get-started • https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/iot-hub/iot- hub-devguide-device-twins.md • https://docs.microsoft.com/en-us/azure/digital-twins/concepts-objectmodel- spatialgraph • https://docs.westcentralus.azuresmartspaces.net/management/swagger/ui/index @FollowEstelle 40
  • 41.
    2018 Ukraine @FollowEstelle41 Where are the instructions? https://aka.ms/ms-docs  docs.microsoft.com is new the platform hosting Microsoft technical documentation  Content is Open Source(*), Hosted on GitHub, Community-enabled + in your own language!  So YOU can help the community of users Worldwide to get a better experience by improving the Docs, and grow your reputation online!! Discover how here https://aka.ms/intldocs
  • 42.
    2018 Ukraine Help theCommunity to get them in your language today! VS Code SQL on Linux Team Explorer Everywhere … and more! Do you like Open Source? https://aka.ms/msossloc
  • 43.
    2018 Ukraine AWS IoT •https://docs.aws.amazon.com/iot/latest/developerguide/what-is- aws-iot.html • https://hub.packtpub.com/build-an-iot-application-with-aws-iot- tutorial/ • https://docs.aws.amazon.com/iot/latest/developerguide/iot- device-shadows.html • https://docs.sumerian.amazonaws.com/tutorials/create/intermedi ate/iot-thing-shadow-script/ @FollowEstelle 43
  • 44.
    2018 Ukraine Thank youfor your time @FollowEstelle 44