JSPM

  • Created
  • Published
  • Downloads 386504
  • Score
    100M100P100Q214667F
  • License MIT

Microsoft Azure Functions NodeJS Framework

Package Exports

  • @azure/functions
  • @azure/functions/dist/azure-functions.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@azure/functions) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Azure Functions Node.js Programming Model

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

Version 4 is currently in public preview! 🎉✨ Try it out and let us know what you think: https://aka.ms/AzFuncNodeV4

Install

npm install @azure/functions

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.

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();

Contributing

  • Clone the repository locally and open in VS Code
  • Run "Extensions: Show Recommended Extensions" from the command palette and install all extensions listed under "Workspace Recommendations"
  • Run npm install
  • Run npm run build
  • Run npm link
  • Create or open a local function app to test with
  • In the local function app:
    • Make sure you are calling func.setup() somewhere in your app, as described above in the "Usage" section
    • Run npm link @azure/functions. This will point your app to the local repository for the @azure/functions package
    • Add the following settings to your "local.settings.json" file or configure them directly as environment variables
      • languageWorkers__node__arguments: --inspect

        💡 Tip: Set logging__logLevel__Worker to debug if you want to view worker-specific logs in the output of func start

    • Start the app (i.e. run func start or press F5)
  • Back in the framework repository, press F5 and select the process for your running function app
  • Before you submit a PR, run npm test and fix any issues. If you want to debug the tests, switch your launch profile in VS Code to "Launch Unit Tests" and press F5.

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Contributing to type definitions

The type definitions are located in the types folder. Please make sure to update the tests in ./test/types/index.test.ts as well.