41
Azure Functions Real World Examples Yochay Kiriaty Oct 2 nd 2016

Azure Functions Real World Examples

Embed Size (px)

Citation preview

Page 1: Azure Functions Real World Examples

Azure Functions Real World Examples

Yochay Kiriaty

Oct 2nd 2016

Page 2: Azure Functions Real World Examples

Yochay KiriatyPrincipal Program Manager @ MicrosoftAzure / App Service Tech Evangelist Various Start Ups

https://blogs.msdn.microsoft.com/appserviceteam@[email protected]

Page 3: Azure Functions Real World Examples

Agenda• Why Serverless?• What is serverless? • Intro Azure Functions• Serverless patterns / Real-world examples

Page 4: Azure Functions Real World Examples

Before cloud

On-PremiseCo-Lo

Page 5: Azure Functions Real World Examples

Before cloud

How many servers do I need?

Which OS should I use?

How often should I patch my servers?

What size of servers

should I buy?

How often should I backup

my server?

How can I increase server utilization?

How I deploy new code to my server?

Which packages should be on my server?

It takes how long to provision a new server?

Are my server in a

secure location?

What happens if

the

power goes out?Do I n

eed secondary

network connection?

What is th

e right si

ze of

servers for m

y business n

eeds?

Who has physical

access to my servers?

Do I need a UPS?

What media should I

use to keep backup?

What storage I need to use?

How I scale my app?

What happens in case of

server hardware failure?

How can I d

ynamically

configure my app?

Who monitors

my Servers?Who monitors

my App?

Page 6: Azure Functions Real World Examples

Then came IaaS …

How many servers do I need?

Which OS should I use?

How often should I patch my servers?

What size of servers

should I buy?

How often should I backup

my server?

How can I increase server utilization?

How I deploy new code to my server?

Which packages should be on my server?

It takes how long to provision a new server?

Are my server in a

secure location?

What happens if

the

power goes out?Do I n

eed secondary

network connection?

What is th

e right si

ze of

servers for m

y business n

eeds?

Who has physical

access to my servers?

Do I need a UPS?

What media should I

use to keep backup?

What storage I need to use?

How I scale my app?

What happens in case of

server hardware failure?

How can I d

ynamically

configure my app?

Who monitors

my Servers?Who monitors

my App?

Page 7: Azure Functions Real World Examples

Is it PaaS time?

How many servers do I need?

Which OS should I use?

How often should I patch my servers?

How often should I backup

my server?

How can I increase server utilization?

How I deploy new code to my server?

Which packages should be on my server?

What is th

e right si

ze of

servers for m

y business n

eeds?

How I scale my app?

How can I d

ynamically

configure my app?

Who monitors

my App?

Page 8: Azure Functions Real World Examples

Is it PaaS time?

How many servers do I need?

Which OS should I use?

How often should I patch my servers?

How often should I backup

my server?

How can I increase server utilization?

How I deploy new code to my server?

Which packages should be on my server?

What is th

e right si

ze of

servers for m

y business n

eeds?

How I scale my app?

How can I d

ynamically

configure my app?

Who monitors

my App?

Page 9: Azure Functions Real World Examples

Serverless . . .

How many servers do I need?

How can I increase server utilization?What is

the rig

ht size of

servers for m

y business n

eeds?

How I scale my app?

Page 10: Azure Functions Real World Examples

Event-driven/ instant scale

Sub-second billing

Abstraction of

servers

What is Serverless?

Page 11: Azure Functions Real World Examples

Focus on Business

LogicReduced Time To Market

Reduced DevOps

Benefits of Serverless?

Page 12: Azure Functions Real World Examples

Application’s evolution

Ship.

Acct. Mang.

Hist.

Database

Client

Ship.

DB

Client

Hist.

DB

Mang.

DB

Acct.

DB

POST

GET

POST

UPDATE

Monolithic Microservices

Page 13: Azure Functions Real World Examples

Application’s evolution

Ship.

Acct. Mang.

Hist.

Database

Client

Monolithic

Ship.

DB

Client

Hist.

DB

Mang.

DB

Acct.

DB

POST

GET

POST

UPDATE

Microservices

Page 14: Azure Functions Real World Examples

Application’s evolution

Ship.

DB

Client

Hist.

DB

Mang.

DB

Acct.

DB

POST

GET

POST

UPDATE

Microservices

Page 15: Azure Functions Real World Examples

Application’s evolution

Client Mang.

DB

Microservices

POST Users

Users/Id

Users/Id

Users/Id

CreatUser

GetUser

UpdateUser

DeleteUser

GET

UPDATE

DELETE

Serverless

Page 16: Azure Functions Real World Examples

Microsoft Serverless

App ServiceCortana Management Suite

Media ServicesLogic AppFunctionsStorage

Traffic Manager

Visual StudioServices

OMS Management SuitMachine LearningCDNDocument DB

Search

Scheduler

Active Directory Key Vault App Insights Cognitive Services Embedded Power BI

Hockey AppStream AnalyticsNotification HubIoT Hub Service Bus

Page 17: Azure Functions Real World Examples

Azure FunctionsProcess events with Serverless code.

Make composing Cloud Apps insanely easyDevelop Functions in C#, Node.js, F#, Python, PHP, Batch and more Easily schedule event-driven tasks across servicesExpose Functions as HTTP API endpointsScale Functions based on customer demandEasily integrate with Logic Apps

Code Events + dataAzure Functions

Page 18: Azure Functions Real World Examples

Functions Hello WorldDemo

Page 19: Azure Functions Real World Examples

Functions Programming ModelTrigger(data) Input Input

code

Output

Output

• Function as a single unit of work• Functions are executed per trigger • Functions have inputs and outputs

Input

Page 20: Azure Functions Real World Examples

Triggers and

bindings

Page 21: Azure Functions Real World Examples

Image Processing

Demo

Page 22: Azure Functions Real World Examples

Dual abstraction

Business Logic

Serverless PaaS

Other Services

• Serverless compute abstracts away the compute• Azure Functions Bindings abstract away the services you interact with

Page 23: Azure Functions Real World Examples

Building Applications With FunctionsInstead of …• implementing a route inside of a Web Application server, I

write a function.• pulling – triggers • ‘SDK’ – bindings• writing large functional tests against a server, your

functional tests look more like unit tests per function.• building and deploying servers, deploy collections of

Functions

Page 24: Azure Functions Real World Examples

Functions Programming Model - Best Practices• Functions should “do one thing”• Functions should be stateless• Functions should be idempotent• Functions should finish as quickly as possible

1

Page 25: Azure Functions Real World Examples

Serverless Patterns

Page 26: Azure Functions Real World Examples

Every 15 minutes Clean tableFind and clean invalid data

ApplicationsExample: Timer based processing

Page 27: Azure Functions Real World Examples

FTP Download Function

Blob Replication

Blob Storage Cool Storage

Abnormal behavior

Page 28: Azure Functions Real World Examples

Problem• Replicate logs from

one data center to another • Analyze the logs• Take action

Using Functions• Setup a VM/

Container/ WebJobs• Build/ patch/ deploy• Monitor• Manage FTP cred• Use FTP library• Use Azure SDK

Before Functions• Setup a VM/

Container/ WebJobs• Build/ patch/ deploy• Monitor• Manage FTP cred• Use FTP library• Use Azure SDK

Page 29: Azure Functions Real World Examples

FTP Download Function

Blob Replication

Blob Storage Cool Storage

Abnormal behavior

Page 30: Azure Functions Real World Examples

Blob Replication

Blob Storage Cool Storage

Abnormal behavior

FTP Download Manager Function

Single Folder Single Folder Single Folder

Page 31: Azure Functions Real World Examples

File added toBlob Storage

Transform CSV to datarows Power BIChart graphic

ApplicationsExample: Azure service event processing

Page 32: Azure Functions Real World Examples

Photo taken andWebHook called Stores in blob storage Produces scaled images

Async background processingExample: Serverless Mobile back ends

Page 33: Azure Functions Real World Examples

API

Photo taken andWebHook called

Page 34: Azure Functions Real World Examples

Problem• Expose REST API• Upload data to

storage• Process data

Using Functions• Setup a VM/

Container/ WebJobs• Build/ patch/ deploy• Monitor• Use Azure SDK• Async data

processing (scale)

Before Functions• Setup a VM/

Container/ WebJobs• Build/ patch/ deploy• Monitor• Use Azure SDK• Async data

processing (scale)

Photo taken andWebHook called

Page 35: Azure Functions Real World Examples

Loaded web pagecallsWebHook

Completed pageCreate ad based on user profile

ApplicationsExample: Serverless Web Applications architectures

Page 36: Azure Functions Real World Examples

Millionsof devices feedinto Stream Analytics

Store data inSQL Online

Transform to structured data

ApplicationsExample: Real-time stream processing

Page 37: Azure Functions Real World Examples
Page 38: Azure Functions Real World Examples

Problem• Collect tweets• Analyze tweets• Display rich analysis

Using Serverless• Setup a VM/ Container/

WebJobs• Build/ patch/ deploy• Monitor• Connect (auth)to twitter • Using Twitter API (SDK)• Analyze tweets• Build rich client to show

results

Before Serverless• Setup a VM/ Container/

WebJobs• Build/ patch/ deploy• Monitor• Connect (auth)to twitter • Using Twitter API (SDK)• Analyze tweets• Build rich client to show

results

Page 39: Azure Functions Real World Examples

•Thick clients; thin & stateless backends• SPAs like Angular/React are your friend• Be sure to enable CORS

•Sync is nice, but Async is nicer• Async, queue based systems are more resilient• Read and internalize the reactive manifesto - http://www.reactivemanifesto.org/ • While synchronous work will happen, minimize the work done in a sync function and

kick off to a queue based async process (HTTP status code 202, not 201 )

•Live and die by the cloud• Like never before, develop on the cloud, test on the cloud, ship on the cloud• Not just FaaS, but use other serverless tech that best solves the problem (like Logic

Apps)

General practices for serverless

Page 40: Azure Functions Real World Examples

Microsoft and ServerlessTry Functions – https://functions.azure.comTry App Service – https://tryappservice.azure.com

Page 41: Azure Functions Real World Examples