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.
682
+
The following example shows a SQL input binding that executes a stored procedure with input from the HTTP request query parameter.
630
683
631
684
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 +1127,39 @@ In the [Java functions runtime library](/java/api/overview/azure/functions/runti
1053
1127
|**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
1128
1055
1129
::: zone-end
1056
-
1057
-
::: zone pivot="programming-language-javascript,programming-language-powershell,programming-language-python"
1130
+
::: zone pivot="programming-language-javascript,programming-language-typescript"
1131
+
1132
+
## Configuration
1133
+
1134
+
# [Model v4](#tab/nodejs-v4)
1135
+
1136
+
The following table explains the properties that you can set on the `options` object passed to the `input.sql()` method.
1137
+
1138
+
| Property | Description |
1139
+
|---------|----------------------|
1140
+
|**commandText**| Required. The Transact-SQL query command or name of the stored procedure executed by the binding. |
1141
+
|**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). |
1142
+
|**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. |
1143
+
|**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 (`=`). |
1144
+
1145
+
# [Model v3](#tab/nodejs-v3)
1146
+
1147
+
The following table explains the binding configuration properties that you set in the function.json file.
1148
+
1149
+
| Property | Description |
1150
+
|---------|----------------------|
1151
+
|**type**| Required. Must be set to `sql`. |
1152
+
|**direction**| Required. Must be set to `in`. |
1153
+
|**name**| Required. The name of the variable that represents the query results in function code. |
1154
+
|**commandText**| Required. The Transact-SQL query command or name of the stored procedure executed by the binding. |
1155
+
|**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). |
1156
+
|**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. |
1157
+
|**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 (`=`). |
1158
+
1159
+
---
1160
+
1161
+
::: zone-end
1162
+
::: zone pivot="programming-language-powershell,programming-language-python"
1058
1163
## Configuration
1059
1164
1060
1165
The following table explains the binding configuration properties that you set in the function.json file.
@@ -1075,17 +1180,12 @@ The following table explains the binding configuration properties that you set i
1075
1180
1076
1181
## Usage
1077
1182
1078
-
::: zone pivot="programming-language-csharp,programming-language-javascript,programming-language-powershell,programming-language-python,programming-language-java"
1079
-
1080
1183
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
1184
1082
1185
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
1186
1084
1187
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
1188
1086
-
1087
-
::: zone-end
1088
-
1089
1189
## Next steps
1090
1190
1091
1191
-[Save data to a database (Output binding)](./functions-bindings-azure-sql-output.md)
0 commit comments