SlideShare a Scribd company logo
1 of 38
Building API in the cloud
using Azure Functions
Aleksandar Bozinovski
Technical Lead, Seavus
PLATINUM
GOLD
SILVER
BRONZE
MEDIA
PARTNER
SUPPORTING
PARTNERS
OUR PARTNERS
Ве молиме исклучете ги
мобилните уреди
Please turn off your
mobile devices
Agenda
• Journey to Azure Functions
• Developing Azure Functions in Azure Portal
• Developing Azure Functions with Visual Studio
• Hosting and pricing
• Typical usage scenarios
App Service
• Hosting applications inside of IIS (Internet
Information Services) on Windows
• Needs an App Service Plan
• The App Service Plan defines the hardware resources
• Made to support mainly web applications
• Difficult to run
• Batch processing
• Scheduled tasks
• Long-running processes
Web Jobs
• Built-in triggers
• Azure Storage Queue
• Service Bus
• Schedule tasks
• Needs an App Service Plan
• The App Service Plan defines the hardware
resources
• Difficult to scale
App Service Plan
Introducing Functions
+
Code Events + Data
Azure Functions
• More triggers
• Cosmos DB
• Event Hub
• HTTP
• Web Hook
• Pay-per-use
• Doesn’t need an App Service Plan
• Although can run on a App Service Plan too
• Easy to scale
Azure Functions History
App Service FunctionsWeb Jobs
Azure Functions - Serverless
Event-driven
instant scale
Micro-billingAbstraction
of servers
Supported Languages
C# Script - CSX
• Automatically referenced
• mscorlib
• System
• System.Core
• System.Xml
• System.Net.Http
• Microsoft.Azure.WebJobs
• Microsoft.Azure.WebJobs.Host
• Microsoft.Azure.WebJobs.Extensions
• System.Web.Http
• System.Net.Http.Formatting
• Platform packages, use #r
directly
• Newtonsoft.Json
• Microsoft.WindowsAzure.Storage
• Microsoft.ServiceBus
• Microsoft.AspNet.WebHooks.Receivers
• Microsoft.AspNet.WebHooks.Common
• Microsoft.Azure.NotificationHubs
Triggers and Bindings
DEMO 1
Create CSX Azure Function in Portal
Create Function App
• Create Function App
Create Http Triggered Function
• Create Http Triggered Function
Run Function
• Run Function
Create Timer Triggered Function
• Create Timer Triggered Function
Function Live Monitoring
• Function Live Monitoring
Azure Functions Tools for Visual
Studio
• Edit, build, and run
functions locally.
• Publish directly to Azure.
• Use attributes to declare
function bindings directly in
the C# code.
• Develop and deploy pre-
compiled C# functions.
• Included in the Visual
Studio 2017 version 15.5
Azure Function App
• Based on .NET class
libraries
• Get the full power of
IntelliSense, unit testing,
and local debugging
Visual Studio 2017 Tooling
• Create Timer Triggered Function
DEMO 2
Azure Functions BlobTrigger AI data processing
Function App with Visual Studio
Used APIs and libraries
• Faces API
• Project Oxford SDK.
• CoreCompat GDI (our Azure Functions
are in .NET Core).
BlobTrigger
• Triggers function execution when blob is created
• Writes the output to a blob
Azure Functions hosting
• Consumption plan
• Instances are dynamically added and removed.
• Pay only when your functions are running.
• Scale out automatically, even during periods of high load.
• App Service plan
• Function apps run on dedicated App Service VMs.
• Pay for the utilized resources under the App Service plan.
• Functions can run longer than the maximum execution time
allowed on the Consumption plan (of 10 minutes).
Azure Functions scaling
• Up to 200
instances.
• A single instance
may process more
than one message
or request at a
time.
• New instances will
only be allocated
at most once every
10 seconds.
Azure Functions billing
• Based on per-second resource consumption and
executions
METRIC PRICE FREE GRANT (PER
MONTH)
Execution Time* $0.000016/GB-s 400,000 GB-s
Total Executions* $0.20 per million
executions
1 million executions
Micro billing example
serverlesscalc.com
Usage 1 – as Web API
• HTTP Trigger Function == Web API Action *
// Endpoint URL: /api/products/{id}
public static async Task<HttpResponseMessage> Run(
[HttpTrigger(AuthorizationLevel.User, "get", Route = "products/{id}")]
HttpRequestMessage req,
int id, TraceWriter log)
{
var msg = new { Id = id, Message = "Hello World" };
return req.CreateResponse(HttpStatusCode.OK, msg);
}
// Endpoint URL: /products/{id}
[Route("products/{id}")]
[HttpGet]
public async Task<IActionResult> GetProduct(int id)
{
var msg = new { Id = id, Message = "Hello World" };
return Ok(msg);
}
* Except that is not!
Usage 1 – as Web API
• Functions are always static methods.
• Functions always receive HttpRequestMessage instance as
a parameter.
• DI not natively supported!
• Benefits in scaling and maybe in pricing due to micro
billing.
Usage 2 – for scheduled tasks
• Only one instance
runs at a time.
• Executions do not
overlap.
• Timer history
kept in storage.
Usage 3 – for backend event-based
processing
• Email when VM
changes.
• By using Azure Event
Grid.
• Process uploaded
images.
• By using Blob Trigger.
• Respond to Service
Bus event.
• By using Azure
Service Bus.
Thanks!
Any Questions?

More Related Content

What's hot

React.js - and how it changed our thinking about UI
React.js - and how it changed our thinking about UIReact.js - and how it changed our thinking about UI
React.js - and how it changed our thinking about UI
Marcin Grzywaczewski
 
Codestrong 2012 breakout session building your own custom cloud services
Codestrong 2012 breakout session   building your own custom cloud servicesCodestrong 2012 breakout session   building your own custom cloud services
Codestrong 2012 breakout session building your own custom cloud services
Axway Appcelerator
 

What's hot (20)

Azure functions
Azure functionsAzure functions
Azure functions
 
From Serverless to InterCloud
From Serverless to InterCloudFrom Serverless to InterCloud
From Serverless to InterCloud
 
Azure PaaS (WebApp & SQL Database) workshop solution
Azure PaaS (WebApp & SQL Database) workshop solutionAzure PaaS (WebApp & SQL Database) workshop solution
Azure PaaS (WebApp & SQL Database) workshop solution
 
React.js - and how it changed our thinking about UI
React.js - and how it changed our thinking about UIReact.js - and how it changed our thinking about UI
React.js - and how it changed our thinking about UI
 
Forge - DevCon 2016: From Desktop to the Cloud with Forge
Forge - DevCon 2016: From Desktop to the Cloud with ForgeForge - DevCon 2016: From Desktop to the Cloud with Forge
Forge - DevCon 2016: From Desktop to the Cloud with Forge
 
Azure Functions in Action #CodePaLOUsa
Azure Functions in Action #CodePaLOUsaAzure Functions in Action #CodePaLOUsa
Azure Functions in Action #CodePaLOUsa
 
Tokyo Azure Meetup #7 - Introduction to Serverless Architectures with Azure F...
Tokyo Azure Meetup #7 - Introduction to Serverless Architectures with Azure F...Tokyo Azure Meetup #7 - Introduction to Serverless Architectures with Azure F...
Tokyo Azure Meetup #7 - Introduction to Serverless Architectures with Azure F...
 
TechEvent 2019: Nachhaltige Client-Architekturen mit Angular Elements; Thomas...
TechEvent 2019: Nachhaltige Client-Architekturen mit Angular Elements; Thomas...TechEvent 2019: Nachhaltige Client-Architekturen mit Angular Elements; Thomas...
TechEvent 2019: Nachhaltige Client-Architekturen mit Angular Elements; Thomas...
 
Public v1 real world example of azure functions serverless conf london 2016
Public v1 real world example of azure functions serverless conf london 2016 Public v1 real world example of azure functions serverless conf london 2016
Public v1 real world example of azure functions serverless conf london 2016
 
Codestrong 2012 breakout session building your own custom cloud services
Codestrong 2012 breakout session   building your own custom cloud servicesCodestrong 2012 breakout session   building your own custom cloud services
Codestrong 2012 breakout session building your own custom cloud services
 
Azure Functions Overview
Azure Functions OverviewAzure Functions Overview
Azure Functions Overview
 
Building microservices with azure functions
Building microservices with azure functionsBuilding microservices with azure functions
Building microservices with azure functions
 
Developing Azure Functions as custom connectors for Flow and Nintex
Developing Azure Functions as custom connectors for Flow and NintexDeveloping Azure Functions as custom connectors for Flow and Nintex
Developing Azure Functions as custom connectors for Flow and Nintex
 
Azure Container Apps
Azure Container AppsAzure Container Apps
Azure Container Apps
 
Go Serverless with Cosmos DB, Azure Functions and Blazor
Go Serverless with Cosmos DB, Azure Functions and BlazorGo Serverless with Cosmos DB, Azure Functions and Blazor
Go Serverless with Cosmos DB, Azure Functions and Blazor
 
Play with azure functions
Play with azure functionsPlay with azure functions
Play with azure functions
 
Azure Update, July 2016
Azure Update, July 2016Azure Update, July 2016
Azure Update, July 2016
 
Azure functions
Azure functionsAzure functions
Azure functions
 
Web app job and functions - TUGAIT 2017
Web app job and functions  - TUGAIT 2017Web app job and functions  - TUGAIT 2017
Web app job and functions - TUGAIT 2017
 
Azure staticwebapps
Azure staticwebappsAzure staticwebapps
Azure staticwebapps
 

Similar to Building API in the cloud using Azure Functions

Similar to Building API in the cloud using Azure Functions (20)

Azure Functions Real World Examples
Azure Functions Real World Examples Azure Functions Real World Examples
Azure Functions Real World Examples
 
JoTechies - Azure Functions Using c#
JoTechies - Azure Functions Using c#JoTechies - Azure Functions Using c#
JoTechies - Azure Functions Using c#
 
Getting started with development in azure
Getting started with development in azureGetting started with development in azure
Getting started with development in azure
 
Serverless API with Azure Functions
Serverless API with Azure FunctionsServerless API with Azure Functions
Serverless API with Azure Functions
 
Developing Azure Functions for Flow and Nintex SPS SD 2018
Developing Azure Functions for Flow and Nintex SPS SD 2018Developing Azure Functions for Flow and Nintex SPS SD 2018
Developing Azure Functions for Flow and Nintex SPS SD 2018
 
Era of server less computing final
Era of server less computing finalEra of server less computing final
Era of server less computing final
 
Chris O'Brien - Best bits of Azure for Office 365/SharePoint developers
Chris O'Brien - Best bits of Azure for Office 365/SharePoint developersChris O'Brien - Best bits of Azure for Office 365/SharePoint developers
Chris O'Brien - Best bits of Azure for Office 365/SharePoint developers
 
Azure Functions 101
Azure Functions 101Azure Functions 101
Azure Functions 101
 
Era of server less computing
Era of server less computingEra of server less computing
Era of server less computing
 
Serverless in the Azure World
Serverless in the Azure WorldServerless in the Azure World
Serverless in the Azure World
 
SPS calgary 2017 introduction to azure functions microsoft flow
SPS calgary 2017 introduction to azure functions microsoft flowSPS calgary 2017 introduction to azure functions microsoft flow
SPS calgary 2017 introduction to azure functions microsoft flow
 
Azure Functions in Action #OrlandoCC
Azure Functions in Action #OrlandoCCAzure Functions in Action #OrlandoCC
Azure Functions in Action #OrlandoCC
 
Tokyo Azure Meetup #14 - Azure Functions Proxies
Tokyo Azure Meetup #14  -  Azure Functions ProxiesTokyo Azure Meetup #14  -  Azure Functions Proxies
Tokyo Azure Meetup #14 - Azure Functions Proxies
 
Introduction to Azure Functions
Introduction to Azure FunctionsIntroduction to Azure Functions
Introduction to Azure Functions
 
Heading to the Cloud : Introduction to deploying a Provider-Hosted App in Azure
Heading to the Cloud : Introduction to deploying a Provider-Hosted App in AzureHeading to the Cloud : Introduction to deploying a Provider-Hosted App in Azure
Heading to the Cloud : Introduction to deploying a Provider-Hosted App in Azure
 
SPCA2013 - Developing SharePoint 2013 Apps with Visual Studio 2012
SPCA2013 - Developing SharePoint 2013 Apps with Visual Studio 2012SPCA2013 - Developing SharePoint 2013 Apps with Visual Studio 2012
SPCA2013 - Developing SharePoint 2013 Apps with Visual Studio 2012
 
Developing SharePoint 2013 apps with Visual Studio 2012 - SharePoint Connecti...
Developing SharePoint 2013 apps with Visual Studio 2012 - SharePoint Connecti...Developing SharePoint 2013 apps with Visual Studio 2012 - SharePoint Connecti...
Developing SharePoint 2013 apps with Visual Studio 2012 - SharePoint Connecti...
 
Azure serverless computing
Azure serverless computingAzure serverless computing
Azure serverless computing
 
ASP .Net Core SPA Templates
ASP .Net Core SPA TemplatesASP .Net Core SPA Templates
ASP .Net Core SPA Templates
 
How to create a Function App on Cosmos DB
How to create a Function App on Cosmos DBHow to create a Function App on Cosmos DB
How to create a Function App on Cosmos DB
 

Recently uploaded

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 

Recently uploaded (20)

%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 

Building API in the cloud using Azure Functions

  • 1.
  • 2. Building API in the cloud using Azure Functions Aleksandar Bozinovski Technical Lead, Seavus
  • 4. Ве молиме исклучете ги мобилните уреди Please turn off your mobile devices
  • 5. Agenda • Journey to Azure Functions • Developing Azure Functions in Azure Portal • Developing Azure Functions with Visual Studio • Hosting and pricing • Typical usage scenarios
  • 6. App Service • Hosting applications inside of IIS (Internet Information Services) on Windows • Needs an App Service Plan • The App Service Plan defines the hardware resources • Made to support mainly web applications • Difficult to run • Batch processing • Scheduled tasks • Long-running processes
  • 7. Web Jobs • Built-in triggers • Azure Storage Queue • Service Bus • Schedule tasks • Needs an App Service Plan • The App Service Plan defines the hardware resources • Difficult to scale
  • 10. Azure Functions • More triggers • Cosmos DB • Event Hub • HTTP • Web Hook • Pay-per-use • Doesn’t need an App Service Plan • Although can run on a App Service Plan too • Easy to scale
  • 11. Azure Functions History App Service FunctionsWeb Jobs
  • 12. Azure Functions - Serverless Event-driven instant scale Micro-billingAbstraction of servers
  • 14. C# Script - CSX • Automatically referenced • mscorlib • System • System.Core • System.Xml • System.Net.Http • Microsoft.Azure.WebJobs • Microsoft.Azure.WebJobs.Host • Microsoft.Azure.WebJobs.Extensions • System.Web.Http • System.Net.Http.Formatting • Platform packages, use #r directly • Newtonsoft.Json • Microsoft.WindowsAzure.Storage • Microsoft.ServiceBus • Microsoft.AspNet.WebHooks.Receivers • Microsoft.AspNet.WebHooks.Common • Microsoft.Azure.NotificationHubs
  • 16. DEMO 1 Create CSX Azure Function in Portal
  • 17. Create Function App • Create Function App
  • 18. Create Http Triggered Function • Create Http Triggered Function
  • 20. Create Timer Triggered Function • Create Timer Triggered Function
  • 21. Function Live Monitoring • Function Live Monitoring
  • 22. Azure Functions Tools for Visual Studio • Edit, build, and run functions locally. • Publish directly to Azure. • Use attributes to declare function bindings directly in the C# code. • Develop and deploy pre- compiled C# functions. • Included in the Visual Studio 2017 version 15.5
  • 23. Azure Function App • Based on .NET class libraries • Get the full power of IntelliSense, unit testing, and local debugging
  • 24. Visual Studio 2017 Tooling • Create Timer Triggered Function
  • 25. DEMO 2 Azure Functions BlobTrigger AI data processing
  • 26. Function App with Visual Studio
  • 27. Used APIs and libraries • Faces API • Project Oxford SDK. • CoreCompat GDI (our Azure Functions are in .NET Core).
  • 28. BlobTrigger • Triggers function execution when blob is created • Writes the output to a blob
  • 29. Azure Functions hosting • Consumption plan • Instances are dynamically added and removed. • Pay only when your functions are running. • Scale out automatically, even during periods of high load. • App Service plan • Function apps run on dedicated App Service VMs. • Pay for the utilized resources under the App Service plan. • Functions can run longer than the maximum execution time allowed on the Consumption plan (of 10 minutes).
  • 30. Azure Functions scaling • Up to 200 instances. • A single instance may process more than one message or request at a time. • New instances will only be allocated at most once every 10 seconds.
  • 31. Azure Functions billing • Based on per-second resource consumption and executions METRIC PRICE FREE GRANT (PER MONTH) Execution Time* $0.000016/GB-s 400,000 GB-s Total Executions* $0.20 per million executions 1 million executions
  • 34. Usage 1 – as Web API • HTTP Trigger Function == Web API Action * // Endpoint URL: /api/products/{id} public static async Task<HttpResponseMessage> Run( [HttpTrigger(AuthorizationLevel.User, "get", Route = "products/{id}")] HttpRequestMessage req, int id, TraceWriter log) { var msg = new { Id = id, Message = "Hello World" }; return req.CreateResponse(HttpStatusCode.OK, msg); } // Endpoint URL: /products/{id} [Route("products/{id}")] [HttpGet] public async Task<IActionResult> GetProduct(int id) { var msg = new { Id = id, Message = "Hello World" }; return Ok(msg); } * Except that is not!
  • 35. Usage 1 – as Web API • Functions are always static methods. • Functions always receive HttpRequestMessage instance as a parameter. • DI not natively supported! • Benefits in scaling and maybe in pricing due to micro billing.
  • 36. Usage 2 – for scheduled tasks • Only one instance runs at a time. • Executions do not overlap. • Timer history kept in storage.
  • 37. Usage 3 – for backend event-based processing • Email when VM changes. • By using Azure Event Grid. • Process uploaded images. • By using Blob Trigger. • Respond to Service Bus event. • By using Azure Service Bus.

Editor's Notes

  1. WebJobs WebJobs were the first attempt to solve this problem. WebJobs have built-in triggers for a number of different events inside of Azure: storage queues, blobs, service bus queues, topics and schedule triggers. 
  2. Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. You can write just the code you need for the problem at hand, without worrying about a whole application or the infrastructure to run it. Functions can make development even more productive, and you can use your development language of choice, such as C#, F#, Node.js, Java, or PHP. A developer can deploy a piece of code as a Function in Azure. The function is triggered in some way to spawn an instance of execution. One can view Functions as a successor to Web Jobs that were based on an App Service Plan. 
  3. Abstraction of servers, infrastructure and configuration of operating system Event-driven scale Sub-second billing Stateless Serverless compute is a fully managed service. Some refer to it as Functions as a Service OS and Framework patching is performed for you There is zero administrative tasks and no need to manage any infrastructure You just deploy your code (function) and it runs Your code runs within seconds and for very short period of time Serverless compute scales quickly (almost instantly) and vastly Automatically scales within seconds No scale configuration is required (there is no way to configure scale or limits) Scales to match any given workload. Scales from zero to handle tens of thousands concurrent functions invocations within seconds Pay only for the time your code is running Serverless compute reacts to events React, in near real-time, to events and triggers Triggered by virtually any event from Azure service or 3rd party services Setup time, provisioning is long & costly
  4. The experimental languages in version 1.x don't scale well and don't support all bindings. For example, 1.x Python is slow because the Functions runtime runs python.exe with each function invocation. And while Python supports HTTP bindings, it can't access the request object. Experimental support for PowerShell in 1.x is limited to version 5.1, because that is what's installed by default on the VMs on which function apps run. If you want to run PowerShell scripts, consider Azure Automation.
  5. The Scale Controller monitors the rate of events and determine whether to scale out or scale in. The scale controller uses heuristics for each trigger type. 
  6. Executions Functions are billed based on total number of requested executions each month for all functions. Executions are counted each time a function is executed in response to an event, triggered by a binding. The first million executions are included free each month. Resource consumption Functions are billed based on observed resource consumption measured in gigabyte seconds (GB-s). Observed resource consumption is calculated by multiplying average memory size in gigabytes by the time in milliseconds it takes to execute the function. Memory used by a function is measured by rounding up to the nearest 128 MB, up to the maximum memory size of 1,536 MB, with execution time calculated by rounding up to the nearest 1 ms. The minimum execution time and memory for a single function execution is 100 ms and 128 mb respectively. Functions pricing includes a monthly free grant of 400,000 GB-s.
  7. Functions are always static methods. => Some architecture considerations. HttpRequestMessage instance as a parameter. => pipeline is very different. DI not natively supported. => Must use ServiceLocator or home made solutions.
  8. Functions are always static methods. => Some architecture considerations. HttpRequestMessage instance as a parameter. => pipeline is very different. DI not natively supported. => Must use ServiceLocator or home made solutions.
  9. Functions are always static methods. => Some architecture considerations. HttpRequestMessage instance as a parameter. => pipeline is very different. DI not natively supported. => Must use ServiceLocator or home made solutions.