liveBook · Manning

Function

As explained in Microsoft Azure in Action

An Azure function is a deployable unit of event-driven code that executes in response to a trigger.

An Azure function is a deployable unit of event-driven code. A trigger tells it when to run, and every function has exactly one trigger. An HTTP trigger responds to a web request; a Blob Storage trigger responds when a blob is created or updated. section 8.2.1

Bindings connect the function to other resources through input and output parameters. In a practical image-preview workflow, the function reads an NFT image from Blob Storage, resizes it, writes a smaller copy to another container, and returns it to the API caller. section 8.2.2

Resize an image with HTTP and Blob bindings

A C# function named ProcessNFT accepts GET and POST requests at an nft/{nftid} route. Its bindings read originalnfts/{nftid} and write copynfts/{nftid}; the function resizes the image to 320×200 and saves the result. The project adds SixLabors.ImageSharp 2.1.3, and the local function can be called with /api/nft/nft-1-2022.png before deployment to Azure from VS Code. section 8.2.2

public static async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", 
Route = null)] HttpRequest req,
            ILogger log)

Use the trigger signature to see how authorization, HTTP methods, request data, and logging enter a function. section 8.2.1

How Microsoft Azure in Action covers it

How deep it goes
Explains triggers and bindings through a worked image-processing function, while deferring additional trigger types.
Examples
Uses an HTTP-triggered ProcessNFT function that resizes an NFT image from one Blob Storage container into another.
What it assumes
Assumes a C# project and basic method and decorator syntax while defining triggers and bindings explicitly.
What you can do after
Builds a C# function that accepts HTTP requests, reads and writes Blob Storage streams, resizes images, and deploys from VS Code.
How it connects
Connects functions with triggers, bindings, HTTP requests, Blob Storage, serverless computing, and image processing.

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.