Azure Docs Free Azure Account

Develop Azure Functions with Node.js

Overview

Azure Functions provides a serverless compute experience for building event-driven applications using JavaScript or TypeScript. This guide walks you through creating, testing, and deploying Node.js functions.

Prerequisites

Create a New Function

Run the following commands in your terminal:

func init MyFunctionApp --worker-runtime node
cd MyFunctionApp
func new --template "HTTP trigger" --name HttpExample

Local Development

Start the function host locally:

func start

Open http://localhost:7071/api/HttpExample in a browser to test.

Debugging with VS Code

Open the project folder in VS Code and press F5 to launch the debugger.

Deploy to Azure

Log in to Azure and create a resource group and storage account if you haven't already:

az group create --name MyResourceGroup --location eastus
az storage account create --name mystorageaccount --location eastus --resource-group MyResourceGroup --sku Standard_LRS

Deploy the function app:

func azure functionapp publish my-node-func-app

Environment Variables

Set application settings via the Azure portal or CLI:

az functionapp config appsettings set --name my-node-func-app --resource-group MyResourceGroup --settings MySetting=Value

Next Steps