introduction to azure functions

33
Unconference Web 2017 – 28.01.2017 Introduction to Azure Functions Marco Parenzan Microsoft MVP for Azure @marco_parenzan

Upload: marco-parenzan

Post on 13-Apr-2017

320 views

Category:

Software


2 download

TRANSCRIPT

Page 1: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

Introduction to Azure Functions

Marco ParenzanMicrosoft MVP for Azure

@marco_parenzan

Page 2: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

@marco_parenzan◇ Microsoft MVP 2016 for Azure

◇ Azure Trainer in Cloud Academy, Inc.

◇ Community Lead per 1nn0va

Page 3: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

How we always explained cloud services

Page 4: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

Misundestanding on PaaS◇ You control only the application and data◇ No control over other tiers

■ No on underlying hardware■ CPU and RAM….hardware?

◇ Always example about our applications, web as an example■ …and we compare IaaS (IIS) with PaaS (App Services)■ …so we configure the CPU, the RAM, but nothing else…

Page 5: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

Cortana Management SuiteMedia ServicesStorage Traffic

Manager

Visual StudioServices

OMS Management SuitMachine LearningCDNDocument DB

Search

SchedulerActive Directory Key Vault App Insights Cognitive Services Embedded Power BI

Hockey AppStream AnalyticsNotification HubIoT Hub Service Bus

Logic App

Where you decide the CPU on these?

Page 6: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

Real World PaaS…◇ Don’t decide on CPU and RAM…why?

■ Control vs Configure◇ You cannot plan your workload capacity

■ Only with testing◇ Infact Real World PaaS is about….

■ IOPS (Azure Storage)■ Streaming Units (Media Services)■ Resource Units (DocumentDb)■ Throughput Units (Event Hubs)■ Streaming Unit (Stream Analytics)■ Data Transaction Units (SQL Database)

Page 7: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

Find who is missing…

Cortana Management SuiteMedia ServicesStorage Traffic

Manager

Visual StudioServices

OMS Management SuitMachine LearningCDNDocument DB

Search

SchedulerActive Directory Key Vault App Insights Cognitive Services Embedded Power BI

Hockey AppStream AnalyticsNotification HubIoT Hub Service Bus

Logic App

Page 8: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

Yes it is!

Azure App Service

“PaaS that developers love and businesses can trust”

Page 9: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

Ship.

Acct. Mang.

Hist.

Database

Client

Ship.

DB

Client

Hist.

DB

Mang.

DB

Acct.

DB

POST

GET

POST

UPDATE

Monolithic Microservices

Application’s evolution

Page 10: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

Ship.

Acct. Mang.

Hist.

Database

Client

Monolithic

Ship.

DB

Client

Hist.

DB

Mang.

DB

Acct.

DB

POST

GET

POST

UPDATE

Microservices

Application’s evolution

Page 11: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

Serverless manifesto◇ Function are the unit of deployment and scaling.◇ No machines, VMs, or containers visible in the programming model.◇ Permanent storage lives elsewhere.◇ Scales per request; Users cannot over- or under-provision capacity.◇ Never pay for idle (no cold servers/containers or their costs).◇ Implicitly fault-tolerant because functions can run anywhere.◇ BYOC - Bring Your Own Code.◇ Metrics and logging are a universal right.

P.S. Home not found!

Page 12: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

Serverless origins◇ https://martinfowler.com/articles/serverless.html#origin◇ Why The Future Of Software And Apps Is Serverless

■ 2012 KEN FROMM■ http://readwrite.com/2012/10/15/why-the-future-of-software-and-apps-is-serverless/■ https://medium.com/@ken_fromm/thinking-serverless-how-new-approaches-address-mo

dern-data-processing-needs-part-1-af6a158a3af1#.iqlx5xky9

◇ Lambda■ AWS, 2014■ [Google Cloud Function, 2016]

Page 13: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

Ship.

DB

Client

Hist.

DB

Mang.

DB

Acct.

DB

POST

GET

POST

UPDATE

Microservices

Application’s evolution

Page 14: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

ClientMang.

DB

Microservices

POST Users

Users/Id

Users/Id

Users/Id

CreatUser

GetUser

UpdateUser

DeleteUser

GET

UPDATE

DELETE

Serverless

Application’s evolution

Page 15: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

Serverless Principles

Page 16: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

Code Events + dataAzure Functions

Azure Functions◇ Process events with Serverless code. ◇ Make composing Cloud Apps insanely easy◇ Develop Functions in C#, Node.js, Python, PHP, Batch and more ◇ Easily schedule event-driven tasks across services◇ Expose Functions as HTTP API endpoints◇ Scale Functions based on customer demand◇ Easily integrate with Logic Apps

Page 17: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

Now complete Serverless

Cortana Management SuiteMedia ServicesStorage Traffic

Manager

Visual StudioServices

OMS Management SuitMachine LearningCDNDocument DB

Search

SchedulerActive Directory Key Vault App Insights Cognitive Services Embedded Power BI

Hockey AppStream AnalyticsNotification HubIoT Hub Service Bus

Functions Logic App

Page 18: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

Serverless Humor

Page 19: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

AzureFunctions

APIM

Notification Hubs

Web Apps

Mobile Apps

API Apps

Logic Apps

Custom AppseCommerce Digital Global Presence LOBApps

Services

App ServiceDeveloper Experience

• Languages and Frameworks• Superior DevOps• Self service supportability

Fully Managed Platform

• Auto scale• OS and Framework patching• Load balancing

Enterprise Grade

• Enterprise grade SLA• Security and

Compliance• On-Premise

ConnectivityPlatform

API / Services / ISV

Page 20: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

Platform and scaling◇ App Service offers dedicated and consumption tiers.◇ Dedicated is the existing App Service plan tiers

■ Basic, Standard, Premium■ Pay based on # of reserved VMs■ You’re responsible for scale

◇ Consumption (Dynamic)■ Pay on number of executions■ Platform responsible for scale

Page 21: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

Dynamic tier pricing◇ Pay per execution model - two meters, three units

• Number of executions• Duration of execution x reserved memory

Page 22: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

Dual abstraction◇ Serverless compute abstracts away the

compute◇ Azure Functions Bindings abstract away the

services you interact with

Business Logic

Serverless PaaS

Other Services

Page 23: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

Supported bindingsType Service Trigger Input OutputSchedule Azure Functions ✔

HTTP (REST or WebHook) Azure Functions ✔ ✔

Blob Storage Azure Storage ✔ ✔ ✔

Queues Azure Storage ✔ ✔

Tables Azure Storage ✔ ✔

Tables Azure Mobile Apps Easy Tables ✔ ✔

No-SQL DB Azure DocumentDB ✔ ✔

Streams Azure Event Hubs ✔ ✔

Push Notifications Azure Notification Hubs ✔

Page 24: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

Azure Functions architecture◇ Azure Functions is built around the WebJobs SDK runtime. The WebJobs SDK makes it easy to

react to events and work with data in a consistent abstracted fashion.

App Service Dynamic Runtime

WebJobs Core SDK

WebJobs Extensions

WebJobs Script

Runtime

Triggers

Inputs/ Outputs

Language Abstraction

Code

Config

Page 25: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

Supported Languages◇ 1st class support

■ Node/JavaScript■ C#

◇ Experimental support■ F#■ Python■ PHP■ Batch■ Bash■ PowerShell

Page 26: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

Trigger(data) Input Input

code

Output

OutputInput

Functions Programming Model

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

Page 27: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

Demo

Page 28: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

Conclusions

Page 29: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

Focus on Business

Logic

Reduced Time To Market

Reduced DevOps

Benefits of Serverless?

Page 30: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

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 31: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

General practices for serverless◇ 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)

Page 32: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

Azure Functions is open sourced◇ The runtime, “portal”, and templates are all on GitHub

■ https://github.com/Azure/azure-webjobs-sdk■ https://github.com/Azure/azure-webjobs-sdk-extensions■ https://github.com/Azure/azure-webjobs-sdk-script■ https://github.com/Azure/azure-webjobs-sdk-templates■ https://github.com/ProjectKudu/WebJobsPortal

◇ Open roadmap■ Use the cutting edge features■ Transparency into priorities and velocity■ Influence the direction of the project

◇ Runtime is intended to be portable■ MIT License

Page 33: Introduction to Azure Functions

Unconference Web 2017 – 28.01.2017

Any questions?You can find me at: marco [dot] parenzan [at] 1nn0va [dot] it

Thanks!