SlideShare una empresa de Scribd logo
1 de 53
AzureF#unctions
@MikhailShilkov
https://mikhail.io
• Runs on top of App Service
• Web Jobs
• WebJobs SDK
• Consumption Plan
• Fixed Plan
• Self-hosted Runtime (preview)
• £0.15 per million executions
• £12 per million GB*s
• Free: 400,000 GB*s / 1 million executions
• Timer
• HTTP
• Queue / Service Bus / Event Hub
• Blob
• Cosmos DB Change
• Event Grid (and your custom events)
• Integrations (Logic Apps, Stream
Analytics, …)
Languages
• C#
• Javascript
• F#
• Java
• Others, experimental
// run.fsx
let run (myTimer: TimerInfo, log: TraceWriter) =
log.Info "Welcome to F# eXchange"
// function.json
{
"bindings": [
{
"type": "timerTrigger",
"name": "myTimer",
"schedule": "0 * * * * *"
}
]
}
Triggered on schedule
Cron expression
Log
Code
Files
Functions CLI
• Visual Studio Code + Ionide
• Paket
• FAKE
• Expecto
• Type Providers
• …
namespace PrecompiledApp
open Microsoft.AspNetCore.Mvc
open Microsoft.AspNetCore.Http
open Microsoft.Azure.WebJobs.Host
module PrecompiledHttp =
let run(req: HttpRequest, log: TraceWriter) =
log.Info "HTTP is easy with Azure Functions"
ContentResult(Content = "Precompiled F# FTW")
{
"bindings": [
{
"type": "httpTrigger",
"methods": ["get"],
"name": "req",
"route": "hellohttp"
}
],
"scriptFile": "../bin/PrecompiledApp.dll",
"entryPoint": "PrecompiledApp.PrecompiledHttp.run"
}
Triggered when this URL is requested
What to invoke
[<FunctionName("YourFunctionName")>]
let run(
[<HttpTrigger>] req: HttpRequest,
log: TraceWriter) =
log.Info "F# HTTP function smooshed your request."
ContentResult("function.json gets auto-generated")
It’s a Function…
… triggered by HTTP
{
"generatedBy": "Microsoft.NET.Sdk.Functions.Generator-1.0.9",
"configurationSource": "attributes",
"bindings": [
{
"type": "httpTrigger",
"name": "req"
}
],
"scriptFile": "../bin/AttributeBasedApp.dll",
"entryPoint": "AttributeBasedApp.AttributeBased.run"
}
Source of truth
[<FunctionName("Results")>]
let run([<HttpTrigger(AuthorizationLevel.Anonymous,
"get", "options", Route = "/products")>]
req,
[<DocumentDB("testdb", "testcollection",
ConnectionStringSetting = "CosmosDB",
SqlQuery = "SELECT top 2 * FROM c order by c._ts desc")>]
documents,
[<Table("SentimentTable", "DefaultPartition")>]
resultsTable) =
// ...
{
"bindings": [
{
"type": "queueTrigger",
"name": "tweet",
"queueName": "twitter"
}
]
}
{
"bindings": [
{
"type": "queueTrigger",
"name": "tweet",
"queueName": "twitter"
},
{
"direction": "out",
"name": "$return",
"type": "table",
"tableName": "Sentiment"
}
]
}
Return value goes to Table Storage
let run (tweet: Tweet): SentimentResult =
let score = TextAnalyticsAPI.SentimentScore(tweet.Text)
SentimentResult(
PartitionKey = "twitter",
RowKey = tweet.Id,
Text = tweet.Text,
Score = score)
{
"bindings": [
{
"type": "httpTrigger",
"name": "req",
"route": "{filename}/{name}"
},
{
"direction": "in",
"name": "template",
"type": "blob",
"path": "html/{filename}.html"
},
{
"type": "http",
"name": "$return",
"direction": "out"
}
]
}
Link
let run(req: HttpRequestMessage,
template: string,
name: string) =
let html = template.Replace("%name%", name)
ContentResult(
Content = html,
ContentType = "text/html")
Comes from Blob storage
Function
Chaining Functions
Workflow Orchestration
[<FunctionName("ChargeCreditCard")>]
let ChargeCreditCard([<ActivityTrigger>] order) = //...
[<FunctionName("ReserveStock")>]
let ReserveStock([<ActivityTrigger>] order) = //...
[<FunctionName("PlanShipment")>]
let PlanShipment([<ActivityTrigger>] order) = //...
open FSharp.Control.Tasks
[<FunctionName("OrderOrchestrator")>]
let run([<OrchestrationTrigger>] context: DurableOrchestrationContext) = task {
let order = context.GetInput<Order>()
let! payment = context.CallActivityAsync<Payment>("ChargeCreditCard", order)
let! stockItem = context.CallActivityAsync<StockItem>("ReserveStock", order)
let! shipment = context.CallActivityAsync<Shipment>("PlanShipment", order)
return OrderConfirmation(order, payment, stockItem, shipment)
}
async won’t work
• Stateless mindset
• But instances are reused between executions
0
200000
400000
600000
800000
1000000
1200000
0 1 2 3 4 5 6 7 8 9 10 11 12 13
#messagespending
minutes
0
100
200
300
400
500
600
700
800
900
0:00 0:10 0:20 0:30 0:40 0:50 1:00
0
100
200
300
400
500
600
700
800
900
0
50
100
150
200
250
300
350
400
0:00 0:10 0:20 0:30 0:40 0:50 1:00
Requests 50th 90th 95th
• .NET Framework 4.7.1
• GA
• All triggers supported
• Full scalability
• .NET Core 2.0
• Preview
• WIP
• Limited scalability
• Fast growth => Technical debt
• No uniformity among Binding types
• Reference version conflicts
• External paket.lock defined by Azure Functions team
• Use it in paket.dependencies:
• “Developed in the open”
• Scale Controller is not open
• “Glue”: webhooks, integration with Azure services
• Prototypes
• Low traffic apps
• Unusual load profiles
• Message/event processing
• Small, green-field, event-driven application
• Avoid migration of existing complex projects (yet)
Thank You!

Más contenido relacionado

La actualidad más candente

Alfresco SAUG: CMIS & Integrations
Alfresco SAUG: CMIS & IntegrationsAlfresco SAUG: CMIS & Integrations
Alfresco SAUG: CMIS & Integrations
Jeff Potts
 
Lift 2 0
Lift 2 0Lift 2 0
Lift 2 0
SO
 

La actualidad más candente (20)

Alex Thissen "Server-less compute with .NET based Azure Functions"
Alex Thissen "Server-less compute with .NET based Azure Functions"Alex Thissen "Server-less compute with .NET based Azure Functions"
Alex Thissen "Server-less compute with .NET based Azure Functions"
 
REST Web API with MongoDB
REST Web API with MongoDBREST Web API with MongoDB
REST Web API with MongoDB
 
AJAX
AJAXAJAX
AJAX
 
MongoDB at ZPUGDC
MongoDB at ZPUGDCMongoDB at ZPUGDC
MongoDB at ZPUGDC
 
mobile in the cloud with diamonds. improved.
mobile in the cloud with diamonds. improved.mobile in the cloud with diamonds. improved.
mobile in the cloud with diamonds. improved.
 
Learn Ajax here
Learn Ajax hereLearn Ajax here
Learn Ajax here
 
Synapseindia dot net development web applications with ajax
Synapseindia dot net development  web applications with ajaxSynapseindia dot net development  web applications with ajax
Synapseindia dot net development web applications with ajax
 
JSON and XML
JSON and XMLJSON and XML
JSON and XML
 
Benchx: An XQuery benchmarking web application
Benchx: An XQuery benchmarking web application Benchx: An XQuery benchmarking web application
Benchx: An XQuery benchmarking web application
 
Joins and Other Aggregation Enhancements Coming in MongoDB 3.2
Joins and Other Aggregation Enhancements Coming in MongoDB 3.2Joins and Other Aggregation Enhancements Coming in MongoDB 3.2
Joins and Other Aggregation Enhancements Coming in MongoDB 3.2
 
Alfresco SAUG: CMIS & Integrations
Alfresco SAUG: CMIS & IntegrationsAlfresco SAUG: CMIS & Integrations
Alfresco SAUG: CMIS & Integrations
 
Querying Nested JSON Data Using N1QL and Couchbase
Querying Nested JSON Data Using N1QL and CouchbaseQuerying Nested JSON Data Using N1QL and Couchbase
Querying Nested JSON Data Using N1QL and Couchbase
 
SharePoint 2013 APIs
SharePoint 2013 APIsSharePoint 2013 APIs
SharePoint 2013 APIs
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
 
Lift 2 0
Lift 2 0Lift 2 0
Lift 2 0
 
Xa transactions over camel routes
Xa transactions over camel routesXa transactions over camel routes
Xa transactions over camel routes
 
The Ring programming language version 1.2 book - Part 31 of 84
The Ring programming language version 1.2 book - Part 31 of 84The Ring programming language version 1.2 book - Part 31 of 84
The Ring programming language version 1.2 book - Part 31 of 84
 
JOOQ and Flyway
JOOQ and FlywayJOOQ and Flyway
JOOQ and Flyway
 
Introduction about-ajax-framework
Introduction about-ajax-frameworkIntroduction about-ajax-framework
Introduction about-ajax-framework
 
Building .NET Apps using Couchbase Lite
Building .NET Apps using Couchbase LiteBuilding .NET Apps using Couchbase Lite
Building .NET Apps using Couchbase Lite
 

Similar a Azure F#unctions

OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
mfrancis
 
jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013
jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013
jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013
Kiril Iliev
 

Similar a Azure F#unctions (20)

Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディングXitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
 
Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014
 
Going Serverless with Azure Functions
Going Serverless with Azure FunctionsGoing Serverless with Azure Functions
Going Serverless with Azure Functions
 
Html5 For Jjugccc2009fall
Html5 For Jjugccc2009fallHtml5 For Jjugccc2009fall
Html5 For Jjugccc2009fall
 
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
 
OSGi and Spring Data for simple (Web) Application Development
OSGi and Spring Data  for simple (Web) Application DevelopmentOSGi and Spring Data  for simple (Web) Application Development
OSGi and Spring Data for simple (Web) Application Development
 
Asynchronous Web Programming with HTML5 WebSockets and Java
Asynchronous Web Programming with HTML5 WebSockets and JavaAsynchronous Web Programming with HTML5 WebSockets and Java
Asynchronous Web Programming with HTML5 WebSockets and Java
 
Socket.io
Socket.ioSocket.io
Socket.io
 
Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSockets
 
Go Web Development
Go Web DevelopmentGo Web Development
Go Web Development
 
How to Build Your First Web App in Go
How to Build Your First Web App in GoHow to Build Your First Web App in Go
How to Build Your First Web App in Go
 
jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013
jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013
jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013
 
Rich Portlet Development in uPortal
Rich Portlet Development in uPortalRich Portlet Development in uPortal
Rich Portlet Development in uPortal
 
Introduction to Vert.x
Introduction to Vert.xIntroduction to Vert.x
Introduction to Vert.x
 
Html5 and web technology update
Html5 and web technology updateHtml5 and web technology update
Html5 and web technology update
 
Play!ng with scala
Play!ng with scalaPlay!ng with scala
Play!ng with scala
 
Web Standards Support in WebKit
Web Standards Support in WebKitWeb Standards Support in WebKit
Web Standards Support in WebKit
 
Mail OnLine Android Application at DroidCon - Turin - Italy
Mail OnLine Android Application at DroidCon - Turin - ItalyMail OnLine Android Application at DroidCon - Turin - Italy
Mail OnLine Android Application at DroidCon - Turin - Italy
 
HashiCorp Vault Plugin Infrastructure
HashiCorp Vault Plugin InfrastructureHashiCorp Vault Plugin Infrastructure
HashiCorp Vault Plugin Infrastructure
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. REST
 

Más de ☁️ Mikhail Shilkov

Más de ☁️ Mikhail Shilkov (9)

Monads Explained for OOP Developers
Monads Explained for OOP DevelopersMonads Explained for OOP Developers
Monads Explained for OOP Developers
 
Performance Tales of Serverless - CloudNative London 2018
Performance Tales of Serverless - CloudNative London 2018Performance Tales of Serverless - CloudNative London 2018
Performance Tales of Serverless - CloudNative London 2018
 
Performance Tales of Serverless
Performance Tales of ServerlessPerformance Tales of Serverless
Performance Tales of Serverless
 
Monads Explained for OOP Developers
Monads Explained for OOP DevelopersMonads Explained for OOP Developers
Monads Explained for OOP Developers
 
Azure F#unctions
Azure F#unctionsAzure F#unctions
Azure F#unctions
 
Event Driven Applications in F#
Event Driven Applications in F#Event Driven Applications in F#
Event Driven Applications in F#
 
Why Learn F# and Functional Programming
Why Learn F# and Functional ProgrammingWhy Learn F# and Functional Programming
Why Learn F# and Functional Programming
 
The taste of F#
The taste of F#The taste of F#
The taste of F#
 
Introduction of Functional Programming
Introduction of Functional ProgrammingIntroduction of Functional Programming
Introduction of Functional Programming
 

Último

Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
David Celestin
 
Uncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoUncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac Folorunso
Kayode Fayemi
 
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptxChiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
raffaeleoman
 
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
amilabibi1
 
If this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaIf this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New Nigeria
Kayode Fayemi
 

Último (15)

Dreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIIDreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio III
 
My Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle BaileyMy Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle Bailey
 
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdfAWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
 
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
 
Dreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video TreatmentDreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video Treatment
 
Uncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoUncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac Folorunso
 
lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.
 
Report Writing Webinar Training
Report Writing Webinar TrainingReport Writing Webinar Training
Report Writing Webinar Training
 
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdfSOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
 
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptxChiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
 
ICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdfICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdf
 
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
 
Digital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of DrupalDigital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of Drupal
 
If this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaIf this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New Nigeria
 
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdfThe workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
 

Azure F#unctions

Notas del editor

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