You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Upgrade guide from v3 to v4](https://learn.microsoft.com/azure/azure-functions/functions-node-upgrade-v4)
18
+
-[Create your first TypeScript function](https://docs.microsoft.com/azure/azure-functions/create-first-function-vs-code-typescript?pivots=nodejs-model-v4)
19
+
-[Create your first JavaScript function](https://docs.microsoft.com/azure/azure-functions/create-first-function-vs-code-node?pivots=nodejs-model-v4)
20
+
21
+
## Considerations
15
22
16
-
_**UPDATE**_: **See here for important information on v4 of the Azure Functions Node.js Framework: https://aka.ms/AzFuncNodeV4**
23
+
- During preview, the v4 model requires you to set the app setting `AzureWebJobsFeatureFlags` to `EnableWorkerIndexing`. For more information, see [Enable v4 programming model](https://learn.microsoft.com/azure/azure-functions/functions-reference-node?pivots=nodejs-model-v4#enable-v4-programming-model).
24
+
- The Node.js "programming model" shouldn't be confused with the Azure Functions "runtime".
25
+
-_**Programming model**_: Defines how you author your code and is specific to JavaScript and TypeScript.
26
+
-_**Runtime**_: Defines underlying behavior of Azure Functions and is shared across all languages.
27
+
- The programming model version is strictly tied to the version of the [`@azure/functions`](https://www.npmjs.com/package/@azure/functions) npm package, and is versioned independently of the [runtime](https://learn.microsoft.com/azure/azure-functions/functions-versions?pivots=programming-language-javascript). Both the runtime and the programming model use "4" as their latest major version, but that is purely a coincidence.
17
28
18
-
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 Framework for Node.js. This framework package is included by default in [v4.x of the Azure Functions runtime](https://docs.microsoft.com/azure/azure-functions/functions-versions?pivots=programming-language-javascript), 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.
29
+
## Usage
19
30
20
-
### TypeScript:
31
+
### TypeScript
21
32
22
-
For a full tutorial, see [how to create your first TypeScript function](https://docs.microsoft.com/azure/azure-functions/create-first-function-vs-code-typescript).
context.log(`Http function processed request for url "${request.url}"`);
31
38
32
-
func.setup();
33
-
```
39
+
const name =request.query.get('name') ||awaitrequest.text() ||'world';
34
40
35
-
**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.
41
+
return { body: `Hello, ${name}!` };
42
+
};
36
43
37
-
For more documentation, see the [TypeScript developer guide](https://docs.microsoft.com/azure/azure-functions/functions-reference-node#typescript).
44
+
app.http('httpTrigger1', {
45
+
methods: ['GET', 'POST'],
46
+
authLevel: 'anonymous',
47
+
handler: httpTrigger1
48
+
});
49
+
```
38
50
39
51
### JavaScript
40
52
41
-
For a full tutorial, see [how to create your first JavaScript function](https://docs.microsoft.com/azure/azure-functions/create-first-function-vs-code-node).
53
+
```javascript
54
+
const { app } =require('@azure/functions');
42
55
43
-
1. Specify a main entrypoint in your package.json
44
-
```json
45
-
"main": "src/index.js"
46
-
```
47
-
2. Add the following code to your entrypoint file:
48
-
```javascript
49
-
const func = require('@azure/functions');
50
-
51
-
func.setup();
52
-
```
56
+
app.http('httpTrigger1', {
57
+
methods: ['GET', 'POST'],
58
+
authLevel:'anonymous',
59
+
handler:async (request, context) => {
60
+
context.log(`Http function processed request for url "${request.url}"`);
53
61
54
-
For more documentation, see the [JavaScript developer guide](https://docs.microsoft.com/azure/azure-functions/functions-reference-node).
0 commit comments