Microsoft Docs

Azure Functions

Core Concepts

Azure Functions is a serverless compute service that enables you to run code on-demand without explicitly provisioning or managing infrastructure. With Azure Functions, you can build applications by using single pieces of code that are triggered by various events. This document explains the core concepts behind Azure Functions.

Event-Driven Serverless Computing

Azure Functions is built around the concept of event-driven architecture. This means that your code runs in response to an event. These events can come from a variety of sources, including:

This event-driven model allows you to build highly scalable and cost-effective applications, as you only pay for the compute time your code consumes when it's actually running.

Functions

A Function is the fundamental unit of work in Azure Functions. It's a piece of code that performs a specific task and is triggered by a defined event. Functions can be written in various programming languages, including C#, F#, Java, JavaScript, PowerShell, and Python.

Each function typically consists of:

Triggers

Triggers are Azure resources that function apps use to find the event that triggers the execution of a function. Every function must have exactly one trigger. Triggers define how a function is invoked. Common triggers include:

Bindings

Bindings provide a declarative way to manage the integration between your function and other Azure services or data sources. With bindings, you can easily connect to services like Azure Cosmos DB, Azure Storage, Azure Service Bus, and more, without writing extensive boilerplate code for connection management, serialization, and deserialization.

Bindings are categorized into:

For example, a function could be triggered by an HTTP request and use an input binding to read data from a Cosmos DB document, then use an output binding to write a result to a Service Bus queue.

Function App

A Function App is the logical grouping of individual functions that share the same lifecycle, deployment, and hosting plan. A function app provides an execution context for your functions. It can be hosted on various plans, including the Consumption plan (pay-per-execution), Premium plan (enhanced performance and features), and App Service plan (dedicated resources).

Hosting Plans

Developer Experience

Azure Functions supports a rich developer experience across multiple languages and tools:

Important Note:

Understanding the interplay between triggers and bindings is crucial for designing efficient and robust serverless applications with Azure Functions.

Developer Tip:

Consider using input and output bindings to abstract away service integrations, simplifying your function code and improving maintainability.