liveBook · Manning

Azure Functions

As explained in Microsoft Azure in Action

Azure Functions is an Azure serverless compute service that runs event-driven code without requiring management of the underlying servers.

An email attachment lands in Blob Storage. A small piece of code resizes the image, saves a web-friendly copy, and stops. Azure Functions runs that kind of single-purpose, event-driven work without requiring you to manage the underlying servers. A trigger starts each function; Azure allocates compute when it runs. “Serverless” still involves servers—they’re simply someone else’s responsibility. section 2.2 section 2.2.14 section 8.6

Functions live inside a Function App, which provides their hosting and management environment. One app can hold multiple functions. Each function has exactly one trigger, such as an HTTP request, a new blob, or a queue message. Bindings connect it to other Azure resources, sparing the code some resource-handling work. section 2.2.14 section 8.6

Resize an uploaded photo

When a new image arrives in Blob Storage, a blob trigger passes it to a function. Configure a Blob Storage output binding to save the resized copy in a separate container, preserving the original. The example uses C# streams for the input and output and the ImageSharp library to resize the image to 100 × 100 pixels. That fixed size may distort it: a useful first working version, not a portrait photographer. section 2.2 section 2.2.19 section 2.2.20

Choose hosting to fit the workload, not just the word “serverless”:

  • Consumption scales to zero and charges for usage, suiting sporadic work; an idle function may experience a cold start. section 8.2.3
  • Premium keeps instances warm for faster starts and supports longer runs and virtual network integration, but reserved capacity costs money even when idle. section 8.2.3
  • Flex Consumption offers more control over memory, scaling, and networking; Dedicated uses an App Service plan, while Container Apps supports container-based workloads. section 8.2.3
Table 8.3 Azure Function pricing for various hosting options

Hosting option

Key features and use cases

Cost model

Consumption

Cost effective, scales to zero; suitable for infrequent or bursty workloads

Per execution and resource consumption (first 1 million executions/month free)

Premium

Fast, warm instances; long execution and virtual network (VNet) access; higher cost

Per vCPU-second and gigabyte-second of allocated instances (always running)

Flex Consumption

Serverless with more control—memory, scaling, VNet, reduced cold starts

Per execution and allocated memory; charges for always-ready instances if used

Dedicated

Predictable pricing; use existing Azure App Service infrastructure

Fixed monthly price for chosen App Service plan tier

Container Apps

Full container flexibility within serverless microservices ecosystem

Per active vCPU-second and memory-­second; scale to zero when idle

Compare the five hosting options by use case and charging model before selecting a plan. section 8.2.3

To get started, create a Function App with the Azure portal or Azure CLI, then create a function with a trigger. The CLI setup needs a storage account; keeping it in the same region as the app reduces travel time for data. VS Code supports local development before publishing. For an HTTP trigger, choose its authorization level deliberately: anonymous accepts requests without a key. Azure can add function instances as work increases, but scaling does not replace a sensible choice of hosting plan. section 8.2 section 2.3.1 section 8.2.3

How Microsoft Azure in Action covers it

How deep it goes
Works through triggers, bindings, app creation, and hosting choices, but does not teach the image-processing code in full.
Examples
Uses a blob-triggered image resizer, an HTTP-triggered function, and a Cosmos DB inventory-update scenario.
What it assumes
Defines serverless and Function Apps from the ground up; does not require prior C# knowledge for the initial walkthrough.
What you can do after
Build it from scratch with Azure CLI or VS Code, configuring a trigger and bindings while choosing a hosting plan.
How it connects
Connects serverless computing with Function Apps, triggers, bindings, Blob Storage, Logic Apps, and Azure Cosmos DB.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microsoft Azure in Action. The section links point to the parts of the book it draws on.