Functions.Templates/Templates/MySqlOutputBinding-PowerShell/run.ps1 (25 lines of code) (raw):
<#
Sample MySql Output Binding
These tasks should be completed prior to running :
1. Update "commandText" in function.json - this should be the name of the table that you wish to upsert values to
2. Add an app setting named "MySqlConnectionString" containing the connection string to use for the MySql connection
@param Request The HttpRequest that triggered this function
#>
using namespace System.Net
# Trigger binding data passed in via param block
param($Request)
# Write to the Azure Functions log stream.
Write-Host "PowerShell function with MySql Output Binding processed a request."
# Update req_body with the body of the 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.
$req_body = $Request.Body
# Assign the value we want to pass to the MySql Output binding.
# The -Name value corresponds to the name property in the function.json for the binding
Push-OutputBinding -Name results -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
})