Azure Functions 2.0 - serverless architecture with real world example

Azure Functions 2.0 - serverless architecture with real world example

1. What is serverless?
2. Why it matters?
3. What is Azure Functions?
4. Features
5. Triggers & Bindings
6. Development
7. Business case
8. CI Setup
9. Monitoring
10. Costs

B30c151ccb4d043a2028691515db4130?s=128

Robert Witkowski

November 30, 2018
Tweet

Transcript

  1. Serverless architecture with real world example Wojciech Suwała, Head Architect,

    ASC LAB Robert Witkowski, Senior Software Engineer, ASC LAB Azure Functions 2.0
  2. 2 What is serverless?

  3. 3 Some definitions The most common definition is that it

    allows you to set up a piece of code to be executed as a reaction to an event. Gojko Adzic There are ideas to stop talking about serverless and start talking about servicefull, then there’s also a half-serious proposal to rename the whole thing to Jeff. Paul Johnston https://serverless.zone/serverless-is-just-a-name-we-could-have-called-it-jeff-1958dd4c63d7
  4. 4 Why it matters? • Financial incentives – You get

    financial benefits for good design and you get financial penalty for bad design • Promotes better engineering practices • You can focus on writing modular apps, made of really small autonomous components without worrying about: deployment, scaling, monitoring etc.
  5. 5 What is Azure Functions? Code Events + data

  6. 1) Trigger 7) Develop locally 3) Develop 4) Execute 6)

    Monitor and improve 2) Input binding 5) Output binding Azure Services Consumption Plan Azure Services Web Hooks Azure Services
  7. Features • Choice of language - Write functions using C#,

    F#, JavaScript (Node 8 & 10), Java 8 • Pay-per-use pricing model - Pay only for the time spent running your code. See the Consumption hosting plan option in the pricing section. • Bring your own dependencies - Functions supports NuGet and NPM, so you can use your favorite libraries. • Integrated security - Protect HTTP-triggered functions with OAuth providers such as Azure Active Directory, Facebook, Google, Twitter, and Microsoft Account. • Simplified integration - Easily leverage Azure services and software-as-a- service (SaaS) offerings: SendGrid, Twilio • Flexible development - Code your functions right in the portal or set up continuous integration and deploy your code through GitHub, local Git and other supported development tools. • Open-source - The Functions runtime is open-source and available on GitHub. https://docs.microsoft.com/en-gb/azure/azure-functions/functions-overview
  8. 8 Triggers and bindings https://docs.microsoft.com/en-gb/azure/azure-functions/functions-triggers-bindings

  9. 9 Cost • Consumption plan - When your function runs,

    Azure provides all of the necessary computational resources. You don't have to worry about resource management, and you only pay for the time that your code runs. • App Service plan - Run your functions just like your web, mobile, and API apps. When you are already using App Service for your other applications, you can run your functions on the same plan at no additional cost.
  10. 10 Cost – Consumption plan • In consumption plan we

    pay for gigabyte seconds (GB-s) resources that are actually used • Functions pricing includes a monthly free grant of 400,000 GB-s • Time limit max. 10 minutes (default set to 5 minutes) • Max 1,5GB RAM is allocated per function instance • Autoscaling provided out of the box by Azure Runtime: different heuristics for different triggers (for example Queue trigger heuristic is based on queue length and oldest message date). Scales up and down automatically.
  11. 11 Autoscaling example

  12. 12 Autoscaling example

  13. Future • Python private preview • Premium Functions private preview

    – VNet connectivity – Always on cores (so you don’t hit cold start) – Unlimited execution duration – Same rapid scale out and scale in of consumption – REQUIREMENT: Pay for 1 core 24/7
  14. 18 Development

  15. 19 Install Azure development tools for Visual Studio

  16. 20 Create a project

  17. 21 Create a function

  18. 22 Add dependencies - use NuGet Package Manager

  19. 23 Run locally - just hit F5

  20. 24 Deploy to Azure

  21. 25 Deploy to Azure

  22. 26 Deployment • Manual from Visual Studio • Or using

    Azure CLI https://docs.microsoft.com/en-us/azure/azure-functions/functions-create- first-azure-function-azure-cli
  23. 27 Security • Function Keys (API-Keys) • Azure Active Directory

    support with support for integration with various OAuth providers • In HTTP triggered functions we have access to HTTP request so all kinds of HTTP Auth can be implemented – for example JWT token validation
  24. Use case

  25. 29 CI Setup with Azure DevOps - pipeline definition

  26. 30 CI Setup with Azure DevOps - monitoring

  27. 31 CI Setup with Azure DevOps - monitoring in GitHub

  28. Monitoring

  29. Monitoring

  30. Monitoring

  31. Use case - cost NAME AVG Time GenerateBillingItemsFunc 5,61s GenerateInvoiceFunc

    3,27s PrintInvoiceFunc 3s NotifyInvoiceFunc 2s
  32. Use case - cost

  33. 37 What’s not covered • Durable functions • CD config

    • Function proxies • Azure Functions vs AWS Lambdas vs Google Cloud Functions
  34. https://github.com/asc-lab/ azure-functions-billing https://asc.altkom.pl/en/blog/ azure-functions

  35. 39 asc.altkom.pl github.com/asc-lab @AltkomSC asc-lab@altkom.pl