Skip to content

Latest commit

 

History

History
63 lines (41 loc) · 3.48 KB

README.md

File metadata and controls

63 lines (41 loc) · 3.48 KB

Azure Functions Node.js Programming Model

Branch Status Support level Node.js Versions
v3.x Build Status Test Status GA 20 (Preview), 18, 16, 14

Install

npm install @azure/functions@3

Documentation

Considerations

  • The Node.js "programming model" shouldn't be confused with the Azure Functions "runtime".
    • Programming model: Defines how you author your code and is specific to JavaScript and TypeScript.
    • Runtime: Defines underlying behavior of Azure Functions and is shared across all languages.
  • The programming model version is strictly tied to the version of the @azure/functions npm package, and is versioned independently of the runtime. Both the runtime and the programming model use "4" as their latest major version, but that is purely a coincidence.
  • You can't mix the v3 and v4 programming models in the same function app. As soon as you register one v4 function in your app, any v3 functions registered in function.json files are ignored.

Usage

Prior to version 3.5.0, this package only contained TypeScript type definitions. Starting with version 3.5.0 it also contains the underlying Azure Functions Programming Model for Node.js. This package is included by default in v4.x of the Azure Functions runtime, meaning you do not need to include the package in your app. However, there may be cases where you want a specific version of the package, so you can override the default shipped in Azure with the below steps.

TypeScript

  1. Specify a main entrypoint in your package.json

    "main": "dist/src/index.js"
  2. Add the following code to your entrypoint file (e.g. src/index.ts):

    import * as func from '@azure/functions';
    
    func.setup();

IMPORTANT NOTE: If you only want this package for the TypeScript type definitions, you may list this package in the "devDependencies" section of your package.json. If you are overriding the default shipped in Azure as described above, the package must be listed in the production "dependencies" section of your package.json.

JavaScript

  1. Specify a main entrypoint in your package.json

    "main": "src/index.js"
  2. Add the following code to your entrypoint file:

    const func = require('@azure/functions');
    
    func.setup();