Skip to content
Learni
View all tutorials
Cloud & DevOps

How to Develop Azure Functions with TypeScript in 2026

18 minINTERMEDIATE
Lire en français

Introduction

Azure Functions lets you run serverless code without managing infrastructure. In 2026, TypeScript integration provides a modern development experience with strong typing and advanced tooling. This tutorial guides you step by step through creating functions with HTTP and Timer triggers, from local setup to Azure deployment. Ideal for intermediate developers looking to optimize automated workflows or lightweight APIs.

Prerequisites

  • Node.js 20+ and npm
  • Azure CLI installed and connected
  • Azure account with an active subscription
  • Basic knowledge of TypeScript and REST

Initialize the Project

terminal
npm install -g azure-functions-core-tools@4
func init myFunctionApp --typescript
cd myFunctionApp
npm install

This command installs the Azure Functions tools and initializes a TypeScript project. The folder contains the necessary configuration files for the v4 runtime.

Create an HTTP Trigger

src/functions/httpTrigger.ts
import { app, HttpRequest, HttpResponseInit, InvocationContext } from '@azure/functions';

export async function httpTrigger(request: HttpRequest, context: InvocationContext): Promise<HttpResponseInit> {
  context.log(`HTTP request received for ${request.url}`);
  const name = request.query.get('name') || await request.text() || 'World';
  return { body: `Hello, ${name}!` };
}

app.http('httpTrigger', {
  methods: ['GET', 'POST'],
  authLevel: 'anonymous',
  handler: httpTrigger
});

This code defines an HTTP function that accepts GET and POST requests. It logs the request and returns a personalized message. Strong typing ensures safety and autocompletion support.

Add a Timer Trigger

src/functions/timerTrigger.ts
import { app, InvocationContext, Timer } from '@azure/functions';

export async function timerTrigger(myTimer: Timer, context: InvocationContext): Promise<void> {
  context.log('Timer triggered at', new Date().toISOString());
  // Business logic here
}

app.timer('timerTrigger', {
  schedule: '0 */5 * * * *',
  handler: timerTrigger
});

This function runs every 5 minutes via CRON. The context enables logging and access to bindings for reliable scheduled tasks.

Configure local.settings.json

local.settings.json
{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "node",
    "FUNCTIONS_WORKER_RUNTIME_VERSION": "~20"
  }
}

This file configures the local environment for storage and the Node runtime. Use real environment variables in production.

Deploy to Azure

terminal
az login
az group create --name rg-functions --location westeurope
az storage account create --name mystoragefunc --resource-group rg-functions --location westeurope --sku Standard_LRS
func azure functionapp create --resource-group rg-functions --consumption-plan-location westeurope --runtime node --runtime-version 20 --functions-version 4 --name myfuncapp2026 --storage-account mystoragefunc
func azure functionapp publish myfuncapp2026

These commands create the Azure resources and publish the code. The Consumption plan is cost-effective for variable workloads.

Best Practices

  • Use environment variables for secrets
  • Implement error handling with try/catch in every handler
  • Enable Application Insights for monitoring
  • Limit function execution duration
  • Test locally with func start before deployment

Common Errors to Avoid

  • Forgetting to configure AzureWebJobsStorage causes binding errors
  • Using incompatible Node runtime versions
  • Ignoring timeouts on Timer triggers
  • Failing to validate HTTP request inputs

Going Further

Explore Durable Functions for complex workflows. Check out our Learni courses on Azure and serverless.