Azure Functions
Agenda
• Why Serverless?
• Azure Functions 101
• FaaS vs. “Reality”
• Azure Durable Functions
About me
• Software Development since 2005
• Focus Topics: Extensibility, Cloud Native Development,
Serverless
• @lechnerc77
• www.linkedin.com/in/christian-lechner-963b7017
Why Serverless?StackAbstraction
Focus on Business Logic
Virtual Machines
Serverless
Containers
• Fully managed services
• Flexible scaling
• Only pay for what you use
• Seamless integration
• Enhanced productivity
What FaaS offerings do you know/use?
Go to www.menti.com
Code: 36 93 46
What does Microsoft bring
to the table?
Azure Functions
Azure Functions - Prerequisites
• Step 1: Install Node.JS (LTS) - https://nodejs.org/en/
• Step 2: Install Microsoft Visual Studio Code
https://code.visualstudio.com/
• Step 3: Install Azure Core Tools
npm install -g azure-functions-core-tools@3
• Step 4: Azure Functions extension - via Visual Studio Code Marketplace
https://marketplace.visualstudio.com/items?itemName=ms-
azuretools.vscode-azurefunctions
Azure Functions 101
How to deal with Business
Processes and FaaS?
FaaS - Principles
• Functions must be stateless
• Functions should not call other functions
• Functions should do only one thing
• BUT: Business Processes need state
Function Chaining to achieve State
• Queues are a necessary evil
• Context must be stored in a DB
• Unclear relation between functions
• Error handling becomes very complex
Function 1 Function 2 Function 3
Durable Functions for the Rescue
• Extension to the Azure Functions Framework
• Preserves local state via Event Sourcing
• Heavy work happens behind the curtain
• Supports you in front of the curtain with additional features
Tasks in orchestrator
1. let x = await ctx.CallActivityAsync(“F1”)
2. let y = await ctx.CallActivityAsync(“F2”, x)
3. return await ctx.CallActivityAsync(“F3”, y)
Tasks in orchestrator
1. let x = await ctx.CallActivityAsync(“F1”)
2. let y = await ctx.CallActivityAsync(“F2”, x)
3. return await ctx.CallActivityAsync(“F3”, y)
Trigger
Orchestrator
Activity
Tasks in orchestrator
1. let x = await ctx.CallActivityAsync(“F1”)
2. let y = await ctx.CallActivityAsync(“F2”, x)
3. return await ctx.CallActivityAsync(“F3”, y)
Trigger
Orchestrator
Activity
Tasks in orchestrator
1. let x = await ctx.CallActivityAsync(“F1”)
2. let y = await ctx.CallActivityAsync(“F2”, x)
3. return await ctx.CallActivityAsync(“F3”, y)
Trigger
Orchestrator
Activity
Tasks in orchestrator
1. let x = await ctx.CallActivityAsync(“F1”)
2. let y = await ctx.CallActivityAsync(“F2”, x)
3. return await ctx.CallActivityAsync(“F3”, y)
Trigger
Orchestrator
Activity
Tasks in orchestrator
1. let x = await ctx.CallActivityAsync(“F1”)
2. let y = await ctx.CallActivityAsync(“F2”, x)
3. return await ctx.CallActivityAsync(“F3”, y)
Trigger
Orchestrator
Activity
Tasks in orchestrator
1. let x = await ctx.CallActivityAsync(“F1”)
2. let y = await ctx.CallActivityAsync(“F2”, x)
3. return await ctx.CallActivityAsync(“F3”, y)
Trigger
Orchestrator
Activity
Tasks in orchestrator
1. let x = await ctx.CallActivityAsync(“F1”)
2. let y = await ctx.CallActivityAsync(“F2”, x)
3. return await ctx.CallActivityAsync(“F3”, y)
Trigger
Activity
In one Picture …
Azure Durable Functions - Prerequistes
• Step 1 – Install Azure Durable Functions Extension
(npm install durable-functions)
• Step 2 – Install Microsoft Azure Storage Emulator
(https://github.com/MicrosoftDocs/azure-
docs/blob/master/articles/storage/common/storage-use-
emulator.md)
• Optional: Microsoft Azure Storage Explorer
(https://azure.microsoft.com/en-us/features/storage-explorer/)
Azure Durable Functions 101
Challenge
Handle Errors in Activity Calls (Retry)
Orchestrator
Activity 1 Activity 2
SAP Cloud Applications
Challenge
Handle Timeouts in Activity Calls
Orchestrator
Activity 1 Activity 2
SAP Cloud Applications
Race Condition
Wrap Up – Azure Functions …
• … are cool ☺
• … have a low entry barrier due to local development options
• … allow modelling of complex scenarios without losing the benefits of FaaS
via Durable Functions
• … have even more (like Durable Entities)
• … just wait for you to try them
Thanks For Your Attention!
Q: Is there a lock-in to Microsoft Azure
A: No Azure Functions are Open Source as are Durable Functions
You can put them into a container and deploy them to docker
(supported by the func CLI)
If you deploy to Kubernetes – take a look at KEDA (https://keda.sh/)
Q: What about Cold Starts?
A: In general the Azure Team tries to reduce the cold start time
You can mitigate it via (more expensive consumption plans)
Q: What if my preferred language is not
supported?
A: You can implement Custom Handlers.
See also: https://github.com/Azure-Samples/functions-custom-
handlers
Q: I need a binding that is not supported
A: You can create your own bindings via so called custom bindings

FaaS by Microsoft: Azure Functions and Azure Durable Functions

  • 1.
  • 2.
    Agenda • Why Serverless? •Azure Functions 101 • FaaS vs. “Reality” • Azure Durable Functions
  • 3.
    About me • SoftwareDevelopment since 2005 • Focus Topics: Extensibility, Cloud Native Development, Serverless • @lechnerc77 • www.linkedin.com/in/christian-lechner-963b7017
  • 4.
    Why Serverless?StackAbstraction Focus onBusiness Logic Virtual Machines Serverless Containers • Fully managed services • Flexible scaling • Only pay for what you use • Seamless integration • Enhanced productivity
  • 5.
    What FaaS offeringsdo you know/use? Go to www.menti.com Code: 36 93 46
  • 6.
    What does Microsoftbring to the table?
  • 7.
  • 8.
    Azure Functions -Prerequisites • Step 1: Install Node.JS (LTS) - https://nodejs.org/en/ • Step 2: Install Microsoft Visual Studio Code https://code.visualstudio.com/ • Step 3: Install Azure Core Tools npm install -g azure-functions-core-tools@3 • Step 4: Azure Functions extension - via Visual Studio Code Marketplace https://marketplace.visualstudio.com/items?itemName=ms- azuretools.vscode-azurefunctions
  • 9.
  • 10.
    How to dealwith Business Processes and FaaS?
  • 11.
    FaaS - Principles •Functions must be stateless • Functions should not call other functions • Functions should do only one thing • BUT: Business Processes need state
  • 12.
    Function Chaining toachieve State • Queues are a necessary evil • Context must be stored in a DB • Unclear relation between functions • Error handling becomes very complex Function 1 Function 2 Function 3
  • 13.
    Durable Functions forthe Rescue • Extension to the Azure Functions Framework • Preserves local state via Event Sourcing • Heavy work happens behind the curtain • Supports you in front of the curtain with additional features
  • 14.
    Tasks in orchestrator 1.let x = await ctx.CallActivityAsync(“F1”) 2. let y = await ctx.CallActivityAsync(“F2”, x) 3. return await ctx.CallActivityAsync(“F3”, y)
  • 15.
    Tasks in orchestrator 1.let x = await ctx.CallActivityAsync(“F1”) 2. let y = await ctx.CallActivityAsync(“F2”, x) 3. return await ctx.CallActivityAsync(“F3”, y) Trigger Orchestrator Activity
  • 16.
    Tasks in orchestrator 1.let x = await ctx.CallActivityAsync(“F1”) 2. let y = await ctx.CallActivityAsync(“F2”, x) 3. return await ctx.CallActivityAsync(“F3”, y) Trigger Orchestrator Activity
  • 17.
    Tasks in orchestrator 1.let x = await ctx.CallActivityAsync(“F1”) 2. let y = await ctx.CallActivityAsync(“F2”, x) 3. return await ctx.CallActivityAsync(“F3”, y) Trigger Orchestrator Activity
  • 18.
    Tasks in orchestrator 1.let x = await ctx.CallActivityAsync(“F1”) 2. let y = await ctx.CallActivityAsync(“F2”, x) 3. return await ctx.CallActivityAsync(“F3”, y) Trigger Orchestrator Activity
  • 19.
    Tasks in orchestrator 1.let x = await ctx.CallActivityAsync(“F1”) 2. let y = await ctx.CallActivityAsync(“F2”, x) 3. return await ctx.CallActivityAsync(“F3”, y) Trigger Orchestrator Activity
  • 20.
    Tasks in orchestrator 1.let x = await ctx.CallActivityAsync(“F1”) 2. let y = await ctx.CallActivityAsync(“F2”, x) 3. return await ctx.CallActivityAsync(“F3”, y) Trigger Orchestrator Activity
  • 21.
    Tasks in orchestrator 1.let x = await ctx.CallActivityAsync(“F1”) 2. let y = await ctx.CallActivityAsync(“F2”, x) 3. return await ctx.CallActivityAsync(“F3”, y) Trigger Activity
  • 22.
  • 23.
    Azure Durable Functions- Prerequistes • Step 1 – Install Azure Durable Functions Extension (npm install durable-functions) • Step 2 – Install Microsoft Azure Storage Emulator (https://github.com/MicrosoftDocs/azure- docs/blob/master/articles/storage/common/storage-use- emulator.md) • Optional: Microsoft Azure Storage Explorer (https://azure.microsoft.com/en-us/features/storage-explorer/)
  • 24.
  • 25.
    Challenge Handle Errors inActivity Calls (Retry) Orchestrator Activity 1 Activity 2 SAP Cloud Applications
  • 26.
    Challenge Handle Timeouts inActivity Calls Orchestrator Activity 1 Activity 2 SAP Cloud Applications Race Condition
  • 27.
    Wrap Up –Azure Functions … • … are cool ☺ • … have a low entry barrier due to local development options • … allow modelling of complex scenarios without losing the benefits of FaaS via Durable Functions • … have even more (like Durable Entities) • … just wait for you to try them
  • 28.
    Thanks For YourAttention!
  • 29.
    Q: Is therea lock-in to Microsoft Azure A: No Azure Functions are Open Source as are Durable Functions You can put them into a container and deploy them to docker (supported by the func CLI) If you deploy to Kubernetes – take a look at KEDA (https://keda.sh/)
  • 30.
    Q: What aboutCold Starts? A: In general the Azure Team tries to reduce the cold start time You can mitigate it via (more expensive consumption plans)
  • 31.
    Q: What ifmy preferred language is not supported? A: You can implement Custom Handlers. See also: https://github.com/Azure-Samples/functions-custom- handlers
  • 32.
    Q: I needa binding that is not supported A: You can create your own bindings via so called custom bindings