SlideShare a Scribd company logo
The art of Azure Functions (unit)
testing and monitoring
Massimo Bonanni
Paranormal Trainer, with the head in the Cloud and all the REST in microservices!
massimo.bonanni@microsoft.com
@massimobonanni
The issue….
If you want to use Azure Functions
as a components of your Enterprise
solutions, you must to test and
monitor them!!!
What are Azure Functions
Author functions in
C#, F#, Node.JS, Java,
Powershell, and
more
CodeEvents
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
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!!)
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
Logger
(infrastructure)
Your Service
Your Service
Your Service
Your Service
Azure Function … untestable!!
Azure Function … trigger!!
Trigger
You can mock it because
the trigger payload is a
POCO class
Azure Function … bindings!!
Binding
You can mock it because
the binding payload is an
interface
Azure Function … logger!!
Logger
(infrastructural stuffs)
You can mock it because
the logger is an interface
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
Make your Azure Function testable!!!
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!!
Azure Function … how to use mock!!
Mock
Create a mock to use in the
test!!
Azure Functions
Unit Testing
DEMO
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 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.
Azure Functions Monitor
Azure Functions provide out-of-the-box monitor feature.
For each Function, you have info about every function execution.
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.
Custom Metric
Azure Function SDK provides
you extension methods to
log custom metrics.
Azure Functions
Monitoring
DEMO
Take away
Writing an Azure Functions is simple!
Testing Azure Functions is simple!
Monitoring Azure Functions is simple!
…. then ….
The art of Azure Functions (unit) testing and monitoring
Q&A
Thanks for your
attention!!!!!
Massimo Bonanni
Azure Technical Trainer @ Microsoft
massimo.bonanni@microsoft.com
@massimobonanni
Connect with me on LinkedIn
linkedin.com/in/massimobonanni/
http://bit.ly/MasteringServerless
Q&A
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
Demo MortgageCalculator – GitHub
http://bit.ly/TestAZFunc
Demo Monitor Azure Functions – GitHub
http://bit.ly/MonitorAZFunc

More Related Content

What's hot (20)

PDF
IoT in salsa Serverless
Massimo Bonanni
 
PDF
IoT in salsa serverless
Massimo Bonanni
 
PDF
Xmas Serverless Transformation: when the elf doesn’t scale!
Massimo Bonanni
 
PPTX
TUTTO SU VISUAL STUDIO ALM 2015
DotNetCampus
 
PDF
70-534: ARCHITECTING MICROSOFT AZURE SOLUTIONS
DotNetCampus
 
PPTX
Dnc2015 azure-microservizi-vforusso
DotNetCampus
 
PPT
Servicehost Customization
Eyal Vardi
 
PPTX
First Look at Azure Logic Apps (BAUG)
Daniel Toomey
 
PDF
Serverless API with Azure Functions
Analben Mehta
 
PPTX
ALM@Work - Team collaboration with visual studio alm 2012
DomusDotNet
 
PDF
From AUI to Atlaskit - Streamlining Development for Server & Cloud Apps
Atlassian
 
PDF
Building Faster With Your Team's UI Kit
Atlassian
 
PPTX
Discovering the Service Fabric's actor model
Massimo Bonanni
 
PPTX
Azure IoT Central
Marco Parenzan
 
PPTX
NashTech - Azure Application Insights
Phi Huynh
 
PPTX
Unleash the power of Serverless Computing
Gaurav Madaan
 
PPTX
ASP.NET MVC 5 and SignalR 2
Jaliya Udagedara
 
PDF
Mobx Internals
500Tech
 
PPTX
Discovering the Service Fabric's actor model
Massimo Bonanni
 
PPTX
Angular2 + Ng-Lightning + Lightning Design System = Great Apps
Emily Hurn
 
IoT in salsa Serverless
Massimo Bonanni
 
IoT in salsa serverless
Massimo Bonanni
 
Xmas Serverless Transformation: when the elf doesn’t scale!
Massimo Bonanni
 
TUTTO SU VISUAL STUDIO ALM 2015
DotNetCampus
 
70-534: ARCHITECTING MICROSOFT AZURE SOLUTIONS
DotNetCampus
 
Dnc2015 azure-microservizi-vforusso
DotNetCampus
 
Servicehost Customization
Eyal Vardi
 
First Look at Azure Logic Apps (BAUG)
Daniel Toomey
 
Serverless API with Azure Functions
Analben Mehta
 
ALM@Work - Team collaboration with visual studio alm 2012
DomusDotNet
 
From AUI to Atlaskit - Streamlining Development for Server & Cloud Apps
Atlassian
 
Building Faster With Your Team's UI Kit
Atlassian
 
Discovering the Service Fabric's actor model
Massimo Bonanni
 
Azure IoT Central
Marco Parenzan
 
NashTech - Azure Application Insights
Phi Huynh
 
Unleash the power of Serverless Computing
Gaurav Madaan
 
ASP.NET MVC 5 and SignalR 2
Jaliya Udagedara
 
Mobx Internals
500Tech
 
Discovering the Service Fabric's actor model
Massimo Bonanni
 
Angular2 + Ng-Lightning + Lightning Design System = Great Apps
Emily Hurn
 

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

PPTX
Azure functions
명신 김
 
PPTX
#SpFestSea azr203 Azure functions lessons learned
Vincent Biret
 
PPTX
Azure Functions - Introduction
Venkatesh Narayanan
 
PDF
Azure web functions little bites of services
Aaron Petry
 
PDF
Azure Functions
AxEdge Consulting
 
PPTX
Azure Functions.pptx
YachikaKamra
 
PPTX
Azure Functions in Action #CodePaLOUsa
Baskar rao Dsn
 
PPTX
Building API in the cloud using Azure Functions
Aleksandar Bozinovski
 
PPTX
Azure Functions & Serverless Computing
Abhimanyu Singhal
 
PPTX
Azure Functions primer - LDNA01-2019
Giulio Vian
 
PPTX
#SPFestDC #Azure #Functions V2: What's new and getting started
Vincent Biret
 
PPTX
Introduction to Azure Functions
Callon Campbell
 
PPTX
Azure Functions 101
Martin Abbott
 
PPTX
Play with azure functions
Baskar rao Dsn
 
PPTX
Going Serverless with Azure Functions #1 - Introduction to Azure Functions
Kasun Kodagoda
 
PPTX
#SPFestSea Introduction to #Azure #Functions v2
Vincent Biret
 
PPTX
Putting the 'ctions' in Azure Fun-ctions
NullOps
 
PPTX
Best Of Build: Durable fuctions + SignalR Service + Cognitive Search
Moaid Hathot
 
PDF
Chris Anderson and Yochay Kiriaty - Serverless Patterns with Azure Functions
ServerlessConf
 
PPTX
Durable Azure Functions
Pushkar Saraf
 
Azure functions
명신 김
 
#SpFestSea azr203 Azure functions lessons learned
Vincent Biret
 
Azure Functions - Introduction
Venkatesh Narayanan
 
Azure web functions little bites of services
Aaron Petry
 
Azure Functions
AxEdge Consulting
 
Azure Functions.pptx
YachikaKamra
 
Azure Functions in Action #CodePaLOUsa
Baskar rao Dsn
 
Building API in the cloud using Azure Functions
Aleksandar Bozinovski
 
Azure Functions & Serverless Computing
Abhimanyu Singhal
 
Azure Functions primer - LDNA01-2019
Giulio Vian
 
#SPFestDC #Azure #Functions V2: What's new and getting started
Vincent Biret
 
Introduction to Azure Functions
Callon Campbell
 
Azure Functions 101
Martin Abbott
 
Play with azure functions
Baskar rao Dsn
 
Going Serverless with Azure Functions #1 - Introduction to Azure Functions
Kasun Kodagoda
 
#SPFestSea Introduction to #Azure #Functions v2
Vincent Biret
 
Putting the 'ctions' in Azure Fun-ctions
NullOps
 
Best Of Build: Durable fuctions + SignalR Service + Cognitive Search
Moaid Hathot
 
Chris Anderson and Yochay Kiriaty - Serverless Patterns with Azure Functions
ServerlessConf
 
Durable Azure Functions
Pushkar Saraf
 
Ad

More from Massimo Bonanni (17)

PDF
Architetture Serverless con SQL Server e Azure Functions
Massimo Bonanni
 
PDF
Tutto quello che avreste voluto sapere sull'API Management (e non avete mai o...
Massimo Bonanni
 
PDF
Everything you always wanted to know about API Management (but were afraid to...
Massimo Bonanni
 
PPTX
Welcome Azure Functions 2. 0
Massimo Bonanni
 
PPTX
Soluzioni IoT con le tecnologie Microsoft
Massimo Bonanni
 
PPTX
Project Gesture & Real Sense: il potere nelle mani!!
Massimo Bonanni
 
PPTX
Project Gesture & RealSense: gestures in a simple way!!
Massimo Bonanni
 
PPTX
Project Prague & RealSense: il potere nelle mani!!
Massimo Bonanni
 
PPTX
L'approccio ai microservizi secondo Service Fabric
Massimo Bonanni
 
PPTX
The Microservices world in. NET Core and. NET framework
Massimo Bonanni
 
PPTX
Microservices architecture & Service Fabric
Massimo Bonanni
 
PPTX
Introduzione allo sviluppo UWP per xBox
Massimo Bonanni
 
PPTX
Cognitive Services & LUIS
Massimo Bonanni
 
PPTX
Service Fabric: la potenza dei micro servizi
Massimo Bonanni
 
PPTX
Automated UI testing for iOs and Android mobile apps
Massimo Bonanni
 
PPTX
Soluzioni IoT con le tecnologie Microsoft
Massimo Bonanni
 
PPTX
Xamarin Test Cloud
Massimo Bonanni
 
Architetture Serverless con SQL Server e Azure Functions
Massimo Bonanni
 
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...
Massimo Bonanni
 
Welcome Azure Functions 2. 0
Massimo Bonanni
 
Soluzioni IoT con le tecnologie Microsoft
Massimo Bonanni
 
Project Gesture & Real Sense: il potere nelle mani!!
Massimo Bonanni
 
Project Gesture & RealSense: gestures in a simple way!!
Massimo Bonanni
 
Project Prague & RealSense: il potere nelle mani!!
Massimo Bonanni
 
L'approccio ai microservizi secondo Service Fabric
Massimo Bonanni
 
The Microservices world in. NET Core and. NET framework
Massimo Bonanni
 
Microservices architecture & Service Fabric
Massimo Bonanni
 
Introduzione allo sviluppo UWP per xBox
Massimo Bonanni
 
Cognitive Services & LUIS
Massimo Bonanni
 
Service Fabric: la potenza dei micro servizi
Massimo Bonanni
 
Automated UI testing for iOs and Android mobile apps
Massimo Bonanni
 
Soluzioni IoT con le tecnologie Microsoft
Massimo Bonanni
 
Xamarin Test Cloud
Massimo Bonanni
 
Ad

Recently uploaded (20)

PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
Python basic programing language for automation
DanialHabibi2
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 

The art of Azure Functions (unit) testing and monitoring

  • 1. The art of Azure Functions (unit) testing and monitoring Massimo Bonanni Paranormal Trainer, with the head in the Cloud and all the REST in microservices! [email protected] @massimobonanni
  • 2. The issue…. If you want to use Azure Functions as a components of your Enterprise solutions, you must to test and monitor them!!!
  • 3. What are Azure Functions Author functions in C#, F#, Node.JS, Java, Powershell, and more CodeEvents 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
  • 4. 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!!)
  • 5. 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 Logger (infrastructure) Your Service Your Service Your Service Your Service
  • 6. Azure Function … untestable!!
  • 7. Azure Function … trigger!! Trigger You can mock it because the trigger payload is a POCO class
  • 8. Azure Function … bindings!! Binding You can mock it because the binding payload is an interface
  • 9. Azure Function … logger!! Logger (infrastructural stuffs) You can mock it because the logger is an interface
  • 10. 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
  • 11. Make your Azure Function testable!!!
  • 12. 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!!
  • 13. Azure Function … how to use mock!! Mock Create a mock to use in the test!!
  • 15. 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 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.
  • 16. Azure Functions Monitor Azure Functions provide out-of-the-box monitor feature. For each Function, you have info about every function execution.
  • 17. 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.
  • 18. Custom Metric Azure Function SDK provides you extension methods to log custom metrics.
  • 20. Take away Writing an Azure Functions is simple! Testing Azure Functions is simple! Monitoring Azure Functions is simple! …. then ….
  • 22. Q&A Thanks for your attention!!!!! Massimo Bonanni Azure Technical Trainer @ Microsoft [email protected] @massimobonanni Connect with me on LinkedIn linkedin.com/in/massimobonanni/ http://bit.ly/MasteringServerless Q&A
  • 23. 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 Demo MortgageCalculator – GitHub http://bit.ly/TestAZFunc Demo Monitor Azure Functions – GitHub http://bit.ly/MonitorAZFunc