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

.NET Day 19 - Advanced Azure Functions - beyond HTTP GET helloworld by Christian Weyer

.NET Day 19 - Advanced Azure Functions - beyond HTTP GET helloworld by Christian Weyer

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 or 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.

dotnetday

May 28, 2019
Tweet

More Decks by dotnetday

Other Decks in Technology

Transcript

  1. 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) [email protected] @christianweyer https://www.thinktecture.com Christian Weyer Beyond HTTP GET /helloworld Advanced Azure Functions
  2. 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
  3. 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
  4. 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
  5. 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
  6. 9 § Consumption Plan § App Service Plan § Premium

    Plan § Docker § Kubernetes with KEDA (preview) Advanced Azure Functions Beyond HTTP GET /helloworld Hosting Options
  7. 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
  8. 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
  9. 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
  10. 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
  11. 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
  12. 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
  13. 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
  14. 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
  15. 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
  16. 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
  17. Let’s try something… Running ASP.NET Core applications in Azure Functions

    Beyond HTTP GET /helloworld Advanced Azure Functions 23 Experimental!