Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 53 additions & 1 deletion docs/SetupGuide_Javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
- [Array](#array)
- [Single Row](#single-row)
- [Trigger Binding](#trigger-binding)
- [function.json Properties for Trigger Bindings](#functionjson-properties-for-trigger-bindings)
- [Setup for Trigger Bindings](#setup-for-trigger-bindings)
- [Node V4 Model](#node-v4-model)

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

## Trigger Binding

> Trigger binding support is only available for in-proc C# functions at present.
See [Trigger Binding Overview](./BindingsOverview.md#trigger-binding) for general information about the Azure SQL Trigger binding.

### function.json Properties for Trigger Bindings

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

|function.json property | Description|
|---------|----------------------|
| **name** | Required. The name of the parameter that the trigger binds to. |
| **type** | Required. Must be set to `sqlTrigger`.|
| **direction** | Required. Must be set to `in`. |
| **commandText** | Required. The name of the table being monitored by the trigger. |
| **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). |

### Setup for Trigger Bindings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update TOC


Note: This tutorial requires that a SQL database is setup as shown in [Create a SQL Server](./GeneralSetup.md#create-a-sql-server).

- Create a new folder `EmployeeTrigger`
- Inside `EmployeeTrigger` create a new file `function.json`

```json
{
"bindings": [
{
"name": "changes",
"type": "sqlTrigger",
"direction": "in",
"tableName": "dbo.Employees",
"connectionStringSetting": "SqlConnectionString"
}
],
"disabled": false
}
```

- Inside `EmployeeTrigger` create a new file `index.js`

```javascript
module.exports = async function (context, changes) {
context.log(`SQL Changes: ${JSON.stringify(changes)}`)
}
```

- *Skip these steps if you have not completed the output binding tutorial.*
- Open your output binding file and modify some of the values. For example, change the value of Team column from 'Functions' to 'Azure SQL'.
- Hit 'F5' to run your code. Click the link of the HTTP trigger from the output binding tutorial.
- Update, insert, or delete rows in your SQL table while the function app is running and observe the function logs.
- You should see the new log messages in the Visual Studio Code terminal containing the values of row-columns after the update operation.
- Congratulations! You have successfully created your first SQL trigger binding!


## Node V4 Model

Expand Down