Advanced Azure Functions – beyond HTTP GET /helloworld

Advanced Azure Functions – beyond HTTP GET /helloworld

Azure Functions enable to swiftly create serverless applications & services. But in pratice, we soon face situations where the simple Hello-World-ish approaches do no longer suffice. In this talk, Christian Weyer shows you how to use Microsoft's Functions-as-a-Service (FaaS) platform to realize scenarios beyond the usual static triggers & bindings, like HTTP. He illustrates how you can secure your functions, create your own custom extensions, use dynamic bindings to implement tricky use cases. Hosting Azure Functions is also discussed because it is not always possible to use the public Cloud as is. Come and see Azure Functions with C # in action - beyond Hello World.

7e0087a19318ded4ba2203187694740f?s=128

Christian Weyer

May 28, 2019
Tweet

Transcript

  1. Advanced Azure Functions – beyond HTTP GET /helloworld Christian Weyer

    @christianweyer CTO
  2. 2 § 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 § Microsoft Regional Director (since 2003) § Microsoft MVP (since 2002) § Google GDE for Web Technologies (since 2015) christian.weyer@thinktecture.com @christianweyer https://www.thinktecture.com Christian Weyer Beyond HTTP GET /helloworld Advanced Azure Functions
  3. 3 § Azure Functions v2 Recap § Hosting Options §

    Securing Functions § Custom Bindings & Triggers § Let’s try something… Advanced Azure Functions Beyond HTTP GET /helloworld Our Journey Today
  4. Azure Functions v2 Recap Beyond HTTP GET /helloworld Advanced Azure

    Functions 4
  5. 5 Serverless? Programming Model (FaaS) § Event-driven § Stateless §

    Service-full Operational Model § Fully managed § Automatically scaling § Usage priced Beyond HTTP GET /helloworld Advanced Azure Functions
  6. 6 § Azure Functions: code being triggered by an event

    § Use Façade pattern for your business logic/services § Basic principles enable common/repetitive use cases § Events ➔ Triggers & Bindings § V2 Runtime built on .NET Core § Local tooling & runtime § Multiple language bindings supported § C# ▪ Powershell (experimental) § JS, TS ▪ Python (experimental) § F# § Java Advanced Azure Functions Beyond HTTP GET /helloworld Azure Functions: Functions-as-a-Service
  7. 7 § Incoming event triggers function § Input bindings §

    easy access to data from various data sources § Output bindings § easy access to outbound data sinks § Microsoft-offered bindings § https://docs.microsoft.com/en-us/ azure/azure-functions/functions- triggers-bindings #supported-bindings Advanced Azure Functions Beyond HTTP GET /helloworld Functions Triggers & Bindings Your code logic Runtime Azure Function HTTP Trigger Storage Input Binding Push Notification Output Binding Database Output Binding Email Output Binding Example
  8. Azure, Cloud, On-prem Hosting Beyond HTTP GET /helloworld Advanced Azure

    Functions 8
  9. 9 § Consumption Plan § App Service Plan § Premium

    Plan § Docker § Kubernetes with KEDA (preview) Advanced Azure Functions Beyond HTTP GET /helloworld Hosting Options
  10. 10 § Pay-per-use § Free quotas available § For Windows

    § Linux in preview § Automatic scaling based on triggers § Limitations § Max. Function execution duration limited to 10 mins (5 mins by default) § Function App may scale down to 0 instances ➔ cold start § Limited to 1.5 GB RAM and 1 CPU core per Function App Advanced Azure Functions Beyond HTTP GET /helloworld Hosting in Azure - Consumption Plan
  11. 11 § No Function execution duration limits (but 30 mins

    by default) § No cold start, always warm § Limits the RAM and CPU cores based on App Service Plan configuration § Fixed price, paying for idle time § Manual scaling (or semi-automatic with App Service Plan features for scaling) § Not Serverless, IMHO Advanced Azure Functions Beyond HTTP GET /helloworld Hosting in Azure - App Service Plan
  12. 12 § No Function execution duration limits (but 30 mins

    by default) § No cold start, always pre-warmed instances available § VNet integration § Three sizes with different limits for RAM and CPU cores § Rapid scaling § Minimum fixed price + pay-per-use § Not Serverless, IMHO § Currently in preview Advanced Azure Functions Beyond HTTP GET /helloworld Hosting in Azure - Premium Plan
  13. 13 § Only Linux supported § No limits, literally §

    On-premises hosting possible § It is Docker, after all § Dockerfile can be created with CLI tools § Most flexible hosting option ➔ But most Serverless-less hosting Advanced Azure Functions Beyond HTTP GET /helloworld Hosting anywhere - Docker
  14. HTTP Triggers Securing Functions Beyond HTTP GET /helloworld Advanced Azure

    Functions 14
  15. 15 § Must be passed to Function § Query string

    (code) § HTTP Header (x-functions-key) § Can be generated on Function level § Portal § Key Management API (via HTTP) § Master key to access all Functions § Not meant for humans, rather for machine-to-machine § Static keys without information about the caller (or even user) § Only for Azure-hosted Functions Advanced Azure Functions Beyond HTTP GET /helloworld Securing HTTP Functions – Function Keys
  16. 16 § Configurable in Portal § Uses federated identity §

    Azure AD, Microsoft Account, Facebook, Twitter, Google § No custom IDP, officially § Bearer token § Human interaction and machine-to-machine § Contains information about the caller § Only for Azure-hosted Functions Advanced Azure Functions Beyond HTTP GET /helloworld Securing HTTP Functions – EasyAuth
  17. 17 § (ASP.NET Core) Middleware not yet available in Functions

    § Could validate authentication information in Function § But all the bindings used via attributes already ran at that time § Can use dynamic bindings at runtime through IBinder § Execute the dynamic binding after successful authorization check § Yeah… not nice … Advanced Azure Functions Beyond HTTP GET /helloworld Securing HTTP Functions – In Function with Dynamic Binding
  18. Extensibility Custom Bindings & Triggers Beyond HTTP GET /helloworld Advanced

    Azure Functions 18
  19. 19 § 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) Advanced Azure Functions Beyond HTTP GET /helloworld Azure Functions Custom Bindings & Triggers
  20. 20 § 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 Advanced Azure Functions Beyond HTTP GET /helloworld Custom Bindings
  21. 21 § 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 Advanced Azure Functions Beyond HTTP GET /helloworld Custom Triggers
  22. Let’s try something… Beyond HTTP GET /helloworld Advanced Azure Functions

    22
  23. Let’s try something… Running ASP.NET Core applications in Azure Functions

    Beyond HTTP GET /helloworld Advanced Azure Functions 23 Experimental!
  24. 24 Gentle reminder: there are NO servers! https://twitter.com/jeffhollan/status/1030244102082682880 Beyond HTTP

    GET /helloworld Advanced Azure Functions
  25. Chris&an Weyer, Thinktecture AG @chris&anweyer chris&an.weyer@thinktecture.com h:ps://github.com/thinktecture/dotnet-day-ch-2019-azure-func&ons Visit h:ps://blog.wille-zone.de/ for

    advanced topics.