Skip to content

Latest commit

 

History

History
102 lines (95 loc) · 5.17 KB

4.5. Serverless Computing (Azure Functions & Logic Apps).md

File metadata and controls

102 lines (95 loc) · 5.17 KB

Serverless computing

  • Abstraction of servers, infrastructure, and operating systems.
  • Main flow: An event triggers code, code gets data, and gives output
  • Activity based billing: Only pay when you use resources
    • Billing is based just on resources consumed or the actual time your code is running.
  • Serverless applications in Azure:

Azure Functions

  • FaaS: Functions as a Service
  • Built on top of WebJobs SDK.
  • No idle capacity charges.
  • Execute event-driven code with any programming language.
  • Can run locally or in the cloud
    • Azure Functions Runtime is free & open-source.
    • Local development requires bindings.
      • Bindings are a way to provide input and output to the function.
      • A function can have multiple input and output bindings.
      • They're defined in a Json file can have different parameters (queueName, tableName) etc. depending on bound target.
  • Auto-scaling
    • Scale controller monitors the rate of events and uses heuristics to scales out/in.
    • ❗ A single function app will only scale to a maximum of 200 instances.
      • A single instance may process more than message/request at a time though.
  • Pricing
    • Consumption Plan
      • Scale out automatically.
      • Billing is based on number of executions, execution time, and memory used.
    • App Service Plan
      • Linux only, you pay for the IaaS.
      • Provides cost predictability and warm start.
  • By default, a function will timeout after 5 minutes, and a function can run for a maximum of 10 minutes.
  • Triggers
    • Can be triggered by Event Hubs, storages, devices from IoT hub, custom sources etc.
    • Or with a scheduled by e.g. webhook, API, data processing.
      • Timer is scheduled with CRON expression
  • Bring your own dependencies
    • Supports NuGet, NPM etc., allowing use of preferred libraries.
  • Integrated security
    • HTTP-triggered functions can be protected with OAuth providers (AAD, google etc.)
  • Code directly in portal or use deployments from GitHub, Visual Studio, etc.

Best practices

  • Avoid long running functions
  • Use cross function communication
  • Prefer stateless functions
  • Defensive functions: An exception can happen whenever possible
  • For scalability:
    • Share & manage connections
    • Don't mix test and production code in the same function app
    • Use async code but avoid blocking calls
    • Receive messages in batch whenever possible
    • Configure host behavior to better handle concurrency (max outstanding requests, max concurrent requests etc).

Logic Apps

  • Cloud & serverless only to orchestrate workflows.
    • Connects serverless functions and APIs.
  • Can be integrated with on-prem connectors.
  • Integrates data with apps.
  • You can manage & manipulate data.
  • Many built-in triggers
    • You can have polling triggers, push triggers or recurrence (time-based) triggers.
    • Other built-in triggers include: • HTTP • Request • Azure Functions • Batch • other Azure Logic apps
    • Can be extended.
    • Can be triggered time-based (recurrence scheduling)
  • 200+ built-in connectors
    • Managed connectors: • Azure Service Bus • SQL Server • Microsoft Outlook • Azure Blob Storage • SFTP • SharePoint Online • Dynamics 365 CRM Online • FTP • Salesforce • Twitter • Azure Event Hubs • Azure Event Grid, ...
    • On-prem connectors: • BizTalk Server • File System • IBM DB2 • IBM Informix • MySQL • Oracle DB • PostgreSQL • SharePoint Server • SQL Server • Teradata
    • For additional cost: • Enterprise Connectors (SAP, IBM MQ..)• Integrations account connectors (B2B messages via special protocols, XML handling)
    • Each connector has specific actions
      • E.g. twitter has: • Post a tweet • Get followers • Get following
  • Built logic with
    • Error handlers
    • Conditionals: for each, condition (if), scope, switch, terminate, until.
    • Manage variables with expressions (such as div, concat etc)
      • Data operations: compose, create html/csv, filter array, join, parse json, select
      • Date Time: add to time, convert time zone, current time, get future time, get past time, subtract from time
      • Variables: append to array, append to string, decrement, increment, initialize, set