SlideShare une entreprise Scribd logo
1  sur  40
Télécharger pour lire hors ligne
Lalit Kale
Develop in Ludicrous mode with
Azure Functions
About Me
• 15 years of Programming
• Use .NET to earn bread and butter
• Worked on very large scale systems in e-
Commerce , Banking and Insurance
• In spare time
• python, Go-Lang, OSS
• Loads of TED Talks
Goal
• Serverless
• Azure Serverless Offerings
• Introduction to Azure Functions
• Build Microservice with Azure Functions
• Durable Functions
• Durable Functions Patterns
Microservices – architectural approach
for cloud native apps
Monolithic
APP APP APP
Microservices
Large, all-inclusive app Small, independent services
Independent modules Isolated points of failure
Autonomous scalability
Microservices
Tech flexibility
Faster value delivery
Serverless – Great fit for Microservices
• Problems of traditional microservices
• Scaling of compute resources
• Operations dependency
• Pay per hosting nodes
• Services discovery and
• managing services integration
• Serverless solution
• Automatic scaling based on workload
• No infrastructure management
• Pay per execution (micro-billing)
• Event-Driven programming model
• (triggers + bindings), instant scale
Event-driven/
instant scale
Micro-billingAbstraction
of servers
What is Serverless?
$
What is Serverless?
clear separation between the code and its hosting environment
Azure Serverless Offerings
</>
Our Focus Today…
</>
Introducing Azure Functions
Code EventsAzure
Functions
Azure Functions Internals
Function Code Function Configuration
Language Runtime
WebJobs Core
Azure AppService
Functions Secret Sauce…
• Triggers are ways to start executing Azure function code
• Bindings are declarative way of binding data to Azure function
• All triggers have input data
• Data coming from services become input values for function code
• To output data to another service use the return value of the
function.
Functions Secret Sauce…
• Triggers
• Blob Storage
• Cosmos DB
• Event Hub
• HTTP
• Queues
• Service Bus
• Timer
• Webhook
• Bindings
• File
• Table
• Excel
• OneDrive
• Email
• Mobile app
• Notification
• More…
Scaling happens at the Function App level
Usually, each Function App
represents a different
microservice
Each Function App would
be an API with grouped
endpoints
(one function per endpoint)
Flexibility choosing the
language for each
microservice – one per
Function App
Hosting
options
Gain flexibility and develop your way
Web application backends
Mobile application backends
IoT-connected backends
Real-time file processing
Real-time stream processing
Automation of scheduled tasks
Extending SaaS Applications
Conversational bot processing
Sample scenarios for Functions
Demo
Azure Functions Hello World
- Portal Experience
- Visual Studio
- Azure Functions Core Tools
Migrate from VMs → serverless
Thermostat intelligence
is a clear differentiator
Ready for sudden vertical growth
in the consumer market—charged
for usage as they scale
20K+ IoT devices simulated
Event driven architecture works well for
IoT
Customer Success Story
GLAS®Smart Thermostat by Johnson Controls
Device to Cloud
Cloud to Device
IoT Hub for messaging
and managing devices
Event Hubs for routing
and throttling
Functions as
microservices
SignalR for device
messaging
Demo
Building a Microservice with Azure Functions
Stateless Microservices
What about Stateful Operations?
Not everything fits on a few-seconds
execution
Durable functions
What is Durable Functions?
• Advanced feature for writing long-running orchestrations as a single
C# function. No JSON schemas. No designer.
• New orchestrator functions can synchronously or asynchronously call
other functions.
• Automatic checkpointing, enabling “long running” functions.
• Solves a variety of complex, transactional coding problems in
serverless apps.
• Built on the open source Durable Task Framework.
Durable Functions Patterns
Pattern #1: Function chaining - Today
Problems:
• No visualization to show relationship between functions and queues.
• Middle queues are an implementation detail – conceptual overhead.
• Error handling adds a lot more complexity.
F1 F2 F3 F4
Pattern #1: Function chaining - Better
// calls functions in sequence
public static async Task<object> Run(DurableOrchestrationContext ctx)
{
try
{
var x = await ctx.CallFunctionAsync("F1");
var y = await ctx.CallFunctionAsync("F2", x);
var z = await ctx.CallFunctionAsync("F3", y);
return await ctx.CallFunctionAsync("F4", z);
}
catch (Exception)
{
// global error handling/compensation goes here
}
}
Pattern #2: Fan-out/Fan-in - Today
Problems:
• Fanning-out is easy, but fanning-in is significantly more complicated
• Functions offers no help with this scenario today
• All the same problems of the previous pattern
F1
F2
F3
Pattern #2: Fan-out/Fan-in - Easy
public static async Task Run(DurableOrchestrationContext ctx)
{
var parallelTasks = new List<Task<int>>();
// get a list of N work items to process in parallel
object[] workBatch = await ctx.CallFunctionAsync<object[]>("F1");
for (int i = 0; i < workBatch.Length; i++)
{
Task<int> task = ctx.CallFunctionAsync<int>("F2", workBatch[i]);
parallelTasks.Add(task);
}
await Task.WhenAll(parallelTasks);
// aggregate all N outputs and send result to F3
int sum = parallelTasks.Sum(t => t.Result);
await ctx.CallFunctionAsync("F3", sum);
}
Pattern #3: HTTP Async Response
Problems:
• Execution state needs to be explicitly stored and managed.
• Execution state and trigger state must be kept in sync manually.
• Start and GetStatus is often boilerplate code that is not related to the business problem.
Start DoWork
GetStatus
Pattern #3: HTTP Async Response – Built in!
> curl -X POST https://myfunc.azurewebsites.net/orchestrators/DoWork -H "Content-Length: 0" -i
HTTP/1.1 202 Accepted
Location: https://myfunc.azurewebsites.net/orchestrators/b79baf67f717453ca9e86c5da21e03ec
Server: Microsoft-IIS/8.0
> curl https://myfunc.azurewebsites.net/orchestrators/b79baf67f717453ca9e86c5da21e03ec -i
HTTP/1.1 202 Accepted
Content-Length: 173
Content-Type: application/json
Location: https://myfunc.azurewebsites.net/orchestrators/b79baf67f717453ca9e86c5da21e03ec
Server: Microsoft-IIS/8.0
{"runtimeStatus":"Running","createdTime":"2017-03-16T21:20:36Z","lastUpdatedTime":"2017-03-16T21:20:47Z"}
> curl https://myfunc.azurewebsites.net/orchestrators/b79baf67f717453ca9e86c5da21e03ec -i
HTTP/1.1 200 OK
Content-Length: 175
Content-Type: application/json
Server: Microsoft-IIS/8.0
{"runtimeStatus":"Completed","createdTime":"2017-03-16T21:20:36Z","lastUpdatedTime":"2017-03-16T21:20:57Z"}
Pattern #4: Actors
Problems:
• Functions are stateless and short-lived.
• Read/write access to external state needs to be carefully synchronized.
• Functions do not support the singleton pattern today.
Pattern #4: Actors (Eternal Orchestrations)
public static async Task Run(DurableOrchestrationContext ctx)
{
int counterState = ctx.GetInput<int>();
string operation = await ctx.WaitForExternalEvent<string>("operation");
if (operation == "incr")
{
counterState++;
}
else if (operation == "decr")
{
counterState--;
}
ctx.ContinueAsNew(counterState);
}
Pattern #5: Human Interaction w/Timeout
RequestApproval
Escalate
ProcessApproval
Problems:
• Can’t easily coordinate a timeout with an approval request notification.
• Need a mechanism to reliably cancel either the approval handling or the
timeout depending on the outcome.
Pattern #5: Human Interaction w/Timeout
public static async Task Run(DurableOrchestrationContext ctx)
{
await ctx.CallFunctionAsync<object[]>("RequestApproval");
using (var timeoutCts = new CancellationTokenSource())
{
DateTime dueTime = ctx.CurrentUtcDateTime.AddHours(72);
Task durableTimeout = ctx.CreateTimer(dueTime, 0, cts.Token);
Task<bool> approvalEvent = ctx.WaitForExternalEvent<bool>("ApprovalEvent");
if (approvalEvent == await Task.WhenAny(approvalEvent, durableTimeout))
{
timeoutCts.Cancel();
await ctx.CallFunctionAsync("HandleApproval", approvalEvent.Result);
}
else
{
await ctx.CallFunctionAsync("Escalate");
}
}
}
Important Orchestrator Limitations
• Orchestrator code is replayed on every rehydration to restore all local
state (local variables, etc).
• Function calls are never replayed – the outputs are remembered.
• This requires the orchestrator code to be deterministic.
• Rule #1: Never write logic that depends on random numbers,
DateTime.Now, Guid.NewGuid(), etc.
• Rule #2: Never do I/O directly in the orchestrator function.
• Rule #3: Do not write infinite loops
• Rule #4: Use the built-in workarounds for rules #1, #2, and #3
Takeaways
• Serverless – Glue of Cloud
• Sub-Second Billing
• Instant Scaling
• Focus on your code – Let Azure do the heavy lifting for you.
Questions and Answers
Thank you!
https://tryfunctions.com/ng-min/try?trial=true

Contenu connexe

Tendances

Closer Look at Cloud Centric Architectures
Closer Look at Cloud Centric ArchitecturesCloser Look at Cloud Centric Architectures
Closer Look at Cloud Centric ArchitecturesTodd Kaplinger
 
Introduction to microservices
Introduction to microservicesIntroduction to microservices
Introduction to microservicesAnil Allewar
 
About Microservices, Containers and their Underestimated Impact on Network Pe...
About Microservices, Containers and their Underestimated Impact on Network Pe...About Microservices, Containers and their Underestimated Impact on Network Pe...
About Microservices, Containers and their Underestimated Impact on Network Pe...Nane Kratzke
 
An introduction to Microservices
An introduction to MicroservicesAn introduction to Microservices
An introduction to MicroservicesCisco DevNet
 
Microservice Architecture 101
Microservice Architecture 101Microservice Architecture 101
Microservice Architecture 101Kochih Wu
 
Microservice architecture design principles
Microservice architecture design principlesMicroservice architecture design principles
Microservice architecture design principlesSanjoy Kumar Roy
 
Manatee to Dolphin: Transitioning to a Startup Mentality
Manatee to Dolphin: Transitioning to a Startup MentalityManatee to Dolphin: Transitioning to a Startup Mentality
Manatee to Dolphin: Transitioning to a Startup MentalityTodd Kaplinger
 
Microservice vs. Monolithic Architecture
Microservice vs. Monolithic ArchitectureMicroservice vs. Monolithic Architecture
Microservice vs. Monolithic ArchitecturePaul Mooney
 
Micro-services architecture
Micro-services architectureMicro-services architecture
Micro-services architectureFarwa Ansari
 
Microservices Architecture
Microservices ArchitectureMicroservices Architecture
Microservices ArchitectureIzzet Mustafaiev
 
Microservices and the future on Infrastructure
Microservices and the future on InfrastructureMicroservices and the future on Infrastructure
Microservices and the future on InfrastructurePini Reznik
 
Microservices architecture
Microservices architectureMicroservices architecture
Microservices architectureAbdelghani Azri
 
Think Small To Go Big - Introduction To Microservices
Think Small To Go Big - Introduction To MicroservicesThink Small To Go Big - Introduction To Microservices
Think Small To Go Big - Introduction To MicroservicesRyan Baxter
 
Airbnb, From Monolith to Microservices: How to Scale Your Architecture, Futur...
Airbnb, From Monolith to Microservices: How to Scale Your Architecture, Futur...Airbnb, From Monolith to Microservices: How to Scale Your Architecture, Futur...
Airbnb, From Monolith to Microservices: How to Scale Your Architecture, Futur...New Relic
 
Engage 2018 - What About the Apps? A Domino Modernisation Story
Engage 2018 - What About the Apps? A Domino Modernisation StoryEngage 2018 - What About the Apps? A Domino Modernisation Story
Engage 2018 - What About the Apps? A Domino Modernisation StoryJared Roberts
 
Microservices for Application Modernisation
Microservices for Application ModernisationMicroservices for Application Modernisation
Microservices for Application ModernisationAjay Kumar Uppal
 

Tendances (20)

Closer Look at Cloud Centric Architectures
Closer Look at Cloud Centric ArchitecturesCloser Look at Cloud Centric Architectures
Closer Look at Cloud Centric Architectures
 
Introduction to microservices
Introduction to microservicesIntroduction to microservices
Introduction to microservices
 
About Microservices, Containers and their Underestimated Impact on Network Pe...
About Microservices, Containers and their Underestimated Impact on Network Pe...About Microservices, Containers and their Underestimated Impact on Network Pe...
About Microservices, Containers and their Underestimated Impact on Network Pe...
 
An introduction to Microservices
An introduction to MicroservicesAn introduction to Microservices
An introduction to Microservices
 
Microservices Architecture
Microservices ArchitectureMicroservices Architecture
Microservices Architecture
 
Microservice Architecture 101
Microservice Architecture 101Microservice Architecture 101
Microservice Architecture 101
 
Microservice architecture design principles
Microservice architecture design principlesMicroservice architecture design principles
Microservice architecture design principles
 
Manatee to Dolphin: Transitioning to a Startup Mentality
Manatee to Dolphin: Transitioning to a Startup MentalityManatee to Dolphin: Transitioning to a Startup Mentality
Manatee to Dolphin: Transitioning to a Startup Mentality
 
Microservice vs. Monolithic Architecture
Microservice vs. Monolithic ArchitectureMicroservice vs. Monolithic Architecture
Microservice vs. Monolithic Architecture
 
From SOA to MSA
From SOA to MSAFrom SOA to MSA
From SOA to MSA
 
Micro-services architecture
Micro-services architectureMicro-services architecture
Micro-services architecture
 
Microservices Architecture
Microservices ArchitectureMicroservices Architecture
Microservices Architecture
 
Microservices and the future on Infrastructure
Microservices and the future on InfrastructureMicroservices and the future on Infrastructure
Microservices and the future on Infrastructure
 
Microservices architecture
Microservices architectureMicroservices architecture
Microservices architecture
 
Think Small To Go Big - Introduction To Microservices
Think Small To Go Big - Introduction To MicroservicesThink Small To Go Big - Introduction To Microservices
Think Small To Go Big - Introduction To Microservices
 
Microservices
MicroservicesMicroservices
Microservices
 
Introduction to Microservices
Introduction  to MicroservicesIntroduction  to Microservices
Introduction to Microservices
 
Airbnb, From Monolith to Microservices: How to Scale Your Architecture, Futur...
Airbnb, From Monolith to Microservices: How to Scale Your Architecture, Futur...Airbnb, From Monolith to Microservices: How to Scale Your Architecture, Futur...
Airbnb, From Monolith to Microservices: How to Scale Your Architecture, Futur...
 
Engage 2018 - What About the Apps? A Domino Modernisation Story
Engage 2018 - What About the Apps? A Domino Modernisation StoryEngage 2018 - What About the Apps? A Domino Modernisation Story
Engage 2018 - What About the Apps? A Domino Modernisation Story
 
Microservices for Application Modernisation
Microservices for Application ModernisationMicroservices for Application Modernisation
Microservices for Application Modernisation
 

Similaire à Develop in ludicrous mode with azure serverless

What's New in .Net 4.5
What's New in .Net 4.5What's New in .Net 4.5
What's New in .Net 4.5Malam Team
 
JoTechies - Azure Functions Using c#
JoTechies - Azure Functions Using c#JoTechies - Azure Functions Using c#
JoTechies - Azure Functions Using c#JoTechies
 
El camino a las Cloud Native Apps - Introduction
El camino a las Cloud Native Apps - IntroductionEl camino a las Cloud Native Apps - Introduction
El camino a las Cloud Native Apps - IntroductionPlain Concepts
 
Exploring Twitter's Finagle technology stack for microservices
Exploring Twitter's Finagle technology stack for microservicesExploring Twitter's Finagle technology stack for microservices
Exploring Twitter's Finagle technology stack for microservices💡 Tomasz Kogut
 
Azure Service Fabric: notes from the field (Sam Vanhoute @Integrate 2016)
Azure Service Fabric: notes from the field (Sam Vanhoute @Integrate 2016)Azure Service Fabric: notes from the field (Sam Vanhoute @Integrate 2016)
Azure Service Fabric: notes from the field (Sam Vanhoute @Integrate 2016)Codit
 
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
 
Durable Functions vs Logic App : la guerra dei workflow!!
Durable Functions vs Logic App : la guerra dei workflow!!Durable Functions vs Logic App : la guerra dei workflow!!
Durable Functions vs Logic App : la guerra dei workflow!!Massimo Bonanni
 
Building workflow solution with Microsoft Azure and Cloud | Integration Monday
Building workflow solution with Microsoft Azure and Cloud | Integration MondayBuilding workflow solution with Microsoft Azure and Cloud | Integration Monday
Building workflow solution with Microsoft Azure and Cloud | Integration MondayBizTalk360
 
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...MongoDB
 
Stateful patterns in Azure Functions
Stateful patterns in Azure FunctionsStateful patterns in Azure Functions
Stateful patterns in Azure FunctionsMassimo Bonanni
 
APIdays Paris 2018 - Will Serverless kill Containers and Operations? Stéphane...
APIdays Paris 2018 - Will Serverless kill Containers and Operations? Stéphane...APIdays Paris 2018 - Will Serverless kill Containers and Operations? Stéphane...
APIdays Paris 2018 - Will Serverless kill Containers and Operations? Stéphane...apidays
 
Will ServerLess kill containers and Operations
Will ServerLess kill containers and OperationsWill ServerLess kill containers and Operations
Will ServerLess kill containers and OperationsStephane Woillez
 
Working with data using Azure Functions.pdf
Working with data using Azure Functions.pdfWorking with data using Azure Functions.pdf
Working with data using Azure Functions.pdfStephanie Locke
 
Introduction to Realm Mobile Platform
Introduction to Realm Mobile PlatformIntroduction to Realm Mobile Platform
Introduction to Realm Mobile PlatformChristian Melchior
 
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...MSDEVMTL
 
Windows Workflow Foundation Demystified - overview and business cases
Windows Workflow Foundation Demystified - overview and business casesWindows Workflow Foundation Demystified - overview and business cases
Windows Workflow Foundation Demystified - overview and business casesAndrei Oros
 

Similaire à Develop in ludicrous mode with azure serverless (20)

What's New in .Net 4.5
What's New in .Net 4.5What's New in .Net 4.5
What's New in .Net 4.5
 
JoTechies - Azure Functions Using c#
JoTechies - Azure Functions Using c#JoTechies - Azure Functions Using c#
JoTechies - Azure Functions Using c#
 
El camino a las Cloud Native Apps - Introduction
El camino a las Cloud Native Apps - IntroductionEl camino a las Cloud Native Apps - Introduction
El camino a las Cloud Native Apps - Introduction
 
Exploring Twitter's Finagle technology stack for microservices
Exploring Twitter's Finagle technology stack for microservicesExploring Twitter's Finagle technology stack for microservices
Exploring Twitter's Finagle technology stack for microservices
 
ServerLess by usama Azure fuctions.pptx
ServerLess by usama Azure fuctions.pptxServerLess by usama Azure fuctions.pptx
ServerLess by usama Azure fuctions.pptx
 
Azure Service Fabric: notes from the field (Sam Vanhoute @Integrate 2016)
Azure Service Fabric: notes from the field (Sam Vanhoute @Integrate 2016)Azure Service Fabric: notes from the field (Sam Vanhoute @Integrate 2016)
Azure Service Fabric: notes from the field (Sam Vanhoute @Integrate 2016)
 
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...
 
Azure Umbraco workshop
Azure Umbraco workshopAzure Umbraco workshop
Azure Umbraco workshop
 
Durable Functions vs Logic App : la guerra dei workflow!!
Durable Functions vs Logic App : la guerra dei workflow!!Durable Functions vs Logic App : la guerra dei workflow!!
Durable Functions vs Logic App : la guerra dei workflow!!
 
Building workflow solution with Microsoft Azure and Cloud | Integration Monday
Building workflow solution with Microsoft Azure and Cloud | Integration MondayBuilding workflow solution with Microsoft Azure and Cloud | Integration Monday
Building workflow solution with Microsoft Azure and Cloud | Integration Monday
 
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
 
Stateful patterns in Azure Functions
Stateful patterns in Azure FunctionsStateful patterns in Azure Functions
Stateful patterns in Azure Functions
 
[Struyf] Automate Your Tasks With Azure Functions
[Struyf] Automate Your Tasks With Azure Functions[Struyf] Automate Your Tasks With Azure Functions
[Struyf] Automate Your Tasks With Azure Functions
 
APIdays Paris 2018 - Will Serverless kill Containers and Operations? Stéphane...
APIdays Paris 2018 - Will Serverless kill Containers and Operations? Stéphane...APIdays Paris 2018 - Will Serverless kill Containers and Operations? Stéphane...
APIdays Paris 2018 - Will Serverless kill Containers and Operations? Stéphane...
 
Will ServerLess kill containers and Operations
Will ServerLess kill containers and OperationsWill ServerLess kill containers and Operations
Will ServerLess kill containers and Operations
 
Working with data using Azure Functions.pdf
Working with data using Azure Functions.pdfWorking with data using Azure Functions.pdf
Working with data using Azure Functions.pdf
 
Introduction to Realm Mobile Platform
Introduction to Realm Mobile PlatformIntroduction to Realm Mobile Platform
Introduction to Realm Mobile Platform
 
Azure functions
Azure functionsAzure functions
Azure functions
 
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...
 
Windows Workflow Foundation Demystified - overview and business cases
Windows Workflow Foundation Demystified - overview and business casesWindows Workflow Foundation Demystified - overview and business cases
Windows Workflow Foundation Demystified - overview and business cases
 

Plus de Lalit Kale

For Business's Sake, Let's focus on AppSec
For Business's Sake, Let's focus on AppSecFor Business's Sake, Let's focus on AppSec
For Business's Sake, Let's focus on AppSecLalit Kale
 
Dot net platform and dotnet core fundamentals
Dot net platform and dotnet core fundamentalsDot net platform and dotnet core fundamentals
Dot net platform and dotnet core fundamentalsLalit Kale
 
Code refactoring
Code refactoringCode refactoring
Code refactoringLalit Kale
 
Application Security Tools
Application Security ToolsApplication Security Tools
Application Security ToolsLalit Kale
 
Threat Modeling And Analysis
Threat Modeling And AnalysisThreat Modeling And Analysis
Threat Modeling And AnalysisLalit Kale
 
Application Security-Understanding The Horizon
Application Security-Understanding The HorizonApplication Security-Understanding The Horizon
Application Security-Understanding The HorizonLalit Kale
 
Coding guidelines
Coding guidelinesCoding guidelines
Coding guidelinesLalit Kale
 
Code review guidelines
Code review guidelinesCode review guidelines
Code review guidelinesLalit Kale
 
State management
State managementState management
State managementLalit Kale
 
Implementing application security using the .net framework
Implementing application security using the .net frameworkImplementing application security using the .net framework
Implementing application security using the .net frameworkLalit Kale
 
Data normailazation
Data normailazationData normailazation
Data normailazationLalit Kale
 
Versioning guidelines for product
Versioning guidelines for productVersioning guidelines for product
Versioning guidelines for productLalit Kale
 
Bowling Game Kata by Robert C. Martin
Bowling Game Kata by Robert C. MartinBowling Game Kata by Robert C. Martin
Bowling Game Kata by Robert C. MartinLalit Kale
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven DesignLalit Kale
 
Web 2.0 concept
Web 2.0 conceptWeb 2.0 concept
Web 2.0 conceptLalit Kale
 
Jump Start To Ooad And Design Patterns
Jump Start To Ooad And Design PatternsJump Start To Ooad And Design Patterns
Jump Start To Ooad And Design PatternsLalit Kale
 
How To Create Strategic Marketing Plan
How To Create Strategic Marketing PlanHow To Create Strategic Marketing Plan
How To Create Strategic Marketing PlanLalit Kale
 
Model Driven Architectures
Model Driven ArchitecturesModel Driven Architectures
Model Driven ArchitecturesLalit Kale
 

Plus de Lalit Kale (19)

For Business's Sake, Let's focus on AppSec
For Business's Sake, Let's focus on AppSecFor Business's Sake, Let's focus on AppSec
For Business's Sake, Let's focus on AppSec
 
Dot net platform and dotnet core fundamentals
Dot net platform and dotnet core fundamentalsDot net platform and dotnet core fundamentals
Dot net platform and dotnet core fundamentals
 
Code refactoring
Code refactoringCode refactoring
Code refactoring
 
Application Security Tools
Application Security ToolsApplication Security Tools
Application Security Tools
 
Threat Modeling And Analysis
Threat Modeling And AnalysisThreat Modeling And Analysis
Threat Modeling And Analysis
 
Application Security-Understanding The Horizon
Application Security-Understanding The HorizonApplication Security-Understanding The Horizon
Application Security-Understanding The Horizon
 
Coding guidelines
Coding guidelinesCoding guidelines
Coding guidelines
 
Code review guidelines
Code review guidelinesCode review guidelines
Code review guidelines
 
State management
State managementState management
State management
 
Implementing application security using the .net framework
Implementing application security using the .net frameworkImplementing application security using the .net framework
Implementing application security using the .net framework
 
Data normailazation
Data normailazationData normailazation
Data normailazation
 
Opps
OppsOpps
Opps
 
Versioning guidelines for product
Versioning guidelines for productVersioning guidelines for product
Versioning guidelines for product
 
Bowling Game Kata by Robert C. Martin
Bowling Game Kata by Robert C. MartinBowling Game Kata by Robert C. Martin
Bowling Game Kata by Robert C. Martin
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Web 2.0 concept
Web 2.0 conceptWeb 2.0 concept
Web 2.0 concept
 
Jump Start To Ooad And Design Patterns
Jump Start To Ooad And Design PatternsJump Start To Ooad And Design Patterns
Jump Start To Ooad And Design Patterns
 
How To Create Strategic Marketing Plan
How To Create Strategic Marketing PlanHow To Create Strategic Marketing Plan
How To Create Strategic Marketing Plan
 
Model Driven Architectures
Model Driven ArchitecturesModel Driven Architectures
Model Driven Architectures
 

Dernier

Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsYoss Cohen
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...BookNet Canada
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Mark Simos
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 

Dernier (20)

Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platforms
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 

Develop in ludicrous mode with azure serverless

  • 1. Lalit Kale Develop in Ludicrous mode with Azure Functions
  • 2. About Me • 15 years of Programming • Use .NET to earn bread and butter • Worked on very large scale systems in e- Commerce , Banking and Insurance • In spare time • python, Go-Lang, OSS • Loads of TED Talks
  • 3. Goal • Serverless • Azure Serverless Offerings • Introduction to Azure Functions • Build Microservice with Azure Functions • Durable Functions • Durable Functions Patterns
  • 4. Microservices – architectural approach for cloud native apps Monolithic APP APP APP Microservices Large, all-inclusive app Small, independent services
  • 5. Independent modules Isolated points of failure Autonomous scalability Microservices Tech flexibility Faster value delivery
  • 6. Serverless – Great fit for Microservices • Problems of traditional microservices • Scaling of compute resources • Operations dependency • Pay per hosting nodes • Services discovery and • managing services integration • Serverless solution • Automatic scaling based on workload • No infrastructure management • Pay per execution (micro-billing) • Event-Driven programming model • (triggers + bindings), instant scale
  • 8. What is Serverless? clear separation between the code and its hosting environment
  • 11. Introducing Azure Functions Code EventsAzure Functions
  • 12. Azure Functions Internals Function Code Function Configuration Language Runtime WebJobs Core Azure AppService
  • 13. Functions Secret Sauce… • Triggers are ways to start executing Azure function code • Bindings are declarative way of binding data to Azure function • All triggers have input data • Data coming from services become input values for function code • To output data to another service use the return value of the function.
  • 14. Functions Secret Sauce… • Triggers • Blob Storage • Cosmos DB • Event Hub • HTTP • Queues • Service Bus • Timer • Webhook • Bindings • File • Table • Excel • OneDrive • Email • Mobile app • Notification • More…
  • 15. Scaling happens at the Function App level Usually, each Function App represents a different microservice Each Function App would be an API with grouped endpoints (one function per endpoint) Flexibility choosing the language for each microservice – one per Function App
  • 17. Web application backends Mobile application backends IoT-connected backends Real-time file processing Real-time stream processing Automation of scheduled tasks Extending SaaS Applications Conversational bot processing Sample scenarios for Functions
  • 18. Demo Azure Functions Hello World - Portal Experience - Visual Studio - Azure Functions Core Tools
  • 19. Migrate from VMs → serverless Thermostat intelligence is a clear differentiator Ready for sudden vertical growth in the consumer market—charged for usage as they scale 20K+ IoT devices simulated Event driven architecture works well for IoT Customer Success Story GLAS®Smart Thermostat by Johnson Controls
  • 20. Device to Cloud Cloud to Device IoT Hub for messaging and managing devices Event Hubs for routing and throttling Functions as microservices SignalR for device messaging
  • 21. Demo Building a Microservice with Azure Functions
  • 22. Stateless Microservices What about Stateful Operations?
  • 23. Not everything fits on a few-seconds execution
  • 25. What is Durable Functions? • Advanced feature for writing long-running orchestrations as a single C# function. No JSON schemas. No designer. • New orchestrator functions can synchronously or asynchronously call other functions. • Automatic checkpointing, enabling “long running” functions. • Solves a variety of complex, transactional coding problems in serverless apps. • Built on the open source Durable Task Framework.
  • 27. Pattern #1: Function chaining - Today Problems: • No visualization to show relationship between functions and queues. • Middle queues are an implementation detail – conceptual overhead. • Error handling adds a lot more complexity. F1 F2 F3 F4
  • 28. Pattern #1: Function chaining - Better // calls functions in sequence public static async Task<object> Run(DurableOrchestrationContext ctx) { try { var x = await ctx.CallFunctionAsync("F1"); var y = await ctx.CallFunctionAsync("F2", x); var z = await ctx.CallFunctionAsync("F3", y); return await ctx.CallFunctionAsync("F4", z); } catch (Exception) { // global error handling/compensation goes here } }
  • 29. Pattern #2: Fan-out/Fan-in - Today Problems: • Fanning-out is easy, but fanning-in is significantly more complicated • Functions offers no help with this scenario today • All the same problems of the previous pattern F1 F2 F3
  • 30. Pattern #2: Fan-out/Fan-in - Easy public static async Task Run(DurableOrchestrationContext ctx) { var parallelTasks = new List<Task<int>>(); // get a list of N work items to process in parallel object[] workBatch = await ctx.CallFunctionAsync<object[]>("F1"); for (int i = 0; i < workBatch.Length; i++) { Task<int> task = ctx.CallFunctionAsync<int>("F2", workBatch[i]); parallelTasks.Add(task); } await Task.WhenAll(parallelTasks); // aggregate all N outputs and send result to F3 int sum = parallelTasks.Sum(t => t.Result); await ctx.CallFunctionAsync("F3", sum); }
  • 31. Pattern #3: HTTP Async Response Problems: • Execution state needs to be explicitly stored and managed. • Execution state and trigger state must be kept in sync manually. • Start and GetStatus is often boilerplate code that is not related to the business problem. Start DoWork GetStatus
  • 32. Pattern #3: HTTP Async Response – Built in! > curl -X POST https://myfunc.azurewebsites.net/orchestrators/DoWork -H "Content-Length: 0" -i HTTP/1.1 202 Accepted Location: https://myfunc.azurewebsites.net/orchestrators/b79baf67f717453ca9e86c5da21e03ec Server: Microsoft-IIS/8.0 > curl https://myfunc.azurewebsites.net/orchestrators/b79baf67f717453ca9e86c5da21e03ec -i HTTP/1.1 202 Accepted Content-Length: 173 Content-Type: application/json Location: https://myfunc.azurewebsites.net/orchestrators/b79baf67f717453ca9e86c5da21e03ec Server: Microsoft-IIS/8.0 {"runtimeStatus":"Running","createdTime":"2017-03-16T21:20:36Z","lastUpdatedTime":"2017-03-16T21:20:47Z"} > curl https://myfunc.azurewebsites.net/orchestrators/b79baf67f717453ca9e86c5da21e03ec -i HTTP/1.1 200 OK Content-Length: 175 Content-Type: application/json Server: Microsoft-IIS/8.0 {"runtimeStatus":"Completed","createdTime":"2017-03-16T21:20:36Z","lastUpdatedTime":"2017-03-16T21:20:57Z"}
  • 33. Pattern #4: Actors Problems: • Functions are stateless and short-lived. • Read/write access to external state needs to be carefully synchronized. • Functions do not support the singleton pattern today.
  • 34. Pattern #4: Actors (Eternal Orchestrations) public static async Task Run(DurableOrchestrationContext ctx) { int counterState = ctx.GetInput<int>(); string operation = await ctx.WaitForExternalEvent<string>("operation"); if (operation == "incr") { counterState++; } else if (operation == "decr") { counterState--; } ctx.ContinueAsNew(counterState); }
  • 35. Pattern #5: Human Interaction w/Timeout RequestApproval Escalate ProcessApproval Problems: • Can’t easily coordinate a timeout with an approval request notification. • Need a mechanism to reliably cancel either the approval handling or the timeout depending on the outcome.
  • 36. Pattern #5: Human Interaction w/Timeout public static async Task Run(DurableOrchestrationContext ctx) { await ctx.CallFunctionAsync<object[]>("RequestApproval"); using (var timeoutCts = new CancellationTokenSource()) { DateTime dueTime = ctx.CurrentUtcDateTime.AddHours(72); Task durableTimeout = ctx.CreateTimer(dueTime, 0, cts.Token); Task<bool> approvalEvent = ctx.WaitForExternalEvent<bool>("ApprovalEvent"); if (approvalEvent == await Task.WhenAny(approvalEvent, durableTimeout)) { timeoutCts.Cancel(); await ctx.CallFunctionAsync("HandleApproval", approvalEvent.Result); } else { await ctx.CallFunctionAsync("Escalate"); } } }
  • 37. Important Orchestrator Limitations • Orchestrator code is replayed on every rehydration to restore all local state (local variables, etc). • Function calls are never replayed – the outputs are remembered. • This requires the orchestrator code to be deterministic. • Rule #1: Never write logic that depends on random numbers, DateTime.Now, Guid.NewGuid(), etc. • Rule #2: Never do I/O directly in the orchestrator function. • Rule #3: Do not write infinite loops • Rule #4: Use the built-in workarounds for rules #1, #2, and #3
  • 38. Takeaways • Serverless – Glue of Cloud • Sub-Second Billing • Instant Scaling • Focus on your code – Let Azure do the heavy lifting for you.

Notes de l'éditeur

  1. 19
  2. CallFunctionAsync uses queues under the covers, thus they can be scaled out to multiple VMs.
  3. Logic Apps and Microsoft Flow have built-in support for this pattern. Note that specifics URL routes are subject to change (and have already changed since this deck was originally written).
  4. Note that orchestrators are single-threaded, so there is no need to worry about concurrency. Orchestration instances are also implicitly singletons, so they only run on one VM at a time.
  5. We will expose a mechanism for sending named events to an orchestrator from outside the orchestration context – e.g. REST API and/or output binding.