Slide 1

Slide 1 text

Advanced Azure Functions – beyond HTTP GET /helloworld Christian Weyer @christianweyer CTO

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

Azure Functions v2 Recap Beyond HTTP GET /helloworld Advanced Azure Functions 4

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

Azure, Cloud, On-prem Hosting Beyond HTTP GET /helloworld Advanced Azure Functions 8

Slide 9

Slide 9 text

9 § Consumption Plan § App Service Plan § Premium Plan § Docker § Kubernetes with KEDA (preview) Advanced Azure Functions Beyond HTTP GET /helloworld Hosting Options

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

HTTP Triggers Securing Functions Beyond HTTP GET /helloworld Advanced Azure Functions 14

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

Extensibility Custom Bindings & Triggers Beyond HTTP GET /helloworld Advanced Azure Functions 18

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

Let’s try something… Beyond HTTP GET /helloworld Advanced Azure Functions 22

Slide 23

Slide 23 text

Let’s try something… Running ASP.NET Core applications in Azure Functions Beyond HTTP GET /helloworld Advanced Azure Functions 23 Experimental!

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

Chris&an Weyer, Thinktecture AG @chris&anweyer chris&[email protected] h:ps://github.com/thinktecture/dotnet-day-ch-2019-azure-func&ons Visit h:ps://blog.wille-zone.de/ for advanced topics.