SlideShare a Scribd company logo
1 of 35
Download to read offline
1
TOPIC
IoT in salsa
Serverless
Massimo Bonanni
Paranormal Trainer, with the head in the Cloud and all
the REST in microservices!
massimo.bonanni@microsoft.com
@massimobonanni
2
Photo by Karolina Grabowska from Pexels
3
A simple IoT scenario….
Simulator
IoT Hub
Telemetry
Dashboard
Telemetry Devices
?
Devices
Every single device
produces telemetries
about temperature and
humidity
IoTHub ingests
telemetry in Azure
We need a simulator
to test our solution
We want to
• elaborate the telemetries
• store the last m minutes
• provide APIs to retrieve the telemetries
• having many types of devices with
different logic
We need a
dashboard to
show the devices
and telemetries.
External
Services
We need to interact
with external
services to provide
alerts or notifications
4
Photo by Tim Gouw on Unsplash
Our requirements:
• Event-driven scalability
• State management abstraction
• Asynchronous interaction
• Different types of devices
5
Photo by Andrea Piacquadio from Pexels
Durable
Entities….
why not?
6
Azure Functions
Extension
Based on Azure Functions
Adds new Triggers and
Bindings
Manages state,
checkpoints, and
restarts
Durable Task
Framework
Long running persistent
workflows in C#
Used within various
teams at Microsoft to
reliably orchestrate
long running
operations
Languages
C#
JavaScript
F#
What are Durable Functions?
7
Client
Is the triggered functions
that will create new
instances of an
orchestration.
It is the entry point for
creating an instance of
a durable orchestration
Orchestrator
Is the heart of a durable
function.
Orchestrator functions
describe the way and
order actions are
executed.
Activity
Is the basic unit of work
in a durable
orchestration.
An activity function must
be triggered by
an activity trigger.
What are Durable Functions?
8
Based on Durable Functions
Functions with special
trigger
Entity Functions define operations
for reading and updating small
piece of state (serialized in a
storage table)
Entity Functions are
accessed using:
Entity Name
Entity Key
Entity Functions operations can
be accessed using:
Entity Key
Operation Name
Operation Input
Scheduled time
Durable Entities aka Entity Functions
9
Entity ID
An entity ID is simply a pair of strings that uniquely identifies an
entity instance.
Entity Name
Is a name that identifies the type of
the entity.
This name must match the name of the
entity function that implements the
entity.
It isn't sensitive to case
Entity Key
Is a string that uniquely identifies the
entity among all other entities of the
same name
10
Define the entity
Function-
based syntax
Class-based
syntax
11
Define the entity
Function-
based syntax
Class-based
syntax
Entities are represented as functions
and operations are explicitly
executed in the function body.
This syntax works well for entities
with simple state, few operations, or
a dynamic set of operations like in
application frameworks.
This syntax doesn't catch type errors
at compile time
12
Define the entity
Function-
based syntax
Class-based
syntax
Entities are represented by classes.
This syntax produces more easily
readable code and allows operations
to be invoked in a type-safe way.
Function-based and Class –based
variants can be used interchangeably
in the same application.
13
Define the entity
Function-
based syntax
Class-based
syntax
The class must be constructible
The class must be JSON-serializable
Operations must have at most one argument, and not have any overloads or generic
type arguments.
Arguments and return values must be serializable values or objects.
You can define an interface for the entity
14
What an operation can do
Read or update entity state
External I/O operation
Use context to interact with other entities
Use context to start an orchestration
15
Define an interface for an Entity
Entity interfaces must only define methods.
Entity interfaces must not contain generic parameters.
Entity interface methods must not have more than one parameter.
Entity interface methods must return void, Task, or Task<T>
16
Accessing the Entities
Two-way (round-trip) communication.
You send an operation message to the entity, and then
wait for the response message before you continue.
Calling
(round-
trip)
One-way (fire and forget) communication.
You send an operation message but don't wait for a
response.
Signaling
(fire-and-
forget)
Two-way communication.
You can retrieve the state of an entity
State
Orchestrator
Orchestrator
Client
Entity
Client
17
Anatomy of the Device
Properties (state)
Operations
Entry Function
18
Durable Entities vs Actor model
The actor model in computer science is a mathematical model of concurrent
computation (originated in 1973).
In response to a message it receives, an actor can:
✓ make local decisions,
✓ create more actors,
✓ send more messages,
✓ determine how to respond to the next message
received.
Actors have their own private state.
Actors can process only one message at time.
19
A possible solution….
IoT Hub
Telemetry
Dashboard
Telemetry
Dispatcher
20
A possible solution….
Front-End Layer:
Azure Functions expose Rest APIs to
send telemetry, search devices and
retrieve status for each device
Stateful Data Layer:
Durable Entities provide stateful layer
to manage status for each device.
Integration Layer:
Durable Functions provide integration
with external services and allow you to
create complex workflow to integrate
more than one external service.
Front-End
Layer
Stateful
Data
Layer
Integration
Layer
21
The telemetry journey….
Telemetry
Dispatcher
MQTT Event
Processor
REST
API
CLIENT
Signal
ORCHESTRATOR
Start
ENTITY
STORAGE
Devices produce and
send telemetries to
IoTHub using Json and
MQTT protocol
22
The telemetry journey….
Telemetry
Dispatcher
MQTT Event
Processor
REST
API
CLIENT
Signal
ORCHESTRATOR
Start
ENTITY
STORAGE
Telemetry
Dispatcher retrieves
telemetries from
IoTHub
23
The telemetry journey….
Telemetry
Dispatcher
MQTT Event
Processor
REST
API
CLIENT
Signal
ORCHESTRATOR
Start
ENTITY
STORAGE
Telemetry Dispatcher calls
the REST APIs exposed by
the Azure Functions (Client
Function)
24
The telemetry journey….
Telemetry
Dispatcher
MQTT Event
Processor
REST
API
CLIENT
Signal
ORCHESTRATOR
Start
ENTITY
STORAGE
Each client function signals
the telemetry to the
specific device (Entity
Function)
25
The telemetry journey….
Telemetry
Dispatcher
MQTT Event
Processor
REST
API
CLIENT
Signal
ORCHESTRATOR
Start
ENTITY
STORAGE
The Entity manages the
status (last telemetries) and
start an Orchestrator
Function if an alert occurs
Serverless IoT
Platform
27
Photo by Tim Gouw on Unsplash
Our requirements:
• Event-driven scalability
• State management abstraction
• Asynchronous interaction
• Different types of devices
28
Photo by Tim Gouw on Unsplash
Our requirements:
• Event-driven scalability
• State management abstraction
• Asynchronous interaction
• Different types of devices
29
Photo by Tim Gouw on Unsplash
Our requirements:
✓ Event-driven scalability → Serverless
• State management abstraction
• Asynchronous interaction
• Different types of devices
30
Photo by Tim Gouw on Unsplash
Our requirements:
✓ Event-driven scalability → Serverless
✓ State management abstraction → Durable Entities
• Asynchronous interaction
• Different types of devices
31
Photo by Tim Gouw on Unsplash
Our requirements:
✓ Event-driven scalability → Serverless
✓ State management abstraction → Durable Entities
✓ Asynchronous interaction → Signaling
• Different types of devices
32
Photo by Tim Gouw on Unsplash
Our requirements:
✓ Event-driven scalability → Serverless
✓ State management abstraction → Durable Entities
✓ Asynchronous interaction → Signaling
✓ Different types of devices → Entity Interface
33
Thanks for your
attention!!!!!
Massimo Bonanni
Azure Technical Trainer
massimo.bonanni@microsoft.com
@massimobonanni
Connect with meonLinkedIn
linkedin.com/in/massimobonanni/
http://bit.ly/MasteringServerless
References
Photo by Ashim D’Silva on Unsplash
Azure Functions
Documentation
https://docs.microsoft.com/en-
US/azure/azure-functions/
Durable Functions overview
https://docs.microsoft.com/en-
us/azure/azure-
functions/durable/durable-
functions-overview?tabs=csharp
Developer's guide to
durable entities in .NET
https://docs.microsoft.com/en-
us/azure/azure-
functions/durable/durable-
functions-dotnet-entities
Entity Functions
https://docs.microsoft.com/en-
us/azure/azure-
functions/durable/durable-
functions-entities?tabs=csharp
Durable Task Framework
https://github.com/Azure/durableta
sk
GitHub ServerlessIoT Demo
https://github.com/massimobonann
i/ServerlessIoT
@cloudgen_verona
#CodeGen2021

More Related Content

What's hot

Net campus2015 antimomusone
Net campus2015 antimomusoneNet campus2015 antimomusone
Net campus2015 antimomusone
DotNetCampus
 
Windows iot barone
Windows iot baroneWindows iot barone
Windows iot barone
DotNetCampus
 

What's hot (20)

Empower every Azure Function to achieve more!!
Empower every Azure Function to achieve more!!Empower every Azure Function to achieve more!!
Empower every Azure Function to achieve more!!
 
IoT in salsa serverless
IoT in salsa serverlessIoT in salsa serverless
IoT in salsa serverless
 
Linq
LinqLinq
Linq
 
Net campus2015 antimomusone
Net campus2015 antimomusoneNet campus2015 antimomusone
Net campus2015 antimomusone
 
Xmas Serverless Transformation: when the elf doesn’t scale!
Xmas Serverless Transformation: when the elf doesn’t scale!Xmas Serverless Transformation: when the elf doesn’t scale!
Xmas Serverless Transformation: when the elf doesn’t scale!
 
Code Generation for Azure with .net
Code Generation for Azure with .netCode Generation for Azure with .net
Code Generation for Azure with .net
 
Discovering the Service Fabric's actor model
Discovering the Service Fabric's actor modelDiscovering the Service Fabric's actor model
Discovering the Service Fabric's actor model
 
Windows iot barone
Windows iot baroneWindows iot barone
Windows iot barone
 
Discovering the Service Fabric's actor model
Discovering the Service Fabric's actor modelDiscovering the Service Fabric's actor model
Discovering the Service Fabric's actor model
 
Grails with swagger
Grails with swaggerGrails with swagger
Grails with swagger
 
Introducing to Azure Functions
Introducing to Azure FunctionsIntroducing to Azure Functions
Introducing to Azure Functions
 
Massively Scalable Applications - TechFerry
Massively Scalable Applications - TechFerryMassively Scalable Applications - TechFerry
Massively Scalable Applications - TechFerry
 
Building and running Spring Cloud-based microservices on AWS ECS
Building and running Spring Cloud-based microservices on AWS ECSBuilding and running Spring Cloud-based microservices on AWS ECS
Building and running Spring Cloud-based microservices on AWS ECS
 
Content as a Service with Umbraco Headless
Content as a Service with Umbraco HeadlessContent as a Service with Umbraco Headless
Content as a Service with Umbraco Headless
 
Booting your Microservices Architecture with Spring & Netflix
Booting your Microservices Architecture with Spring & NetflixBooting your Microservices Architecture with Spring & Netflix
Booting your Microservices Architecture with Spring & Netflix
 
Full-Stack, Message-oriented Programming w/ Akka.NET Actors
Full-Stack, Message-oriented Programming w/ Akka.NET ActorsFull-Stack, Message-oriented Programming w/ Akka.NET Actors
Full-Stack, Message-oriented Programming w/ Akka.NET Actors
 
It depends: Loving .NET Core dependency injection or not
It depends: Loving .NET Core dependency injection or notIt depends: Loving .NET Core dependency injection or not
It depends: Loving .NET Core dependency injection or not
 
Azure Durable Functions
Azure Durable FunctionsAzure Durable Functions
Azure Durable Functions
 
Reactive applications with Akka.Net - DDD East Anglia 2015
Reactive applications with Akka.Net - DDD East Anglia 2015Reactive applications with Akka.Net - DDD East Anglia 2015
Reactive applications with Akka.Net - DDD East Anglia 2015
 
Microservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring CloudMicroservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring Cloud
 

Similar to IoT in salsa Serverless

Similar to IoT in salsa Serverless (20)

PATTERNS06 - The .NET Event Model
PATTERNS06 - The .NET Event ModelPATTERNS06 - The .NET Event Model
PATTERNS06 - The .NET Event Model
 
Dutchchain aug18
Dutchchain aug18Dutchchain aug18
Dutchchain aug18
 
System Modelling.ppt
System Modelling.pptSystem Modelling.ppt
System Modelling.ppt
 
Developing Actors in Azure with .net
Developing Actors in Azure with .netDeveloping Actors in Azure with .net
Developing Actors in Azure with .net
 
Inside Logic Apps
Inside Logic AppsInside Logic Apps
Inside Logic Apps
 
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
 
Dot NET Remoting
Dot NET RemotingDot NET Remoting
Dot NET Remoting
 
Implementare e gestire soluzioni per l'Internet of Things (IoT) in modo rapid...
Implementare e gestire soluzioni per l'Internet of Things (IoT) in modo rapid...Implementare e gestire soluzioni per l'Internet of Things (IoT) in modo rapid...
Implementare e gestire soluzioni per l'Internet of Things (IoT) in modo rapid...
 
CONTROL CLOUD DATA ACCESS PRIVILEGE AND ANONYMITY WITH FULLY ANONYMOUS ATTRI...
 CONTROL CLOUD DATA ACCESS PRIVILEGE AND ANONYMITY WITH FULLY ANONYMOUS ATTRI... CONTROL CLOUD DATA ACCESS PRIVILEGE AND ANONYMITY WITH FULLY ANONYMOUS ATTRI...
CONTROL CLOUD DATA ACCESS PRIVILEGE AND ANONYMITY WITH FULLY ANONYMOUS ATTRI...
 
CONTROL CLOUD DATA ACCESS PRIVILEGE AND ANONYMITY WITH FULLY ANONYMOUS ATTRIB...
CONTROL CLOUD DATA ACCESS PRIVILEGE AND ANONYMITY WITH FULLY ANONYMOUS ATTRIB...CONTROL CLOUD DATA ACCESS PRIVILEGE AND ANONYMITY WITH FULLY ANONYMOUS ATTRIB...
CONTROL CLOUD DATA ACCESS PRIVILEGE AND ANONYMITY WITH FULLY ANONYMOUS ATTRIB...
 
CONTROL CLOUD DATA ACCESS PRIVILEGE AND ANONYMITY WITH FULLY ANONYMOUS ATTRI...
 CONTROL CLOUD DATA ACCESS PRIVILEGE AND ANONYMITY WITH FULLY ANONYMOUS ATTRI... CONTROL CLOUD DATA ACCESS PRIVILEGE AND ANONYMITY WITH FULLY ANONYMOUS ATTRI...
CONTROL CLOUD DATA ACCESS PRIVILEGE AND ANONYMITY WITH FULLY ANONYMOUS ATTRI...
 
Control cloud data access privilege and
Control cloud data access privilege andControl cloud data access privilege and
Control cloud data access privilege and
 
Oop2011 actor presentation_stal
Oop2011 actor presentation_stalOop2011 actor presentation_stal
Oop2011 actor presentation_stal
 
Develop a portal to manage your IoT Hub solution
 Develop a portal to manage your IoT Hub solution Develop a portal to manage your IoT Hub solution
Develop a portal to manage your IoT Hub solution
 
Tdd,Ioc
Tdd,IocTdd,Ioc
Tdd,Ioc
 
Integrating Cloud Services in Behaviour Programming for Autonomous Robots
Integrating Cloud Services in Behaviour  Programming for Autonomous RobotsIntegrating Cloud Services in Behaviour  Programming for Autonomous Robots
Integrating Cloud Services in Behaviour Programming for Autonomous Robots
 
What is an IoT Agent
What is an IoT AgentWhat is an IoT Agent
What is an IoT Agent
 
orocos-presentation-Barcelona2006.pdf
orocos-presentation-Barcelona2006.pdforocos-presentation-Barcelona2006.pdf
orocos-presentation-Barcelona2006.pdf
 
Jar chapter 4, part 1
Jar chapter 4, part 1Jar chapter 4, part 1
Jar chapter 4, part 1
 
S4: Distributed Stream Computing Platform
S4: Distributed Stream Computing PlatformS4: Distributed Stream Computing Platform
S4: Distributed Stream Computing Platform
 

More from Massimo Bonanni

More from Massimo Bonanni (19)

Architetture Serverless con SQL Server e Azure Functions
Architetture Serverless con SQL Server e Azure FunctionsArchitetture Serverless con SQL Server e Azure Functions
Architetture Serverless con SQL Server e Azure Functions
 
Tutto quello che avreste voluto sapere sull'API Management (e non avete mai o...
Tutto quello che avreste voluto sapere sull'API Management (e non avete mai o...Tutto quello che avreste voluto sapere sull'API Management (e non avete mai o...
Tutto quello che avreste voluto sapere sull'API Management (e non avete mai o...
 
The art of Azure Functions (unit) testing and monitoring
The art of Azure Functions (unit) testing and monitoringThe art of Azure Functions (unit) testing and monitoring
The art of Azure Functions (unit) testing and monitoring
 
Everything you always wanted to know about API Management (but were afraid to...
Everything you always wanted to know about API Management (but were afraid to...Everything you always wanted to know about API Management (but were afraid to...
Everything you always wanted to know about API Management (but were afraid to...
 
Welcome Azure Functions 2. 0
Welcome Azure Functions 2. 0Welcome Azure Functions 2. 0
Welcome Azure Functions 2. 0
 
Testing a Service Fabric solution and live happy!!
Testing a Service Fabric solution and live happy!!Testing a Service Fabric solution and live happy!!
Testing a Service Fabric solution and live happy!!
 
Soluzioni IoT con le tecnologie Microsoft
Soluzioni IoT con le tecnologie MicrosoftSoluzioni IoT con le tecnologie Microsoft
Soluzioni IoT con le tecnologie Microsoft
 
Project Gesture & Real Sense: il potere nelle mani!!
Project Gesture & Real Sense: il potere nelle mani!!Project Gesture & Real Sense: il potere nelle mani!!
Project Gesture & Real Sense: il potere nelle mani!!
 
Project Gesture & RealSense: gestures in a simple way!!
Project Gesture & RealSense: gestures in a simple way!!Project Gesture & RealSense: gestures in a simple way!!
Project Gesture & RealSense: gestures in a simple way!!
 
Project Prague & RealSense: il potere nelle mani!!
Project Prague & RealSense: il potere nelle mani!!Project Prague & RealSense: il potere nelle mani!!
Project Prague & RealSense: il potere nelle mani!!
 
L'approccio ai microservizi secondo Service Fabric
L'approccio ai microservizi secondo Service FabricL'approccio ai microservizi secondo Service Fabric
L'approccio ai microservizi secondo Service Fabric
 
The Microservices world in. NET Core and. NET framework
The Microservices world in. NET Core and. NET frameworkThe Microservices world in. NET Core and. NET framework
The Microservices world in. NET Core and. NET framework
 
Microservices architecture & Service Fabric
Microservices architecture & Service FabricMicroservices architecture & Service Fabric
Microservices architecture & Service Fabric
 
Introduzione allo sviluppo UWP per xBox
Introduzione allo sviluppo UWP per xBoxIntroduzione allo sviluppo UWP per xBox
Introduzione allo sviluppo UWP per xBox
 
Cognitive Services & LUIS
Cognitive Services & LUISCognitive Services & LUIS
Cognitive Services & LUIS
 
Service Fabric: la potenza dei micro servizi
Service Fabric:  la potenza dei micro serviziService Fabric:  la potenza dei micro servizi
Service Fabric: la potenza dei micro servizi
 
Automated UI testing for iOs and Android mobile apps
Automated UI testing for iOs and Android mobile appsAutomated UI testing for iOs and Android mobile apps
Automated UI testing for iOs and Android mobile apps
 
Soluzioni IoT con le tecnologie Microsoft
Soluzioni IoT con le tecnologie MicrosoftSoluzioni IoT con le tecnologie Microsoft
Soluzioni IoT con le tecnologie Microsoft
 
Xamarin Test Cloud
Xamarin Test CloudXamarin Test Cloud
Xamarin Test Cloud
 

Recently uploaded

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software Engineering
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 

IoT in salsa Serverless

  • 1. 1 TOPIC IoT in salsa Serverless Massimo Bonanni Paranormal Trainer, with the head in the Cloud and all the REST in microservices! massimo.bonanni@microsoft.com @massimobonanni
  • 2. 2 Photo by Karolina Grabowska from Pexels
  • 3. 3 A simple IoT scenario…. Simulator IoT Hub Telemetry Dashboard Telemetry Devices ? Devices Every single device produces telemetries about temperature and humidity IoTHub ingests telemetry in Azure We need a simulator to test our solution We want to • elaborate the telemetries • store the last m minutes • provide APIs to retrieve the telemetries • having many types of devices with different logic We need a dashboard to show the devices and telemetries. External Services We need to interact with external services to provide alerts or notifications
  • 4. 4 Photo by Tim Gouw on Unsplash Our requirements: • Event-driven scalability • State management abstraction • Asynchronous interaction • Different types of devices
  • 5. 5 Photo by Andrea Piacquadio from Pexels Durable Entities…. why not?
  • 6. 6 Azure Functions Extension Based on Azure Functions Adds new Triggers and Bindings Manages state, checkpoints, and restarts Durable Task Framework Long running persistent workflows in C# Used within various teams at Microsoft to reliably orchestrate long running operations Languages C# JavaScript F# What are Durable Functions?
  • 7. 7 Client Is the triggered functions that will create new instances of an orchestration. It is the entry point for creating an instance of a durable orchestration Orchestrator Is the heart of a durable function. Orchestrator functions describe the way and order actions are executed. Activity Is the basic unit of work in a durable orchestration. An activity function must be triggered by an activity trigger. What are Durable Functions?
  • 8. 8 Based on Durable Functions Functions with special trigger Entity Functions define operations for reading and updating small piece of state (serialized in a storage table) Entity Functions are accessed using: Entity Name Entity Key Entity Functions operations can be accessed using: Entity Key Operation Name Operation Input Scheduled time Durable Entities aka Entity Functions
  • 9. 9 Entity ID An entity ID is simply a pair of strings that uniquely identifies an entity instance. Entity Name Is a name that identifies the type of the entity. This name must match the name of the entity function that implements the entity. It isn't sensitive to case Entity Key Is a string that uniquely identifies the entity among all other entities of the same name
  • 10. 10 Define the entity Function- based syntax Class-based syntax
  • 11. 11 Define the entity Function- based syntax Class-based syntax Entities are represented as functions and operations are explicitly executed in the function body. This syntax works well for entities with simple state, few operations, or a dynamic set of operations like in application frameworks. This syntax doesn't catch type errors at compile time
  • 12. 12 Define the entity Function- based syntax Class-based syntax Entities are represented by classes. This syntax produces more easily readable code and allows operations to be invoked in a type-safe way. Function-based and Class –based variants can be used interchangeably in the same application.
  • 13. 13 Define the entity Function- based syntax Class-based syntax The class must be constructible The class must be JSON-serializable Operations must have at most one argument, and not have any overloads or generic type arguments. Arguments and return values must be serializable values or objects. You can define an interface for the entity
  • 14. 14 What an operation can do Read or update entity state External I/O operation Use context to interact with other entities Use context to start an orchestration
  • 15. 15 Define an interface for an Entity Entity interfaces must only define methods. Entity interfaces must not contain generic parameters. Entity interface methods must not have more than one parameter. Entity interface methods must return void, Task, or Task<T>
  • 16. 16 Accessing the Entities Two-way (round-trip) communication. You send an operation message to the entity, and then wait for the response message before you continue. Calling (round- trip) One-way (fire and forget) communication. You send an operation message but don't wait for a response. Signaling (fire-and- forget) Two-way communication. You can retrieve the state of an entity State Orchestrator Orchestrator Client Entity Client
  • 17. 17 Anatomy of the Device Properties (state) Operations Entry Function
  • 18. 18 Durable Entities vs Actor model The actor model in computer science is a mathematical model of concurrent computation (originated in 1973). In response to a message it receives, an actor can: ✓ make local decisions, ✓ create more actors, ✓ send more messages, ✓ determine how to respond to the next message received. Actors have their own private state. Actors can process only one message at time.
  • 19. 19 A possible solution…. IoT Hub Telemetry Dashboard Telemetry Dispatcher
  • 20. 20 A possible solution…. Front-End Layer: Azure Functions expose Rest APIs to send telemetry, search devices and retrieve status for each device Stateful Data Layer: Durable Entities provide stateful layer to manage status for each device. Integration Layer: Durable Functions provide integration with external services and allow you to create complex workflow to integrate more than one external service. Front-End Layer Stateful Data Layer Integration Layer
  • 21. 21 The telemetry journey…. Telemetry Dispatcher MQTT Event Processor REST API CLIENT Signal ORCHESTRATOR Start ENTITY STORAGE Devices produce and send telemetries to IoTHub using Json and MQTT protocol
  • 22. 22 The telemetry journey…. Telemetry Dispatcher MQTT Event Processor REST API CLIENT Signal ORCHESTRATOR Start ENTITY STORAGE Telemetry Dispatcher retrieves telemetries from IoTHub
  • 23. 23 The telemetry journey…. Telemetry Dispatcher MQTT Event Processor REST API CLIENT Signal ORCHESTRATOR Start ENTITY STORAGE Telemetry Dispatcher calls the REST APIs exposed by the Azure Functions (Client Function)
  • 24. 24 The telemetry journey…. Telemetry Dispatcher MQTT Event Processor REST API CLIENT Signal ORCHESTRATOR Start ENTITY STORAGE Each client function signals the telemetry to the specific device (Entity Function)
  • 25. 25 The telemetry journey…. Telemetry Dispatcher MQTT Event Processor REST API CLIENT Signal ORCHESTRATOR Start ENTITY STORAGE The Entity manages the status (last telemetries) and start an Orchestrator Function if an alert occurs
  • 27. 27 Photo by Tim Gouw on Unsplash Our requirements: • Event-driven scalability • State management abstraction • Asynchronous interaction • Different types of devices
  • 28. 28 Photo by Tim Gouw on Unsplash Our requirements: • Event-driven scalability • State management abstraction • Asynchronous interaction • Different types of devices
  • 29. 29 Photo by Tim Gouw on Unsplash Our requirements: ✓ Event-driven scalability → Serverless • State management abstraction • Asynchronous interaction • Different types of devices
  • 30. 30 Photo by Tim Gouw on Unsplash Our requirements: ✓ Event-driven scalability → Serverless ✓ State management abstraction → Durable Entities • Asynchronous interaction • Different types of devices
  • 31. 31 Photo by Tim Gouw on Unsplash Our requirements: ✓ Event-driven scalability → Serverless ✓ State management abstraction → Durable Entities ✓ Asynchronous interaction → Signaling • Different types of devices
  • 32. 32 Photo by Tim Gouw on Unsplash Our requirements: ✓ Event-driven scalability → Serverless ✓ State management abstraction → Durable Entities ✓ Asynchronous interaction → Signaling ✓ Different types of devices → Entity Interface
  • 33. 33 Thanks for your attention!!!!! Massimo Bonanni Azure Technical Trainer massimo.bonanni@microsoft.com @massimobonanni Connect with meonLinkedIn linkedin.com/in/massimobonanni/ http://bit.ly/MasteringServerless
  • 34. References Photo by Ashim D’Silva on Unsplash Azure Functions Documentation https://docs.microsoft.com/en- US/azure/azure-functions/ Durable Functions overview https://docs.microsoft.com/en- us/azure/azure- functions/durable/durable- functions-overview?tabs=csharp Developer's guide to durable entities in .NET https://docs.microsoft.com/en- us/azure/azure- functions/durable/durable- functions-dotnet-entities Entity Functions https://docs.microsoft.com/en- us/azure/azure- functions/durable/durable- functions-entities?tabs=csharp Durable Task Framework https://github.com/Azure/durableta sk GitHub ServerlessIoT Demo https://github.com/massimobonann i/ServerlessIoT