-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathrun.ps1
30 lines (24 loc) · 1.22 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
# 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."
# Currently the Powershell worker does not allow empty/null values to be passed through the
# query parameters. We use TriggerMetadata here as a workaround for that issue.
# Issue link: https://github.com/Azure/azure-functions-powershell-worker/issues/895
$req_query = @{
"ProductId"= $TriggerMetadata["productId"];
"Name"= $TriggerMetadata["name"];
"Cost"= $TriggerMetadata["cost"];
};
# 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 product -Value $req_query
# 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_query
})