d22a8c2b4a
Based on this PR from host: https://github.com/Azure/azure-functions-host/pull/10256 And clean up CodeQL settings based on this PR: https://github.com/Azure/azure-functions-host/pull/10198 |
||
---|---|---|
.github | ||
.vscode | ||
azure-pipelines | ||
scripts | ||
src | ||
test | ||
types | ||
types-core | ||
.eslintrc.json | ||
.gitignore | ||
.prettierrc | ||
CONTRIBUTING.md | ||
LICENSE | ||
README.md | ||
SECURITY.md | ||
package-lock.json | ||
package.json | ||
tsconfig.json | ||
webpack.config.js |
README.md
Azure Functions Node.js Programming Model
Branch | Status | Support level | Node.js Versions |
---|---|---|---|
v3.x | GA | 20, 18 |
Install
npm install @azure/functions@3
Documentation
- Azure Functions JavaScript Developer Guide
- Create your first TypeScript function
- Create your first JavaScript function
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
-
Specify a main entrypoint in your package.json
"main": "dist/src/index.js"
-
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
-
Specify a main entrypoint in your package.json
"main": "src/index.js"
-
Add the following code to your entrypoint file:
const func = require('@azure/functions'); func.setup();