2. 2
What is a serverless architecture?
What is serverless on Azure?
What are Azure Functions?
What can they do?
How do I develop Azure Functions?
How the heck can I deploy the stuff?
Questions to be answered
4. 4
Who heard about it?
Was your first reaction “Bullshit, there are always server involved”?
Who has an idea what it is?
Serverless architecture
5. 5
Definition from Mike Roberts:
Serverless architectures are internet based systems where the
application development does not use the usual server process.
Instead they rely solely on a combination of third-party services,
client-side logic, and service hosted remote procedure calls.
https://martinfowler.com/bliki/Serverless.html
Serverless architecture
6. 6
By using 3rd party services and sticking them together, I don’t
care anymore on which server the code is running.
Serverless architecture
7. 7
Big differences to normal pricing models:
• Classic VM hosting pricing model
• X €/Month independent of usage
• Serverless pricing models
• A€ for B number of executions
• C€ for D usage of resources.
Business driven development
8. 8
Export of data into specific format
• Feature that is rarely used
• Needs a lot of resources
Classic:
Separate VM(s) that provide the functionality
• No influence on performance of the remaining application
• If the feature is not used, it costs a lot of money to have the
infrastructure running
Serverless:
• Single Function
Business driven development - Example
9. 9
“… the number of active users increased roughly by 50%, but
our hosting costs dropped slightly less than 50%. Plus, we
replaced what was probably our biggest bottleneck with
something that scales without any effort on our side“
Gojko Adzic
https://gojko.net/2017/02/23/serverless-migration-lesson.html
Business driven development
19. 19
• Azure Functions are not State-full or State-less
• Multiple calls could be in same process
• Up- Scaling needs time
• Just because you are having 10 requests at a moment, you
do not get 10 separate processes
• Currently not the best performance
Behavior
20. 20
Execution time:
€0.000014/GB-s (GigaByte Seconds)
1GB used for one second = 1 GB-s
512 MB used for 2 seconds = 1 GB-s
Execution count:
€0.169 per Million Executions
Free:
• 400.000 GB-s
• 1 Million Executions
How much does it cost?
30. 30
Function app A
/customer
Function app B
/products
Function app C
Function3/orders
Function1
API proxy endpoints
HttpTrigger function endpoints
Key:
/products
/orders
Function2
Azure Functions Proxy
31. 31
{
"proxies": {
"proxy1": {
"matchCondition": {
"methods": [],
"route": "/api/{test}"
},
"backendUri": "https://contoso.azurewebsites.net/api/{test}"
}
}
}
New file on site root: proxies.json
34. 34
• Avoid large long running functions
• Cross function communication
• Write functions to be stateless
• Write defensive functions
• Don't mix test and production code in the same function app
• Use async code but avoid Task.Result
Best Practices
39. 39
“Migrating to a Serverless Architecture” Training by Gojko Adzic
3-day Training
22-24 March 2017, 9 am to 5 pm
https://techtalk.at/trainings/migrating-to-a-serverless-
architecture/
Commercial break
Without bindings, an Azure Function would just be a “disconnected” algorithm without any way to serve a purpose. Bindings server to connect functions and output to other services. Some of the most common binding types and features are listed in the table, however variations and adaptations can and do exist.
Avoid large long running functions
unexpected timeout issues
many Node.js dependencies
refactor large functions into smaller function
Cross function communication
use storage queues
Write functions to be stateless
Also if a previous run failed to complete, the next run should pick up where it left off.
Write defensive functions
continue from a previous fail
Don't mix test and production code in the same function app
Functions within a function app share resources.
Use async code but avoid Task.Result
Holding a lock creates the potential for deadlocks.