Azure Functions
Serverless compute for event-driven workloads, APIs, and scheduled tasks.
⚠️ MANDATORY: Use Composition Algorithm
>
NEVER synthesize Bicep or Terraform from scratch for Azure Functions.
>
You MUST follow the base + recipe composition workflow:
- Load selection.md — decision tree for choosing base template + recipe
- Follow composition.md — the algorithm for fetching and composing
>
This ensures proven IaC patterns, correct RBAC, and Flex Consumption defaults.
When to Use
- Event-driven workloads
- Scheduled tasks (cron jobs)
- HTTP APIs with variable traffic
- Message/queue processing
- Real-time file processing
- MCP servers for AI agents
- Real-time streaming and event processing
- Orchestrations and workflows (Durable Functions)
Service Type in azure.yaml
services:
my-function:
host: function
project: ./src/my-functionRequired Supporting Resources
| Resource | Purpose |
|---|---|
| Storage Account | Function runtime state |
| App Service Plan | Hosting (Consumption or Premium) |
| Application Insights | Monitoring |
Hosting Plans
Use Flex Consumption for new deployments (all AZD templates default to Flex).
| Plan | Use Case | Scaling | VNET | Slots |
|---|---|---|---|---|
| Flex Consumption ⭐ | Default for new projects | Auto, pay-per-execution | ✅ | ❌ |
| Consumption Windows (Y1) | Legacy/maintenance, Windows-only features | Auto, scale to zero | ❌ | ✅ 1 staging slot |
| Consumption Linux (Y1) | Legacy/maintenance | Auto, scale to zero | ❌ | ❌ |
| Premium (EP1-EP3) | No cold starts, longer execution, slots | Auto, min instances | ✅ | ✅ 20 slots |
| Dedicated | Predictable load, existing App Service | Manual or auto | ✅ | ✅ varies by SKU |
⚠️ Deployment Slots Guidance:
- Windows Consumption (Y1) supports 1 staging slot — valid for existing apps or specific Windows requirements.
Prefer Elastic Premium (EP1) or Dedicated for new apps requiring slots, as Consumption cold starts affect swap reliability.
- Linux Consumption and Flex Consumption do not support deployment slots.
- For new projects needing slots: use Elastic Premium or an App Service Plan (Standard+).
Runtime Stacks
⚠️ ALWAYS QUERY OFFICIAL DOCUMENTATION FOR VERSIONS
>
Do NOT use hardcoded versions. Query for latest GA versions before generating code:
>
Primary Source: Azure Functions Supported Languages
>
Use the azure-documentation MCP tool to fetch current supported versions:
intent: "Azure Functions supported language runtime versions" learn: true
Version Selection Priority
- Latest GA — For new projects (best features, longest support window)
- LTS — For enterprise/compliance requirements
- User-specified — When explicitly requested
| Language | FUNCTIONSWORKERRUNTIME | linuxFxVersion | |
|---|---|---|---|
| Node.js | node | `Node\ | <version>` |
| Python | python | `Python\ | <version>` |
| .NET | dotnet-isolated | `DOTNET-ISOLATED\ | <version>` |
| Java | java | `Java\ | <version>` |
| PowerShell | powershell | `PowerShell\ | <version>` |
References
- Selection Guide — Start here: decision tree for base + recipe
- Composition Algorithm — How to fetch and compose templates
- AZD Templates — Template overview
- Bicep Patterns
- Terraform Patterns
- Durable Functions
- Aspire + Container Apps