SlideShare a Scribd company logo
1 of 33
Download to read offline
#PitchOnline presents:
#PitchOnline presents:
Massimo Bonanni
Paranormal Trainer, with the head in the Cloud and all the REST in microservices!
massimo.bonanni@microsoft.com
@massimobonanni
Scifoni Ivano Fabio Mannis Francesco Del Re Matteo Riccardi Valerio Benedetti
The art of Azure Functions (unit) testing and monitoring!
The issue….
If you want to use Azure
Functions as components
of your Enterprise
solutions, you must test
and monitor them!!!
What are Azure Functions
Author functions in
C#, F#, Node.JS, Java,
Powershell, and more
Code
Events
React to timers, HTTP
, or
events from your favorite
Azure services, with more
on the way
Outputs
Send results to an
ever-growing collection
of services
The art of Azure Functions (unit) testing and monitoring!
What is a Unit Test
In a unit test you invoke a piece of your code with a
set of parameters and you checks the correctness its
behavior.
In a unit test you must substitute all your external
reference with a mock or stub.
Mock is for the software what a dummy is for a car
crash test (you don’t test a car with a human being
inside…I Hope!!)
The art of Azure Functions (unit) testing and monitoring!
Azure Functions Dependencies
You should implement your Azure Functions to allow you to
use mock/stub for all external reference!
Your
Function
Trigger
Binding
Binding
Binding
Binding
Your Service
Your Service
Your Service
Your Service
Logger
(infrastructure)
The art of Azure Functions (unit) testing and monitoring!
Azure Function … untestable!!
The art of Azure Functions (unit) testing and monitoring!
Azure Function … trigger!!
Trigger
You can mock it
because the trigger
payload is a POCO
class
The art of Azure Functions (unit) testing and monitoring!
Azure Function … bindings!!
Binding
You can mock it because
the binding payload is
an interface
The art of Azure Functions (unit) testing and monitoring!
Azure Function … logger!!
Logger
(infrastructural objects)
You can mock it because
the logger is an interface
The art of Azure Functions (unit) testing and monitoring!
Azure Function … your service!!
External service
You cannot substitute it
with your mock because it
is created inside the Azure
Function and you haven’t a
way to substitute it
The art of Azure Functions (unit) testing and monitoring!
Make your Azure Function testable!!!
The solution of your problem is: Dependency Injection !!
Azure Functions Runtime is based on .NET Core.
Azure Functions support the same ASP.NET Core
Dependency Injection!!!
Using Dependency Injection you provide a way to substitute
your Services with a mock!
The art of Azure Functions (unit) testing and monitoring!
Azure Function … testable!!
Constructor Injection
You can choose what kind of
actual service you want to use
when you instantiate the
function.
In a test you can substitute it
with a mock!!
The art of Azure Functions (unit) testing and monitoring!
Azure Function … how to use mock!!
Mock
Create a mock to use in the
test!!
The art of Azure Functions (unit) testing and monitoring!
DEMO
Azure Functions
Unit Testing
The art of Azure Functions (unit) testing and monitoring!
Monitoring Azure Functions
Once you deploy your Azure Functions on Azure, you need to monitor them to check when something
goes wrong.
The signature of an Azure Function Run method provides the instance of ILogger that you can use to log
information about your code.
Using ILogger, you can collect information from your code execution to monitor and triage errors and
exceptions.
The art of Azure Functions (unit) testing and monitoring!
Azure Functions Monitor
Azure Functions provide out-of-the-box monitor feature.
For each Function, you can have info about every function execution.
The art of Azure Functions (unit) testing and monitoring!
Azure Functions and Application Insight
The Azure Functions platform offers built-in integration with Azure
Application Insights.
Put the Application Insights instrumentation key in the function app
settings.
The art of Azure Functions (unit) testing and monitoring!
Configure monitoring
Logging is configured in host.json file.
Logger default level
Logger level for all the functions in
Function App
Logger level for a specific function
in Function App
Logger category for .NET runtime
components invoked by the host
The art of Azure Functions (unit) testing and monitoring!
Custom Metrics
Azure Function SDK
provides you extension
methods to log custom
metrics.
The art of Azure Functions (unit) testing and monitoring!
Pricing
Azure Functions consumption plan is billed based on per-second
resource consumption and executions
The art of Azure Functions (unit) testing and monitoring!
Pricing
Azure Functions consumption plan is billed based on per-second
resource consumption and executions
If your function use 1GB of
memory and its duration is 1
second, you pay €0.000014
each time the function runs.
The art of Azure Functions (unit) testing and monitoring!
Pricing
Azure Functions consumption plan is billed based on per-second
resource consumption and executions If your function runs 1 million
times every month, you pay
€0.169 each month.
The art of Azure Functions (unit) testing and monitoring!
Pricing - Example
You have a function:
• It runs every second
• Its duration is 1 second
• It uses 512 MB of memory
The art of Azure Functions (unit) testing and monitoring!
Resource Consumption Billing Calculation
• It runs every second
• Its duration is 1 second
• It uses 512 MB of memory
Executions 2,592,000
Resource Consumption Total 2,592,000 x 1 sec = 2,592,000 sec
Total GB-s 2,592,000 x 0.5 GB = 1,296,000 GB-s
Total billable consumption 1,296,000 – 400,000 = 896,000 GB-s
Total cost 896,000 x 0.000014€ = 12.54 €
The art of Azure Functions (unit) testing and monitoring!
Executions billing calculation
• It runs every second
• Its duration is 1 second
• It uses 512 MB of memory
Billable Monthly Executions 2,592,000 – 1,000,000 = 1,592,000
Total cost 1.592 x 0.169 € = 0.269 €
The art of Azure Functions (unit) testing and monitoring!
Total Monthly Cost
• It runs every second
• Its duration is 1 second
• It uses 512 MB of memory
Monthly resource consumption cost 12.540 €
Monthly executions cost 0.269 €
Total monthly cost 12.809 €
The art of Azure Functions (unit) testing and monitoring!
DEMO
Azure Functions
Monitoring
The art of Azure Functions (unit) testing and monitoring!
Takeaway
Write an Azure Functions is simple!
Testing Azure Functions is simple!
Monitoring Azure Functions is simple!
…. then ….
Photo by Aaron Burden on Unsplash
Massimo Bonanni
Azure Technical Trainer @ Microsoft
massimo.bonanni@microsoft.com
@massimobonanni
Connect with me on LinkedIn
linkedin.com/in/massimobonanni/
http://bit.ly/MasteringServerless
References
Azure Functions Documentation
https://docs.microsoft.com/en-US/azure/azure-functions/
Azure Functions Code Samples
https://azure.microsoft.com/en-us/resources/samples/?service=functions&sort=0
Azure Updates
https://azure.microsoft.com/en-us/roadmap/?category=compute
Azure Friday – Build Serverless APIs with Azure Functions
https://azure.microsoft.com/en-us/resources/videos/azure-friday-build-serverless-apis-with-azure-functions/
GitHub Demo
https://github.com/massimobonanni/AzureFunctionsSamples
The art of Azure Functions (unit) testing and monitoring!
Thank You!
Our Socials

More Related Content

What's hot

Servicehost Customization
Servicehost CustomizationServicehost Customization
Servicehost CustomizationEyal Vardi
 
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!!Massimo Bonanni
 
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!Massimo Bonanni
 
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 modelMassimo Bonanni
 
Linq
LinqLinq
Linqtnkreddy
 
Azure functions
Azure functionsAzure functions
Azure functionsRajesh Kolla
 
Windows iot barone
Windows iot baroneWindows iot barone
Windows iot baroneDotNetCampus
 
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 modelMassimo Bonanni
 
Integrating consumers IoT devices into Business Workflow
Integrating consumers IoT devices into Business WorkflowIntegrating consumers IoT devices into Business Workflow
Integrating consumers IoT devices into Business WorkflowYakov Fain
 
Angular 4 for Java Developers
Angular 4 for Java DevelopersAngular 4 for Java Developers
Angular 4 for Java DevelopersYakov Fain
 
Reactive Thinking in Java with RxJava2
Reactive Thinking in Java with RxJava2Reactive Thinking in Java with RxJava2
Reactive Thinking in Java with RxJava2Yakov Fain
 
Angular2 Development for Java developers
Angular2 Development for Java developersAngular2 Development for Java developers
Angular2 Development for Java developersYakov Fain
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScriptYakov Fain
 
Building a Lightning App with Angular Material Design
Building a Lightning App with Angular Material DesignBuilding a Lightning App with Angular Material Design
Building a Lightning App with Angular Material DesignSalesforce Developers
 
Asp.Net Ajax Component Development
Asp.Net Ajax Component DevelopmentAsp.Net Ajax Component Development
Asp.Net Ajax Component DevelopmentChui-Wen Chiu
 
Advanced Spring Boot with Consul
Advanced Spring Boot with ConsulAdvanced Spring Boot with Consul
Advanced Spring Boot with ConsulVMware Tanzu
 
Deep dive into azure durable functions
Deep dive into azure durable functionsDeep dive into azure durable functions
Deep dive into azure durable functionsAhmed Elharouny
 
Phonegap android angualr material design
Phonegap android angualr material designPhonegap android angualr material design
Phonegap android angualr material designSrinadh Kanugala
 

What's hot (20)

Servicehost Customization
Servicehost CustomizationServicehost Customization
Servicehost Customization
 
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!!
 
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!
 
Introducing to Azure Functions
Introducing to Azure FunctionsIntroducing to Azure Functions
Introducing to Azure Functions
 
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
 
Linq
LinqLinq
Linq
 
Azure functions
Azure functionsAzure functions
Azure functions
 
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
 
Integrating consumers IoT devices into Business Workflow
Integrating consumers IoT devices into Business WorkflowIntegrating consumers IoT devices into Business Workflow
Integrating consumers IoT devices into Business Workflow
 
Angular 4 for Java Developers
Angular 4 for Java DevelopersAngular 4 for Java Developers
Angular 4 for Java Developers
 
Reactive Thinking in Java with RxJava2
Reactive Thinking in Java with RxJava2Reactive Thinking in Java with RxJava2
Reactive Thinking in Java with RxJava2
 
Angular2 Development for Java developers
Angular2 Development for Java developersAngular2 Development for Java developers
Angular2 Development for Java developers
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
 
Building a Lightning App with Angular Material Design
Building a Lightning App with Angular Material DesignBuilding a Lightning App with Angular Material Design
Building a Lightning App with Angular Material Design
 
Asp.Net Ajax Component Development
Asp.Net Ajax Component DevelopmentAsp.Net Ajax Component Development
Asp.Net Ajax Component Development
 
Advanced Spring Boot with Consul
Advanced Spring Boot with ConsulAdvanced Spring Boot with Consul
Advanced Spring Boot with Consul
 
Deep dive into azure durable functions
Deep dive into azure durable functionsDeep dive into azure durable functions
Deep dive into azure durable functions
 
Phonegap android angualr material design
Phonegap android angualr material designPhonegap android angualr material design
Phonegap android angualr material design
 

Similar to The art of Azure Functions (unit) testing and monitoring

Azure Functions - Introduction
Azure Functions - IntroductionAzure Functions - Introduction
Azure Functions - IntroductionVenkatesh Narayanan
 
Serverless Computing with Azure
Serverless Computing with AzureServerless Computing with Azure
Serverless Computing with AzureAnalben Mehta
 
Azure Functions.pptx
Azure Functions.pptxAzure Functions.pptx
Azure Functions.pptxYachikaKamra
 
Serverless API with Azure Functions
Serverless API with Azure FunctionsServerless API with Azure Functions
Serverless API with Azure FunctionsAnalben Mehta
 
Getting Started with Serverless Architectures using Azure Functions
Getting Started with Serverless Architectures using Azure FunctionsGetting Started with Serverless Architectures using Azure Functions
Getting Started with Serverless Architectures using Azure FunctionsMarc Duiker
 
Massimo Bonanni - Workflow as code with Azure Durable Functions - Codemotion ...
Massimo Bonanni - Workflow as code with Azure Durable Functions - Codemotion ...Massimo Bonanni - Workflow as code with Azure Durable Functions - Codemotion ...
Massimo Bonanni - Workflow as code with Azure Durable Functions - Codemotion ...Codemotion
 
Serverless Development with Azure Durable Functions in .Net by Jonah Andersson
Serverless Development with Azure Durable Functions in .Net by Jonah AnderssonServerless Development with Azure Durable Functions in .Net by Jonah Andersson
Serverless Development with Azure Durable Functions in .Net by Jonah AnderssonJonah Andersson
 
Guidelines to understand durable functions with .net core, c# and stateful se...
Guidelines to understand durable functions with .net core, c# and stateful se...Guidelines to understand durable functions with .net core, c# and stateful se...
Guidelines to understand durable functions with .net core, c# and stateful se...Concetto Labs
 
Serverless on Azure with Functions
Serverless on Azure with FunctionsServerless on Azure with Functions
Serverless on Azure with FunctionsChristos Matskas
 
SharePoint meetup Speaking Deck - Knowing the formula
SharePoint meetup Speaking Deck -  Knowing the formulaSharePoint meetup Speaking Deck -  Knowing the formula
SharePoint meetup Speaking Deck - Knowing the formulaKenneth Cooper
 
Building stateful serverless orchestrations with Azure Durable Azure Function...
Building stateful serverless orchestrations with Azure Durable Azure Function...Building stateful serverless orchestrations with Azure Durable Azure Function...
Building stateful serverless orchestrations with Azure Durable Azure Function...Callon Campbell
 
Anti Patterns and Mistakes Using Serverless (ServerlessConf SF - 08 2018)
Anti Patterns and Mistakes Using Serverless (ServerlessConf SF - 08 2018)Anti Patterns and Mistakes Using Serverless (ServerlessConf SF - 08 2018)
Anti Patterns and Mistakes Using Serverless (ServerlessConf SF - 08 2018)Yochay Kiriaty
 
Durable Azure Functions
Durable Azure FunctionsDurable Azure Functions
Durable Azure FunctionsPushkar Saraf
 
Workflow as code with Azure Durable Functions
Workflow as code with Azure Durable FunctionsWorkflow as code with Azure Durable Functions
Workflow as code with Azure Durable FunctionsMassimo Bonanni
 
Building API in the cloud using Azure Functions
Building API in the cloud using Azure FunctionsBuilding API in the cloud using Azure Functions
Building API in the cloud using Azure FunctionsAleksandar Bozinovski
 
Building scalable applications with angular js
Building scalable applications with angular jsBuilding scalable applications with angular js
Building scalable applications with angular jsAndrew Alpert
 
4 Integrating azure monitor with power bi and power automate
4 Integrating azure monitor with power bi and power automate4 Integrating azure monitor with power bi and power automate
4 Integrating azure monitor with power bi and power automateKumton Suttiraksiri
 

Similar to The art of Azure Functions (unit) testing and monitoring (20)

Azure Functions - Introduction
Azure Functions - IntroductionAzure Functions - Introduction
Azure Functions - Introduction
 
Serverless Computing with Azure
Serverless Computing with AzureServerless Computing with Azure
Serverless Computing with Azure
 
Azure Functions.pptx
Azure Functions.pptxAzure Functions.pptx
Azure Functions.pptx
 
Serverless API with Azure Functions
Serverless API with Azure FunctionsServerless API with Azure Functions
Serverless API with Azure Functions
 
Getting Started with Serverless Architectures using Azure Functions
Getting Started with Serverless Architectures using Azure FunctionsGetting Started with Serverless Architectures using Azure Functions
Getting Started with Serverless Architectures using Azure Functions
 
slides.pptx
slides.pptxslides.pptx
slides.pptx
 
Durable functions
Durable functionsDurable functions
Durable functions
 
Save Azure Cost
Save Azure CostSave Azure Cost
Save Azure Cost
 
Massimo Bonanni - Workflow as code with Azure Durable Functions - Codemotion ...
Massimo Bonanni - Workflow as code with Azure Durable Functions - Codemotion ...Massimo Bonanni - Workflow as code with Azure Durable Functions - Codemotion ...
Massimo Bonanni - Workflow as code with Azure Durable Functions - Codemotion ...
 
Serverless Development with Azure Durable Functions in .Net by Jonah Andersson
Serverless Development with Azure Durable Functions in .Net by Jonah AnderssonServerless Development with Azure Durable Functions in .Net by Jonah Andersson
Serverless Development with Azure Durable Functions in .Net by Jonah Andersson
 
Guidelines to understand durable functions with .net core, c# and stateful se...
Guidelines to understand durable functions with .net core, c# and stateful se...Guidelines to understand durable functions with .net core, c# and stateful se...
Guidelines to understand durable functions with .net core, c# and stateful se...
 
Serverless on Azure with Functions
Serverless on Azure with FunctionsServerless on Azure with Functions
Serverless on Azure with Functions
 
SharePoint meetup Speaking Deck - Knowing the formula
SharePoint meetup Speaking Deck -  Knowing the formulaSharePoint meetup Speaking Deck -  Knowing the formula
SharePoint meetup Speaking Deck - Knowing the formula
 
Building stateful serverless orchestrations with Azure Durable Azure Function...
Building stateful serverless orchestrations with Azure Durable Azure Function...Building stateful serverless orchestrations with Azure Durable Azure Function...
Building stateful serverless orchestrations with Azure Durable Azure Function...
 
Anti Patterns and Mistakes Using Serverless (ServerlessConf SF - 08 2018)
Anti Patterns and Mistakes Using Serverless (ServerlessConf SF - 08 2018)Anti Patterns and Mistakes Using Serverless (ServerlessConf SF - 08 2018)
Anti Patterns and Mistakes Using Serverless (ServerlessConf SF - 08 2018)
 
Durable Azure Functions
Durable Azure FunctionsDurable Azure Functions
Durable Azure Functions
 
Workflow as code with Azure Durable Functions
Workflow as code with Azure Durable FunctionsWorkflow as code with Azure Durable Functions
Workflow as code with Azure Durable Functions
 
Building API in the cloud using Azure Functions
Building API in the cloud using Azure FunctionsBuilding API in the cloud using Azure Functions
Building API in the cloud using Azure Functions
 
Building scalable applications with angular js
Building scalable applications with angular jsBuilding scalable applications with angular js
Building scalable applications with angular js
 
4 Integrating azure monitor with power bi and power automate
4 Integrating azure monitor with power bi and power automate4 Integrating azure monitor with power bi and power automate
4 Integrating azure monitor with power bi and power automate
 

More from Massimo Bonanni

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 FunctionsMassimo Bonanni
 
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...Massimo Bonanni
 
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...Massimo Bonanni
 
Welcome Azure Functions 2. 0
Welcome Azure Functions 2. 0Welcome Azure Functions 2. 0
Welcome Azure Functions 2. 0Massimo Bonanni
 
Soluzioni IoT con le tecnologie Microsoft
Soluzioni IoT con le tecnologie MicrosoftSoluzioni IoT con le tecnologie Microsoft
Soluzioni IoT con le tecnologie MicrosoftMassimo Bonanni
 
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!!Massimo Bonanni
 
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!!Massimo Bonanni
 
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!!Massimo Bonanni
 
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 FabricMassimo Bonanni
 
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 frameworkMassimo Bonanni
 
Microservices architecture & Service Fabric
Microservices architecture & Service FabricMicroservices architecture & Service Fabric
Microservices architecture & Service FabricMassimo Bonanni
 
Introduzione allo sviluppo UWP per xBox
Introduzione allo sviluppo UWP per xBoxIntroduzione allo sviluppo UWP per xBox
Introduzione allo sviluppo UWP per xBoxMassimo Bonanni
 
Cognitive Services & LUIS
Cognitive Services & LUISCognitive Services & LUIS
Cognitive Services & LUISMassimo Bonanni
 
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 serviziMassimo Bonanni
 
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 appsMassimo Bonanni
 
Soluzioni IoT con le tecnologie Microsoft
Soluzioni IoT con le tecnologie MicrosoftSoluzioni IoT con le tecnologie Microsoft
Soluzioni IoT con le tecnologie MicrosoftMassimo Bonanni
 
Xamarin Test Cloud
Xamarin Test CloudXamarin Test Cloud
Xamarin Test CloudMassimo Bonanni
 

More from Massimo Bonanni (17)

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...
 
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
 
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

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 

Recently uploaded (20)

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 

The art of Azure Functions (unit) testing and monitoring

  • 1. #PitchOnline presents: #PitchOnline presents: Massimo Bonanni Paranormal Trainer, with the head in the Cloud and all the REST in microservices! massimo.bonanni@microsoft.com @massimobonanni
  • 2. Scifoni Ivano Fabio Mannis Francesco Del Re Matteo Riccardi Valerio Benedetti The art of Azure Functions (unit) testing and monitoring!
  • 3. The issue…. If you want to use Azure Functions as components of your Enterprise solutions, you must test and monitor them!!!
  • 4. What are Azure Functions Author functions in C#, F#, Node.JS, Java, Powershell, and more Code Events React to timers, HTTP , or events from your favorite Azure services, with more on the way Outputs Send results to an ever-growing collection of services The art of Azure Functions (unit) testing and monitoring!
  • 5. What is a Unit Test In a unit test you invoke a piece of your code with a set of parameters and you checks the correctness its behavior. In a unit test you must substitute all your external reference with a mock or stub. Mock is for the software what a dummy is for a car crash test (you don’t test a car with a human being inside…I Hope!!) The art of Azure Functions (unit) testing and monitoring!
  • 6. Azure Functions Dependencies You should implement your Azure Functions to allow you to use mock/stub for all external reference! Your Function Trigger Binding Binding Binding Binding Your Service Your Service Your Service Your Service Logger (infrastructure) The art of Azure Functions (unit) testing and monitoring!
  • 7. Azure Function … untestable!! The art of Azure Functions (unit) testing and monitoring!
  • 8. Azure Function … trigger!! Trigger You can mock it because the trigger payload is a POCO class The art of Azure Functions (unit) testing and monitoring!
  • 9. Azure Function … bindings!! Binding You can mock it because the binding payload is an interface The art of Azure Functions (unit) testing and monitoring!
  • 10. Azure Function … logger!! Logger (infrastructural objects) You can mock it because the logger is an interface The art of Azure Functions (unit) testing and monitoring!
  • 11. Azure Function … your service!! External service You cannot substitute it with your mock because it is created inside the Azure Function and you haven’t a way to substitute it The art of Azure Functions (unit) testing and monitoring!
  • 12. Make your Azure Function testable!!! The solution of your problem is: Dependency Injection !! Azure Functions Runtime is based on .NET Core. Azure Functions support the same ASP.NET Core Dependency Injection!!! Using Dependency Injection you provide a way to substitute your Services with a mock! The art of Azure Functions (unit) testing and monitoring!
  • 13. Azure Function … testable!! Constructor Injection You can choose what kind of actual service you want to use when you instantiate the function. In a test you can substitute it with a mock!! The art of Azure Functions (unit) testing and monitoring!
  • 14. Azure Function … how to use mock!! Mock Create a mock to use in the test!! The art of Azure Functions (unit) testing and monitoring!
  • 15. DEMO Azure Functions Unit Testing The art of Azure Functions (unit) testing and monitoring!
  • 16. Monitoring Azure Functions Once you deploy your Azure Functions on Azure, you need to monitor them to check when something goes wrong. The signature of an Azure Function Run method provides the instance of ILogger that you can use to log information about your code. Using ILogger, you can collect information from your code execution to monitor and triage errors and exceptions. The art of Azure Functions (unit) testing and monitoring!
  • 17. Azure Functions Monitor Azure Functions provide out-of-the-box monitor feature. For each Function, you can have info about every function execution. The art of Azure Functions (unit) testing and monitoring!
  • 18. Azure Functions and Application Insight The Azure Functions platform offers built-in integration with Azure Application Insights. Put the Application Insights instrumentation key in the function app settings. The art of Azure Functions (unit) testing and monitoring!
  • 19. Configure monitoring Logging is configured in host.json file. Logger default level Logger level for all the functions in Function App Logger level for a specific function in Function App Logger category for .NET runtime components invoked by the host The art of Azure Functions (unit) testing and monitoring!
  • 20. Custom Metrics Azure Function SDK provides you extension methods to log custom metrics. The art of Azure Functions (unit) testing and monitoring!
  • 21. Pricing Azure Functions consumption plan is billed based on per-second resource consumption and executions The art of Azure Functions (unit) testing and monitoring!
  • 22. Pricing Azure Functions consumption plan is billed based on per-second resource consumption and executions If your function use 1GB of memory and its duration is 1 second, you pay €0.000014 each time the function runs. The art of Azure Functions (unit) testing and monitoring!
  • 23. Pricing Azure Functions consumption plan is billed based on per-second resource consumption and executions If your function runs 1 million times every month, you pay €0.169 each month. The art of Azure Functions (unit) testing and monitoring!
  • 24. Pricing - Example You have a function: • It runs every second • Its duration is 1 second • It uses 512 MB of memory The art of Azure Functions (unit) testing and monitoring!
  • 25. Resource Consumption Billing Calculation • It runs every second • Its duration is 1 second • It uses 512 MB of memory Executions 2,592,000 Resource Consumption Total 2,592,000 x 1 sec = 2,592,000 sec Total GB-s 2,592,000 x 0.5 GB = 1,296,000 GB-s Total billable consumption 1,296,000 – 400,000 = 896,000 GB-s Total cost 896,000 x 0.000014€ = 12.54 € The art of Azure Functions (unit) testing and monitoring!
  • 26. Executions billing calculation • It runs every second • Its duration is 1 second • It uses 512 MB of memory Billable Monthly Executions 2,592,000 – 1,000,000 = 1,592,000 Total cost 1.592 x 0.169 € = 0.269 € The art of Azure Functions (unit) testing and monitoring!
  • 27. Total Monthly Cost • It runs every second • Its duration is 1 second • It uses 512 MB of memory Monthly resource consumption cost 12.540 € Monthly executions cost 0.269 € Total monthly cost 12.809 € The art of Azure Functions (unit) testing and monitoring!
  • 28. DEMO Azure Functions Monitoring The art of Azure Functions (unit) testing and monitoring!
  • 29. Takeaway Write an Azure Functions is simple! Testing Azure Functions is simple! Monitoring Azure Functions is simple! …. then …. Photo by Aaron Burden on Unsplash
  • 30.
  • 31. Massimo Bonanni Azure Technical Trainer @ Microsoft massimo.bonanni@microsoft.com @massimobonanni Connect with me on LinkedIn linkedin.com/in/massimobonanni/ http://bit.ly/MasteringServerless
  • 32. References Azure Functions Documentation https://docs.microsoft.com/en-US/azure/azure-functions/ Azure Functions Code Samples https://azure.microsoft.com/en-us/resources/samples/?service=functions&sort=0 Azure Updates https://azure.microsoft.com/en-us/roadmap/?category=compute Azure Friday – Build Serverless APIs with Azure Functions https://azure.microsoft.com/en-us/resources/videos/azure-friday-build-serverless-apis-with-azure-functions/ GitHub Demo https://github.com/massimobonanni/AzureFunctionsSamples The art of Azure Functions (unit) testing and monitoring!