Skip to content

Commit 2a02404

Browse files
committed
feedback
1 parent 6ee98fa commit 2a02404

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

articles/azure-functions/functions-reference-node.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ The required folder structure for a JavaScript project looks like the following
6161
The main project folder, *<project_root>*, can contain the following files:
6262

6363
- **.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.
6565
- **myFirstFunction/index.js**: Stores your function code. To change this default file path, see [using scriptFile](#using-scriptfile).
6666
- **.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.
6767
- **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
115115

116116
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.
117117

118+
Your function is passed an [invocation `context`](#invocation-context) as the first argument and your [inputs](#inputs) as the remaining arguments.
119+
118120
The following example is a simple function that logs that it was triggered and responds with `Hello, world!`:
119121

120122
```json
@@ -288,7 +290,7 @@ You can use the `dataType` property on an input binding to change the type of yo
288290
- In Node.js, only `string` and `binary` are supported (`stream` isn't)
289291
- 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).
290292
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`.
292294
293295
```json
294296
{
@@ -338,7 +340,7 @@ app.http('helloWorld1', {
338340
339341
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.
340342
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):
342344
343345
```javascript
344346
const { app, output } = require('@azure/functions');
@@ -693,8 +695,8 @@ The `HttpRequest` object has the following properties:
693695
| **`query`** | `Record<string, string>` | Query string parameter keys and values from the URL. |
694696
| **`params`** | `Record<string, string>` | Route parameter keys and values. |
695697
| **`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. |
698700
| **`bufferBody`** | `Buffer` | The body as a buffer. |
699701
700702
::: zone-end
@@ -759,13 +761,28 @@ The response can be set in several ways:
759761
"direction": "out",
760762
"name": "$return"
761763
}
762-
```
764+
```
763765

764766
```javascript
765767
module.exports = async function (context, request) {
766768
return { body: `Hello, world!` };
767769
```
768770
771+
- **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:
772+
773+
```json
774+
{
775+
"type": "http",
776+
"direction": "out",
777+
"name": "response1"
778+
}
779+
```
780+
781+
```javascript
782+
module.exports = async function (context, request) {
783+
context.bindings.response1 = { body: `Hello, world!` };
784+
```
785+
769786
- **Call `context.res.send()`:** This option is deprecated. It implicitly calls `context.done()` and can't be used in an async function.
770787
771788
```javascript

0 commit comments

Comments
 (0)