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

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

Egal ob Sie Java, .NET oder node.js als Haupttechnologie nutzen: mit Serverless-Ansätzen können Sie schnell "Gummi auf die Straße" bringen, um ihre Microservices oder Ihren "Glue Code" mir-nichts-dir-nichts entwickeln und bereitstellen zu können. In diesem Workshop sehen Sie Azure Serverless-Dienste ohne großes Marketing-Tamtam im Einsatz. Neben den Grundlagen werden vor allem typische Anwendungsszenarien für Azure Functions, Azure Service Bus, Azure Storage und Co. illustriert. Lehnen Sie sich also zurück und sehen Sie Serverless in Action, mit Java, .NET und JavaScript.

7e0087a19318ded4ba2203187694740f?s=128

Christian Weyer

December 11, 2019
Tweet

Transcript

  1. Serverless-Architekturen für Java, .NET und node.js – mit Azure Functions

    & Co. Christian Weyer @christianweyer Thinktecture AG, CTO
  2. 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 christian.weyer@thinktecture.com @christianweyer https://www.thinktecture.com Christian Weyer Serverless-Architekturen für Java, .NET und node.js Azure Functions & Co.
  3. 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
  4. 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
  5. 5 Serverless-Architekturen für Java, .NET und node.js Azure Functions &

    Co. IaaS
  6. 6 The other Cloud Azure Serverless-Architekturen für Java, .NET und

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

    Co. 8
  9. 9 How ‘large’ is ‘small’? ‘Micro’ Services Serverless-Architekturen für Java,

    .NET und node.js Azure Functions & Co.
  10. 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
  11. 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
  12. Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js

    Sample Architecture – Shopping Order Monitoring 12
  13. 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
  14. 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
  15. 15 A different approach to Microservices Serverless Serverless-Architekturen für Java,

    .NET und node.js Azure Functions & Co.
  16. 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
  17. 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
  18. 18 Azure Functions & Co. Serverless-Architekturen für Java, .NET und

    node.js Typical Serverless attributes
  19. 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)
  20. 20 Azure Functions & Co. Serverless-Architekturen für Java, .NET und

    node.js There are NO servers! https://twitter.com/jeffhollan/status/1030244102082682880
  21. 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
  22. 22 Azure Storage & Cosmos DB Serverless Data Serverless-Architekturen für

    Java, .NET und node.js Azure Functions & Co.
  23. 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
  24. 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
  25. 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.
  26. 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
  27. 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.
  28. 28 Azure Functions Serverless Compute Serverless-Architekturen für Java, .NET und

    node.js Azure Functions & Co.
  29. 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.
  30. 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
  31. 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
  32. 32 Serverless-Architekturen für Java, .NET und node.js Triggers & Bindings

    in Code Azure Functions & Co.
  33. 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
  34. 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/
  35. 35 Azure Service Bus Serverless Messaging Serverless-Architekturen für Java, .NET

    und node.js Azure Functions & Co.
  36. 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
  37. 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.
  38. 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
  39. 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
  40. 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
  41. 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
  42. 42 Azure SignalR Service Serverless Realtime Serverless-Architekturen für Java, .NET

    und node.js Azure Functions & Co.
  43. 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
  44. 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
  45. Azure Functions Extensibility Custom Bindings & Triggers Serverless-Architekturen für Java,

    .NET und node.js Azure Functions & Co. 45
  46. 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
  47. 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
  48. 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
  49. 49 Wrapping up Serverless Serverless-Architekturen für Java, .NET und node.js

    Azure Functions & Co.
  50. 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
  51. 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
  52. Azure Functions & Co. Serverless-Architekturen für Java, .NET und node.js

    https://twitter.com/swardley/status/1024764547436085249 52
  53. Christian Weyer, Thinktecture AG @christianweyer christian.weyer@thinktecture.com https://github.com/thinktecture/serverless-microservices https://github.com/thinktecture/azure-functions-extensibility