+ All Categories
Home > Technology > Serverless with Azure Functions

Serverless with Azure Functions

Date post: 12-Apr-2017
Category:
Upload: andreas-willich
View: 106 times
Download: 0 times
Share this document with a friend
40
1 www.techtalk .at Add Picture Raoul Holzer Andreas Willich Serverless with Azure Functions
Transcript
Page 1: Serverless with Azure Functions

1www.techtalk.

at

Add Picture

Raoul HolzerAndreas Willich

Serverless with Azure Functions

Page 2: Serverless with Azure Functions

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

Page 3: Serverless with Azure Functions

3

Serverless Architecture

Page 4: Serverless with Azure Functions

4

Who heard about it?

Was your first reaction “Bullshit, there are always server involved”?

Who has an idea what it is?

Serverless architecture

Page 5: Serverless with Azure Functions

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

Page 6: Serverless with Azure Functions

6

By using 3rd party services and sticking them together, I don’t care anymore on which server the code is running.

Serverless architecture

Page 7: Serverless with Azure Functions

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

Page 8: Serverless with Azure Functions

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 runningServerless:

• Single Function

Business driven development - Example

Page 9: Serverless with Azure Functions

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

Page 10: Serverless with Azure Functions

10

Azure’s part

Page 11: Serverless with Azure Functions

11

• Microsoft Flow• Azure Logic Apps• Azure Automation• Azure Functions

Azure’s parts for Serverless Architecture

Page 12: Serverless with Azure Functions

12

Azure Functions

Page 13: Serverless with Azure Functions

13

Which languages can I use?• C#• F#• JavaScript• PHP• Python• Batch• PowerShell• Bash

Most important question first!

Page 14: Serverless with Azure Functions

14

Through different triggers• Timer schedule• HTTP

• REST• WebHook

• Blob Storage • EventHub• Queue Storage

How gets a Function called?

Page 15: Serverless with Azure Functions

15

• HTTP Requests• Blobs• Events• Queue Entries• Tables• Push Notifications

What gets in? What gets out?

Page 16: Serverless with Azure Functions

16

Bindings serve as the basis for all connections to and from a function.

Function Bindings

Type Service Trigger Input OutputSchedule Azure Functions ✔HTTP (REST or webhook) Azure Functions ✔ ✔Blob Storage Azure Storage ✔ ✔ ✔Events Azure Event Hubs ✔ ✔Queues Azure Storage ✔ ✔Tables Azure Storage ✔ ✔Tables Azure Mobile Apps ✔ ✔

No-SQL DB Azure DocumentDB ✔ ✔

Push Notifications Azure Notification Hubs ✔

Page 17: Serverless with Azure Functions

17

• Scaling• done automatically with magic

• Proxies• One API surface for multiple function app

Which batteries are included?

Page 18: Serverless with Azure Functions

18

Demo – Creating a function app

Page 19: Serverless with Azure Functions

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

Page 20: Serverless with Azure Functions

20

Execution time:€0.000014/GB-s (GigaByte Seconds)1GB used for one second = 1 GB-s512 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?

Page 21: Serverless with Azure Functions

21

Development & Deployment of Azure Functions

Page 22: Serverless with Azure Functions

22

• Flow => included in Office 365, some connections costs• Logic => per Action and App Service Plan • Automation => minute

Prices

Page 23: Serverless with Azure Functions

23

Programming in Web Browser ?

What if we develop in teams?

Only one code file ?

Real World Development

Page 24: Serverless with Azure Functions

24

• Azure Functions CLI• https://www.npmjs.com/package/azure-functions-cli

• Visual Studio Tools for Azure Functions• Preview• Visual Studio 2015 Update 3• https://aka.ms/FunctionsVsTools

Tools

Page 25: Serverless with Azure Functions

Demo

Page 26: Serverless with Azure Functions

26

• Kudu (Azure Copy Deploy)• Bitbucket• Dropbox• Git local repo• Git external repo• GitHub• Mercurial external repo• OneDrive• Visual Studio Team Services

Deploy Azure Functions in Team Environment

Page 27: Serverless with Azure Functions

27

• wwwroot• | - host.json• | - FirstFunction• | | - function.json• | | - index.js• | | - node_modules• | | | - ... packages ...• | | - package.json• | - SecondFunction• | | - function.json• | | - run.csx

Folder Hierachy for development

Page 28: Serverless with Azure Functions

Demo

Page 29: Serverless with Azure Functions

29

Isolated Azure Functions

Page 30: Serverless with Azure Functions

30

Function app A

/customer

Function app B

/products

Function app C

Function3/orders

Function1

API proxy endpointsHttpTrigger function endpoints

Key:

/products

/orders

Function2

Azure Functions Proxy

Page 31: Serverless with Azure Functions

31

{ "proxies": { "proxy1": { "matchCondition": { "methods": [], "route": "/api/{test}" }, "backendUri": "https://contoso.azurewebsites.net/api/{test}" } }}

New file on site root: proxies.json

Page 32: Serverless with Azure Functions

32

• System• System.Collections.Generic• System.IO• System.Linq• System.Net.Http• System.Threading.Tasks• Microsoft.Azure.WebJobs• Microsoft.Azure.WebJobs.Host.

Automatically imported References

Page 33: Serverless with Azure Functions

33

• #r "System.Web.Http„• Package management (NuGet, NPM)• Copy to Bin Folder• #load "mylogger.csx" • #load "..\shared\mylogger.csx”

Referencing External Assemblies

Page 34: Serverless with Azure Functions

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

Page 35: Serverless with Azure Functions

35

• Thanks to Mark Heath

Example

Page 36: Serverless with Azure Functions

36

• Azure Functions Source Code:• https://github.com/Azure/azure-webjobs-sdk • https://github.com/Azure/azure-webjobs-sdk-script • https://github.com/projectkudu/AzureFunctionsPortal

• Visualizer Azurehttp://Armviz.io

Links

Page 37: Serverless with Azure Functions

37

Reading stuff• https://martinfowler.com/articles/serverless.html• https://martinfowler.com/bliki/Serverless.html• https://gojko.net/2016/08/27/serverless.html• https://gojko.net/2017/02/23/serverless-migration-lesso

n.html

Page 38: Serverless with Azure Functions

Thank you!

Page 40: Serverless with Azure Functions

40


Recommended