Microsoft Azure Functions NodeJS Framework
npm install @azure/functionsbash
npm install @azure/functions
`
Documentation
- Azure Functions JavaScript Developer Guide
- Upgrade guide from v3 to v4
- 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
$3
`typescript
import { app, HttpRequest, HttpResponseInit, InvocationContext } from "@azure/functions";
export async function httpTrigger1(request: HttpRequest, context: InvocationContext): Promise {
context.log( Http function processed request for url "${request.url}");
const name = request.query.get('name') || await request.text() || 'world';
return { body: Hello, ${name}! };
};
app.http('httpTrigger1', {
methods: ['GET', 'POST'],
authLevel: 'anonymous',
handler: httpTrigger1
});
`
$3
`javascript
const { app } = require('@azure/functions');
app.http('httpTrigger1', {
methods: ['GET', 'POST'],
authLevel: 'anonymous',
handler: async (request, context) => {
context.log(Http function processed request for url "${request.url}");
const name = request.query.get('name') || await request.text() || 'world';
return { body: Hello, ${name}! };
}
});
``