Slide 1

Slide 1 text

Serverless-Architekturen für Java, .NET und node.js – mit Azure Functions & Co. Christian Weyer @christianweyer Thinktecture AG, CTO

Slide 2

Slide 2 text

2 § Co-Founder & CTO at Thinktecture AG § Personal focus on § Mobile & web-based application architectures § Interoperability, cross-device § Pragmatic end-to-end solutions § Cloud-native & serverless architectures § Independent Microsoft Regional Director § Microsoft MVP for Developer Technologies & Azure ASPInsider, AzureInsider § Google GDE for Web Technologies, Angular [email protected] @christianweyer https://www.thinktecture.com Christian Weyer Serverless-Architekturen für Java, .NET und node.js Azure Functions & Co.

Slide 3

Slide 3 text

3 § Azure § Microservices, Nanoservices § Serverless in Azure § Serverless Data: Storage & CosmosDB § Serverless Compute: Azure Functions § Serverless Messaging: Azure Service Bus § Serverless Realtime: Azure SignalR § Azure Functions Extensibility § Summary Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js Our Journey Today

Slide 4

Slide 4 text

4 § We can choose from a continuum § VM ➔ § Containers ➔ § Orchestrators ➔ § PaaS ➔ § Serverless Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js Evolution to Cloud Compute Continuum PaaS IaaS On-Premises Serverless

Slide 5

Slide 5 text

5 Serverless-Architekturen für Java, .NET und node.js Azure Functions & Co. IaaS

Slide 6

Slide 6 text

6 The other Cloud Azure Serverless-Architekturen für Java, .NET und node.js Azure Functions & Co.

Slide 7

Slide 7 text

7 § Why Azure? § Look beyond one’s own nose § Microsoft has always been strong in the enterprise § It is no longer “Windows Azure” § >50% of VMs running on Linux (increasing) § Strong developer tooling § VS Code, anyone? § Breadth & depth offerings § Very broad availability worldwide Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js Azure Cloud https://www.cbronline.com/news/aws-results-azure

Slide 8

Slide 8 text

https://azure.microsoft.com/en-us/global-infrastructure/regions/ Serverless-Architekturen für Java, .NET und node.js Azure Functions & Co. 8

Slide 9

Slide 9 text

9 How ‘large’ is ‘small’? ‘Micro’ Services Serverless-Architekturen für Java, .NET und node.js Azure Functions & Co.

Slide 10

Slide 10 text

10 Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js Bird’s-Eye-View Target Architectures HTTP API WS API Service D HTTPS HTTPS WebSocket Service A Service B Service C HTTP API

Slide 11

Slide 11 text

Single Responsibility § Focused around business domain § ‘Small’ Isolation § Well-defined technology- agnostic API § Mobility § Choice of technology Autonomy § Exclusive state (data storage) Decoupling § Asynchronous communication § Really, always? Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js (Some) Principles of Microservices 11

Slide 12

Slide 12 text

Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js Sample Architecture – Shopping Order Monitoring 12

Slide 13

Slide 13 text

Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js Sample Architecture – Shopping Order Monitoring Orders Service Products Service Shipping Service AuthN Service Order Monitoring SPA Shopping Web Site (simulated by Postman) 1 - authenticate 2 - register for push 3 - send new order 5 - new order created push 6 - get updated orders 4 - processing order… 13

Slide 14

Slide 14 text

14 § We can choose from a continuum § VM ➔ § Containers ➔ § Orchestrators ➔ § PaaS ➔ § Serverless Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js Evolution to Cloud Compute Continuum PaaS IaaS On-Premises Serverless

Slide 15

Slide 15 text

15 A different approach to Microservices Serverless Serverless-Architekturen für Java, .NET und node.js Azure Functions & Co.

Slide 16

Slide 16 text

16 § We strive for isolating functional services § Choice of technology, use best fitting communication means § Microservice: unit of independent deployment for a business domain-specific service § Nanoservice: like Microservice, but more focused & lightweight; may be replaced easier § Functions as the mental model § Basic idea: make things easier, get productive with business, not infrastructure Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js Microservices – or rather: Nanoservices

Slide 17

Slide 17 text

17 Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js Serverless Sweet Spot Programming Model (FaaS) § Event-driven § Stateless § Service-full Operational Model § Fully managed § Automatically scaling § Usage priced

Slide 18

Slide 18 text

18 Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js Typical Serverless attributes

Slide 19

Slide 19 text

19 § Serverless Compute → Azure Functions § Serverless SQL Database → Azure SQL Database Serverless § Serverless NoSQL Database → Azure Cosmos DB § Serverless Storage → Azure Storage § Serverless Realtime → Azure SignalR Service § Serverless Events → Azure Event Grid § Serverless Messaging → Azure Service Bus § Serverless Workflows → Azure Logic Apps Azure Durable Functions § Serverless IoT → Azure IoT Hub § Serverless Analytics → Azure Application Insights § Serverless Containers → Azure Container Instances Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js Serverless in Azure (my personal choice)

Slide 20

Slide 20 text

20 Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js There are NO servers! https://twitter.com/jeffhollan/status/1030244102082682880

Slide 21

Slide 21 text

Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js Sample Architecture – Shopping Order Monitoring: Serverless Orders Service Products Service Shipping Service AuthN Service Order Monitoring SPA Shopping Web Site (simulated by Postman) Azure Function App – C# Azure Function App - C# Azure Function App - JS Azure Function App - Java Azure Service Bus Azure Blob Storage Azure SignalR Service Azure Table Storage Azure Cosmos DB Identity Server 21

Slide 22

Slide 22 text

22 Azure Storage & Cosmos DB Serverless Data Serverless-Architekturen für Java, .NET und node.js Azure Functions & Co.

Slide 23

Slide 23 text

23 § Blob § Highly scalable storage for arbitrary data § Can host static websites § Integrated with Event Grid § Files: fully managed cloud file shares § Sync § SMB, HTTPS § Table § Very simple schemaless table storage § Highly scalable § Needs thorough upfront design of data structures Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js Azure Storage

Slide 24

Slide 24 text

Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js Sample Architecture – Shopping Order Monitoring: Serverless Orders Service Products Service Shipping Service AuthN Service Order Monitoring SPA Shopping Web Site (simulated by Postman) Azure Function App – C# Azure Function App - C# Azure Function App - JS Azure Function App - Java Azure Service Bus Azure Blob Storage Azure SignalR Service Azure Table Storage Azure Cosmos DB Identity Server 24

Slide 25

Slide 25 text

25 § Globally distributed, elastically scalable § Fully managed by Azure § But not yet fully automatically scaling § Pricing not (yet?) suitable for low-entry projects § Multi-model database § Key-value, document, graph § Multiple APIs § DocumentDB, with SQL & JS APIs § MongoDB API § Cassandra API § Table Storage API § Graph Database with Gremlin API Serverless-Architekturen für Java, .NET und node.js Cosmos DB: A NoSQL Database with Many Faces Azure Functions & Co.

Slide 26

Slide 26 text

Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js Sample Architecture – Shopping Order Monitoring: Serverless Orders Service Products Service Shipping Service AuthN Service Order Monitoring SPA Shopping Web Site (simulated by Postman) Azure Function App – C# Azure Function App - C# Azure Function App - JS Azure Function App - Java Azure Service Bus Azure Blob Storage Azure SignalR Service Azure Table Storage Azure Cosmos DB Identity Server 26

Slide 27

Slide 27 text

27 § Building event-driven architectures with Cosmos DB § Listening to Azure Cosmos DB collection for any changes § Inserts, updates, soft-deletes § Subscribe to collection changes Serverless-Architekturen für Java, .NET und node.js Cosmos DB Change Feed Azure Functions & Co.

Slide 28

Slide 28 text

28 Azure Functions Serverless Compute Serverless-Architekturen für Java, .NET und node.js Azure Functions & Co.

Slide 29

Slide 29 text

29 § Azure Functions: Code being triggered by an event § Basic principles enable powerful use cases § Events ➔ Triggers § Bindings § Various ways of operation § Cost-optimized, automatic scale (aka Consumption Plan) § Always-on § V2 Runtime built on .NET Core § Available for e.g. self-hosting § Local tooling & runtime available § Multiple language bindings supported Serverless-Architekturen für Java, .NET und node.js Azure Functions: Functions-as-a-Service Azure Functions & Co.

Slide 30

Slide 30 text

Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js Sample Architecture – Shopping Order Monitoring: Serverless Orders Service Products Service Shipping Service AuthN Service Order Monitoring SPA Shopping Web Site (simulated by Postman) Azure Function App – C# Azure Function App - C# Azure Function App - JS Azure Function App - Java Azure Service Bus Azure Blob Storage Azure SignalR Service Azure Table Storage Azure Cosmos DB Identity Server 30

Slide 31

Slide 31 text

31 § Incoming event triggers function § Input bindings enable easy access to data from various data sources § Output bindings offer easy access to outbound data sinks Serverless-Architekturen für Java, .NET und node.js Triggers & Bindings Azure Functions & Co. Your code logic Runtime Azure Function HTTP Trigger Storage Input Binding Push Notification Output Binding Database Output Binding Email Output Binding Example

Slide 32

Slide 32 text

32 Serverless-Architekturen für Java, .NET und node.js Triggers & Bindings in Code Azure Functions & Co.

Slide 33

Slide 33 text

33 Serverless-Architekturen für Java, .NET und node.js Azure Functions & Co. https://docs.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings Triggers & Bindings

Slide 34

Slide 34 text

34 § Azure Functions host instances are automatically managed § Spawning new instances → cold start § Reusing existing instances → warm start Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js Azure Functions: Activation & Scaling in Consumption Plan https://blogs.msdn.microsoft.com/appserviceteam/2018/02/07/understanding-serverless-cold-start/

Slide 35

Slide 35 text

35 Azure Service Bus Serverless Messaging Serverless-Architekturen für Java, .NET und node.js Azure Functions & Co.

Slide 36

Slide 36 text

36 § Asynchronous communication for decoupling Microservices § Different messaging services in Azure § Events, messages, data points § Event Grid § Primary use case: Reactive programming § Service Bus § Primary use case: Enterprise-grade messaging § Event Hubs § Primary use case: Big data streams Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js Communication is key to Cloud Architectures

Slide 37

Slide 37 text

37 § Fully-managed centralized event routing service § Simplifies development of event-based applications § Simplifies creation of serverless workflows § Supports direct event filtering using event type, prefix or suffix § Your application will only need to receive the events you care about § Same underlying model for different use-cases § System-provided events § Custom application-specific events Serverless-Architekturen für Java, .NET und node.js Reactive Programming: Event Grid Azure Functions & Co.

Slide 38

Slide 38 text

38 § Queues & Topics § Reliable asynchronous communication § Rich features for temporal control § Routing and filtering § Transactions § Convoys & Sessions (related messages with state) Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js Service Bus: Messaging-as-a-Service

Slide 39

Slide 39 text

39 Sender § Sender sends message to queue § Queue ACKs receipt § Receiver connects to queue & retrieves message § Receiver ACKs complete (or other action) Service Bus Queues Serverless-Architekturen für Java, .NET und node.js Azure Functions & Co. Receiver

Slide 40

Slide 40 text

Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js Sample Architecture – Shopping Order Monitoring: Serverless Orders Service Products Service Shipping Service AuthN Service Order Monitoring SPA Shopping Web Site (simulated by Postman) Azure Function App – C# Azure Function App - C# Azure Function App - JS Azure Function App - Java Azure Service Bus Azure Blob Storage Azure SignalR Service Azure Table Storage Azure Cosmos DB Identity Server 40

Slide 41

Slide 41 text

41 § Sender only knows about Topic § Receivers only know about Subscriptions § Filters and Actions exist on Subscriptions Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js Service Bus Topics & Subscriptions Type == ‘order‘ Sender type=order type=quote Topic Type == ‘quote‘ Filter Filter Subscrip- tion 1 Subscrip- tion 2

Slide 42

Slide 42 text

42 Azure SignalR Service Serverless Realtime Serverless-Architekturen für Java, .NET und node.js Azure Functions & Co.

Slide 43

Slide 43 text

43 § Realtime messaging is a wanted feature nowadays § Dashboards and monitoring apps § Collaborative apps § Apps that require notifications § ASP.NET Core SignalR provides programming model for bi-directional ‘method invocation’ § Via WebSockets, SSE or Long Polling § Wanted: “SignalR messaging & scale-out”-as-a-Service ➔ Azure SignalR Service § Azure Functions bindings available for accessing Hubs Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js Azure SignalR Service

Slide 44

Slide 44 text

Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js Sample Architecture – Shopping Order Monitoring: Serverless Orders Service Products Service Shipping Service AuthN Service Order Monitoring SPA Shopping Web Site (simulated by Postman) Azure Function App – C# Azure Function App - C# Azure Function App - JS Azure Function App - Java Azure Service Bus Azure Blob Storage Azure SignalR Service Azure Table Storage Azure Cosmos DB Identity Server 44

Slide 45

Slide 45 text

Azure Functions Extensibility Custom Bindings & Triggers Serverless-Architekturen für Java, .NET und node.js Azure Functions & Co. 45

Slide 46

Slide 46 text

46 § Connecting your own data sources and data sinks to Azure Functions § Beyond available bindings & triggers § E.g. build input binding for your own ERP system § Or… SQL Server § E.g. provide output binding for Web Push protocol (used in PWAs) Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js Azure Functions Custom Bindings & Triggers

Slide 47

Slide 47 text

47 § Custom Input and Outputs bindings possible § Must be implemented with .NET Core and C# § Can be used with other languages and runtimes § Three major parts § Attribute § One or more converters § Configuration Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js Custom Bindings

Slide 48

Slide 48 text

48 § Currently gray area: Not really supported, but possible to build § May not work in consumption plan § May not scale in consumption plan § May not work in any plan, actually… § But they work in Docker (of course) § Implement ITriggerBinding Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js Custom Triggers

Slide 49

Slide 49 text

49 Wrapping up Serverless Serverless-Architekturen für Java, .NET und node.js Azure Functions & Co.

Slide 50

Slide 50 text

50 § Greenfield projects (but consider cold starts) § Integration use cases - the glue § Dissecting a monolith - isolate business functionality Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js When to use Serverless Azure

Slide 51

Slide 51 text

Single Responsibility § Focused around business domain § ‘Small’ unit ➡ Dedicated Azure Functions App ➡ Dedicated Azure DevOps Pipeline Isolation § Choice of technology ➡ .NET, Java, node.js, Python supported § Well-defined technology-agnostic APIs ➡ HTTPS, AMQP, MQTT, custom § Mobility ➡ Portable runtime ➡ Can use Docker, k8s with Functions ➡ Easily deploy & run in Cloud Autonomy § Exclusive state (data storage) ➡ Use separate Azure Storage, Azure SQL, Azure CosmosDB instances Decoupling § Asynchronous communication ➡ Azure Service Bus with queues or topics & subscriptions Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js (Some) Principles of Microservices – with Serverless Azure 51

Slide 52

Slide 52 text

Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js https://twitter.com/swardley/status/1024764547436085249 52

Slide 53

Slide 53 text

Christian Weyer, Thinktecture AG @christianweyer [email protected] https://github.com/thinktecture/serverless-microservices https://github.com/thinktecture/azure-functions-extensibility