Skip to content

Commit 537ee5a

Browse files
authored
Update SetupGuide_Javascript.md (#847)
* Update SetupGuide_Javascript.md * fix toc
1 parent 13bcb75 commit 537ee5a

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

docs/SetupGuide_Javascript.md

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
- [Array](#array)
2121
- [Single Row](#single-row)
2222
- [Trigger Binding](#trigger-binding)
23+
- [function.json Properties for Trigger Bindings](#functionjson-properties-for-trigger-bindings)
24+
- [Setup for Trigger Bindings](#setup-for-trigger-bindings)
2325
- [Node V4 Model](#node-v4-model)
2426

2527
## Setup Function Project
@@ -206,7 +208,57 @@ See the [AddProduct](https://github.com/Azure/azure-functions-sql-extension/tree
206208

207209
## Trigger Binding
208210

209-
> Trigger binding support is only available for in-proc C# functions at present.
211+
See [Trigger Binding Overview](./BindingsOverview.md#trigger-binding) for general information about the Azure SQL Trigger binding.
212+
213+
### function.json Properties for Trigger Bindings
214+
215+
The following table explains the binding configuration properties that you set in the *function.json* file.
216+
217+
|function.json property | Description|
218+
|---------|----------------------|
219+
| **name** | Required. The name of the parameter that the trigger binds to. |
220+
| **type** | Required. Must be set to `sqlTrigger`.|
221+
| **direction** | Required. Must be set to `in`. |
222+
| **commandText** | Required. The name of the table being monitored by the trigger. |
223+
| **connectionStringSetting** | Required. The name of an app setting that contains the connection string for the database containing the table monitored for changes. This isn't the actual connection string and must instead resolve to an environment variable. Optional keywords in the connection string value are [available to refine SQL bindings connectivity](https://aka.ms/sqlbindings#sql-connection-string). |
224+
225+
### Setup for Trigger Bindings
226+
227+
Note: This tutorial requires that a SQL database is setup as shown in [Create a SQL Server](./GeneralSetup.md#create-a-sql-server).
228+
229+
- Create a new folder `EmployeeTrigger`
230+
- Inside `EmployeeTrigger` create a new file `function.json`
231+
232+
```json
233+
{
234+
"bindings": [
235+
{
236+
"name": "changes",
237+
"type": "sqlTrigger",
238+
"direction": "in",
239+
"tableName": "dbo.Employees",
240+
"connectionStringSetting": "SqlConnectionString"
241+
}
242+
],
243+
"disabled": false
244+
}
245+
```
246+
247+
- Inside `EmployeeTrigger` create a new file `index.js`
248+
249+
```javascript
250+
module.exports = async function (context, changes) {
251+
context.log(`SQL Changes: ${JSON.stringify(changes)}`)
252+
}
253+
```
254+
255+
- *Skip these steps if you have not completed the output binding tutorial.*
256+
- Open your output binding file and modify some of the values. For example, change the value of Team column from 'Functions' to 'Azure SQL'.
257+
- Hit 'F5' to run your code. Click the link of the HTTP trigger from the output binding tutorial.
258+
- Update, insert, or delete rows in your SQL table while the function app is running and observe the function logs.
259+
- You should see the new log messages in the Visual Studio Code terminal containing the values of row-columns after the update operation.
260+
- Congratulations! You have successfully created your first SQL trigger binding!
261+
210262

211263
## Node V4 Model
212264

0 commit comments

Comments
 (0)