Skip to content

Latest commit

 

History

History
72 lines (56 loc) · 3.9 KB

3.1.4. Serverless Computing.md

File metadata and controls

72 lines (56 loc) · 3.9 KB

Serverless Computing

Serverless concepts

Abstraction of servers

  • Completely abstracts the underlying hosting environment.
  • No infrastructure configuration / maintenance.
    • Basically deploy your code and it runs with high availability.
  • Automatically scaling, performance and allocation/deallocation of resources
    • You never explicitly reserve capacity.

Event-driven scale

  • Good fit for workloads that respond to incoming events.
  • Events include triggers by e.g.
    • timers e.g. if a function needs to run every day at 10:00 AM UTC
    • HTTP e.g. API and webhook scenarios
    • queues e.g. with order processing)
  • Triggers & bindings
    • A function contains both code and metadata about its triggers and bindings.
    • Triggers define how a function is invoked
    • Bindings provide a declarative way to connect to services from within the code.
  • The platform automatically schedules the function to run and scales the number of compute instances based on the rate of incoming events.

Micro-billing

  • Pay only for the time the code runs.
  • No active function executions occur = they're not charged.
  • E.g. if the code runs once a day for two minutes, they're charged for one execution and two minutes of computing time.

Azure Functions

  • Can execute code in almost any modern language.
  • Commonly used when you need to perform work in response to an event.
  • Can be either
    • Stateless (the default)
      • Behave as if restarted every time responding to an event
    • Stateful (called "Durable Functions")
      • Has a context to track prior activity.
  • Open-source, can deploy anywhere. See Azure functions host

Azure Logic Apps

  • Execute workflows designed to automate business scenarios and built from predefined logic blocks.
  • Every logic app workflow starts with a trigger (many can be scheduled) and runs actions
    • Actions include data conversions and flow controls (e.g. conditional / switch statements, loops, and branching)
  • You create using a visual designer on the Azure portal or in Visual Studio.
    • The workflows are persisted as a JSON file with a known workflow schema.
  • Azure provides over 200 different connectors and processing blocks to interact with different services
    • You can also build custom connectors to interact.
  • Often no code is written.
  • E.g. a ticket arrives in ZenDesk, you could detect the intent of the message with cognitive services and then create an item in SharePoint to track the issue.

Functions vs. Logic Apps

Functions and Logic Apps can both create complex orchestrations. An orchestration is a collection of functions or steps, that are executed to accomplish a complex task. With Azure Functions, you write code to complete each step, with Logic Apps, you use a GUI to define the actions and how they relate to one another.

You can mix and match services when you build an orchestration, calling functions from logic apps and calling logic apps from functions. Here are some common differences between the two.

Functions Logic Apps
State Normally stateless, but Durable Functions provide state Stateful
Development Code-first (imperative) Designer-first (declarative)
Connectivity Write code for custom bindings from many binding types Large collection of connectors, Enterprise Integration Pack for B2B scenarios, build custom connectors
Actions Each activity is an Azure function; write code for activity functions Large collection of ready-made actions
Monitoring Azure Application Insights Azure portal, Log Analytics
Management REST API, Visual Studio Azure portal, REST API, PowerShell, Visual Studio
Execution context Can run locally or in the cloud Runs only in the cloud.