Skip to content

Commit 344a78d

Browse files
Merge pull request #259088 from hhunter-ms/hh-183241
[Dapr/Functions] Add Node.js v4 to reference docs
2 parents d5c7564 + 8aa03bc commit 344a78d

10 files changed

+489
-33
lines changed

articles/azure-functions/functions-bindings-dapr-input-secret.md

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,32 @@ public void run(
6868

6969
::: zone pivot="programming-language-javascript"
7070

71-
> [!NOTE]
72-
> The [Node.js v4 model for Azure Functions](functions-reference-node.md?pivots=nodejs-model-v4) isn't currently available for use with the Dapr extension during the preview.
71+
# [Node.js v4](#tab/v4)
72+
73+
In the following example, the Dapr secret input binding is paired with a Dapr invoke trigger, which is registered by the `app` object:
74+
75+
```javascript
76+
const { app, trigger } = require('@azure/functions');
77+
78+
app.generic('RetrieveSecret', {
79+
trigger: trigger.generic({
80+
type: 'daprServiceInvocationTrigger',
81+
name: "payload"
82+
}),
83+
extraInputs: [daprSecretInput],
84+
handler: async (request, context) => {
85+
context.log("Node function processed a RetrieveSecret request from the Dapr Runtime.");
86+
const daprSecretInputValue = context.extraInputs.get(daprSecretInput);
87+
88+
// print the fetched secret value
89+
for (var key in daprSecretInputValue) {
90+
context.log(`Stored secret: Key=${key}, Value=${daprSecretInputValue[key]}`);
91+
}
92+
}
93+
});
94+
```
95+
96+
# [Node.js v3](#tab/v3)
7397

7498
The following examples show Dapr triggers in a _function.json_ file and JavaScript code that uses those bindings.
7599

@@ -105,6 +129,8 @@ module.exports = async function (context) {
105129
};
106130
```
107131

132+
---
133+
108134
::: zone-end
109135

110136
::: zone pivot="programming-language-powershell"
@@ -269,7 +295,33 @@ The `DaprSecretInput` annotation allows you to have your function access a secre
269295

270296
::: zone-end
271297

272-
::: zone pivot="programming-language-javascript, programming-language-powershell"
298+
::: zone pivot="programming-language-javascript"
299+
300+
# [Node.js v4](#tab/v4)
301+
302+
The following table explains the binding configuration properties that you set in the code.
303+
304+
|Property | Description |
305+
|-----------------------|-------------|
306+
|**key** | The secret key value. |
307+
|**secretStoreName** | Name of the secret store as defined in the _local-secret-store.yaml_ component file. |
308+
|**metadata** | The metadata namespace. |
309+
310+
# [Node.js v3](#tab/v3)
311+
312+
The following table explains the binding configuration properties that you set in the function.json file.
313+
314+
|function.json property | Description |
315+
|-----------------------|-------------|
316+
|**key** | The secret key value. |
317+
|**secretStoreName** | Name of the secret store as defined in the _local-secret-store.yaml_ component file. |
318+
|**metadata** | The metadata namespace. |
319+
320+
---
321+
322+
::: zone-end
323+
324+
::: zone pivot="programming-language-powershell"
273325

274326
The following table explains the binding configuration properties that you set in the function.json file.
275327

articles/azure-functions/functions-bindings-dapr-input-state.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,35 @@ public String run(
7070

7171
::: zone pivot="programming-language-javascript"
7272

73-
> [!NOTE]
74-
> The [Node.js v4 model for Azure Functions](functions-reference-node.md?pivots=nodejs-model-v4) isn't currently available for use with the Dapr extension during the preview.
73+
# [Node.js v4](#tab/v4)
74+
75+
In the following example, the Dapr invoke input binding is added as an `extraInput` and paired with an HTTP trigger, which is registered by the `app` object:
76+
77+
```javascript
78+
const { app, trigger } = require('@azure/functions');
79+
80+
app.generic('StateInputBinding', {
81+
trigger: trigger.generic({
82+
type: 'httpTrigger',
83+
authLevel: 'anonymous',
84+
methods: ['GET'],
85+
route: "state/{key}",
86+
name: "req"
87+
}),
88+
extraInputs: [daprStateInput],
89+
handler: async (request, context) => {
90+
context.log("Node HTTP trigger function processed a request.");
91+
92+
const daprStateInputValue = context.extraInputs.get(daprStateInput);
93+
// print the fetched state value
94+
context.log(daprStateInputValue);
95+
96+
return daprStateInputValue;
97+
}
98+
});
99+
```
100+
101+
# [Node.js v3](#tab/v3)
75102

76103
The following examples show Dapr triggers in a _function.json_ file and JavaScript code that uses those bindings.
77104

@@ -101,6 +128,8 @@ module.exports = async function (context, req) {
101128
};
102129
```
103130

131+
---
132+
104133
::: zone-end
105134

106135
::: zone pivot="programming-language-powershell"
@@ -254,13 +283,26 @@ The `DaprStateInput` annotation allows you to read Dapr state into your function
254283

255284
::: zone pivot="programming-language-javascript"
256285

286+
# [Node.js v4](#tab/v4)
287+
288+
The following table explains the binding configuration properties that you set in the code.
289+
290+
|Property | Description |
291+
|-----------------------|-------------|
292+
|**stateStore** | The name of the state store. |
293+
|**key** | The name of the key to retrieve from the specified state store. |
294+
295+
# [Node.js v3](#tab/v3)
296+
257297
The following table explains the binding configuration properties that you set in the function.json file.
258298

259299
|function.json property | Description |
260300
|-----------------------|-------------|
261301
|**stateStore** | The name of the state store. |
262302
|**key** | The name of the key to retrieve from the specified state store. |
263303

304+
---
305+
264306
::: zone-end
265307

266308
::: zone pivot="programming-language-powershell"

articles/azure-functions/functions-bindings-dapr-output-invoke.md

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,34 @@ public String run(
8585

8686
::: zone pivot="programming-language-javascript"
8787

88-
> [!NOTE]
89-
> The [Node.js v4 model for Azure Functions](functions-reference-node.md?pivots=nodejs-model-v4) isn't currently available for use with the Dapr extension during the preview.
88+
# [Node.js v4](#tab/v4)
89+
90+
In the following example, the Dapr invoke output binding is paired with an HTTP trigger, which is registered by the `app` object:
91+
92+
```javascript
93+
const { app, trigger } = require('@azure/functions');
94+
95+
app.generic('InvokeOutputBinding', {
96+
trigger: trigger.generic({
97+
type: 'httpTrigger',
98+
authLevel: 'anonymous',
99+
methods: ['POST'],
100+
route: "invoke/{appId}/{methodName}",
101+
name: "req"
102+
}),
103+
return: daprInvokeOutput,
104+
handler: async (request, context) => {
105+
context.log("Node HTTP trigger function processed a request.");
106+
107+
const payload = await request.text();
108+
context.log(JSON.stringify(payload));
109+
110+
return { body: payload };
111+
}
112+
});
113+
```
114+
115+
# [Node.js v3](#tab/v3)
90116

91117
The following examples show Dapr triggers in a _function.json_ file and JavaScript code that uses those bindings.
92118

@@ -118,6 +144,8 @@ module.exports = async function (context, req) {
118144
};
119145
```
120146

147+
---
148+
121149
::: zone-end
122150

123151
::: zone pivot="programming-language-powershell"
@@ -288,7 +316,35 @@ The `DaprInvokeOutput` annotation allows you to have your function invoke and li
288316

289317
::: zone-end
290318

291-
::: zone pivot="programming-language-javascript, programming-language-powershell"
319+
::: zone pivot="programming-language-javascript"
320+
321+
# [Node.js v4](#tab/v4)
322+
323+
The following table explains the binding configuration properties that you set in the code.
324+
325+
|Property | Description| Can be sent via Attribute | Can be sent via RequestBody |
326+
|-----------------------|------------| :---------------------: | :-----------------------: |
327+
|**appId** | The app ID of the application involved in the invoke binding. | :heavy_check_mark: | :heavy_check_mark: |
328+
|**methods** | Post or get. | :heavy_check_mark: | :heavy_check_mark: |
329+
| **body** | _Required._ The body of the request. | :x: | :heavy_check_mark: |
330+
331+
# [Node.js v3](#tab/v3)
332+
333+
The following table explains the binding configuration properties that you set in the function.json file.
334+
335+
|function.json property | Description| Can be sent via Attribute | Can be sent via RequestBody |
336+
|-----------------------|------------| :---------------------: | :-----------------------: |
337+
|**appId** | The app ID of the application involved in the invoke binding. | :heavy_check_mark: | :heavy_check_mark: |
338+
|**methodName** | The name of the method variable. | :heavy_check_mark: | :heavy_check_mark: |
339+
|**httpVerb** | Post or get. | :heavy_check_mark: | :heavy_check_mark: |
340+
| **body** | _Required._ The body of the request. | :x: | :heavy_check_mark: |
341+
342+
---
343+
344+
::: zone-end
345+
346+
::: zone pivot="programming-language-powershell"
347+
292348
The following table explains the binding configuration properties that you set in the function.json file.
293349

294350
|function.json property | Description| Can be sent via Attribute | Can be sent via RequestBody |

articles/azure-functions/functions-bindings-dapr-output-publish.md

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,33 @@ public String run(
7474

7575
::: zone pivot="programming-language-javascript"
7676

77-
> [!NOTE]
78-
> The [Node.js v4 model for Azure Functions](functions-reference-node.md?pivots=nodejs-model-v4) isn't currently available for use with the Dapr extension during the preview.
77+
# [Node.js v4](#tab/v4)
78+
79+
In the following example, the Dapr publish output binding is paired with an HTTP trigger, which is registered by the `app` object:
80+
81+
```javascript
82+
const { app, trigger } = require('@azure/functions');
83+
84+
app.generic('PublishOutputBinding', {
85+
trigger: trigger.generic({
86+
type: 'httpTrigger',
87+
authLevel: 'anonymous',
88+
methods: ['POST'],
89+
route: "topic/{topicName}",
90+
name: "req"
91+
}),
92+
return: daprPublishOutput,
93+
handler: async (request, context) => {
94+
context.log("Node HTTP trigger function processed a request.");
95+
const payload = await request.text();
96+
context.log(JSON.stringify(payload));
97+
98+
return { payload: payload };
99+
}
100+
});
101+
```
102+
103+
# [Node.js v3](#tab/v3)
79104

80105
The following examples show Dapr triggers in a _function.json_ file and JavaScript code that uses those bindings.
81106

@@ -106,6 +131,8 @@ module.exports = async function (context, req) {
106131
};
107132
```
108133

134+
---
135+
109136
::: zone-end
110137

111138
::: zone pivot="programming-language-powershell"
@@ -270,7 +297,33 @@ The `DaprPublishOutput` annotation allows you to have a function access a publis
270297

271298
::: zone-end
272299

273-
::: zone pivot="programming-language-javascript, programming-language-powershell"
300+
::: zone pivot="programming-language-javascript"
301+
302+
# [Node.js v4](#tab/v4)
303+
304+
The following table explains the binding configuration properties that you set in the code.
305+
306+
|Property | Description| Can be sent via Attribute | Can be sent via RequestBody |
307+
|-----------------------|------------| :---------------------: | :-----------------------: |
308+
|**pubsubname** | The name of the publisher component service. | :heavy_check_mark: | :heavy_check_mark: |
309+
|**topic** | The name/identifier of the publisher topic. | :heavy_check_mark: | :heavy_check_mark: |
310+
| **payload** | _Required._ The message being published. | :x: | :heavy_check_mark: |
311+
312+
# [Node.js v3](#tab/v3)
313+
314+
The following table explains the binding configuration properties that you set in the function.json file.
315+
316+
|function.json property | Description| Can be sent via Attribute | Can be sent via RequestBody |
317+
|-----------------------|------------| :---------------------: | :-----------------------: |
318+
|**pubsubname** | The name of the publisher component service. | :heavy_check_mark: | :heavy_check_mark: |
319+
|**topic** | The name/identifier of the publisher topic. | :heavy_check_mark: | :heavy_check_mark: |
320+
| **payload** | _Required._ The message being published. | :x: | :heavy_check_mark: |
321+
322+
---
323+
324+
::: zone-end
325+
326+
::: zone pivot="programming-language-powershell"
274327

275328
The following table explains the binding configuration properties that you set in the _function.json_ file.
276329

articles/azure-functions/functions-bindings-dapr-output-state.md

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,34 @@ public String run(
8080

8181
::: zone pivot="programming-language-javascript"
8282

83-
> [!NOTE]
84-
> The [Node.js v4 model for Azure Functions](functions-reference-node.md?pivots=nodejs-model-v4) isn't currently available for use with the Dapr extension during the preview.
83+
# [Node.js v4](#tab/v4)
84+
85+
In the following example, the Dapr state output binding is paired with an HTTP trigger, which is registered by the `app` object:
86+
87+
```javascript
88+
const { app, trigger } = require('@azure/functions');
89+
90+
app.generic('StateOutputBinding', {
91+
trigger: trigger.generic({
92+
type: 'httpTrigger',
93+
authLevel: 'anonymous',
94+
methods: ['POST'],
95+
route: "state/{key}",
96+
name: "req"
97+
}),
98+
return: daprStateOutput,
99+
handler: async (request, context) => {
100+
context.log("Node HTTP trigger function processed a request.");
101+
102+
const payload = await request.text();
103+
context.log(JSON.stringify(payload));
104+
105+
return { value : payload };
106+
}
107+
});
108+
```
109+
110+
# [Node.js v3](#tab/v3)
85111

86112
The following examples show Dapr triggers in a _function.json_ file and JavaScript code that uses those bindings.
87113

@@ -117,6 +143,8 @@ module.exports = async function (context, req) {
117143
};
118144
```
119145

146+
---
147+
120148
::: zone-end
121149

122150
::: zone pivot="programming-language-powershell"
@@ -280,7 +308,34 @@ The `DaprStateOutput` annotation allows you to function access a state store.
280308

281309
::: zone-end
282310

283-
::: zone pivot="programming-language-javascript, programming-language-powershell"
311+
::: zone pivot="programming-language-javascript"
312+
313+
# [Node.js v4](#tab/v4)
314+
315+
The following table explains the binding configuration properties that you set in the code.
316+
317+
|Property | Description| Can be sent via Attribute | Can be sent via RequestBody |
318+
|-----------------------|------------| :---------------------: | :-----------------------: |
319+
| **stateStore** | The name of the state store to save state. | :heavy_check_mark: | :x: |
320+
| **key** | The name of the key to save state within the state store. | :heavy_check_mark: | :heavy_check_mark: |
321+
| **value** | _Required._ The value being stored. | :x: | :heavy_check_mark: |
322+
323+
324+
# [Node.js v3](#tab/v3)
325+
326+
The following table explains the binding configuration properties that you set in the function.json file.
327+
328+
|function.json property | Description| Can be sent via Attribute | Can be sent via RequestBody |
329+
|-----------------------|------------| :---------------------: | :-----------------------: |
330+
| **stateStore** | The name of the state store to save state. | :heavy_check_mark: | :x: |
331+
| **key** | The name of the key to save state within the state store. | :heavy_check_mark: | :heavy_check_mark: |
332+
| **value** | _Required._ The value being stored. | :x: | :heavy_check_mark: |
333+
334+
---
335+
336+
::: zone-end
337+
338+
::: zone pivot="programming-language-powershell"
284339

285340
The following table explains the binding configuration properties that you set in the _function.json_ file.
286341

0 commit comments

Comments
 (0)