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
Copy file name to clipboardExpand all lines: articles/azure-functions/functions-reference-node.md
+23-6Lines changed: 23 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,7 +61,7 @@ The required folder structure for a JavaScript project looks like the following
61
61
The main project folder, *<project_root>*, can contain the following files:
62
62
63
63
-**.vscode/**: (Optional) Contains the stored Visual Studio Code configuration. To learn more, see [Visual Studio Code settings](https://code.visualstudio.com/docs/getstarted/settings).
64
-
-**myFirstFunction/function.json**: Contains configuration for the function's inputs and outputs. The name of the directory determines the name of your function.
64
+
-**myFirstFunction/function.json**: Contains configuration for the function's trigger, inputs, and outputs. The name of the directory determines the name of your function.
65
65
-**myFirstFunction/index.js**: Stores your function code. To change this default file path, see [using scriptFile](#using-scriptfile).
66
66
-**.funcignore**: (Optional) Declares files that shouldn't get published to Azure. Usually, this file contains *.vscode/* to ignore your editor setting, *test/* to ignore test cases, and *local.settings.json* to prevent local app settings being published.
67
67
-**host.json**: Contains configuration options that affect all functions in a function app instance. This file does get published to Azure. Not all options are supported when running locally. To learn more, see [host.json](functions-host-json.md).
@@ -115,6 +115,8 @@ The v3 model registers a function based on the existence of two files. First, yo
115
115
116
116
The function you export should always be declared as an [`async function`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/async_function) in the v3 model. You can export a synchronous function, but then you must call [`context.done()`](#contextdone) to signal that your function is completed, which is deprecated and not recommended.
117
117
118
+
Your function is passed an [invocation `context`](#invocation-context) as the first argument and your [inputs](#inputs) as the remaining arguments.
119
+
118
120
The following example is a simple function that logs that it was triggered and responds with `Hello, world!`:
119
121
120
122
```json
@@ -288,7 +290,7 @@ You can use the `dataType` property on an input binding to change the type of yo
288
290
- In Node.js, only `string` and `binary` are supported (`stream` isn't)
289
291
- For HTTP inputs, the `dataType` property is ignored. Instead, use properties on the `request` object to get the body in your desired format. For more information, see [HTTP request](#http-request).
290
292
291
-
In the following example of a [storage queue trigger](./functions-bindings-storage-queue-trigger.md), the default type of `myQueueItem` is a `string`, but if you set `dataType` to `binary` the type changes to a Node.js `Buffer`.
293
+
In the following example of a [storage queue trigger](./functions-bindings-storage-queue-trigger.md), the default type of `myQueueItem` is a `string`, but if you set `dataType` to `binary`, the type changes to a Node.js `Buffer`.
292
294
293
295
```json
294
296
{
@@ -338,7 +340,7 @@ app.http('helloWorld1', {
338
340
339
341
The return output is optional, and in some cases configured by default. For example, an HTTP trigger registered with `app.http` is configured to return an HTTP response output automatically. For most output types, you specify the return configuration on the `options` argument with the help of the `output` object exported from the `@azure/functions` module. During execution, you set this output by returning it from your handler.
340
342
341
-
The following examples uses a [timer trigger](./functions-bindings-timer.md) and a [storage queue output](./functions-bindings-storage-queue-output.md):
343
+
The following example uses a [timer trigger](./functions-bindings-timer.md) and a [storage queue output](./functions-bindings-storage-queue-output.md):
| **`user`** | `HttpRequestUser |null` | Object representing logged-in user, either through Functions authentication, SWA Authentication, or null when no such user is logged in. |
696
-
| **`body`** | `Buffer | string | any` | If the media type is "application/octet-stream" or "multipart/*", the body is a Buffer. If the value is a JSON parse-able string, the body is the parsed object. Otherwise, the body is a string. |
697
-
| **`rawBody`** | `Buffer | string` | If the media type is "application/octet-stream" or "multipart/*", the body is a Buffer. Otherwise, the body is a string. The only difference between `body` and `rawBody` is that `rawBody` doesn't JSON parse a string body. |
698
+
| **`body`** | `Buffer | string | any` | If the media type is "application/octet-stream" or "multipart/*", `body` is a Buffer. If the value is a JSON parse-able string, `body` is the parsed object. Otherwise, `body` is a string. |
699
+
| **`rawBody`** | `Buffer | string` | If the media type is "application/octet-stream" or "multipart/*", `rawBody`is a Buffer. Otherwise, `rawBody` is a string. The only difference between `body` and `rawBody` is that `rawBody` doesn't JSON parse a string body. |
698
700
| **`bufferBody`** | `Buffer` | The body as a buffer. |
699
701
700
702
::: zone-end
@@ -759,13 +761,28 @@ The response can be set in several ways:
- **Set the named output binding:** This option works the same as any non HTTP binding. The binding name in `function.json` must match the key on `context.bindings`, or "response1" in the following example:
0 commit comments