Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Azure in Action: Pragmatische Cloud-Lösungen mi...

Azure in Action: Pragmatische Cloud-Lösungen mit Containern & Serverless

IDE öffnen, „File – New Project – Cloud“, OK klicken und fertig. Oder? Nun, nicht ganz. Denn egal ob AWS, GCP oder eben Azure: am Ende des Tages werden Sie sich fragen, warum, wann und wie gehe ich in die Cloud? Genau diese Fragestellungen wollen Thorsten Hans und Christian Weyer für Java-, node.js- und .NET-Entwickler in diesem Workshop beantworten. Anhand diverser Use Cases werden mögliche Wege mit, über und in Azure diskutiert. Was bedeuten Architekturansätze wie Cloud-Native Microservices und Serverless Microservices? Wie gehe ich bei Brownfield-Projekten vor und wie kann ich Greenfield-Lösungen effizient in Azure realisieren? Wo liegen Unterschiede und Benefits von datengetriebenen und von ereignisgetriebenen Ansätzen? Wie kann ich mit dem Sammelsurium an Patterns, Technologien und Tools in Azure kosteneffektiv hantieren und dennoch flexibel sein? All dies werden wir anhand praktischer Beispiele und pragmatischer Lösungen in interaktiver Art und Weise adressieren. Sehen Sie PaaS, Web Apps, Containers, Orchestrators, Serverless, Functions & Co. mit der Azure-Cloud anhand von .NET-Demos in Action.

Thorsten Hans

June 19, 2019
Tweet

More Decks by Thorsten Hans

Other Decks in Technology

Transcript

  1. Azure in Action: Pragmatische Cloud-Lösungen mit Containern & Serverless Christian

    Weyer @christianweyer CTO Thorsten Hans @ThorstenHans Consultant
  2. 2 § Co-Founder & CTO at Thinktecture AG § Personal

    focus on § Mobile & web-based application architectures § Pragmatic end-to-end solutions § Cloud-native & serverless architectures § Independent Microsoft Regional Director § Microsoft MVP for Visual Studio Tools & Development ASPInsider, AzureInsider § Google GDE for Web Technologies § [email protected] § @christianweyer Christian Weyer Azure in Action Pragmatische Cloud-Lösungen mit Containern & Serverless
  3. § Consultant at Thinktecture AG § Personal focus on §

    Container technologies § Cloud-native & Serverless architectures § Infrastructure-as-Code § Microsoft MVP for Visual Studio Tools & Development § [email protected] @ThorstenHans § www.thinktecture.com thorsten-hans.com thns.io/slides Thorsten Hans Azure in Action Pragmatische Cloud-Lösungen mit Containern & Serverless 3
  4. 4 Pragmatische Cloud-Lösungen mit Containern & Serverless Azure in Action

    Topics Morning Containers & Orchestrators Afternoon Serverless
  5. 5 § We can choose from a continuum § VM

    ➔ § Containers ➔ § Orchestrators ➔ § PaaS ➔ § Serverless Pragmatische Cloud-Lösungen mit Containern & Serverless Azure in Action Evolution to Cloud Compute Continuum PaaS IaaS On-Premises Serverless
  6. 8 § 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 Pragmatische Cloud-Lösungen mit Containern & Serverless Azure in Action Azure Cloud https://www.cbronline.com/news/aws-results-azure
  7. 10 How ‘large’ is ‘small’? ‘Micro’ Services Azure in Action

    Pragmatische Cloud-Lösungen mit Containern & Serverless
  8. 11 Pragmatische Cloud-Lösungen mit Containern & Serverless Azure in Action

    Bird’s-Eye-View Target Architectures HTTP API WS API Service D HTTPS HTTPS WebSocket Service A Service B Service C HTTP API
  9. 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? Pragmatische Cloud-Lösungen mit Containern & Serverless Azure in Action (Some) Principles of Microservices 12
  10. 1. Web App for Containers 2. What is Azure Kubernetes

    Service 3. Azure Kubernetes Service 101 4. Integrating AKS with Azure Services Containers & Orchestrators - Talking Points Azure in Action Pragmatische Cloud-Lösungen mit Containern & Serverless 14
  11. Containers in Azure Web App for Containers Azure in Action

    Pragmatische Cloud-Lösungen mit Containern & Serverless 15
  12. A „migration“ path for building containerized apps § Well-known App

    Service environment § App Service Plan § Scale-in / Scale-out § Continuous Integration § Support for Windows (currently in open Preview) and Linux Containers Web App for Containers Azure in Action Pragmatische Cloud-Lösungen mit Containern & Serverless 16
  13. What is AKS? Azure Kubernetes Service Azure in Action Pragmatische

    Cloud-Lösungen mit Containern & Serverless 18
  14. AKS § Managed Kubernetes cluster on Azure § AKS supports

    § Cluster auto-scaling § GPU enabled nodes § Development Tooling Integration (aka Azure DevSpaces) § Cost efficient § you pay ONLY for your worker nodes Azure Kubernetes Services Azure in Action Pragmatische Cloud-Lösungen mit Containern & Serverless 19
  15. Azure Kubernetes Services 1 Fully managed Kubernetes Master 2 Seamless

    Azure Integration 3 Simplified Cluster Operations Azure in Action Pragmatische Cloud-Lösungen mit Containern & Serverless 20
  16. Using Azure CLI # Create a resource group az group

    create --name thh-demo --location westeurope --tags @{resp="THH"} # Create a Service Principal az ad sp create-for-rbac --name thh-demo-aks-sp --skip-assignment # Will print something like { "appId": "7248f250-0000-0000-0000-dbdeb8400d85", # --> identifier ($SP_ID) "displayName": "thh-demo-aks-sp", "name": "http://thh-demo-aks-sp", "password": "77851d2c-0000-0000-0000-cb3ebc97975a", # --> client secret ($SP_PWD) "tenant": "72f988bf-0000-0000-0000-2d7cd011db47“ } Prepare a new AKS Cluster Azure in Action Pragmatische Cloud-Lösungen mit Containern & Serverless 22
  17. Using Azure CLI # Create a AKS Cluster az aks

    create --name thh-demo-aks --resource-group thh-demo --location westeurope --service-principal $SP_ID --client-secret $SP_PWD --node-count 3 --node-vm-size Standard_DS1_v2 --tags @{responsible=“Thorsten Hans"} Create a new AKS Cluster Azure in Action Pragmatische Cloud-Lösungen mit Containern & Serverless 23
  18. Using Azure CLI # Scale-Out an AKS Cluster (increase Node

    count to 5) az aks scale --name thh-demo-aks --resource-group thh-demo --node-count 5 Scale-Out an AKS Cluster Azure in Action Pragmatische Cloud-Lösungen mit Containern & Serverless 24
  19. Using Azure CLI # Scale-In an AKS Cluster (reduce Node

    count to 1) az aks scale --name thh-demo-aks --resource-group thh-demo --node-count 1 Scale-In an AKS Cluster Azure in Action Pragmatische Cloud-Lösungen mit Containern & Serverless 25
  20. Using Azure CLI # Get current k8s version az aks

    get-upgrades --name thh-demo-aks --resource-group thh-demo --output table # Name ResourceGroup MasterVersion NodePoolVersion Upgrades # ------- --------------- --------------- ----------------- -------------- # thh... thh-demo 1.10.9 1.10.9 1.10.12, 1.10.13 Get AKS Cluster Upgrades Azure in Action Pragmatische Cloud-Lösungen mit Containern & Serverless 26
  21. Using Azure CLI # Start k8s upgrade az aks upgrade

    --name thh-demo-aks --resource-group thh-demo --kubernetes-version 1.10.13 Upgrade an AKS Cluster Azure in Action Pragmatische Cloud-Lösungen mit Containern & Serverless 27
  22. Integrating AKS with Azure Services 1 Container Registry 2 Storage

    3 Container Instances 4 Key Vault 5 Analytics Azure in Action Pragmatische Cloud-Lösungen mit Containern & Serverless 29
  23. Consume private images § Pull Docker images from ACR §

    Authentication done via Service Principal § Grant Reader permissions to AKS’s underlying SP for ACR Azure Container Registry Azure in Action Pragmatische Cloud-Lösungen mit Containern & Serverless 30
  24. Using Azure CLI # Get ACR Identifier az acr show

    --name thhdemo --resource-group thh --query id # --> identifier ($ACR_ID) # Create Role Assignment for SP az role assignment create --assignee $SP_ID --role Reader --scope $ACR_ID Authenticate with ACR Azure in Action Pragmatische Cloud-Lösungen mit Containern & Serverless 31
  25. Use persistent volumes § Support for Azure Disks and Azure

    Files § Static consumption § Storage is attached to Cluster and app developer uses it (eg in a Pod) § Dynamic consumption § Cluster knows how to dynamically create Azure Disks or Azure Files Shares Azure Storage Account Azure in Action Pragmatische Cloud-Lösungen mit Containern & Serverless 32
  26. Scale cluster dynamically and support hybrid workloads § Deploy Pods

    to ACI § Execute both Windows and Linux containers § Feels like one or more native k8s node § Implemented using Virtual Kubelet Azure Container Instances Azure in Action Pragmatische Cloud-Lösungen mit Containern & Serverless 33
  27. Extend AKS using a virtual-kubelet # Start k8s upgrade az

    aks install-connector --name thh-demo-aks --resource-group thh-demo --connector-name virtual-kubelet --aci-resource-group thh-demo --service-principal $SP_ID --client-secret $SP_PWD --os-type Windows Azure Container Instances Azure in Action Pragmatische Cloud-Lösungen mit Containern & Serverless 34
  28. Keep sensitive data secured § Consume secrets, keys and certificates

    from a secured resource § Final, native integration for Key Vault and competitors not yet landed in k8s § Two different integration scenarios available § Authenticate via Client-Id and –Secret from within an application component § Use AAD to generate an Pod Identity (think of MSI) § Best solution … for NOW Azure Key Vault Azure in Action Pragmatische Cloud-Lösungen mit Containern & Serverless 35
  29. All Insights at one place § Use Application Insights to

    collect application logs § Use Log Insights to collect infrastructure logs § Seamless integration of Log Insights for AKS § Centralized experience in Azure Monitor Azure Monitor Azure in Action Pragmatische Cloud-Lösungen mit Containern & Serverless 36
  30. Enable Monitoring Add-on to stream logs to Azure Monitor #

    Enable Monitoring Add-on on AKS az aks enable-addons --name thh-demo-aks --resource-group thh-demo --addons monitoring --workspace-resource-id $WS_R_ID Azure Log Insights Azure in Action Pragmatische Cloud-Lösungen mit Containern & Serverless 37
  31. 38 § We can choose from a continuum § VM

    ➔ § Containers ➔ § Orchestrators ➔ § PaaS ➔ § Serverless Pragmatische Cloud-Lösungen mit Containern & Serverless Azure in Action Evolution to Cloud Compute Continuum PaaS IaaS On-Premises Serverless
  32. 39 A different approach to Microservices Serverless Azure in Action

    Pragmatische Cloud-Lösungen mit Containern & Serverless
  33. 40 § 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; can be replaced easier § Functions as the mental model § Basic idea: make things easier, get productive with business, not infrastructure Pragmatische Cloud-Lösungen mit Containern & Serverless Azure in Action Microservices – or rather: Nanoservices
  34. Pragmatische Cloud-Lösungen mit Containern & Serverless Azure in Action 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… 42
  35. 43 Pragmatische Cloud-Lösungen mit Containern & Serverless Azure in Action

    Serverless Sweet Spot Programming Model (FaaS) § Event-driven § Stateless § Service-full Operational Model § Fully managed § Automatically scaling § Usage priced
  36. 45 § 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 Pragmatische Cloud-Lösungen mit Containern & Serverless Azure in Action Serverless in Azure (my personal choice)
  37. 46 Pragmatische Cloud-Lösungen mit Containern & Serverless Azure in Action

    There are NO servers! https://twitter.com/jeffhollan/status/1030244102082682880
  38. Pragmatische Cloud-Lösungen mit Containern & Serverless Azure in Action 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 47
  39. 48 Azure Storage & Cosmos DB Serverless Data Azure in

    Action Pragmatische Cloud-Lösungen mit Containern & Serverless
  40. 49 § 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 Pragmatische Cloud-Lösungen mit Containern & Serverless Azure in Action Azure Storage
  41. Pragmatische Cloud-Lösungen mit Containern & Serverless Azure in Action 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 50
  42. 51 § 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 Azure in Action Cosmos DB: A NoSQL Database with Many Faces Pragmatische Cloud-Lösungen mit Containern & Serverless
  43. Pragmatische Cloud-Lösungen mit Containern & Serverless Azure in Action 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 52
  44. 53 § Building event-driven architectures with Cosmos DB § Listening

    to Azure Cosmos DB collection for any changes § Inserts, updates, soft-deletes § Subscribe to collection changes Azure in Action Cosmos DB Change Feed Pragmatische Cloud-Lösungen mit Containern & Serverless
  45. 55 § 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 Azure in Action Azure Functions: Functions-as-a-Service Pragmatische Cloud-Lösungen mit Containern & Serverless
  46. Pragmatische Cloud-Lösungen mit Containern & Serverless Azure in Action 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 56
  47. 57 § Cold vs. warm start Pragmatische Cloud-Lösungen mit Containern

    & Serverless Azure in Action Azure Functions: Activation & Scaling in Consumption Plan https://blogs.msdn.microsoft.com/appserviceteam/2018/02/07/understanding-serverless-cold-start/
  48. 58 § Incoming event triggers function § Input bindings enable

    easy access to data from various data sources § Output bindings offer easy access to outbound data sinks Azure in Action Triggers & Bindings Pragmatische Cloud-Lösungen mit Containern & Serverless Your code logic Runtime Azure Function HTTP Trigger Storage Input Binding Push Notification Output Binding Database Output Binding Email Output Binding Example
  49. 59 Azure in Action Triggers & Bindings in Code Pragmatische

    Cloud-Lösungen mit Containern & Serverless
  50. 60 Azure in Action Pragmatische Cloud-Lösungen mit Containern & Serverless

    https://docs.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings Triggers & Bindings
  51. 62 § 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 Pragmatische Cloud-Lösungen mit Containern & Serverless Azure in Action Communication is key to Cloud Architectures
  52. 63 § 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 Azure in Action Reactive Programming: Event Grid Pragmatische Cloud-Lösungen mit Containern & Serverless
  53. 64 § Queues & Topics § Reliable asynchronous communication §

    Rich features for temporal control § Routing and filtering § Transactions § Convoys & Sessions (related messages with state) Pragmatische Cloud-Lösungen mit Containern & Serverless Azure in Action Service Bus: Messaging-as-a-Service
  54. 65 Sender § Sender sends message to queue § Queue

    ACKs receipt § Receiver connects to queue & retrieves message § Receiver ACKs complete (or other action) Service Bus Queues Azure in Action Pragmatische Cloud-Lösungen mit Containern & Serverless Receiver
  55. Pragmatische Cloud-Lösungen mit Containern & Serverless Azure in Action 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 66
  56. 67 § Sender only knows about Topic § Receivers only

    know about Subscriptions § Filters and Actions exist on Subscriptions Pragmatische Cloud-Lösungen mit Containern & Serverless Azure in Action Service Bus Topics & Subscriptions Type == ‘order‘ Sender type=order type=quote Topic Type == ‘quote‘ Filter Filter Subscrip- tion 1 Subscrip- tion 2
  57. 69 § 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 Pragmatische Cloud-Lösungen mit Containern & Serverless Azure in Action Azure SignalR Service
  58. Pragmatische Cloud-Lösungen mit Containern & Serverless Azure in Action 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 70
  59. Azure Functions Extensibility Custom Bindings & Triggers Azure in Action

    Pragmatische Cloud-Lösungen mit Containern & Serverless 71
  60. 72 § 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) Pragmatische Cloud-Lösungen mit Containern & Serverless Azure in Action Azure Functions Custom Bindings & Triggers
  61. 73 § 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 Pragmatische Cloud-Lösungen mit Containern & Serverless Azure in Action Custom Bindings
  62. 74 § 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 Pragmatische Cloud-Lösungen mit Containern & Serverless Azure in Action Custom Triggers
  63. 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 Pragmatische Cloud-Lösungen mit Containern & Serverless Azure in Action (Some) Principles of Microservices – with Serverless Azure 76
  64. 77 § Greenfield projects (but consider cold starts) § Integration

    use cases - the glue § Dissecting a monolith - isolate business functionality Pragmatische Cloud-Lösungen mit Containern & Serverless Azure in Action When to use Serverless Azure
  65. 79 § Container technologies provide § a soft migration path

    to the cloud § a unified deployment model § AKS integrates perfectly with Azure Services § AKS scales dynamically depending on your needs § Serverless is just one option in the Cloud Continuum § Always think about the use cases and requirements § Serverless will be pre-dominant on the ‘server’ in a couple of years § Azure Functions is way more than just a Web API framework Summary Azure in Action Pragmatische Cloud-Lösungen mit Containern & Serverless
  66. Azure in Action: Pragmatische Cloud-Lösungen mit Containern & Serverless Christian

    Weyer @christianweyer [email protected] Thorsten Hans @ThorstenHans [email protected] https://github.com/thorstenhans/aks-demo-app https://github.com/thinktecture/serverless-microservices https://github.com/thinktecture/azure-functions-extensibility