Azure Functions
Serverless Architecture in the Cloud
Shahed Chowdhuri
Microsoft Corporation
@shahedC
WakeUpAndCode.com
Intro
What’s with the Cloud?
Hosting models
On Premises Infrastructure Platform Software
(as a Service) (as a Service) (as a Service)
You manage
Applications Applications Applications Applications
resilient & manage
You scale, make resilient and manage
You scale, make
Data Data Data Data
Runtime Runtime Runtime Runtime
management by vendor
Scale, resilience and
Middleware Middleware Middleware Middleware
management by vendor
Scale, resilience and
O/S O/S O/S O/S
Managed by vendor
Virtualization Virtualization Virtualization Virtualization
Servers Servers Servers Servers
Storage Storage Storage Storage
Networking Networking Networking Networking
Where does Serverless fit in? Infrastructure Platform
On Premises (as a Service) (as a Service)
Serverless
You manage
Software
Functions Functions Functions Functions (as a Service)
You manage
Applications Applications Applications Applications Applications
resilient & manage
You scale, make resilient and manage
You scale, make
Data Data Data Data Data
Runtime Runtime Runtime Runtime
Scale, resilience and mgmt by vendor
Runtime
management by vendor
Scale, resilience and
Middleware Middleware Middleware Middleware Middleware
O/S O/S O/S O/S O/S
Managed by vendor
Virtualization Virtualization Virtualization Virtualization Virtualization
Servers Servers Servers Servers Servers
Storage Storage Storage Storage Storage
Networking Networking Networking Networking Networking
Azure Functions
Events Code Outputs
React to timers, HTTP, or Author functions in C#, Send results to an ever-
events from your favorite F#, Node.JS, Java, and growing collection of
Azure services, with more more services
on the way
Source: https://myignite.techcommunity.microsoft.com/sessions/65889
Full integration with Azure ecosystem
Functions is the center piece of the Serverless platform
Development Platform
IDE support Event Grid Functions Logic Apps
Integrated
DevOps
Manage all events that can Execute your code based Design workflows and
Local trigger code or logic on events you specify orchestrate processes
development
Monitoring
Database Storage Analytics Intelligence Security IoT
Visual debug
history
Functions 2.0 – What’s New
New Functions Quickstarts by Language
Updated runtime built on .NET Core 2.1
.NET Functions loading changes
New extensibility model
Decoupled from language providers and bindings
Run code from a package
Tooling updates: CLI, Visual Studio & VS Code
Durable Functions (GA)
Consumption mode SLA
Assembly Isolation - Bindings: 2.0 Model
Azure Functions Host – Functions 2.0
Host Assembly Load Context (default) Function Assembly Load Context
Job host Functions Assemblies
Runtime dependencies Bindings
WindowsAzure.Storage 9.3.1 Functions dependencies
WindowsAzure.Storage 9.5.0
9.3.1
public static Run(…, CloudBlockBlob blob,
…))
{
//Function code...;
}
Dev + Hosting
Azure Functions Tooling Options
Visual Studio
VS Code
CLI
Portal
Deployment Options
Visual Studio File | New Project
Azure Portal Function App
Boost development efficiency
Use triggers to define how functions are invoked Connect to data with input and output bindings
Avoid hardcoding with preconfigured JSON files Bind to Azure solutions and third-party services
Triggers Build serverless APIs using HTTP triggers Bindings Use HTTP bindings in tandem with HTTP triggers
Define one API surface for multiple function apps Debug C# and JavaScript functions locally
Create endpoints as reverse proxies to other APIs Use debugging tools in Azure portal, VS, and VS Code
Local
Proxies Condition proxies to use variables debugging
Save time with built-in DevOps Integrate with Azure Application Insights
Deploy functions using App Service for CI Get near real-time details about function apps
CI/CD Leverage Microsoft, partner services for CD Monitoring See metrics around failures, executions, etc.
Sending Emails with SendGrid
https://sendgrid.com/docs/for-developers/sending-email/v3-csharp-code-example
Functions Hosting Models
Serverless Serverless Functions Kubernetes Open Source IoT On Prem
Functions Linux Functions Containers Functions Hosting Functions Functions
Application
Delivery
Execution
Isolation
Infrastructure
Operating
System
Azure Managed Customer Managed
Demo
Durable Functions
What’s still hard?
Durable Functions
• Write long-running orchestrations as a single function
while maintaining local state.
• Simplify complex transactions and coordination
(chaining, etc.) Easily call a Function from another
Function, synchronously or asynchronously.
• All of the above using code-only. No JSON schemas.
No graphical designer.
• Announcing: Generally available (v2) - C# and
JavaScript
Components
Starter Orchestrator Activity
Function Function Function
Starts orchestrations Coordinates activities Performs work
OrchestrationClient OrchestrationContextTrigger ActivityTrigger
What It Looks Like
// calls functions in sequence Orchestrator Function
public static async Task<object> Run(DurableOrchestrationContext ctx)
{
try
{ Activity Functions
var x = await ctx.CallActivityAsync("F1");
var y = await ctx.CallActivityAsync("F2", x);
return await ctx.CallActivityAsync("F3", y);
}
catch (Exception)
{
// global error handling/compensation goes here
}
}
Q&A