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
::: zone pivot="programming-language-javascript,programming-language-typescript"
514
518
515
519
More samples for the Azure SQL input binding are available in the [GitHub repository](https://github.com/Azure/azure-functions-sql-extension/tree/main/samples/samples-js).
516
520
@@ -527,7 +531,29 @@ The examples refer to a database table:
The following example shows a SQL input binding in a function.json file and a JavaScript function that reads from a query and returns the results in the HTTP response.
534
+
The following example shows a SQL input binding that reads from a query and returns the results in the HTTP response.
The following example shows a SQL input binding in a JavaScript function that reads from a query filtered by a parameter from the query string and returns the row in the HTTP response.
609
+
The following example shows a SQL input binding that reads from a query filtered by a parameter from the query string and returns the row in the HTTP response.
The following example shows a SQL input binding in a function.json file and a JavaScript function that executes a stored procedure with input from the HTTP request query parameter.
685
+
The following example shows a SQL input binding that executes a stored procedure with input from the HTTP request query parameter.
630
686
631
687
The stored procedure `dbo.DeleteToDo` must be created on the database. In this example, the stored procedure deletes a single record or all records depending on the value of the parameter.
More samples for the Azure SQL input binding are available in the [GitHub repository](https://github.com/Azure/azure-functions-sql-extension/tree/main/samples/samples-powershell).
@@ -1053,8 +1130,39 @@ In the [Java functions runtime library](/java/api/overview/azure/functions/runti
1053
1130
|**parameters**| Optional. Zero or more parameter values passed to the command during execution as a single string. Must follow the format `@param1=param1,@param2=param2`. Neither the parameter name nor the parameter value can contain a comma (`,`) or an equals sign (`=`). |
1054
1131
1055
1132
::: zone-end
1056
-
1057
-
::: zone pivot="programming-language-javascript,programming-language-powershell,programming-language-python"
1133
+
::: zone pivot="programming-language-javascript,programming-language-typescript"
1134
+
1135
+
## Configuration
1136
+
1137
+
# [Model v4](#tab/nodejs-v4)
1138
+
1139
+
The following table explains the properties that you can set on the `options` object passed to the `input.sql()` method.
1140
+
1141
+
| Property | Description |
1142
+
|---------|----------------------|
1143
+
|**commandText**| Required. The Transact-SQL query command or name of the stored procedure executed by the binding. |
1144
+
|**connectionStringSetting**| Required. The name of an app setting that contains the connection string for the database against which the query or stored procedure is being executed. This value isn't the actual connection string and must instead resolve to an environment variable name. Optional keywords in the connection string value are [available to refine SQL bindings connectivity](./functions-bindings-azure-sql.md#sql-connection-string). |
1145
+
|**commandType**| Required. A [CommandType](/dotnet/api/system.data.commandtype) value, which is [Text](/dotnet/api/system.data.commandtype#fields) for a query and [StoredProcedure](/dotnet/api/system.data.commandtype#fields) for a stored procedure. |
1146
+
|**parameters**| Optional. Zero or more parameter values passed to the command during execution as a single string. Must follow the format `@param1=param1,@param2=param2`. Neither the parameter name nor the parameter value can contain a comma (`,`) or an equals sign (`=`). |
1147
+
1148
+
# [Model v3](#tab/nodejs-v3)
1149
+
1150
+
The following table explains the binding configuration properties that you set in the function.json file.
1151
+
1152
+
| Property | Description |
1153
+
|---------|----------------------|
1154
+
|**type**| Required. Must be set to `sql`. |
1155
+
|**direction**| Required. Must be set to `in`. |
1156
+
|**name**| Required. The name of the variable that represents the query results in function code. |
1157
+
|**commandText**| Required. The Transact-SQL query command or name of the stored procedure executed by the binding. |
1158
+
|**connectionStringSetting**| Required. The name of an app setting that contains the connection string for the database against which the query or stored procedure is being executed. This value isn't the actual connection string and must instead resolve to an environment variable name. Optional keywords in the connection string value are [available to refine SQL bindings connectivity](./functions-bindings-azure-sql.md#sql-connection-string). |
1159
+
|**commandType**| Required. A [CommandType](/dotnet/api/system.data.commandtype) value, which is [Text](/dotnet/api/system.data.commandtype#fields) for a query and [StoredProcedure](/dotnet/api/system.data.commandtype#fields) for a stored procedure. |
1160
+
|**parameters**| Optional. Zero or more parameter values passed to the command during execution as a single string. Must follow the format `@param1=param1,@param2=param2`. Neither the parameter name nor the parameter value can contain a comma (`,`) or an equals sign (`=`). |
1161
+
1162
+
---
1163
+
1164
+
::: zone-end
1165
+
::: zone pivot="programming-language-powershell,programming-language-python"
1058
1166
## Configuration
1059
1167
1060
1168
The following table explains the binding configuration properties that you set in the function.json file.
@@ -1075,17 +1183,12 @@ The following table explains the binding configuration properties that you set i
1075
1183
1076
1184
## Usage
1077
1185
1078
-
::: zone pivot="programming-language-csharp,programming-language-javascript,programming-language-powershell,programming-language-python,programming-language-java"
1079
-
1080
1186
The attribute's constructor takes the SQL command text, the command type, parameters, and the connection string setting name. The command can be a Transact-SQL (T-SQL) query with the command type `System.Data.CommandType.Text` or stored procedure name with the command type `System.Data.CommandType.StoredProcedure`. The connection string setting name corresponds to the application setting (in `local.settings.json` for local development) that contains the [connection string](/dotnet/api/microsoft.data.sqlclient.sqlconnection.connectionstring?view=sqlclient-dotnet-core-5.0&preserve-view=true#Microsoft_Data_SqlClient_SqlConnection_ConnectionString) to the Azure SQL or SQL Server instance.
1081
1187
1082
1188
Queries executed by the input binding are [parameterized](/dotnet/api/microsoft.data.sqlclient.sqlparameter) in Microsoft.Data.SqlClient to reduce the risk of [SQL injection](/sql/relational-databases/security/sql-injection) from the parameter values passed into the binding.
1083
1189
1084
1190
If an exception occurs when a SQL input binding is executed then the function code will not execute. This may result in an error code being returned, such as an HTTP trigger returning a 500 error code.
1085
1191
1086
-
1087
-
::: zone-end
1088
-
1089
1192
## Next steps
1090
1193
1091
1194
-[Save data to a database (Output binding)](./functions-bindings-azure-sql-output.md)
0 commit comments