chad green from zero to serverless · serverless the platform for next generation applications....

89
From Zero to Serverless CoderCruise August 31, 2018 Chad Green

Upload: others

Post on 01-Aug-2020

23 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to ServerlessCoderCruiseAugust 31, 2018

Chad Green

Page 2: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

Who is Chad Green

• Data & Solutions Architect at ProgressiveHealth• Community Involvement

• Code PaLOUsa Conference Chair• Louisville .NET Meetup Organizer• Louisville Tech Leaders Meetup Co-Organizer• Louisville Tech Ladies Committee Member

• Contact Information

[email protected]

Page 3: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

What is Serverless ComputingFrom Zero to Serverless

Page 4: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

The evolution of application platforms

4

On-Premises

Which packages should

be on my server?

How do I deploy new

code to my servers?How can I increase

server utilization?

How often should I

patch my servers?

What size of servers

should I buy?

Who has physical

access to my servers?

It takes how long to

provision a new server?

Page 5: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

The evolution of application platforms

5

IaaS What is the right size of servers for my business needs?

How can I increase server utilization?

How many servers do I need?

How can I scale my application?

How do I deploy new code to my server?

Which Operating System should I use?

Who monitors my application?

How often should I patch my servers?

How often should I backup my server?

Which packages should be on my server?

Page 6: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

The evolution of application platforms

6

PaaS What is the right size of servers for my business needs?

How can I increase server utilization?

How many servers do I need?

How can I scale my application?

Page 7: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

The evolution of application platforms

7

Serverless

The platform for next generation applications

Page 8: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

What is Serverless?

8

• Applications that significantly or fully

depend on services (in the cloud) to

manage server-side logic and state

Area #1 Area #2• Application run in stateless compute

containers that are event-triggered,

ephemeral, and fully managed by a 3rd

party

Backend as a Service (BaaS) Functions as a Service (FaaS)

Page 9: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

What is Serverless?

9

• Applications that significantly or fully

depend on services (in the cloud) to

manage server-side logic and state

Area #1 Area #2• Application run in stateless compute

containers that are event-triggered,

ephemeral, and fully managed by a 3rd

party

Backend as a Service (BaaS) Functions as a Service (FaaS)

Page 10: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

What is Serverless?

10

Abstraction of Servers Event-Driven/Instant Scale Micro-Billing

Page 11: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Benefits of Serverless

11

Reduced DevOps Faster Time to MarketManage apps not servers

Page 12: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Serverless Scale

12

Monolith

Microservice

Microservice

Microservice

Microservice

Function

Function

Function

Function

Function

Function

Function

Function

Function

Function

Function

Nano Services

Page 13: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Challenges of Serverless Architecture

13

ComplexityOrganizational

SupportNo Runtime Optimization

Page 14: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

Serverless OptionsFrom Zero to Serverless

Page 15: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Serverless Options

15

• Zimki

• Google Cloud Functions

• Amazon Lambda

• IBM Cloud Functions

• Auth0 WebTask

• Azure

Page 16: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Azure Serverless

16

FunctionsExecute your code based

on events you specify

Logic AppsDesign workflows and orchestrate processes

Event GridManage all events that

can trigger code or logic

Page 17: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Azure Serverless

17

FunctionsExecute your code based

on events you specify

Logic AppsDesign workflows and orchestrate processes

Event GridManage all events that

can trigger code or logic

Storage Security IoT Analytics IntelligenceDatabase

Page 18: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

Azure FunctionsFrom Zero to Serverless

Events + dataCode

Page 19: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Azure Functions Architecture

19

App Service Dynamic RuntimeHosting, CI, Deployment Slots, Remote Debugging, etc.

WebJobs CoreProgramming model, common abstractions

WebJobs ExtensionsTriggers, input, and output bindings

WebJobs Script RuntimeAzure Functions Host – Dynamic Compilation, Language abstractions, etc.

Language RuntimeC#, Node.js, F#, PHP, etc.

Code Config

Page 20: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Features of Azure Functions

20

• Choice of language

• Pay-per-use pricing model

• Bring your own dependencies

• Integrated security

• Simplified integration

• Flexible development

• Open-source

Batch

Page 21: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Triggers and Bindings

21

Type

Schedule

HTTP (REST or webhook)

Blob Storage

Events

Queues

Queues and topics

Storage tables

SQL tables

NoSQL DB

Push Notifications

Twilio SMS Text

SendGrid Email

Azure Functions

Service

Azure Functions

Azure Storage

Azure Event Hubs

Azure Storage

Azure Service Bus

Azure Storage

Azure Mobile Apps

Azure Cosmos DB

Azure Notification Hubs

Twilio

SendGrid

Trigger Input Output

Page 22: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Develop How You Want

22

• Azure Portal

• Quickly get started without having to install anything

else

• Visual Studio 2017

• First class C# development experience

• Visual Studio Code

• First class Node.js development experience

• Edit any function project generated via CLI

• Azure Functions Core Tools (CLI)

• Build any kind of function and edit in IDE of your

choice

Page 23: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Runtime Versions

23

• .NET Framework 4.6

• Generally Available

Runtime 1.x Runtime 2.x (Preview)• .NET Core 2.0

• Cross Platform

• Language Extensions

• Java

• Binding Extensions

• Microsoft Graph

• Durable Functions

Page 24: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Web Application Backends

24

Page 25: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Mobile Application Backends

25

Page 26: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Real-Time File Processing

26

Page 27: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Real-Time Stream Processing

27

Page 28: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Automation of Scheduled Tasks

28

Page 29: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Extending SaaS Applications

29

Page 30: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

Demo 1: Create an Azure Function from the Portal

Page 31: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 32: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 33: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 34: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 35: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 36: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 37: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 38: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

Demo 2: Create an Azure Function from Visual Studio

Page 39: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 40: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 41: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 42: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 43: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 44: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 45: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 46: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 47: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 48: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 49: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Deployment and Monitoring

49

• Visual Studio

• Functions CLI

• Visual Studio Team Services

• Azure Resource Manager

• Maven / Jenkins

Deployment Options Monitoring Options• Azure App Insights

• Function Logs

• Azure Monitor (preview)

Page 50: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

Demo 3: CI/CD

Page 51: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 52: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 53: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 54: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 55: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 56: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 57: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 58: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 59: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 60: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 61: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Proxies

61

• Provide more control over all functions or just select

methods

• Can point to any HTTP resource

Take our current function url:https://stirtrek.azurewebsites.net/api/HttpTriggerCSharp1?code=k9as3MKuDEA

Oyj3GbniZgJjWrn1cMqTAcDhbzqgAldUcYk67EX8QVg==&name={name}

Our function URL would then be like this:https://stirtrek.azurewebsites.net/HelloWorld/{name}

Page 62: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

Demo 4: Setting up routing and proxies

Page 63: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 64: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 65: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 66: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 67: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 68: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 69: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 70: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 71: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational
Page 72: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Securing your Azure Functions

72

• HTTPTriggers can be protected by OAuth providers

• Azure Active Directory

• Microsoft Account

• Facebook

• Google

• Twitter

Page 73: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Function Timeouts

73

• Default timeout of 5 minutes

• Maximum timeout of 10 minutes

• For longer running functions use the App Service

Plan and/or Durable Functions

Page 74: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

PricingFrom Zero to Serverless

Page 75: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Pricing – General Information

75

• No upfront cost

• No termination fees

• Pay only for what you use

Page 76: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Pricing – Two Different Pricing Plans

76

• Takes care of everything but your code

• Pay only when your functions are running

• Scale out automatically

Consumption Plan App Service Plan• You pretty much take care of everything

• Consider when:

• Existing, underutilized VMs

• Function apps to run continuously

• More CPU or memory options

• Run longer than maximum execution

time

• Require features only available on

App Service plan

• Want to run on Linux (on general

availability tier)

Page 77: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Pricing – Consumption Plan Details

77

• Gigabyte-second (GB-s) – Combination of memory size and execution time

• Executions – Each time a function is executed

Meter Price Free Grant

Execution Time $0.000016 per Gb-s 400,000 GB-s

Executions $0.20 per million executions 1 million executions

Pricing Example• Execution Time

• 3 million executions x 1 second per execution = 3 million seconds

• Resource consumption of 512-Mb → 1.5 million GB-s

• 1.5 million GB-s minus grant of 400,000 Gb-s = 1.1 million Gb-s

• Execution Total = $17.60

• Executions

• 3 million executions minus grant of 1 million executions = 2 million executions

• 2 million transactions at 20 cents per million = $0.40

• Grand Total: $18.00

Page 78: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

Best PracticesFrom Zero to Serverless

Page 79: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

The absolute minimum best practices

79

• Functions should do one thing

• Functions should be idempotent

• Functions should finish as quickly as possible

Page 80: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

General Best Practices

80

• Avoid long running functions

Page 81: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

General Best Practices

81

• Avoid long running functions

• Cross function communication

Page 82: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

General Best Practices

82

• Avoid long running functions

• Cross function communication

• Write functions to be stateless

Page 83: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

General Best Practices

83

• Avoid long running functions

• Cross function communication

• Write functions to be stateless

• Write defensive functions

Page 84: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Scalability Best Practices

84

• Do not mix test and production code in the same

function app

Page 85: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Scalability Best Practices

85

• Do not mix test and production code in the same

function app

• Use async code but avoid blocking calls

Page 86: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Scalability Best Practices

86

• Do not mix test and production code in the same

function app

• Use async code but avoid blocking calls

• Receive messages in batch whenever possible

Page 87: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Scalability Best Practices

87

• Do not mix test and production code in the same

function app

• Use async code but avoid blocking calls

• Receive messages in batch whenever possible

• Configure host behaviors to better handle

concurrency

Page 88: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

From Zero to Serverless

Where to get started

88

• Start small, replace 1 API or background processing

item

• Integration is a great place, often it’s a new layer on

top of old layers

Page 89: Chad Green From Zero to Serverless · Serverless The platform for next generation applications. From Zero to Serverless ... Challenges of Serverless Architecture 13 Complexity Organizational

Questions

[email protected]

bit.ly/CCruise18