-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathrun.ps1
32 lines (26 loc) · 1.23 KB
/
run.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
using namespace System.Net
# Trigger binding data passed in via param block
param($Request, $TriggerMetadata)
# Write to the Azure Functions log stream.
Write-Host "PowerShell function with SQL Output Binding processed a request."
# Note that this expects the body to be a JSON object or array of objects
# which have a property matching each of the columns in the table to upsert to.
# Output bindings require the [ordered] attribute. See https://github.com/Azure/azure-functions-sql-extension#output-bindings for more details.
$req_body = @([ordered]@{
Name="Cup";
Cost=2;
}, [ordered]@{
Name="Glasses";
Cost=12;
});
# Assign the value we want to pass to the SQL Output binding.
# The -Name value corresponds to the name property in the function.json for the binding
Push-OutputBinding -Name products -Value $req_body
# Assign the value to return as the HTTP response.
# The -Name value matches the name property in the function.json for the binding
Push-OutputBinding -Name response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = $req_body
})