Azure Function

Overview

  • A serverless offering on Azure to run event driven functions

  • Serverless means:

    • Consumption based

    • Never worrying about servers

    • Scales automatically out of the box

Hosting Plans

Plan
Description
Use case

Consumption

  • Default and pay for what is being used

  • Max timeout is 10 mins per function

  • No Vnet Integration

  • Prone to cold starts

Don't need features of other plans

Premium plan

  • Predictable pricing

  • No timeout

  • Vnet integration

  • Prewarmed

  • Short but frequent executions

  • Access to vnet resources

Dedicated

  • Runs it in an App Service Plan

  • No cold start issues

  • No timeouts

  • Underutilized App Service Plan

  • Azure function in its own vnet

Triggers and Binding

  • Trigger: What triggers the function. Only 1 per function is possible

  • Binding: inputs and outputs of functions

Consideration
Blob Storage (standard)
Blob Storage (event-based)
Queue Storage
Event Grid

Latency

High (up to 10 min)

Low

Medium

Low

Storage account limitations

Blob-only accounts not supported

general purpose v1 not supported

none

general purpose v1 not supported

Extension version

Any

Storage v5.x+

Any

Any

Processes existing blobs

Yes

No

No

No

Filters

Blob name pattern

Event filters

n/a

Event filters

Requires event subscription

No

Yes

No

Yes

Supports high-scale

No

Yes

Yes

Yes

Description

Default trigger behavior, which relies on polling the container for updates.

Consumes blob storage events from an event subscription. Requires a Source parameter value of EventGrid. For more information, see Tutorial: Trigger Azure Functions on blob containers using an event subscription: https://learn.microsoft.com/en-us/azure/azure-functions/functions-event-grid-blob-trigger?pivots=programming-language-csharp

Blob name string is manually added to a storage queue when a blob is added to the container. This value is passed directly by a Queue Storage trigger to a Blob Storage input binding on the same function.

Provides the flexibility of triggering on events besides those coming from a storage container. Use when need to also have non-storage events trigger your function. For more information, see How to work with Event Grid triggers and bindings in Azure Functions: https://learn.microsoft.com/en-us/azure/azure-functions/event-grid-how-tos?tabs=v2%2Cportal

Configuration Files

  • host.json: global configuration applied to all azure functions

  • function.json under each function folder: define binding and trigger

Azure Durable Function

  • a library (not a feature) that allows you to develop stateful function. Behind the scenes, state is managed for you

Use cases

  1. Function Chaining: Using output of one function as input of another one

  2. Fan out/fan in: Functions are executed in parallel, and their aggregation is used in a single function

Components in Azure Durable Function

  • Orchestrator Function

  • Activity Function

  • Starter Function

Custom Handlers

  • A way to run Azure Functions using unsupported languages by offloading the work to an external web server

Reference:

  • Azure Blob storage trigger for Azure Functions: https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob-trigger?tabs=python-v2%2Cin-process&pivots=programming-language-csharp#event-grid-trigger

  • Azure Functions Custom Handlers: https://learn.microsoft.com/en-us/azure/azure-functions/functions-custom-handlers

  • Azure Web PubSub trigger and bindings for Azure Functions: https://learn.microsoft.com/en-us/azure/azure-web-pubsub/reference-functions-bindings?tabs=javascript#trigger-binding

  • Azure Functions on Kubernetes with KEDA: https://learn.microsoft.com/en-us/azure/azure-functions/functions-kubernetes-keda

Last updated