Skip to content

01 - Run Locally (Premium)

Run the sample Azure Functions Node.js v4 app on your machine before deploying to the Premium (EP1) plan. This track uses Linux shell examples; the same workflow works on Windows with equivalent commands.

Prerequisites

  • You completed the Language Guide overview and have Node.js 20+, Core Tools v4, and Azure CLI installed.
  • You are signed in to Azure CLI (az login).
Tool Version Purpose
Node.js 20+ Local runtime and package execution
Azure Functions Core Tools v4 Local host and publishing
Azure CLI 2.61+ Azure resource provisioning and management

Plan basics

Premium (Elastic Premium, EP1) provides always-warm instances, VNet integration, deployment slots, and unlimited timeout support. Unlike Consumption, Premium keeps at least one instance always warm — eliminating cold-start latency for production APIs.

What You'll Build

You will create a Node.js v4 HTTP-triggered function named helloHttp and run it locally with Azure Functions Core Tools. You will validate the local route at /api/hello/{name?} and confirm the function returns a JSON payload.

Infrastructure Context

Plan: Premium (EP1) | Runtime: Node.js 20 | Local dev: Core Tools v4

This tutorial runs entirely on your local machine. No Azure resources are created. The project structure you build here will be deployed to a Premium plan in Tutorial 02.

flowchart LR
    DEV[Developer Machine] -->|func start| HOST[Core Tools Host\nNode.js 20\nPort 7071]
    HOST --> HTTP[HTTP Trigger\nhelloHttp]
    HTTP -->|GET /api/hello| RESP[JSON Response]

    style DEV fill:#E3F2FD
    style HOST fill:#ff8c00,color:#fff
    style RESP fill:#E8F5E9

Steps

Step 1 — Initialize project

func init node-guide-premium --worker-runtime node --language javascript
cd node-guide-premium
npm install @azure/functions

Expected output (abridged):

Writing package.json
Writing .gitignore
Writing host.json
Writing local.settings.json
Writing /data/GitHub/azure-functions-practical-guide/apps/nodejs/.vscode/extensions.json

Step 2 — Create the v4 handler

Save the following as src/functions/helloHttp.js:

const { app } = require('@azure/functions');

app.http('helloHttp', {
    methods: ['GET'],
    route: 'hello/{name?}',
    handler: async (request, context) => {
        const name = request.params.name || request.query.get('name') || 'world';
        context.log(`Handled hello for ${name}`);
        return { status: 200, jsonBody: { message: `Hello, ${name}` } };
    }
});

Step 3 — Run host and test

func start

Expected output:

Azure Functions Core Tools
Core Tools Version:       4.8.0
Function Runtime Version: 4.1036.1.23224

Functions:

        helloHttp: [GET] http://localhost:7071/api/hello/{name?}

For detailed output, run func with --verbose flag.

In a second terminal, test the endpoint:

curl --request GET "http://localhost:7071/api/hello"

Expected output:

{"message":"Hello, world"}
curl --request GET "http://localhost:7071/api/hello/Azure"

Expected output:

{"message":"Hello, Azure"}

Step 4 — Review Premium-specific notes

  • Premium plans require Azure Files content share settings (WEBSITE_CONTENTAZUREFILECONNECTIONSTRING and WEBSITE_CONTENTSHARE) for content storage during provisioning.
  • Use an EP plan such as EP1 and configure always-ready capacity for low-latency APIs.
  • Premium supports unlimited function timeout ("functionTimeout": "-1" in host.json).
  • Use long-form CLI flags (for example, --resource-group) for maintainable runbooks.

Verification

Functions:
    helloHttp: [GET] http://localhost:7071/api/hello/{name?}

Confirm that the host lists helloHttp, then run curl --request GET "http://localhost:7071/api/hello" and verify a 200 OK response with a JSON body {"message":"Hello, world"}.

See Also

Sources