Skip to content

Commit b90e88a

Browse files
authored
update SetupGuide_PowerShell (#680)
* update PS docs todos * Update SetupGuide_PowerShell.md
1 parent bbb9080 commit b90e88a

File tree

6 files changed

+65
-12
lines changed

6 files changed

+65
-12
lines changed

docs/SetupGuide_PowerShell.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
- [function.json Properties for Output Bindings](#functionjson-properties-for-output-bindings)
1818
- [Setup for Output Bindings](#setup-for-output-bindings)
1919
- [Samples for Output Bindings](#samples-for-output-bindings)
20-
- [ICollector\<T\>/IAsyncCollector\<T\>](#icollectortiasynccollectort)
2120
- [Array](#array)
2221
- [Single Row](#single-row)
2322
- [Trigger Binding](#trigger-binding)
@@ -113,19 +112,19 @@ Note: This tutorial requires that a SQL database is setup as shown in [Create a
113112

114113
#### Query String
115114

116-
_TODO_
115+
See the [GetProducts](https://github.com/Azure/azure-functions-sql-extension/tree/main/samples/samples-powershell/GetProducts) sample
117116

118117
#### Empty Parameter Value
119118

120-
_TODO_
119+
See the [GetProductsNameEmpty](https://github.com/Azure/azure-functions-sql-extension/tree/main/samples/samples-powershell/GetProductsNameEmpty) sample
121120

122121
#### Null Parameter Value
123122

124-
_TODO_
123+
See the [GetProductsNameNull](https://github.com/Azure/azure-functions-sql-extension/tree/main/samples/samples-powershell/GetProductsNameNull) sample
125124

126125
#### Stored Procedure
127126

128-
_TODO_
127+
See the [GetProductsStoredProcedure](https://github.com/Azure/azure-functions-sql-extension/tree/main/samples/samples-powershell/GetProductsStoredProcedure) sample
129128

130129
## Output Binding
131130

@@ -147,7 +146,7 @@ The following table explains the binding configuration properties that you set i
147146

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

150-
- Open your app in VS Code
149+
- Open your project in VS Code
151150
- Press 'F1' and search for 'Azure Functions: Create Function'
152151
- Choose HttpTrigger -> (Provide a function name) -> anonymous
153152
- In the file that opens (`run.ps1`), replace the code within the file the below code. Note that the casing of the Object field names and the table column names must match.
@@ -205,17 +204,14 @@ Note: This tutorial requires that a SQL database is setup as shown in [Create a
205204

206205
### Samples for Output Bindings
207206

208-
#### ICollector&lt;T&gt;/IAsyncCollector&lt;T&gt;
209-
210-
_TODO_
211-
212207
#### Array
213208

214-
_TODO_
209+
See the [AddProductsArray](https://github.com/Azure/azure-functions-sql-extension/tree/main/samples/samples-powershell/AddProductsArray) sample
215210

216211
#### Single Row
217212

218-
_TODO_
213+
See the [AddProduct](https://github.com/Azure/azure-functions-sql-extension/tree/main/samples/samples-powershell/AddProduct) sample
214+
219215

220216
## Trigger Binding
221217

samples/samples-powershell/GetProducts/run.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License. See License.txt in the project root for license information.
33

4+
# The input binding executes the `select * from Products where Cost = @Cost` query, returning the result as json object in the body.
5+
# The *parameters* argument passes the `{cost}` specified in the URL that triggers the function,
6+
# `getproducts/{cost}`, as the value of the `@Cost` parameter in the query.
7+
# *commandType* is set to `Text`, since the constructor argument of the binding is a raw query.
48
using namespace System.Net
59

610
# Trigger and input binding data are passed in via the param block.

samples/samples-powershell/GetProductsNameEmpty/run.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License. See License.txt in the project root for license information.
33

4+
# The parameter value of the `@Name` parameter is an empty string in the parameters arguments.
45
using namespace System.Net
56

67
# Trigger and input binding data are passed in via the param block.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"bindings": [
3+
{
4+
"authLevel": "function",
5+
"name": "Request",
6+
"type": "httpTrigger",
7+
"direction": "in",
8+
"methods": [
9+
"get"
10+
],
11+
"route": "getproducts-namenull/{name}"
12+
},
13+
{
14+
"name": "response",
15+
"type": "http",
16+
"direction": "out"
17+
},
18+
{
19+
"name": "products",
20+
"type": "sql",
21+
"direction": "in",
22+
"commandText": "if @Name is null select * from Products where Name is null else select * from Products where @Name = name",
23+
"commandType": "Text",
24+
"parameters": "@Name={name}",
25+
"connectionStringSetting": "SqlConnectionString"
26+
}
27+
],
28+
"disabled": false
29+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License. See License.txt in the project root for license information.
3+
4+
# If the `{name}` specified in the `getproducts-namenull/{name}` URL is "null",
5+
# the query returns all rows for which the Name column is `NULL`. Otherwise, it returns
6+
# all rows for which the value of the Name column matches the string passed in `{name}`
7+
using namespace System.Net
8+
9+
# Trigger and input binding data are passed in via the param block.
10+
param($Request, $TriggerMetadata, $products)
11+
12+
# Write to the Azure Functions log stream.
13+
Write-Host "PowerShell function with SQL Input Binding processed a request."
14+
15+
# Assign the value to return as the HTTP response.
16+
# The -Name value matches the name property in the function.json for the binding
17+
Push-OutputBinding -Name response -Value ([HttpResponseContext]@{
18+
StatusCode = [System.Net.HttpStatusCode]::OK
19+
Body = $products
20+
})

samples/samples-powershell/GetProductsStoredProcedure/run.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License. See License.txt in the project root for license information.
33

4+
# `SelectsProductCost` is the name of a procedure stored in the user's database.
5+
# In this case, *CommandType* is `StoredProcedure`.
6+
# The parameter value of the `@Cost` parameter in the procedure is once again the `{cost}` specified in the `getproducts-storedprocedure/{cost}` URL.
47
using namespace System.Net
58

69
# Trigger and input binding data are passed in via the param block.

0 commit comments

Comments
 (0)