Azure Functions icon

Serverless compute

Azure Functions

Event-driven, serverless code: write the function, declare what triggers it and what data it binds to, and the platform handles servers, scale (including to zero) and connections. The unit of design is the event, not the server.

Triggers & bindings

Triggers start execution (exactly one per function). Bindings declaratively connect inputs/outputs so your code receives a queue message or writes a Cosmos DB doc without SDK plumbing.

flowchart LR
    subgraph Triggers
        H[HTTP request]
        Q[Service Bus / Storage queue]
        E[Event Grid / Event Hubs]
        Ti[Timer / cron]
        CD[Cosmos DB change feed]
        B[Blob created]
    end
    F["Function code
C# · Python · JS/TS · Java · PowerShell"] subgraph Output bindings O1[Cosmos DB] O2[Service Bus] O3[Blob / Table] O4[SignalR] O5[HTTP response] end H --> F Q --> F E --> F Ti --> F CD --> F B --> F F --> O1 F --> O2 F --> O3 F --> O4 F --> O5
One trigger in, any number of bindings out — glue code without the glue.

Hosting plans

PlanScaleChoose when
Flex ConsumptionTo zero; fast scale-out per-function; instance memory sizes; VNet supportThe new default for serverless — always-ready instances kill cold starts, and you finally get networking on a consumption model.
Consumption (classic)To zeroLegacy default; being superseded by Flex.
Premium (Elastic)Pre-warmed instances, no cold startSteady traffic + serverless bursts, longer executions, VNet.
Dedicated (App Service plan)Manual/autoscale, no scale to zeroReuse existing App Service capacity; predictable cost.
Container Apps hostingKEDA-basedRun Functions as containers alongside microservices in the same Container Apps environment (Dapr, GPU, one ops model).

Durable Functions

Code-first orchestration on top of Functions: orchestrator functions await activities, sleep for days, and survive restarts via event-sourced state. The core serverless workflow patterns:

flowchart TB
    subgraph Chaining[Function chaining]
        A1[F1] --> A2[F2] --> A3[F3]
    end
    subgraph FanOut[Fan-out / fan-in]
        B0[Orchestrator] --> B1[Work 1]
        B0 --> B2[Work 2]
        B0 --> B3[Work N]
        B1 --> BA[Aggregate]
        B2 --> BA
        B3 --> BA
    end
    subgraph Human[Human interaction]
        C1[Request approval] --> C2{Wait for event
or 72h timeout} C2 -->|approved| C3[Proceed] C2 -->|timeout| C4[Escalate] end
Chaining, fan-out/fan-in, async HTTP APIs (202 + status), monitors, human interaction and entity patterns — all in plain code.

Functions in AI architectures

Detailed use cases

Use case

Queue-driven order processing

Service Bus trigger with peek-lock, retries, and dead-lettering; output bindings write results to Cosmos DB and emit events — reliable, elastic backend workers.

Use case

Lightweight APIs & webhooks

HTTP-triggered microservice endpoints behind APIM; scale to zero between calls; Flex Consumption keeps p99 latency respectable.

Use case

File/media pipeline

Blob trigger on upload → validate → resize/transcode/OCR → store + notify. Fan-out for large batches with Durable Functions.

Use case

Scheduled jobs

Timer triggers replace cron VMs: cleanup, report generation, data refresh — with logs, retries and no patching.

Use case

Stream processing

Event Hubs trigger processes IoT/telemetry in batches; checkpointing and partition-parallel scale built in.

Use case

Long-running approvals

Durable human-interaction pattern: kick off, wait for external event (approval webhook) with timeout escalation, resume exactly where it left off.

Best practices