From afc2b34b3bce3af6d6105e3415cfc059c4797049 Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Wed, 19 Oct 2022 18:10:09 -0700 Subject: [PATCH 01/41] add powershell samples --- samples/samples-powershell/.eslintrc.json | 19 ++++ samples/samples-powershell/.funcignore | 7 ++ samples/samples-powershell/.gitignore | 99 +++++++++++++++++++ .../AddProduct/function.json | 27 +++++ samples/samples-powershell/AddProduct/run.ps1 | 23 +++++ .../AddProductParams/function.json | 27 +++++ .../AddProductParams/run.ps1 | 27 +++++ .../AddProductWithDefaultPK/function.json | 27 +++++ .../AddProductWithDefaultPK/run.ps1 | 23 +++++ .../function.json | 27 +++++ .../AddProductWithIdentityColumn/run.ps1 | 26 +++++ .../function.json | 27 +++++ .../run.ps1 | 27 +++++ .../function.json | 27 +++++ .../run.ps1 | 27 +++++ .../AddProductsArray/function.json | 27 +++++ .../AddProductsArray/run.ps1 | 23 +++++ .../function.json | 27 +++++ .../run.ps1 | 29 ++++++ .../GetProductNamesView/function.json | 28 ++++++ .../GetProductNamesView/run.ps1 | 14 +++ .../GetProducts/function.json | 29 ++++++ .../samples-powershell/GetProducts/run.ps1 | 14 +++ .../GetProductsNameEmpty/function.json | 29 ++++++ .../GetProductsNameEmpty/run.ps1 | 14 +++ .../GetProductsStoredProcedure/function.json | 29 ++++++ .../GetProductsStoredProcedure/run.ps1 | 14 +++ .../function.json | 29 ++++++ .../run.ps1 | 14 +++ .../QueueTriggerProducts/function.json | 23 +++++ .../QueueTriggerProducts/run.ps1 | 27 +++++ .../TimerTriggerProducts/function.json | 23 +++++ .../TimerTriggerProducts/run.ps1 | 31 ++++++ samples/samples-powershell/host.json | 15 +++ test/Integration/IntegrationTestBase.cs | 68 ++++++------- .../SqlInputBindingIntegrationTests.cs | 12 ++- .../SqlOutputBindingIntegrationTests.cs | 40 +++++++- .../AddProductColumnTypes/function.json | 28 ++++++ .../AddProductColumnTypes/run.ps1 | 27 +++++ ....Azure.WebJobs.Extensions.Sql.Tests.csproj | 6 ++ 40 files changed, 1022 insertions(+), 38 deletions(-) create mode 100644 samples/samples-powershell/.eslintrc.json create mode 100644 samples/samples-powershell/.funcignore create mode 100644 samples/samples-powershell/.gitignore create mode 100644 samples/samples-powershell/AddProduct/function.json create mode 100644 samples/samples-powershell/AddProduct/run.ps1 create mode 100644 samples/samples-powershell/AddProductParams/function.json create mode 100644 samples/samples-powershell/AddProductParams/run.ps1 create mode 100644 samples/samples-powershell/AddProductWithDefaultPK/function.json create mode 100644 samples/samples-powershell/AddProductWithDefaultPK/run.ps1 create mode 100644 samples/samples-powershell/AddProductWithIdentityColumn/function.json create mode 100644 samples/samples-powershell/AddProductWithIdentityColumn/run.ps1 create mode 100644 samples/samples-powershell/AddProductWithIdentityColumnIncluded/function.json create mode 100644 samples/samples-powershell/AddProductWithIdentityColumnIncluded/run.ps1 create mode 100644 samples/samples-powershell/AddProductWithMultiplePrimaryColumnsAndIdentity/function.json create mode 100644 samples/samples-powershell/AddProductWithMultiplePrimaryColumnsAndIdentity/run.ps1 create mode 100644 samples/samples-powershell/AddProductsArray/function.json create mode 100644 samples/samples-powershell/AddProductsArray/run.ps1 create mode 100644 samples/samples-powershell/AddProductsWithIdentityColumnArray/function.json create mode 100644 samples/samples-powershell/AddProductsWithIdentityColumnArray/run.ps1 create mode 100644 samples/samples-powershell/GetProductNamesView/function.json create mode 100644 samples/samples-powershell/GetProductNamesView/run.ps1 create mode 100644 samples/samples-powershell/GetProducts/function.json create mode 100644 samples/samples-powershell/GetProducts/run.ps1 create mode 100644 samples/samples-powershell/GetProductsNameEmpty/function.json create mode 100644 samples/samples-powershell/GetProductsNameEmpty/run.ps1 create mode 100644 samples/samples-powershell/GetProductsStoredProcedure/function.json create mode 100644 samples/samples-powershell/GetProductsStoredProcedure/run.ps1 create mode 100644 samples/samples-powershell/GetProductsStoredProcedureFromAppSetting/function.json create mode 100644 samples/samples-powershell/GetProductsStoredProcedureFromAppSetting/run.ps1 create mode 100644 samples/samples-powershell/QueueTriggerProducts/function.json create mode 100644 samples/samples-powershell/QueueTriggerProducts/run.ps1 create mode 100644 samples/samples-powershell/TimerTriggerProducts/function.json create mode 100644 samples/samples-powershell/TimerTriggerProducts/run.ps1 create mode 100644 samples/samples-powershell/host.json create mode 100644 test/Integration/test-powershell/AddProductColumnTypes/function.json create mode 100644 test/Integration/test-powershell/AddProductColumnTypes/run.ps1 diff --git a/samples/samples-powershell/.eslintrc.json b/samples/samples-powershell/.eslintrc.json new file mode 100644 index 000000000..48e60a390 --- /dev/null +++ b/samples/samples-powershell/.eslintrc.json @@ -0,0 +1,19 @@ +{ + "root": true, + "parserOptions": { + "ecmaVersion": "latest" + }, + "plugins": [ + "header" + ], + "rules": { + "header/header": [ + 2, + "line", + [ + " Copyright (c) Microsoft Corporation. All rights reserved.", + " Licensed under the MIT License. See License.txt in the project root for license information." + ] + ] + } +} \ No newline at end of file diff --git a/samples/samples-powershell/.funcignore b/samples/samples-powershell/.funcignore new file mode 100644 index 000000000..517922249 --- /dev/null +++ b/samples/samples-powershell/.funcignore @@ -0,0 +1,7 @@ +*.js.map +*.ts +.git* +.vscode +local.settings.json +test +tsconfig.json \ No newline at end of file diff --git a/samples/samples-powershell/.gitignore b/samples/samples-powershell/.gitignore new file mode 100644 index 000000000..01774db7f --- /dev/null +++ b/samples/samples-powershell/.gitignore @@ -0,0 +1,99 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# next.js build output +.next + +# nuxt.js build output +.nuxt + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TypeScript output +dist +out + +# Azure Functions artifacts +bin +obj +appsettings.json +local.settings.json + +# Azurite artifacts +__blobstorage__ +__queuestorage__ +__azurite_db*__.json \ No newline at end of file diff --git a/samples/samples-powershell/AddProduct/function.json b/samples/samples-powershell/AddProduct/function.json new file mode 100644 index 000000000..2afd45793 --- /dev/null +++ b/samples/samples-powershell/AddProduct/function.json @@ -0,0 +1,27 @@ +{ + "bindings": [ + { + "authLevel": "function", + "name": "req", + "direction": "in", + "type": "httpTrigger", + "methods": [ + "post" + ], + "route": "addproduct" + }, + { + "name": "response", + "type": "http", + "direction": "out" + }, + { + "name": "product", + "type": "sql", + "direction": "out", + "commandText": "[dbo].[Products]", + "connectionStringSetting": "SqlConnectionString" + } + ], + "disabled": false +} \ No newline at end of file diff --git a/samples/samples-powershell/AddProduct/run.ps1 b/samples/samples-powershell/AddProduct/run.ps1 new file mode 100644 index 000000000..dad4b722b --- /dev/null +++ b/samples/samples-powershell/AddProduct/run.ps1 @@ -0,0 +1,23 @@ +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 SQL 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 SQL Output binding. +# The -Name value corresponds to the name property in the function.json for the binding +Push-OutputBinding -Name product -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 +}) \ No newline at end of file diff --git a/samples/samples-powershell/AddProductParams/function.json b/samples/samples-powershell/AddProductParams/function.json new file mode 100644 index 000000000..f39b06ca3 --- /dev/null +++ b/samples/samples-powershell/AddProductParams/function.json @@ -0,0 +1,27 @@ +{ + "bindings": [ + { + "authLevel": "function", + "name": "req", + "direction": "in", + "type": "httpTrigger", + "methods": [ + "get" + ], + "route": "addproduct-params" + }, + { + "name": "response", + "type": "http", + "direction": "out" + }, + { + "name": "product", + "type": "sql", + "direction": "out", + "commandText": "[dbo].[Products]", + "connectionStringSetting": "SqlConnectionString" + } + ], + "disabled": false +} \ No newline at end of file diff --git a/samples/samples-powershell/AddProductParams/run.ps1 b/samples/samples-powershell/AddProductParams/run.ps1 new file mode 100644 index 000000000..d8dc5199e --- /dev/null +++ b/samples/samples-powershell/AddProductParams/run.ps1 @@ -0,0 +1,27 @@ +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 SQL 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 = @{ + "productId"= req.body?.productId; + "name"= req.body?.name; + "cost"= req.body?.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_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 +}) \ No newline at end of file diff --git a/samples/samples-powershell/AddProductWithDefaultPK/function.json b/samples/samples-powershell/AddProductWithDefaultPK/function.json new file mode 100644 index 000000000..028fde758 --- /dev/null +++ b/samples/samples-powershell/AddProductWithDefaultPK/function.json @@ -0,0 +1,27 @@ +{ + "bindings": [ + { + "authLevel": "function", + "name": "req", + "direction": "in", + "type": "httpTrigger", + "methods": [ + "post" + ], + "route": "addproductwithdefaultpk" + }, + { + "name": "response", + "type": "http", + "direction": "out" + }, + { + "name": "products", + "type": "sql", + "direction": "out", + "commandText": "[dbo].[ProductsWithDefaultPK]", + "connectionStringSetting": "SqlConnectionString" + } + ], + "disabled": false + } \ No newline at end of file diff --git a/samples/samples-powershell/AddProductWithDefaultPK/run.ps1 b/samples/samples-powershell/AddProductWithDefaultPK/run.ps1 new file mode 100644 index 000000000..8a7b7e402 --- /dev/null +++ b/samples/samples-powershell/AddProductWithDefaultPK/run.ps1 @@ -0,0 +1,23 @@ +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 SQL 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 SQL Output binding. +# The -Name value corresponds to the name property in the function.json for the binding +Push-OutputBinding -Name product -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 +}) \ No newline at end of file diff --git a/samples/samples-powershell/AddProductWithIdentityColumn/function.json b/samples/samples-powershell/AddProductWithIdentityColumn/function.json new file mode 100644 index 000000000..0993c49f3 --- /dev/null +++ b/samples/samples-powershell/AddProductWithIdentityColumn/function.json @@ -0,0 +1,27 @@ +{ + "bindings": [ + { + "authLevel": "function", + "name": "req", + "direction": "in", + "type": "httpTrigger", + "methods": [ + "get" + ], + "route": "addproductwithidentitycolumn" + }, + { + "name": "response", + "type": "http", + "direction": "out" + }, + { + "name": "product", + "type": "sql", + "direction": "out", + "commandText": "[dbo].[ProductsWithIdentity]", + "connectionStringSetting": "SqlConnectionString" + } + ], + "disabled": false +} \ No newline at end of file diff --git a/samples/samples-powershell/AddProductWithIdentityColumn/run.ps1 b/samples/samples-powershell/AddProductWithIdentityColumn/run.ps1 new file mode 100644 index 000000000..71445e60a --- /dev/null +++ b/samples/samples-powershell/AddProductWithIdentityColumn/run.ps1 @@ -0,0 +1,26 @@ +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 SQL 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 = @{ + name=$Request.Body?.name; + cost=$Request.Body?.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_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 +}) \ No newline at end of file diff --git a/samples/samples-powershell/AddProductWithIdentityColumnIncluded/function.json b/samples/samples-powershell/AddProductWithIdentityColumnIncluded/function.json new file mode 100644 index 000000000..db9cd8dac --- /dev/null +++ b/samples/samples-powershell/AddProductWithIdentityColumnIncluded/function.json @@ -0,0 +1,27 @@ +{ + "bindings": [ + { + "authLevel": "function", + "name": "req", + "direction": "in", + "type": "httpTrigger", + "methods": [ + "get" + ], + "route": "addproductwithidentitycolumnincluded" + }, + { + "name": "response", + "type": "http", + "direction": "out" + }, + { + "name": "product", + "type": "sql", + "direction": "out", + "commandText": "[dbo].[ProductsWithIdentity]", + "connectionStringSetting": "SqlConnectionString" + } + ], + "disabled": false +} \ No newline at end of file diff --git a/samples/samples-powershell/AddProductWithIdentityColumnIncluded/run.ps1 b/samples/samples-powershell/AddProductWithIdentityColumnIncluded/run.ps1 new file mode 100644 index 000000000..a66a38fd1 --- /dev/null +++ b/samples/samples-powershell/AddProductWithIdentityColumnIncluded/run.ps1 @@ -0,0 +1,27 @@ +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 SQL 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 = @{ + productId=$Request.Body?.productId; + name=$Request.Body?.name; + cost=$Request.Body?.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_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 +}) \ No newline at end of file diff --git a/samples/samples-powershell/AddProductWithMultiplePrimaryColumnsAndIdentity/function.json b/samples/samples-powershell/AddProductWithMultiplePrimaryColumnsAndIdentity/function.json new file mode 100644 index 000000000..4320535d5 --- /dev/null +++ b/samples/samples-powershell/AddProductWithMultiplePrimaryColumnsAndIdentity/function.json @@ -0,0 +1,27 @@ +{ + "bindings": [ + { + "authLevel": "function", + "name": "req", + "direction": "in", + "type": "httpTrigger", + "methods": [ + "get" + ], + "route": "addproductwithmultipleprimarycolumnsandidentity" + }, + { + "name": "response", + "type": "http", + "direction": "out" + }, + { + "name": "product", + "type": "sql", + "direction": "out", + "commandText": "[dbo].[ProductsWithMultiplePrimaryColumnsAndIdentity]", + "connectionStringSetting": "SqlConnectionString" + } + ], + "disabled": false +} \ No newline at end of file diff --git a/samples/samples-powershell/AddProductWithMultiplePrimaryColumnsAndIdentity/run.ps1 b/samples/samples-powershell/AddProductWithMultiplePrimaryColumnsAndIdentity/run.ps1 new file mode 100644 index 000000000..6dcaf7a95 --- /dev/null +++ b/samples/samples-powershell/AddProductWithMultiplePrimaryColumnsAndIdentity/run.ps1 @@ -0,0 +1,27 @@ +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 SQL 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 = @{ + externalId=$Request.Body?.externalId; + name=$Request.Body?.name; + cost=$Request.Body?.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_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 +}) \ No newline at end of file diff --git a/samples/samples-powershell/AddProductsArray/function.json b/samples/samples-powershell/AddProductsArray/function.json new file mode 100644 index 000000000..baec6005f --- /dev/null +++ b/samples/samples-powershell/AddProductsArray/function.json @@ -0,0 +1,27 @@ +{ + "bindings": [ + { + "authLevel": "function", + "name": "req", + "direction": "in", + "type": "httpTrigger", + "methods": [ + "post" + ], + "route": "addproducts-array" + }, + { + "name": "response", + "type": "http", + "direction": "out" + }, + { + "name": "products", + "type": "sql", + "direction": "out", + "commandText": "[dbo].[Products]", + "connectionStringSetting": "SqlConnectionString" + } + ], + "disabled": false +} \ No newline at end of file diff --git a/samples/samples-powershell/AddProductsArray/run.ps1 b/samples/samples-powershell/AddProductsArray/run.ps1 new file mode 100644 index 000000000..92e89bdbc --- /dev/null +++ b/samples/samples-powershell/AddProductsArray/run.ps1 @@ -0,0 +1,23 @@ +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 SQL 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 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 +}) \ No newline at end of file diff --git a/samples/samples-powershell/AddProductsWithIdentityColumnArray/function.json b/samples/samples-powershell/AddProductsWithIdentityColumnArray/function.json new file mode 100644 index 000000000..6b591da2a --- /dev/null +++ b/samples/samples-powershell/AddProductsWithIdentityColumnArray/function.json @@ -0,0 +1,27 @@ +{ + "bindings": [ + { + "authLevel": "function", + "name": "req", + "direction": "in", + "type": "httpTrigger", + "methods": [ + "get" + ], + "route": "addproductswithidentitycolumnarray" + }, + { + "name": "response", + "type": "http", + "direction": "out" + }, + { + "name": "products", + "type": "sql", + "direction": "out", + "commandText": "[dbo].[ProductsWithIdentity]", + "connectionStringSetting": "SqlConnectionString" + } + ], + "disabled": false +} \ No newline at end of file diff --git a/samples/samples-powershell/AddProductsWithIdentityColumnArray/run.ps1 b/samples/samples-powershell/AddProductsWithIdentityColumnArray/run.ps1 new file mode 100644 index 000000000..5ccf7cb14 --- /dev/null +++ b/samples/samples-powershell/AddProductsWithIdentityColumnArray/run.ps1 @@ -0,0 +1,29 @@ +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 SQL 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 = (@{ + name="Cup"; + cost="2"; +}, { + 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 +}) \ No newline at end of file diff --git a/samples/samples-powershell/GetProductNamesView/function.json b/samples/samples-powershell/GetProductNamesView/function.json new file mode 100644 index 000000000..c13b1e092 --- /dev/null +++ b/samples/samples-powershell/GetProductNamesView/function.json @@ -0,0 +1,28 @@ +{ + "bindings": [ + { + "authLevel": "function", + "name": "req", + "type": "httpTrigger", + "direction": "in", + "methods": [ + "get" + ], + "route":"getproduct-namesview" + }, + { + "name": "response", + "type": "http", + "direction": "out" + }, + { + "name": "products", + "type": "sql", + "direction": "in", + "commandText": "SELECT * FROM ProductNames", + "commandType": "Text", + "connectionStringSetting": "SqlConnectionString" + } + ], + "disabled": false +} \ No newline at end of file diff --git a/samples/samples-powershell/GetProductNamesView/run.ps1 b/samples/samples-powershell/GetProductNamesView/run.ps1 new file mode 100644 index 000000000..53e94ca3a --- /dev/null +++ b/samples/samples-powershell/GetProductNamesView/run.ps1 @@ -0,0 +1,14 @@ +using namespace System.Net + +# Trigger and input binding data are passed in via the param block. +param($Request, $products) + +# Write to the Azure Functions log stream. +Write-Host "PowerShell function with SQL Input Binding processed a request." + +# 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 = [System.Net.HttpStatusCode]::OK + Body = $products +}) \ No newline at end of file diff --git a/samples/samples-powershell/GetProducts/function.json b/samples/samples-powershell/GetProducts/function.json new file mode 100644 index 000000000..a1b5c81aa --- /dev/null +++ b/samples/samples-powershell/GetProducts/function.json @@ -0,0 +1,29 @@ +{ + "bindings": [ + { + "authLevel": "function", + "name": "req", + "type": "httpTrigger", + "direction": "in", + "methods": [ + "get" + ], + "route": "getproducts/{cost}" + }, + { + "name": "response", + "type": "http", + "direction": "out" + }, + { + "name": "products", + "type": "sql", + "direction": "in", + "commandText": "select * from Products where Cost = @Cost", + "commandType": "Text", + "parameters": "@Cost={cost}", + "connectionStringSetting": "SqlConnectionString" + } + ], + "disabled": false +} \ No newline at end of file diff --git a/samples/samples-powershell/GetProducts/run.ps1 b/samples/samples-powershell/GetProducts/run.ps1 new file mode 100644 index 000000000..53e94ca3a --- /dev/null +++ b/samples/samples-powershell/GetProducts/run.ps1 @@ -0,0 +1,14 @@ +using namespace System.Net + +# Trigger and input binding data are passed in via the param block. +param($Request, $products) + +# Write to the Azure Functions log stream. +Write-Host "PowerShell function with SQL Input Binding processed a request." + +# 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 = [System.Net.HttpStatusCode]::OK + Body = $products +}) \ No newline at end of file diff --git a/samples/samples-powershell/GetProductsNameEmpty/function.json b/samples/samples-powershell/GetProductsNameEmpty/function.json new file mode 100644 index 000000000..21240f90f --- /dev/null +++ b/samples/samples-powershell/GetProductsNameEmpty/function.json @@ -0,0 +1,29 @@ +{ + "bindings": [ + { + "authLevel": "function", + "name": "req", + "type": "httpTrigger", + "direction": "in", + "methods": [ + "get" + ], + "route":"getproducts-nameempty/{cost}" + }, + { + "name": "response", + "type": "http", + "direction": "out" + }, + { + "name": "products", + "type": "sql", + "direction": "in", + "commandText": "select * from Products where Cost = @Cost and Name = @Name", + "commandType": "Text", + "parameters": "@Cost={cost},@Name=", + "connectionStringSetting": "SqlConnectionString" + } + ], + "disabled": false +} \ No newline at end of file diff --git a/samples/samples-powershell/GetProductsNameEmpty/run.ps1 b/samples/samples-powershell/GetProductsNameEmpty/run.ps1 new file mode 100644 index 000000000..53e94ca3a --- /dev/null +++ b/samples/samples-powershell/GetProductsNameEmpty/run.ps1 @@ -0,0 +1,14 @@ +using namespace System.Net + +# Trigger and input binding data are passed in via the param block. +param($Request, $products) + +# Write to the Azure Functions log stream. +Write-Host "PowerShell function with SQL Input Binding processed a request." + +# 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 = [System.Net.HttpStatusCode]::OK + Body = $products +}) \ No newline at end of file diff --git a/samples/samples-powershell/GetProductsStoredProcedure/function.json b/samples/samples-powershell/GetProductsStoredProcedure/function.json new file mode 100644 index 000000000..060bbc6b1 --- /dev/null +++ b/samples/samples-powershell/GetProductsStoredProcedure/function.json @@ -0,0 +1,29 @@ +{ + "bindings": [ + { + "authLevel": "function", + "name": "req", + "type": "httpTrigger", + "direction": "in", + "methods": [ + "get" + ], + "route": "getproducts-storedprocedure/{cost}" + }, + { + "name": "response", + "type": "http", + "direction": "out" + }, + { + "name": "products", + "type": "sql", + "direction": "in", + "commandText": "SelectProductsCost", + "commandType": "StoredProcedure", + "parameters": "@Cost={cost}", + "connectionStringSetting": "SqlConnectionString" + } + ], + "disabled": false +} \ No newline at end of file diff --git a/samples/samples-powershell/GetProductsStoredProcedure/run.ps1 b/samples/samples-powershell/GetProductsStoredProcedure/run.ps1 new file mode 100644 index 000000000..53e94ca3a --- /dev/null +++ b/samples/samples-powershell/GetProductsStoredProcedure/run.ps1 @@ -0,0 +1,14 @@ +using namespace System.Net + +# Trigger and input binding data are passed in via the param block. +param($Request, $products) + +# Write to the Azure Functions log stream. +Write-Host "PowerShell function with SQL Input Binding processed a request." + +# 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 = [System.Net.HttpStatusCode]::OK + Body = $products +}) \ No newline at end of file diff --git a/samples/samples-powershell/GetProductsStoredProcedureFromAppSetting/function.json b/samples/samples-powershell/GetProductsStoredProcedureFromAppSetting/function.json new file mode 100644 index 000000000..b5350169c --- /dev/null +++ b/samples/samples-powershell/GetProductsStoredProcedureFromAppSetting/function.json @@ -0,0 +1,29 @@ +{ + "bindings": [ + { + "authLevel": "function", + "name": "req", + "type": "httpTrigger", + "direction": "in", + "methods": [ + "get" + ], + "route": "getproductsbycost" + }, + { + "name": "response", + "type": "http", + "direction": "out" + }, + { + "name": "products", + "type": "sql", + "direction": "in", + "commandText": "%Sp_SelectCost%", + "commandType": "StoredProcedure", + "parameters": "@Cost=%ProductCost%", + "connectionStringSetting": "SqlConnectionString" + } + ], + "disabled": false +} \ No newline at end of file diff --git a/samples/samples-powershell/GetProductsStoredProcedureFromAppSetting/run.ps1 b/samples/samples-powershell/GetProductsStoredProcedureFromAppSetting/run.ps1 new file mode 100644 index 000000000..53e94ca3a --- /dev/null +++ b/samples/samples-powershell/GetProductsStoredProcedureFromAppSetting/run.ps1 @@ -0,0 +1,14 @@ +using namespace System.Net + +# Trigger and input binding data are passed in via the param block. +param($Request, $products) + +# Write to the Azure Functions log stream. +Write-Host "PowerShell function with SQL Input Binding processed a request." + +# 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 = [System.Net.HttpStatusCode]::OK + Body = $products +}) \ No newline at end of file diff --git a/samples/samples-powershell/QueueTriggerProducts/function.json b/samples/samples-powershell/QueueTriggerProducts/function.json new file mode 100644 index 000000000..0e0ecaaa9 --- /dev/null +++ b/samples/samples-powershell/QueueTriggerProducts/function.json @@ -0,0 +1,23 @@ +{ + "bindings": [ + { + "type": "queueTrigger", + "direction": "in", + "name": "queueMessage", + "queueName": "testqueue" + }, + { + "name": "response", + "type": "http", + "direction": "out" + }, + { + "name": "products", + "type": "sql", + "direction": "out", + "commandText": "[dbo].[Products]", + "connectionStringSetting": "SqlConnectionString" + } + ], + "disabled": false +} \ No newline at end of file diff --git a/samples/samples-powershell/QueueTriggerProducts/run.ps1 b/samples/samples-powershell/QueueTriggerProducts/run.ps1 new file mode 100644 index 000000000..0a748feac --- /dev/null +++ b/samples/samples-powershell/QueueTriggerProducts/run.ps1 @@ -0,0 +1,27 @@ +using namespace System.Net + +# Trigger binding data passed in via param block +param($Request) +$totalUpserts = 100; +# Write to the Azure Functions log stream. +Write-Host "[QueueTrigger]: $Get-Date starting execution $queueMessage. Rows to generate=$totalUpserts." + +# 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. +$start = Get-Date + +$products = @() +for ($i = 0; $i -lt $totalUpserts; $i++) { + $products += [PSCustomObject]@{ + productId = $i; + name = "test"; + cost = 100 * $i; + } +} +# 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 $products +$duration = Get-Date - $start; + +Write-Host "[QueueTrigger]: $Get-Date finished execution $queueMessage. Total time to create $totalUpserts rows=$duration." \ No newline at end of file diff --git a/samples/samples-powershell/TimerTriggerProducts/function.json b/samples/samples-powershell/TimerTriggerProducts/function.json new file mode 100644 index 000000000..009103f51 --- /dev/null +++ b/samples/samples-powershell/TimerTriggerProducts/function.json @@ -0,0 +1,23 @@ +{ + "bindings": [ + { + "schedule": "*/5 * * * * *", + "name": "myTimer", + "type": "timerTrigger", + "direction": "in" + }, + { + "name": "response", + "type": "http", + "direction": "out" + }, + { + "name": "products", + "type": "sql", + "direction": "out", + "commandText": "[dbo].[Products]", + "connectionStringSetting": "SqlConnectionString" + } + ], + "disabled": false +} \ No newline at end of file diff --git a/samples/samples-powershell/TimerTriggerProducts/run.ps1 b/samples/samples-powershell/TimerTriggerProducts/run.ps1 new file mode 100644 index 000000000..bc75f510f --- /dev/null +++ b/samples/samples-powershell/TimerTriggerProducts/run.ps1 @@ -0,0 +1,31 @@ +using namespace System.Net + +# Trigger binding data passed in via param block +$executionNumber = 0; +param($Request) +$totalUpserts = 100; +# Write to the Azure Functions log stream. +Write-Host "[QueueTrigger]: $Get-Date starting execution $executionNumber. Rows to generate=$totalUpserts." + +# 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. +$start = Get-Date + +$products = @() +for ($i = 0; $i -lt $totalUpserts; $i++) { + $products += [PSCustomObject]@{ + productId = $i; + name = "test"; + cost = 100 * $i; + } +} +$duration = Get-Date - $start; + +# 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 $products + +Write-Host "[QueueTrigger]: $Get-Date finished execution $queueMessage. Total time to create $totalUpserts rows=$duration." + +$executionNumber += 1; \ No newline at end of file diff --git a/samples/samples-powershell/host.json b/samples/samples-powershell/host.json new file mode 100644 index 000000000..851bea8aa --- /dev/null +++ b/samples/samples-powershell/host.json @@ -0,0 +1,15 @@ +{ + "version": "2.0", + "logging": { + "applicationInsights": { + "samplingSettings": { + "isEnabled": true, + "excludedTypes": "Request" + } + } + }, + "extensionBundle": { + "id": "Microsoft.Azure.Functions.ExtensionBundle.Preview", + "version": "[4.*, 5.0.0)" + } +} diff --git a/test/Integration/IntegrationTestBase.cs b/test/Integration/IntegrationTestBase.cs index 4fe1db996..4f8b5d67f 100644 --- a/test/Integration/IntegrationTestBase.cs +++ b/test/Integration/IntegrationTestBase.cs @@ -9,7 +9,6 @@ using System.IO; using System.Net.Http; using System.Reflection; -using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using Xunit; @@ -187,7 +186,8 @@ protected void StartFunctionHost(string functionName, SupportedLanguages languag { // The full path to the Functions CLI is required in the ProcessStartInfo because UseShellExecute is set to false. // We cannot both use shell execute and redirect output at the same time: https://docs.microsoft.com//dotnet/api/system.diagnostics.processstartinfo.redirectstandardoutput#remarks - FileName = GetFunctionsCoreToolsPath(), + // FileName = GetFunctionsCoreToolsPath(), + FileName = "/usr/local/lib/node_modules/azure-functions-core-tools/bin/func", Arguments = $"start --verbose --port {this.Port} --functions {functionName}", WorkingDirectory = workingDirectory, WindowStyle = ProcessWindowStyle.Hidden, @@ -243,38 +243,38 @@ void SignalStartupHandler(object sender, DataReceivedEventArgs e) taskCompletionSource.Task.Wait(60000); } - private static string GetFunctionsCoreToolsPath() - { - // Determine npm install path from either env var set by pipeline or OS defaults - // Pipeline env var is needed as the Windows hosted agents installs to a non-traditional location - string nodeModulesPath = Environment.GetEnvironmentVariable("NODE_MODULES_PATH"); - if (string.IsNullOrEmpty(nodeModulesPath)) - { - nodeModulesPath = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? - Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"npm\node_modules\") : - @"/usr/local/lib/node_modules"; - } - - string funcExe = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "func.exe" : "func"; - string funcPath = Path.Combine(nodeModulesPath, "azure-functions-core-tools", "bin", funcExe); - - if (!File.Exists(funcPath)) - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Search Program Files folder as well - string programFilesFuncPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Microsoft", "Azure Functions Core Tools", funcExe); - if (File.Exists(programFilesFuncPath)) - { - return programFilesFuncPath; - } - throw new FileNotFoundException($"Azure Function Core Tools not found at {funcPath} or {programFilesFuncPath}"); - } - throw new FileNotFoundException($"Azure Function Core Tools not found at {funcPath}"); - } - - return funcPath; - } + // private static string GetFunctionsCoreToolsPath() + // { + // // Determine npm install path from either env var set by pipeline or OS defaults + // // Pipeline env var is needed as the Windows hosted agents installs to a non-traditional location + // string nodeModulesPath = Environment.GetEnvironmentVariable("NODE_MODULES_PATH"); + // if (string.IsNullOrEmpty(nodeModulesPath)) + // { + // nodeModulesPath = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? + // Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"npm\node_modules\") : + // @"/usr/local/lib/node_modules"; + // } + + // string funcExe = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "func.exe" : "func"; + // string funcPath = Path.Combine(nodeModulesPath, "azure-functions-core-tools", "bin", funcExe); + + // if (!File.Exists(funcPath)) + // { + // if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + // { + // // Search Program Files folder as well + // string programFilesFuncPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Microsoft", "Azure Functions Core Tools", funcExe); + // if (File.Exists(programFilesFuncPath)) + // { + // return programFilesFuncPath; + // } + // throw new FileNotFoundException($"Azure Function Core Tools not found at {funcPath} or {programFilesFuncPath}"); + // } + // throw new FileNotFoundException($"Azure Function Core Tools not found at {funcPath}"); + // } + + // return funcPath; + // } private void LogOutput(string output) { diff --git a/test/Integration/SqlInputBindingIntegrationTests.cs b/test/Integration/SqlInputBindingIntegrationTests.cs index 7b63908a1..3fa33c778 100644 --- a/test/Integration/SqlInputBindingIntegrationTests.cs +++ b/test/Integration/SqlInputBindingIntegrationTests.cs @@ -18,11 +18,11 @@ public class SqlInputBindingIntegrationTests : IntegrationTestBase public SqlInputBindingIntegrationTests(ITestOutputHelper output) : base(output) { } - [Theory] [SqlInlineData(0, 100)] [SqlInlineData(1, -500)] [SqlInlineData(100, 500)] + [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] public async void GetProductsTest(int n, int cost, SupportedLanguages lang) { this.StartFunctionHost(nameof(GetProducts), lang); @@ -45,6 +45,8 @@ public async void GetProductsTest(int n, int cost, SupportedLanguages lang) [SqlInlineData(0, 99)] [SqlInlineData(1, -999)] [SqlInlineData(100, 999)] + [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] + public async void GetProductsStoredProcedureTest(int n, int cost, SupportedLanguages lang) { this.StartFunctionHost(nameof(GetProductsStoredProcedure), lang); @@ -67,6 +69,8 @@ public async void GetProductsStoredProcedureTest(int n, int cost, SupportedLangu [SqlInlineData(0, 0)] [SqlInlineData(1, 20)] [SqlInlineData(100, 1000)] + [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] + public async void GetProductsNameEmptyTest(int n, int cost, SupportedLanguages lang) { this.StartFunctionHost(nameof(GetProductsNameEmpty), lang); @@ -92,6 +96,7 @@ public async void GetProductsNameEmptyTest(int n, int cost, SupportedLanguages l [Theory] [SqlInlineData()] + [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] public async void GetProductsByCostTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(GetProductsStoredProcedureFromAppSetting), lang); @@ -112,6 +117,7 @@ public async void GetProductsByCostTest(SupportedLanguages lang) } [Theory] + [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] [SqlInlineData()] public async void GetProductNamesViewTest(SupportedLanguages lang) { @@ -137,7 +143,7 @@ public async void GetProductNamesViewTest(SupportedLanguages lang) /// [Theory] [SqlInlineData()] - [UnsupportedLanguages(SupportedLanguages.JavaScript)] // Javascript doesn't have the concept of a runtime language used during serialization + [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] public async void GetProductsColumnTypesSerializationDifferentCultureTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(GetProductsColumnTypesSerializationDifferentCulture), lang, true); @@ -157,6 +163,8 @@ public async void GetProductsColumnTypesSerializationDifferentCultureTest(Suppor /// [Theory] [SqlInlineData()] + [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] + public async void GetProductsColumnTypesSerializationTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(GetProductsColumnTypesSerialization), lang, true); diff --git a/test/Integration/SqlOutputBindingIntegrationTests.cs b/test/Integration/SqlOutputBindingIntegrationTests.cs index 9891cb526..fb9748eda 100644 --- a/test/Integration/SqlOutputBindingIntegrationTests.cs +++ b/test/Integration/SqlOutputBindingIntegrationTests.cs @@ -19,11 +19,12 @@ public class SqlOutputBindingIntegrationTests : IntegrationTestBase public SqlOutputBindingIntegrationTests(ITestOutputHelper output) : base(output) { } - [Theory] [SqlInlineData(1, "Test", 5)] [SqlInlineData(0, "", 0)] [SqlInlineData(-500, "ABCD", 580)] + [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] + public void AddProductTest(int id, string name, int cost, SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProduct), lang); @@ -46,6 +47,8 @@ public void AddProductTest(int id, string name, int cost, SupportedLanguages lan [SqlInlineData(1, "Test", 5)] [SqlInlineData(0, "", 0)] [SqlInlineData(-500, "ABCD", 580)] + [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] + public void AddProductParamsTest(int id, string name, int cost, SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductParams), lang); @@ -66,6 +69,8 @@ public void AddProductParamsTest(int id, string name, int cost, SupportedLanguag [Theory] [SqlInlineData()] + [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] + public void AddProductArrayTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductsArray), lang); @@ -106,6 +111,8 @@ public void AddProductArrayTest(SupportedLanguages lang) /// The language to run the test against [Theory] [SqlInlineData()] + [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] + public void AddProductColumnTypesTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductColumnTypes), lang, true); @@ -122,7 +129,8 @@ public void AddProductColumnTypesTest(SupportedLanguages lang) [Theory] [SqlInlineData()] - [UnsupportedLanguages(SupportedLanguages.JavaScript)] // Collectors are only available in C# + [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] + public void AddProductsCollectorTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductsCollector), lang); @@ -135,6 +143,8 @@ public void AddProductsCollectorTest(SupportedLanguages lang) [Theory] [SqlInlineData()] + [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] + public void QueueTriggerProductsTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(QueueTriggerProducts), lang); @@ -152,6 +162,8 @@ public void QueueTriggerProductsTest(SupportedLanguages lang) [Theory] [SqlInlineData()] + [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] + public void TimerTriggerProductsTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(TimerTriggerProducts), lang); @@ -166,6 +178,8 @@ public void TimerTriggerProductsTest(SupportedLanguages lang) [Theory] [SqlInlineData()] + [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] + public void AddProductExtraColumnsTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductExtraColumns), lang, true); @@ -178,6 +192,8 @@ public void AddProductExtraColumnsTest(SupportedLanguages lang) [Theory] [SqlInlineData()] + [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] + public void AddProductMissingColumnsTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductMissingColumns), lang, true); @@ -190,6 +206,8 @@ public void AddProductMissingColumnsTest(SupportedLanguages lang) [Theory] [SqlInlineData()] + [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] + public void AddProductMissingColumnsNotNullTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductMissingColumnsExceptionFunction), lang, true); @@ -201,6 +219,8 @@ public void AddProductMissingColumnsNotNullTest(SupportedLanguages lang) [Theory] [SqlInlineData()] + [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] + public void AddProductNoPartialUpsertTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductsNoPartialUpsert), lang, true); @@ -215,6 +235,8 @@ public void AddProductNoPartialUpsertTest(SupportedLanguages lang) /// [Theory] [SqlInlineData()] + [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] + public void AddProductWithIdentity(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductWithIdentityColumn), lang); @@ -235,6 +257,8 @@ public void AddProductWithIdentity(SupportedLanguages lang) /// [Theory] [SqlInlineData()] + [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] + public void AddProductsWithIdentityColumnArray(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductsWithIdentityColumnArray), lang); @@ -250,6 +274,8 @@ public void AddProductsWithIdentityColumnArray(SupportedLanguages lang) /// [Theory] [SqlInlineData()] + [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] + public void AddProductWithIdentity_MultiplePrimaryColumns(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductWithMultiplePrimaryColumnsAndIdentity), lang); @@ -271,6 +297,8 @@ public void AddProductWithIdentity_MultiplePrimaryColumns(SupportedLanguages lan /// [Theory] [SqlInlineData()] + [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] + public void AddProductWithIdentity_SpecifyIdentityColumn(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductWithIdentityColumnIncluded), lang); @@ -301,6 +329,8 @@ public void AddProductWithIdentity_SpecifyIdentityColumn(SupportedLanguages lang /// [Theory] [SqlInlineData()] + [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] + public void AddProductWithIdentity_NoIdentityColumn(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductWithIdentityColumnIncluded), lang); @@ -329,6 +359,8 @@ public void AddProductWithIdentity_NoIdentityColumn(SupportedLanguages lang) /// [Theory] [SqlInlineData()] + [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] + public void AddProductWithIdentity_MissingPrimaryColumn(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductWithMultiplePrimaryColumnsAndIdentity), lang); @@ -350,6 +382,8 @@ public void AddProductWithIdentity_MissingPrimaryColumn(SupportedLanguages lang) /// [Theory] [SqlInlineData()] + [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] + public void AddProductCaseSensitiveTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductParams), lang); @@ -384,6 +418,8 @@ public void AddProductCaseSensitiveTest(SupportedLanguages lang) /// [Theory] [SqlInlineData()] + [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] + public void AddProductWithDefaultPKTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductWithDefaultPK), lang); diff --git a/test/Integration/test-powershell/AddProductColumnTypes/function.json b/test/Integration/test-powershell/AddProductColumnTypes/function.json new file mode 100644 index 000000000..2345f96b5 --- /dev/null +++ b/test/Integration/test-powershell/AddProductColumnTypes/function.json @@ -0,0 +1,28 @@ +{ + "bindings": [ + { + "authLevel": "function", + "name": "req", + "direction": "in", + "type": "httpTrigger", + "methods": [ + "get" + ], + "route": "addproduct-columntypes" + }, + { + "name": "response", + "type": "http", + "direction": "out" + }, + { + "name": "product", + "type": "sql", + "direction": "out", + "commandText": "[dbo].[ProductsColumnTypes]", + "commandType": "Text", + "connectionStringSetting": "SqlConnectionString" + } + ], + "disabled": false +} \ No newline at end of file diff --git a/test/Integration/test-powershell/AddProductColumnTypes/run.ps1 b/test/Integration/test-powershell/AddProductColumnTypes/run.ps1 new file mode 100644 index 000000000..7ee0b62ef --- /dev/null +++ b/test/Integration/test-powershell/AddProductColumnTypes/run.ps1 @@ -0,0 +1,27 @@ +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 SQL 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 = @{ + productId=$Request.Body?.productId; + datetime= Get-Date; + datetime2= Get-Date; +}; + +# 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_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 +}) \ No newline at end of file diff --git a/test/Microsoft.Azure.WebJobs.Extensions.Sql.Tests.csproj b/test/Microsoft.Azure.WebJobs.Extensions.Sql.Tests.csproj index 78af40db5..075a7091a 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.Sql.Tests.csproj +++ b/test/Microsoft.Azure.WebJobs.Extensions.Sql.Tests.csproj @@ -32,5 +32,11 @@ + + <_PSCopyItems Include="..\samples\samples-powershell\**\*.*" /> + <_PSCopyItems Include="Integration\test-powershell\**\*.*" /> + + + From d3b5a3f0353a4de92f70808a6860f08bac38b57a Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Fri, 21 Oct 2022 12:34:19 -0700 Subject: [PATCH 02/41] add further tests --- .../Common/SupportedLanguagesTestAttribute.cs | 3 +- test/Integration/IntegrationTestBase.cs | 2 +- .../AddProductExtraColumns/function.json | 27 +++++++++++++ .../AddProductExtraColumns/run.ps1 | 26 ++++++++++++ .../AddProductMissingColumns/function.json | 27 +++++++++++++ .../AddProductMissingColumns/run.ps1 | 26 ++++++++++++ .../function.json | 27 +++++++++++++ .../run.ps1 | 26 ++++++++++++ .../AddProductsNoPartialUpsert/function.json | 27 +++++++++++++ .../AddProductsNoPartialUpsert/run.ps1 | 40 +++++++++++++++++++ .../function.json | 28 +++++++++++++ .../run.ps1 | 14 +++++++ 12 files changed, 271 insertions(+), 2 deletions(-) create mode 100644 test/Integration/test-powershell/AddProductExtraColumns/function.json create mode 100644 test/Integration/test-powershell/AddProductExtraColumns/run.ps1 create mode 100644 test/Integration/test-powershell/AddProductMissingColumns/function.json create mode 100644 test/Integration/test-powershell/AddProductMissingColumns/run.ps1 create mode 100644 test/Integration/test-powershell/AddProductMissingColumnsExceptionFunction/function.json create mode 100644 test/Integration/test-powershell/AddProductMissingColumnsExceptionFunction/run.ps1 create mode 100644 test/Integration/test-powershell/AddProductsNoPartialUpsert/function.json create mode 100644 test/Integration/test-powershell/AddProductsNoPartialUpsert/run.ps1 create mode 100644 test/Integration/test-powershell/GetProductsColumnTypesSerialization/function.json create mode 100644 test/Integration/test-powershell/GetProductsColumnTypesSerialization/run.ps1 diff --git a/test/Common/SupportedLanguagesTestAttribute.cs b/test/Common/SupportedLanguagesTestAttribute.cs index 435bad3b5..d4c3ac014 100644 --- a/test/Common/SupportedLanguagesTestAttribute.cs +++ b/test/Common/SupportedLanguagesTestAttribute.cs @@ -71,6 +71,7 @@ public UnsupportedLanguagesAttribute(params SupportedLanguages[] argsWithUnsuppo public enum SupportedLanguages { CSharp, - JavaScript + JavaScript, + PowerShell }; } \ No newline at end of file diff --git a/test/Integration/IntegrationTestBase.cs b/test/Integration/IntegrationTestBase.cs index 4f8b5d67f..a93f10ac0 100644 --- a/test/Integration/IntegrationTestBase.cs +++ b/test/Integration/IntegrationTestBase.cs @@ -187,7 +187,7 @@ protected void StartFunctionHost(string functionName, SupportedLanguages languag // The full path to the Functions CLI is required in the ProcessStartInfo because UseShellExecute is set to false. // We cannot both use shell execute and redirect output at the same time: https://docs.microsoft.com//dotnet/api/system.diagnostics.processstartinfo.redirectstandardoutput#remarks // FileName = GetFunctionsCoreToolsPath(), - FileName = "/usr/local/lib/node_modules/azure-functions-core-tools/bin/func", + FileName = "/usr/local/bin/func", Arguments = $"start --verbose --port {this.Port} --functions {functionName}", WorkingDirectory = workingDirectory, WindowStyle = ProcessWindowStyle.Hidden, diff --git a/test/Integration/test-powershell/AddProductExtraColumns/function.json b/test/Integration/test-powershell/AddProductExtraColumns/function.json new file mode 100644 index 000000000..cd7eba6dd --- /dev/null +++ b/test/Integration/test-powershell/AddProductExtraColumns/function.json @@ -0,0 +1,27 @@ +{ + "bindings": [ + { + "authLevel": "function", + "name": "req", + "direction": "in", + "type": "httpTrigger", + "methods": [ + "post" + ], + "route": "addproduct-extracolumns" + }, + { + "name": "response", + "type": "http", + "direction": "out" + }, + { + "name": "products", + "type": "sql", + "direction": "out", + "commandText": "[dbo].[Products]", + "connectionStringSetting": "SqlConnectionString" + } + ], + "disabled": false +} \ No newline at end of file diff --git a/test/Integration/test-powershell/AddProductExtraColumns/run.ps1 b/test/Integration/test-powershell/AddProductExtraColumns/run.ps1 new file mode 100644 index 000000000..7fd866193 --- /dev/null +++ b/test/Integration/test-powershell/AddProductExtraColumns/run.ps1 @@ -0,0 +1,26 @@ +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 SQL 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 = @{ + productId=1; + name="MissingCost"; +}; + +# 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_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 +}) \ No newline at end of file diff --git a/test/Integration/test-powershell/AddProductMissingColumns/function.json b/test/Integration/test-powershell/AddProductMissingColumns/function.json new file mode 100644 index 000000000..37bc4fd07 --- /dev/null +++ b/test/Integration/test-powershell/AddProductMissingColumns/function.json @@ -0,0 +1,27 @@ +{ + "bindings": [ + { + "authLevel": "function", + "name": "req", + "direction": "in", + "type": "httpTrigger", + "methods": [ + "post" + ], + "route": "addproduct-missingcolumns" + }, + { + "name": "response", + "type": "http", + "direction": "out" + }, + { + "name": "products", + "type": "sql", + "direction": "out", + "commandText": "[dbo].[Products]", + "connectionStringSetting": "SqlConnectionString" + } + ], + "disabled": false +} \ No newline at end of file diff --git a/test/Integration/test-powershell/AddProductMissingColumns/run.ps1 b/test/Integration/test-powershell/AddProductMissingColumns/run.ps1 new file mode 100644 index 000000000..7fd866193 --- /dev/null +++ b/test/Integration/test-powershell/AddProductMissingColumns/run.ps1 @@ -0,0 +1,26 @@ +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 SQL 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 = @{ + productId=1; + name="MissingCost"; +}; + +# 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_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 +}) \ No newline at end of file diff --git a/test/Integration/test-powershell/AddProductMissingColumnsExceptionFunction/function.json b/test/Integration/test-powershell/AddProductMissingColumnsExceptionFunction/function.json new file mode 100644 index 000000000..d038a4701 --- /dev/null +++ b/test/Integration/test-powershell/AddProductMissingColumnsExceptionFunction/function.json @@ -0,0 +1,27 @@ +{ + "bindings": [ + { + "authLevel": "function", + "name": "req", + "direction": "in", + "type": "httpTrigger", + "methods": [ + "post" + ], + "route": "addproduct-missingcolumnsexception" + }, + { + "name": "response", + "type": "http", + "direction": "out" + }, + { + "name": "products", + "type": "sql", + "direction": "out", + "commandText": "[dbo].[ProductsCostNotNull]", + "connectionStringSetting": "SqlConnectionString" + } + ], + "disabled": false +} \ No newline at end of file diff --git a/test/Integration/test-powershell/AddProductMissingColumnsExceptionFunction/run.ps1 b/test/Integration/test-powershell/AddProductMissingColumnsExceptionFunction/run.ps1 new file mode 100644 index 000000000..7fd866193 --- /dev/null +++ b/test/Integration/test-powershell/AddProductMissingColumnsExceptionFunction/run.ps1 @@ -0,0 +1,26 @@ +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 SQL 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 = @{ + productId=1; + name="MissingCost"; +}; + +# 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_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 +}) \ No newline at end of file diff --git a/test/Integration/test-powershell/AddProductsNoPartialUpsert/function.json b/test/Integration/test-powershell/AddProductsNoPartialUpsert/function.json new file mode 100644 index 000000000..36ac1d612 --- /dev/null +++ b/test/Integration/test-powershell/AddProductsNoPartialUpsert/function.json @@ -0,0 +1,27 @@ +{ + "bindings": [ + { + "authLevel": "function", + "name": "req", + "direction": "in", + "type": "httpTrigger", + "methods": [ + "post" + ], + "route": "addproducts-nopartialupsert" + }, + { + "name": "response", + "type": "http", + "direction": "out" + }, + { + "name": "products", + "type": "sql", + "direction": "out", + "commandText": "[dbo].[ProductsNameNotNull]", + "connectionStringSetting": "SqlConnectionString" + } + ], + "disabled": false +} \ No newline at end of file diff --git a/test/Integration/test-powershell/AddProductsNoPartialUpsert/run.ps1 b/test/Integration/test-powershell/AddProductsNoPartialUpsert/run.ps1 new file mode 100644 index 000000000..ce1b50e96 --- /dev/null +++ b/test/Integration/test-powershell/AddProductsNoPartialUpsert/run.ps1 @@ -0,0 +1,40 @@ +using namespace System.Net + +# Trigger binding data passed in via param block +param($Request) +$totalUpserts = 100; +# Write to the Azure Functions log stream. +Write-Host "[QueueTrigger]: $Get-Date starting execution $queueMessage. Rows to generate=$totalUpserts." + +# 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. +$start = Get-Date + +$products = @() +for ($i = 0; $i -lt 1000; $i++) { + $products += [PSCustomObject]@{ + productId = $i; + name = "test"; + cost = 100 * $i; + } +} + +$invalidProduct = @{ + productId=1000; + name=$null; + cost=1000; +}; + +$products += $invalidProduct + +# 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 $products + +# 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 = $products +}) \ No newline at end of file diff --git a/test/Integration/test-powershell/GetProductsColumnTypesSerialization/function.json b/test/Integration/test-powershell/GetProductsColumnTypesSerialization/function.json new file mode 100644 index 000000000..8f1bd3b29 --- /dev/null +++ b/test/Integration/test-powershell/GetProductsColumnTypesSerialization/function.json @@ -0,0 +1,28 @@ +{ + "bindings": [ + { + "authLevel": "function", + "name": "req", + "type": "httpTrigger", + "direction": "in", + "methods": [ + "get" + ], + "route": "getproducts-columntypesserialization" + }, + { + "name": "response", + "type": "http", + "direction": "out" + }, + { + "name": "products", + "type": "sql", + "direction": "in", + "commandText": "SELECT * FROM [dbo].[ProductsColumnTypes]", + "commandType": "Text", + "connectionStringSetting": "SqlConnectionString" + } + ], + "disabled": false +} \ No newline at end of file diff --git a/test/Integration/test-powershell/GetProductsColumnTypesSerialization/run.ps1 b/test/Integration/test-powershell/GetProductsColumnTypesSerialization/run.ps1 new file mode 100644 index 000000000..53e94ca3a --- /dev/null +++ b/test/Integration/test-powershell/GetProductsColumnTypesSerialization/run.ps1 @@ -0,0 +1,14 @@ +using namespace System.Net + +# Trigger and input binding data are passed in via the param block. +param($Request, $products) + +# Write to the Azure Functions log stream. +Write-Host "PowerShell function with SQL Input Binding processed a request." + +# 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 = [System.Net.HttpStatusCode]::OK + Body = $products +}) \ No newline at end of file From c92fa647b64fc56bfc14a5b0d99907dbefe2a020 Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Fri, 21 Oct 2022 15:21:20 -0700 Subject: [PATCH 03/41] fix powershell test --- .../AddProduct/function.json | 2 +- .../AddProductParams/function.json | 2 +- .../AddProductWithDefaultPK/function.json | 2 +- .../function.json | 2 +- .../function.json | 2 +- .../function.json | 2 +- .../AddProductsArray/function.json | 2 +- .../function.json | 2 +- .../GetProductNamesView/function.json | 2 +- .../GetProducts/function.json | 2 +- .../GetProductsNameEmpty/function.json | 2 +- .../GetProductsStoredProcedure/function.json | 2 +- .../function.json | 2 +- test/Integration/IntegrationTestBase.cs | 67 +++++++++---------- .../SqlInputBindingIntegrationTests.cs | 11 +-- .../SqlOutputBindingIntegrationTests.cs | 43 +----------- 16 files changed, 50 insertions(+), 97 deletions(-) diff --git a/samples/samples-powershell/AddProduct/function.json b/samples/samples-powershell/AddProduct/function.json index 2afd45793..70e0a55cd 100644 --- a/samples/samples-powershell/AddProduct/function.json +++ b/samples/samples-powershell/AddProduct/function.json @@ -2,7 +2,7 @@ "bindings": [ { "authLevel": "function", - "name": "req", + "name": "Request", "direction": "in", "type": "httpTrigger", "methods": [ diff --git a/samples/samples-powershell/AddProductParams/function.json b/samples/samples-powershell/AddProductParams/function.json index f39b06ca3..0ee720829 100644 --- a/samples/samples-powershell/AddProductParams/function.json +++ b/samples/samples-powershell/AddProductParams/function.json @@ -2,7 +2,7 @@ "bindings": [ { "authLevel": "function", - "name": "req", + "name": "Request", "direction": "in", "type": "httpTrigger", "methods": [ diff --git a/samples/samples-powershell/AddProductWithDefaultPK/function.json b/samples/samples-powershell/AddProductWithDefaultPK/function.json index 028fde758..c7d30f29f 100644 --- a/samples/samples-powershell/AddProductWithDefaultPK/function.json +++ b/samples/samples-powershell/AddProductWithDefaultPK/function.json @@ -2,7 +2,7 @@ "bindings": [ { "authLevel": "function", - "name": "req", + "name": "Request", "direction": "in", "type": "httpTrigger", "methods": [ diff --git a/samples/samples-powershell/AddProductWithIdentityColumn/function.json b/samples/samples-powershell/AddProductWithIdentityColumn/function.json index 0993c49f3..a186392be 100644 --- a/samples/samples-powershell/AddProductWithIdentityColumn/function.json +++ b/samples/samples-powershell/AddProductWithIdentityColumn/function.json @@ -2,7 +2,7 @@ "bindings": [ { "authLevel": "function", - "name": "req", + "name": "Request", "direction": "in", "type": "httpTrigger", "methods": [ diff --git a/samples/samples-powershell/AddProductWithIdentityColumnIncluded/function.json b/samples/samples-powershell/AddProductWithIdentityColumnIncluded/function.json index db9cd8dac..bd7137c52 100644 --- a/samples/samples-powershell/AddProductWithIdentityColumnIncluded/function.json +++ b/samples/samples-powershell/AddProductWithIdentityColumnIncluded/function.json @@ -2,7 +2,7 @@ "bindings": [ { "authLevel": "function", - "name": "req", + "name": "Request", "direction": "in", "type": "httpTrigger", "methods": [ diff --git a/samples/samples-powershell/AddProductWithMultiplePrimaryColumnsAndIdentity/function.json b/samples/samples-powershell/AddProductWithMultiplePrimaryColumnsAndIdentity/function.json index 4320535d5..02252ebf3 100644 --- a/samples/samples-powershell/AddProductWithMultiplePrimaryColumnsAndIdentity/function.json +++ b/samples/samples-powershell/AddProductWithMultiplePrimaryColumnsAndIdentity/function.json @@ -2,7 +2,7 @@ "bindings": [ { "authLevel": "function", - "name": "req", + "name": "Request", "direction": "in", "type": "httpTrigger", "methods": [ diff --git a/samples/samples-powershell/AddProductsArray/function.json b/samples/samples-powershell/AddProductsArray/function.json index baec6005f..55f5b282d 100644 --- a/samples/samples-powershell/AddProductsArray/function.json +++ b/samples/samples-powershell/AddProductsArray/function.json @@ -2,7 +2,7 @@ "bindings": [ { "authLevel": "function", - "name": "req", + "name": "Request", "direction": "in", "type": "httpTrigger", "methods": [ diff --git a/samples/samples-powershell/AddProductsWithIdentityColumnArray/function.json b/samples/samples-powershell/AddProductsWithIdentityColumnArray/function.json index 6b591da2a..09e5ac77e 100644 --- a/samples/samples-powershell/AddProductsWithIdentityColumnArray/function.json +++ b/samples/samples-powershell/AddProductsWithIdentityColumnArray/function.json @@ -2,7 +2,7 @@ "bindings": [ { "authLevel": "function", - "name": "req", + "name": "Request", "direction": "in", "type": "httpTrigger", "methods": [ diff --git a/samples/samples-powershell/GetProductNamesView/function.json b/samples/samples-powershell/GetProductNamesView/function.json index c13b1e092..6fa0b257f 100644 --- a/samples/samples-powershell/GetProductNamesView/function.json +++ b/samples/samples-powershell/GetProductNamesView/function.json @@ -2,7 +2,7 @@ "bindings": [ { "authLevel": "function", - "name": "req", + "name": "Request", "type": "httpTrigger", "direction": "in", "methods": [ diff --git a/samples/samples-powershell/GetProducts/function.json b/samples/samples-powershell/GetProducts/function.json index a1b5c81aa..3de952d09 100644 --- a/samples/samples-powershell/GetProducts/function.json +++ b/samples/samples-powershell/GetProducts/function.json @@ -2,7 +2,7 @@ "bindings": [ { "authLevel": "function", - "name": "req", + "name": "Request", "type": "httpTrigger", "direction": "in", "methods": [ diff --git a/samples/samples-powershell/GetProductsNameEmpty/function.json b/samples/samples-powershell/GetProductsNameEmpty/function.json index 21240f90f..868b2d0e1 100644 --- a/samples/samples-powershell/GetProductsNameEmpty/function.json +++ b/samples/samples-powershell/GetProductsNameEmpty/function.json @@ -2,7 +2,7 @@ "bindings": [ { "authLevel": "function", - "name": "req", + "name": "Request", "type": "httpTrigger", "direction": "in", "methods": [ diff --git a/samples/samples-powershell/GetProductsStoredProcedure/function.json b/samples/samples-powershell/GetProductsStoredProcedure/function.json index 060bbc6b1..47837c658 100644 --- a/samples/samples-powershell/GetProductsStoredProcedure/function.json +++ b/samples/samples-powershell/GetProductsStoredProcedure/function.json @@ -2,7 +2,7 @@ "bindings": [ { "authLevel": "function", - "name": "req", + "name": "Request", "type": "httpTrigger", "direction": "in", "methods": [ diff --git a/samples/samples-powershell/GetProductsStoredProcedureFromAppSetting/function.json b/samples/samples-powershell/GetProductsStoredProcedureFromAppSetting/function.json index b5350169c..6c7469789 100644 --- a/samples/samples-powershell/GetProductsStoredProcedureFromAppSetting/function.json +++ b/samples/samples-powershell/GetProductsStoredProcedureFromAppSetting/function.json @@ -2,7 +2,7 @@ "bindings": [ { "authLevel": "function", - "name": "req", + "name": "Request", "type": "httpTrigger", "direction": "in", "methods": [ diff --git a/test/Integration/IntegrationTestBase.cs b/test/Integration/IntegrationTestBase.cs index a93f10ac0..bcd098205 100644 --- a/test/Integration/IntegrationTestBase.cs +++ b/test/Integration/IntegrationTestBase.cs @@ -186,8 +186,7 @@ protected void StartFunctionHost(string functionName, SupportedLanguages languag { // The full path to the Functions CLI is required in the ProcessStartInfo because UseShellExecute is set to false. // We cannot both use shell execute and redirect output at the same time: https://docs.microsoft.com//dotnet/api/system.diagnostics.processstartinfo.redirectstandardoutput#remarks - // FileName = GetFunctionsCoreToolsPath(), - FileName = "/usr/local/bin/func", + FileName = GetFunctionsCoreToolsPath(), Arguments = $"start --verbose --port {this.Port} --functions {functionName}", WorkingDirectory = workingDirectory, WindowStyle = ProcessWindowStyle.Hidden, @@ -243,38 +242,38 @@ void SignalStartupHandler(object sender, DataReceivedEventArgs e) taskCompletionSource.Task.Wait(60000); } - // private static string GetFunctionsCoreToolsPath() - // { - // // Determine npm install path from either env var set by pipeline or OS defaults - // // Pipeline env var is needed as the Windows hosted agents installs to a non-traditional location - // string nodeModulesPath = Environment.GetEnvironmentVariable("NODE_MODULES_PATH"); - // if (string.IsNullOrEmpty(nodeModulesPath)) - // { - // nodeModulesPath = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? - // Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"npm\node_modules\") : - // @"/usr/local/lib/node_modules"; - // } - - // string funcExe = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "func.exe" : "func"; - // string funcPath = Path.Combine(nodeModulesPath, "azure-functions-core-tools", "bin", funcExe); - - // if (!File.Exists(funcPath)) - // { - // if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - // { - // // Search Program Files folder as well - // string programFilesFuncPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Microsoft", "Azure Functions Core Tools", funcExe); - // if (File.Exists(programFilesFuncPath)) - // { - // return programFilesFuncPath; - // } - // throw new FileNotFoundException($"Azure Function Core Tools not found at {funcPath} or {programFilesFuncPath}"); - // } - // throw new FileNotFoundException($"Azure Function Core Tools not found at {funcPath}"); - // } - - // return funcPath; - // } + private static string GetFunctionsCoreToolsPath() + { + // Determine npm install path from either env var set by pipeline or OS defaults + // Pipeline env var is needed as the Windows hosted agents installs to a non-traditional location + string nodeModulesPath = Environment.GetEnvironmentVariable("NODE_MODULES_PATH"); + if (string.IsNullOrEmpty(nodeModulesPath)) + { + nodeModulesPath = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? + Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"npm\node_modules\") : + @"/usr/local/lib/node_modules"; + } + + string funcExe = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "func.exe" : "func"; + string funcPath = Path.Combine(nodeModulesPath, "azure-functions-core-tools", "bin", funcExe); + + if (!File.Exists(funcPath)) + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + // Search Program Files folder as well + string programFilesFuncPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Microsoft", "Azure Functions Core Tools", funcExe); + if (File.Exists(programFilesFuncPath)) + { + return programFilesFuncPath; + } + throw new FileNotFoundException($"Azure Function Core Tools not found at {funcPath} or {programFilesFuncPath}"); + } + throw new FileNotFoundException($"Azure Function Core Tools not found at {funcPath}"); + } + + return funcPath; + } private void LogOutput(string output) { diff --git a/test/Integration/SqlInputBindingIntegrationTests.cs b/test/Integration/SqlInputBindingIntegrationTests.cs index 3fa33c778..b66f4c278 100644 --- a/test/Integration/SqlInputBindingIntegrationTests.cs +++ b/test/Integration/SqlInputBindingIntegrationTests.cs @@ -22,7 +22,6 @@ public SqlInputBindingIntegrationTests(ITestOutputHelper output) : base(output) [SqlInlineData(0, 100)] [SqlInlineData(1, -500)] [SqlInlineData(100, 500)] - [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] public async void GetProductsTest(int n, int cost, SupportedLanguages lang) { this.StartFunctionHost(nameof(GetProducts), lang); @@ -45,8 +44,6 @@ public async void GetProductsTest(int n, int cost, SupportedLanguages lang) [SqlInlineData(0, 99)] [SqlInlineData(1, -999)] [SqlInlineData(100, 999)] - [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] - public async void GetProductsStoredProcedureTest(int n, int cost, SupportedLanguages lang) { this.StartFunctionHost(nameof(GetProductsStoredProcedure), lang); @@ -69,8 +66,6 @@ public async void GetProductsStoredProcedureTest(int n, int cost, SupportedLangu [SqlInlineData(0, 0)] [SqlInlineData(1, 20)] [SqlInlineData(100, 1000)] - [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] - public async void GetProductsNameEmptyTest(int n, int cost, SupportedLanguages lang) { this.StartFunctionHost(nameof(GetProductsNameEmpty), lang); @@ -96,7 +91,6 @@ public async void GetProductsNameEmptyTest(int n, int cost, SupportedLanguages l [Theory] [SqlInlineData()] - [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] public async void GetProductsByCostTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(GetProductsStoredProcedureFromAppSetting), lang); @@ -117,7 +111,6 @@ public async void GetProductsByCostTest(SupportedLanguages lang) } [Theory] - [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] [SqlInlineData()] public async void GetProductNamesViewTest(SupportedLanguages lang) { @@ -143,7 +136,7 @@ public async void GetProductNamesViewTest(SupportedLanguages lang) /// [Theory] [SqlInlineData()] - [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] + [UnsupportedLanguages(SupportedLanguages.JavaScript)] // Javascript doesn't have the concept of a runtime language used during serialization public async void GetProductsColumnTypesSerializationDifferentCultureTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(GetProductsColumnTypesSerializationDifferentCulture), lang, true); @@ -163,8 +156,6 @@ public async void GetProductsColumnTypesSerializationDifferentCultureTest(Suppor /// [Theory] [SqlInlineData()] - [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] - public async void GetProductsColumnTypesSerializationTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(GetProductsColumnTypesSerialization), lang, true); diff --git a/test/Integration/SqlOutputBindingIntegrationTests.cs b/test/Integration/SqlOutputBindingIntegrationTests.cs index fb9748eda..c068837ec 100644 --- a/test/Integration/SqlOutputBindingIntegrationTests.cs +++ b/test/Integration/SqlOutputBindingIntegrationTests.cs @@ -1,5 +1,5 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. +// Copyright(c) Microsoft Corporation.All rights reserved. +// Licensed under the MIT License.See License.txt in the project root for license information. using System; using System.Collections.Generic; @@ -23,8 +23,6 @@ public SqlOutputBindingIntegrationTests(ITestOutputHelper output) : base(output) [SqlInlineData(1, "Test", 5)] [SqlInlineData(0, "", 0)] [SqlInlineData(-500, "ABCD", 580)] - [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] - public void AddProductTest(int id, string name, int cost, SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProduct), lang); @@ -47,8 +45,6 @@ public void AddProductTest(int id, string name, int cost, SupportedLanguages lan [SqlInlineData(1, "Test", 5)] [SqlInlineData(0, "", 0)] [SqlInlineData(-500, "ABCD", 580)] - [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] - public void AddProductParamsTest(int id, string name, int cost, SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductParams), lang); @@ -69,8 +65,6 @@ public void AddProductParamsTest(int id, string name, int cost, SupportedLanguag [Theory] [SqlInlineData()] - [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] - public void AddProductArrayTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductsArray), lang); @@ -111,8 +105,6 @@ public void AddProductArrayTest(SupportedLanguages lang) /// The language to run the test against [Theory] [SqlInlineData()] - [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] - public void AddProductColumnTypesTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductColumnTypes), lang, true); @@ -129,8 +121,7 @@ public void AddProductColumnTypesTest(SupportedLanguages lang) [Theory] [SqlInlineData()] - [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] - + [UnsupportedLanguages(SupportedLanguages.JavaScript, SupportedLanguages.PowerShell)] // Collectors are only available in C# public void AddProductsCollectorTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductsCollector), lang); @@ -143,8 +134,6 @@ public void AddProductsCollectorTest(SupportedLanguages lang) [Theory] [SqlInlineData()] - [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] - public void QueueTriggerProductsTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(QueueTriggerProducts), lang); @@ -162,8 +151,6 @@ public void QueueTriggerProductsTest(SupportedLanguages lang) [Theory] [SqlInlineData()] - [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] - public void TimerTriggerProductsTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(TimerTriggerProducts), lang); @@ -178,8 +165,6 @@ public void TimerTriggerProductsTest(SupportedLanguages lang) [Theory] [SqlInlineData()] - [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] - public void AddProductExtraColumnsTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductExtraColumns), lang, true); @@ -192,8 +177,6 @@ public void AddProductExtraColumnsTest(SupportedLanguages lang) [Theory] [SqlInlineData()] - [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] - public void AddProductMissingColumnsTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductMissingColumns), lang, true); @@ -206,8 +189,6 @@ public void AddProductMissingColumnsTest(SupportedLanguages lang) [Theory] [SqlInlineData()] - [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] - public void AddProductMissingColumnsNotNullTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductMissingColumnsExceptionFunction), lang, true); @@ -219,8 +200,6 @@ public void AddProductMissingColumnsNotNullTest(SupportedLanguages lang) [Theory] [SqlInlineData()] - [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] - public void AddProductNoPartialUpsertTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductsNoPartialUpsert), lang, true); @@ -235,8 +214,6 @@ public void AddProductNoPartialUpsertTest(SupportedLanguages lang) /// [Theory] [SqlInlineData()] - [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] - public void AddProductWithIdentity(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductWithIdentityColumn), lang); @@ -257,8 +234,6 @@ public void AddProductWithIdentity(SupportedLanguages lang) /// [Theory] [SqlInlineData()] - [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] - public void AddProductsWithIdentityColumnArray(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductsWithIdentityColumnArray), lang); @@ -274,8 +249,6 @@ public void AddProductsWithIdentityColumnArray(SupportedLanguages lang) /// [Theory] [SqlInlineData()] - [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] - public void AddProductWithIdentity_MultiplePrimaryColumns(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductWithMultiplePrimaryColumnsAndIdentity), lang); @@ -297,8 +270,6 @@ public void AddProductWithIdentity_MultiplePrimaryColumns(SupportedLanguages lan /// [Theory] [SqlInlineData()] - [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] - public void AddProductWithIdentity_SpecifyIdentityColumn(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductWithIdentityColumnIncluded), lang); @@ -329,8 +300,6 @@ public void AddProductWithIdentity_SpecifyIdentityColumn(SupportedLanguages lang /// [Theory] [SqlInlineData()] - [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] - public void AddProductWithIdentity_NoIdentityColumn(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductWithIdentityColumnIncluded), lang); @@ -359,8 +328,6 @@ public void AddProductWithIdentity_NoIdentityColumn(SupportedLanguages lang) /// [Theory] [SqlInlineData()] - [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] - public void AddProductWithIdentity_MissingPrimaryColumn(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductWithMultiplePrimaryColumnsAndIdentity), lang); @@ -382,8 +349,6 @@ public void AddProductWithIdentity_MissingPrimaryColumn(SupportedLanguages lang) /// [Theory] [SqlInlineData()] - [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] - public void AddProductCaseSensitiveTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductParams), lang); @@ -418,8 +383,6 @@ public void AddProductCaseSensitiveTest(SupportedLanguages lang) /// [Theory] [SqlInlineData()] - [UnsupportedLanguages(SupportedLanguages.CSharp, SupportedLanguages.JavaScript)] - public void AddProductWithDefaultPKTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductWithDefaultPK), lang); From 738337ad13f02ac000dd27cfe59437533deb653c Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Fri, 21 Oct 2022 15:24:02 -0700 Subject: [PATCH 04/41] include runtime --- test/Integration/IntegrationTestBase.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Integration/IntegrationTestBase.cs b/test/Integration/IntegrationTestBase.cs index bcd098205..4fe1db996 100644 --- a/test/Integration/IntegrationTestBase.cs +++ b/test/Integration/IntegrationTestBase.cs @@ -9,6 +9,7 @@ using System.IO; using System.Net.Http; using System.Reflection; +using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using Xunit; From ab4d551c3bddd3404144aa9f2deb368209c0ac10 Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Fri, 21 Oct 2022 15:26:16 -0700 Subject: [PATCH 05/41] copyright header fix --- test/Integration/SqlOutputBindingIntegrationTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Integration/SqlOutputBindingIntegrationTests.cs b/test/Integration/SqlOutputBindingIntegrationTests.cs index c068837ec..2080bb3a9 100644 --- a/test/Integration/SqlOutputBindingIntegrationTests.cs +++ b/test/Integration/SqlOutputBindingIntegrationTests.cs @@ -1,5 +1,5 @@ -// Copyright(c) Microsoft Corporation.All rights reserved. -// Licensed under the MIT License.See License.txt in the project root for license information. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. using System; using System.Collections.Generic; From eb3b33c8abbec8e9eb4cd3a5f88b504b4129b9bf Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Tue, 25 Oct 2022 14:31:40 -0700 Subject: [PATCH 06/41] deseralize powershell test --- samples/samples-csharp/Common/Product.cs | 10 ++++++++++ test/Integration/SqlInputBindingIntegrationTests.cs | 6 +++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/samples/samples-csharp/Common/Product.cs b/samples/samples-csharp/Common/Product.cs index 2f2bdb1e9..ec27e77f4 100644 --- a/samples/samples-csharp/Common/Product.cs +++ b/samples/samples-csharp/Common/Product.cs @@ -10,6 +10,16 @@ public class Product public string Name { get; set; } public int Cost { get; set; } + + public override bool Equals(object obj) + { + if (obj is Product) + { + var that = obj as Product; + return this.ProductID == that.ProductID && this.Name == that.Name && this.Cost == that.Cost; + } + return false; + } } public class ProductWithOptionalId diff --git a/test/Integration/SqlInputBindingIntegrationTests.cs b/test/Integration/SqlInputBindingIntegrationTests.cs index b66f4c278..b09b403d6 100644 --- a/test/Integration/SqlInputBindingIntegrationTests.cs +++ b/test/Integration/SqlInputBindingIntegrationTests.cs @@ -104,10 +104,10 @@ public async void GetProductsByCostTest(SupportedLanguages lang) HttpResponseMessage response = await this.SendInputRequest("getproductsbycost"); // Verify result - string expectedResponse = JsonConvert.SerializeObject(productsWithCost100); + Product[] expectedResponse = productsWithCost100; string actualResponse = await response.Content.ReadAsStringAsync(); - - Assert.Equal(expectedResponse, TestUtils.CleanJsonString(actualResponse), StringComparer.OrdinalIgnoreCase); + Product[] actualProductResponse = JsonConvert.DeserializeObject(actualResponse); + Assert.Equal(expectedResponse, actualProductResponse); } [Theory] From fa2271865da5f5aabce1ad4b082d53de3b003279 Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Wed, 26 Oct 2022 11:08:53 -0700 Subject: [PATCH 07/41] add local.settings.json --- samples/samples-powershell/.funcignore | 1 - 1 file changed, 1 deletion(-) diff --git a/samples/samples-powershell/.funcignore b/samples/samples-powershell/.funcignore index 517922249..6970d441b 100644 --- a/samples/samples-powershell/.funcignore +++ b/samples/samples-powershell/.funcignore @@ -2,6 +2,5 @@ *.ts .git* .vscode -local.settings.json test tsconfig.json \ No newline at end of file From c133228cfc07457c6aff4e3ad712f8805ab6f059 Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Wed, 26 Oct 2022 11:10:11 -0700 Subject: [PATCH 08/41] add local.settings.json --- samples/samples-powershell/.gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/samples/samples-powershell/.gitignore b/samples/samples-powershell/.gitignore index 01774db7f..987137e25 100644 --- a/samples/samples-powershell/.gitignore +++ b/samples/samples-powershell/.gitignore @@ -91,7 +91,6 @@ out bin obj appsettings.json -local.settings.json # Azurite artifacts __blobstorage__ From 64c2c1b4f5d60e15a4f4c55f358e4a3bc98b2846 Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Wed, 26 Oct 2022 13:52:00 -0700 Subject: [PATCH 09/41] add local.settings.json correct for samples/ps --- .gitignore | 2 +- Test1/Test1.sqlproj | 70 +++++++++++++++++++ .../local.settings.json | 5 +- 3 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 Test1/Test1.sqlproj rename samples/{samples-csharp => samples-powershell}/local.settings.json (80%) diff --git a/.gitignore b/.gitignore index 0278bab71..c3db6171b 100644 --- a/.gitignore +++ b/.gitignore @@ -350,7 +350,7 @@ MigrationBackup/ .ionide/ # Azure Functions localsettings file -local.settings.json +# local.settings.json # Azurite artifacts __blobstorage__ diff --git a/Test1/Test1.sqlproj b/Test1/Test1.sqlproj new file mode 100644 index 000000000..845471066 --- /dev/null +++ b/Test1/Test1.sqlproj @@ -0,0 +1,70 @@ + + + + Debug + AnyCPU + Test1 + 2.0 + 4.1 + {09B706AB-606B-4E20-842C-8D8BBC8DB602} + Microsoft.Data.Tools.Schema.Sql.Sql150DatabaseSchemaProvider + Database + + + Test1 + Test1 + 1033, CI + BySchemaAndSchemaType + True + v4.5 + CS + Properties + False + True + True + + + bin\Release\ + $(MSBuildProjectName).sql + False + pdbonly + true + false + true + prompt + 4 + + + bin\Debug\ + $(MSBuildProjectName).sql + false + true + full + false + true + true + prompt + 4 + + + 11.0 + + True + 11.0 + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/samples-csharp/local.settings.json b/samples/samples-powershell/local.settings.json similarity index 80% rename from samples/samples-csharp/local.settings.json rename to samples/samples-powershell/local.settings.json index 2ee8fdfec..02754944b 100644 --- a/samples/samples-csharp/local.settings.json +++ b/samples/samples-powershell/local.settings.json @@ -2,9 +2,10 @@ "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "UseDevelopmentStorage=true", - "FUNCTIONS_WORKER_RUNTIME": "dotnet", + "FUNCTIONS_WORKER_RUNTIME": "powershell", "SqlConnectionString": "", "Sp_SelectCost": "SelectProductsCost", "ProductCost": 100 } -} \ No newline at end of file +} + From 3eb0fc9fb6763254af16aab6c57f757e1ef15595 Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Wed, 26 Oct 2022 14:25:26 -0700 Subject: [PATCH 10/41] add local.settings.json for each sampels --- Test1/Test1.sqlproj | 70 ------------------- samples/samples-csharp/.gitignore | 2 +- samples/samples-csharp/local.settings.json | 10 +++ samples/samples-js/.gitignore | 2 +- samples/samples-powershell/.gitignore | 1 + .../samples-powershell/local.settings.json | 2 +- samples/samples-python/.gitignore | 2 +- 7 files changed, 15 insertions(+), 74 deletions(-) delete mode 100644 Test1/Test1.sqlproj create mode 100644 samples/samples-csharp/local.settings.json diff --git a/Test1/Test1.sqlproj b/Test1/Test1.sqlproj deleted file mode 100644 index 845471066..000000000 --- a/Test1/Test1.sqlproj +++ /dev/null @@ -1,70 +0,0 @@ - - - - Debug - AnyCPU - Test1 - 2.0 - 4.1 - {09B706AB-606B-4E20-842C-8D8BBC8DB602} - Microsoft.Data.Tools.Schema.Sql.Sql150DatabaseSchemaProvider - Database - - - Test1 - Test1 - 1033, CI - BySchemaAndSchemaType - True - v4.5 - CS - Properties - False - True - True - - - bin\Release\ - $(MSBuildProjectName).sql - False - pdbonly - true - false - true - prompt - 4 - - - bin\Debug\ - $(MSBuildProjectName).sql - false - true - full - false - true - true - prompt - 4 - - - 11.0 - - True - 11.0 - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/samples-csharp/.gitignore b/samples/samples-csharp/.gitignore index ff5b00c50..ad9b6e1b9 100644 --- a/samples/samples-csharp/.gitignore +++ b/samples/samples-csharp/.gitignore @@ -2,7 +2,7 @@ ## files generated by popular Visual Studio add-ons. # Azure Functions localsettings file -local.settings.json +# local.settings.json # User-specific files *.suo diff --git a/samples/samples-csharp/local.settings.json b/samples/samples-csharp/local.settings.json new file mode 100644 index 000000000..2ee8fdfec --- /dev/null +++ b/samples/samples-csharp/local.settings.json @@ -0,0 +1,10 @@ +{ + "IsEncrypted": false, + "Values": { + "AzureWebJobsStorage": "UseDevelopmentStorage=true", + "FUNCTIONS_WORKER_RUNTIME": "dotnet", + "SqlConnectionString": "", + "Sp_SelectCost": "SelectProductsCost", + "ProductCost": 100 + } +} \ No newline at end of file diff --git a/samples/samples-js/.gitignore b/samples/samples-js/.gitignore index 01774db7f..6120e81e7 100644 --- a/samples/samples-js/.gitignore +++ b/samples/samples-js/.gitignore @@ -91,7 +91,7 @@ out bin obj appsettings.json -local.settings.json +# local.settings.json # Azurite artifacts __blobstorage__ diff --git a/samples/samples-powershell/.gitignore b/samples/samples-powershell/.gitignore index 987137e25..6120e81e7 100644 --- a/samples/samples-powershell/.gitignore +++ b/samples/samples-powershell/.gitignore @@ -91,6 +91,7 @@ out bin obj appsettings.json +# local.settings.json # Azurite artifacts __blobstorage__ diff --git a/samples/samples-powershell/local.settings.json b/samples/samples-powershell/local.settings.json index 02754944b..fac758659 100644 --- a/samples/samples-powershell/local.settings.json +++ b/samples/samples-powershell/local.settings.json @@ -3,9 +3,9 @@ "Values": { "AzureWebJobsStorage": "UseDevelopmentStorage=true", "FUNCTIONS_WORKER_RUNTIME": "powershell", + "FUNCTIONS_WORKER_RUNTIME_VERSION" : "~7", "SqlConnectionString": "", "Sp_SelectCost": "SelectProductsCost", "ProductCost": 100 } } - diff --git a/samples/samples-python/.gitignore b/samples/samples-python/.gitignore index 304fe4ce6..e61abf6bc 100644 --- a/samples/samples-python/.gitignore +++ b/samples/samples-python/.gitignore @@ -1,5 +1,5 @@ # Azure Functions localsettings file -local.settings.json +# local.settings.json # Azurite artifacts __blobstorage__ From b55cb98512a3dc20ebc0fa944b1f440e1ea83895 Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Wed, 26 Oct 2022 15:18:17 -0700 Subject: [PATCH 11/41] update test to deseralize JSON objects and compare --- .../AddProductParams/run.ps1 | 6 ++--- .../SqlInputBindingIntegrationTests.cs | 23 +++++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/samples/samples-powershell/AddProductParams/run.ps1 b/samples/samples-powershell/AddProductParams/run.ps1 index d8dc5199e..0307f89af 100644 --- a/samples/samples-powershell/AddProductParams/run.ps1 +++ b/samples/samples-powershell/AddProductParams/run.ps1 @@ -10,9 +10,9 @@ 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. $req_body = @{ - "productId"= req.body?.productId; - "name"= req.body?.name; - "cost"= req.body?.cost; + "productId"= $Request.Body?.productId; + "name"= $Request.Body?.name; + "cost"= $Request.Body?.cost; }; # Assign the value we want to pass to the SQL Output binding. diff --git a/test/Integration/SqlInputBindingIntegrationTests.cs b/test/Integration/SqlInputBindingIntegrationTests.cs index b09b403d6..bb4b48ce7 100644 --- a/test/Integration/SqlInputBindingIntegrationTests.cs +++ b/test/Integration/SqlInputBindingIntegrationTests.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -using System; using System.Net.Http; using Newtonsoft.Json; using Microsoft.Azure.WebJobs.Extensions.Sql.Samples.Common; @@ -34,10 +33,11 @@ public async void GetProductsTest(int n, int cost, SupportedLanguages lang) HttpResponseMessage response = await this.SendInputRequest("getproducts", cost.ToString()); // Verify result - string expectedResponse = JsonConvert.SerializeObject(products); + Product[] expectedResponse = products; string actualResponse = await response.Content.ReadAsStringAsync(); + Product[] actualProductResponse = JsonConvert.DeserializeObject(actualResponse); - Assert.Equal(expectedResponse, TestUtils.CleanJsonString(actualResponse), StringComparer.OrdinalIgnoreCase); + Assert.Equal(expectedResponse, actualProductResponse); } [Theory] @@ -56,10 +56,11 @@ public async void GetProductsStoredProcedureTest(int n, int cost, SupportedLangu HttpResponseMessage response = await this.SendInputRequest("getproducts-storedprocedure", cost.ToString()); // Verify result - string expectedResponse = JsonConvert.SerializeObject(products); + Product[] expectedResponse = products; string actualResponse = await response.Content.ReadAsStringAsync(); + Product[] actualProductResponse = JsonConvert.DeserializeObject(actualResponse); - Assert.Equal(expectedResponse, TestUtils.CleanJsonString(actualResponse), StringComparer.OrdinalIgnoreCase); + Assert.Equal(expectedResponse, actualProductResponse); } [Theory] @@ -83,10 +84,11 @@ public async void GetProductsNameEmptyTest(int n, int cost, SupportedLanguages l HttpResponseMessage response = await this.SendInputRequest("getproducts-nameempty", cost.ToString()); // Verify result - string expectedResponse = JsonConvert.SerializeObject(products); + Product[] expectedResponse = products; string actualResponse = await response.Content.ReadAsStringAsync(); + Product[] actualProductResponse = JsonConvert.DeserializeObject(actualResponse); - Assert.Equal(expectedResponse, TestUtils.CleanJsonString(actualResponse), StringComparer.OrdinalIgnoreCase); + Assert.Equal(expectedResponse, actualProductResponse); } [Theory] @@ -107,6 +109,7 @@ public async void GetProductsByCostTest(SupportedLanguages lang) Product[] expectedResponse = productsWithCost100; string actualResponse = await response.Content.ReadAsStringAsync(); Product[] actualProductResponse = JsonConvert.DeserializeObject(actualResponse); + Assert.Equal(expectedResponse, actualProductResponse); } @@ -124,10 +127,12 @@ public async void GetProductNamesViewTest(SupportedLanguages lang) HttpResponseMessage response = await this.SendInputRequest("getproduct-namesview"); // Verify result - string expectedResponse = "[{\"name\":\"test\"}]"; + // string expectedResponse = "[{\"name\":\"test\"}]"; + Product[] expectedResponse = products; string actualResponse = await response.Content.ReadAsStringAsync(); + Product[] actualProductResponse = JsonConvert.DeserializeObject(actualResponse); - Assert.Equal(expectedResponse, TestUtils.CleanJsonString(actualResponse), StringComparer.OrdinalIgnoreCase); + Assert.Equal(expectedResponse, actualProductResponse); } /// From 3957d8e4b473bb76a9c9c4f09e20177bc93721a4 Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Wed, 26 Oct 2022 17:11:38 -0700 Subject: [PATCH 12/41] update input test to fix views test --- samples/samples-csharp/Common/Product.cs | 10 ++++++++++ test/Integration/SqlInputBindingIntegrationTests.cs | 5 ++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/samples/samples-csharp/Common/Product.cs b/samples/samples-csharp/Common/Product.cs index ec27e77f4..9eeda4ff3 100644 --- a/samples/samples-csharp/Common/Product.cs +++ b/samples/samples-csharp/Common/Product.cs @@ -34,6 +34,16 @@ public class ProductWithOptionalId public class ProductName { public string Name { get; set; } + + public override bool Equals(object obj) + { + if (obj is Product) + { + var that = obj as Product; + return this.Name == that.Name; + } + return false; + } } public class ProductWithDefaultPK diff --git a/test/Integration/SqlInputBindingIntegrationTests.cs b/test/Integration/SqlInputBindingIntegrationTests.cs index bb4b48ce7..157228af8 100644 --- a/test/Integration/SqlInputBindingIntegrationTests.cs +++ b/test/Integration/SqlInputBindingIntegrationTests.cs @@ -127,10 +127,9 @@ public async void GetProductNamesViewTest(SupportedLanguages lang) HttpResponseMessage response = await this.SendInputRequest("getproduct-namesview"); // Verify result - // string expectedResponse = "[{\"name\":\"test\"}]"; - Product[] expectedResponse = products; + ProductName[] expectedResponse = JsonConvert.DeserializeObject("[{name:test}]"); string actualResponse = await response.Content.ReadAsStringAsync(); - Product[] actualProductResponse = JsonConvert.DeserializeObject(actualResponse); + ProductName[] actualProductResponse = JsonConvert.DeserializeObject(actualResponse); Assert.Equal(expectedResponse, actualProductResponse); } From 92acf93cdb6a00d65ce53f6a6f6373b37d0c2b48 Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Wed, 26 Oct 2022 19:23:34 -0700 Subject: [PATCH 13/41] add product params test --- samples/samples-powershell/AddProductParams/run.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/samples-powershell/AddProductParams/run.ps1 b/samples/samples-powershell/AddProductParams/run.ps1 index 0307f89af..345ad0feb 100644 --- a/samples/samples-powershell/AddProductParams/run.ps1 +++ b/samples/samples-powershell/AddProductParams/run.ps1 @@ -10,9 +10,9 @@ 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. $req_body = @{ - "productId"= $Request.Body?.productId; - "name"= $Request.Body?.name; - "cost"= $Request.Body?.cost; + "productId"= $Request.Body.productId; + "name"= $Request.Body.name; + "cost"= $Request.Body.cost; }; # Assign the value we want to pass to the SQL Output binding. From d975b53adcfafcd8b8b7ad42937972d8d26190be Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Thu, 27 Oct 2022 13:33:02 -0700 Subject: [PATCH 14/41] address merge conflicts --- test/Integration/SqlInputBindingIntegrationTests.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/Integration/SqlInputBindingIntegrationTests.cs b/test/Integration/SqlInputBindingIntegrationTests.cs index e5a194897..c43888c67 100644 --- a/test/Integration/SqlInputBindingIntegrationTests.cs +++ b/test/Integration/SqlInputBindingIntegrationTests.cs @@ -3,6 +3,7 @@ using System.Net.Http; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using Microsoft.Azure.WebJobs.Extensions.Sql.Samples.Common; using Microsoft.Azure.WebJobs.Extensions.Sql.Samples.InputBindingSamples; using Xunit; @@ -140,7 +141,7 @@ public async void GetProductNamesViewTest(SupportedLanguages lang) [Theory] [SqlInlineData("en-US")] [SqlInlineData("it-IT")] - [UnsupportedLanguages(SupportedLanguages.JavaScript)] // IAsyncEnumerable is only available in C# + [UnsupportedLanguages(SupportedLanguages.JavaScript, SupportedLanguages.PowerShell)] // IAsyncEnumerable is only available in C# public async void GetProductsColumnTypesSerializationAsyncEnumerableTest(string culture, SupportedLanguages lang) { this.StartFunctionHost(nameof(GetProductsColumnTypesSerializationAsyncEnumerable), lang, true); @@ -153,10 +154,11 @@ public async void GetProductsColumnTypesSerializationAsyncEnumerableTest(string HttpResponseMessage response = await this.SendInputRequest("getproducts-columntypesserializationasyncenumerable", $"?culture={culture}"); // We expect the datetime and datetime2 fields to be returned in UTC format - string expectedResponse = "[{\"productId\":999,\"datetime\":\"2022-10-20T12:39:13.123Z\",\"datetime2\":\"2022-10-20T12:39:13.123Z\"}]"; + JObject expectedResponse = JsonConvert.DeserializeObject("[{productId:999,datetime:2022-10-20T12:39:13.123Z,datetime2:2022-10-20T12:39:13.123Z}]"); string actualResponse = await response.Content.ReadAsStringAsync(); + JObject actualProductResponse = JsonConvert.DeserializeObject(actualResponse); - Assert.Equal(expectedResponse, TestUtils.CleanJsonString(actualResponse), StringComparer.OrdinalIgnoreCase); + Assert.Equal(expectedResponse, actualProductResponse); } /// @@ -176,10 +178,11 @@ public async void GetProductsColumnTypesSerializationTest(SupportedLanguages lan HttpResponseMessage response = await this.SendInputRequest("getproducts-columntypesserialization"); // We expect the datetime and datetime2 fields to be returned in UTC format - string expectedResponse = "[{\"ProductId\":999,\"Datetime\":\"2022-10-20T12:39:13.123Z\",\"Datetime2\":\"2022-10-20T12:39:13.123Z\"}]"; + var expectedResponse = JObject.Parse("[{ProductId:999,Datetime:2022-10-20T12:39:13.123Z,Datetime2:2022-10-20T12:39:13.123Z}]"); string actualResponse = await response.Content.ReadAsStringAsync(); + JObject actualProductResponse = JsonConvert.DeserializeObject(actualResponse); - Assert.Equal(expectedResponse, TestUtils.CleanJsonString(actualResponse), StringComparer.OrdinalIgnoreCase); + Assert.Equal(expectedResponse, actualProductResponse); } } } From cbd8ee1514517b93613e4451acc264aea61db503 Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Thu, 27 Oct 2022 14:49:58 -0700 Subject: [PATCH 15/41] address merge fixes --- test/Integration/SqlInputBindingIntegrationTests.cs | 7 +++---- .../test-powershell/AddProductColumnTypes/function.json | 2 +- .../test-powershell/AddProductExtraColumns/function.json | 2 +- .../test-powershell/AddProductMissingColumns/function.json | 2 +- .../AddProductsNoPartialUpsert/function.json | 2 +- .../GetProductsColumnTypesSerialization/function.json | 2 +- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/test/Integration/SqlInputBindingIntegrationTests.cs b/test/Integration/SqlInputBindingIntegrationTests.cs index c43888c67..4c8e394a0 100644 --- a/test/Integration/SqlInputBindingIntegrationTests.cs +++ b/test/Integration/SqlInputBindingIntegrationTests.cs @@ -141,7 +141,7 @@ public async void GetProductNamesViewTest(SupportedLanguages lang) [Theory] [SqlInlineData("en-US")] [SqlInlineData("it-IT")] - [UnsupportedLanguages(SupportedLanguages.JavaScript, SupportedLanguages.PowerShell)] // IAsyncEnumerable is only available in C# + [UnsupportedLanguages(SupportedLanguages.JavaScript)] // IAsyncEnumerable is only available in C# public async void GetProductsColumnTypesSerializationAsyncEnumerableTest(string culture, SupportedLanguages lang) { this.StartFunctionHost(nameof(GetProductsColumnTypesSerializationAsyncEnumerable), lang, true); @@ -154,11 +154,10 @@ public async void GetProductsColumnTypesSerializationAsyncEnumerableTest(string HttpResponseMessage response = await this.SendInputRequest("getproducts-columntypesserializationasyncenumerable", $"?culture={culture}"); // We expect the datetime and datetime2 fields to be returned in UTC format - JObject expectedResponse = JsonConvert.DeserializeObject("[{productId:999,datetime:2022-10-20T12:39:13.123Z,datetime2:2022-10-20T12:39:13.123Z}]"); + string expectedResponse = "[{\"productId\":999,\"datetime\":\"2022-10-20T12:39:13.123Z\",\"datetime2\":\"2022-10-20T12:39:13.123Z\"}]"; string actualResponse = await response.Content.ReadAsStringAsync(); - JObject actualProductResponse = JsonConvert.DeserializeObject(actualResponse); - Assert.Equal(expectedResponse, actualProductResponse); + Assert.Equal(expectedResponse, TestUtils.CleanJsonString(actualResponse), StringComparer.OrdinalIgnoreCase); } /// diff --git a/test/Integration/test-powershell/AddProductColumnTypes/function.json b/test/Integration/test-powershell/AddProductColumnTypes/function.json index 2345f96b5..3a80fd4bd 100644 --- a/test/Integration/test-powershell/AddProductColumnTypes/function.json +++ b/test/Integration/test-powershell/AddProductColumnTypes/function.json @@ -2,7 +2,7 @@ "bindings": [ { "authLevel": "function", - "name": "req", + "name": "Request", "direction": "in", "type": "httpTrigger", "methods": [ diff --git a/test/Integration/test-powershell/AddProductExtraColumns/function.json b/test/Integration/test-powershell/AddProductExtraColumns/function.json index cd7eba6dd..3fc82a035 100644 --- a/test/Integration/test-powershell/AddProductExtraColumns/function.json +++ b/test/Integration/test-powershell/AddProductExtraColumns/function.json @@ -2,7 +2,7 @@ "bindings": [ { "authLevel": "function", - "name": "req", + "name": "Request", "direction": "in", "type": "httpTrigger", "methods": [ diff --git a/test/Integration/test-powershell/AddProductMissingColumns/function.json b/test/Integration/test-powershell/AddProductMissingColumns/function.json index 37bc4fd07..d4dffc0e4 100644 --- a/test/Integration/test-powershell/AddProductMissingColumns/function.json +++ b/test/Integration/test-powershell/AddProductMissingColumns/function.json @@ -2,7 +2,7 @@ "bindings": [ { "authLevel": "function", - "name": "req", + "name": "Request", "direction": "in", "type": "httpTrigger", "methods": [ diff --git a/test/Integration/test-powershell/AddProductsNoPartialUpsert/function.json b/test/Integration/test-powershell/AddProductsNoPartialUpsert/function.json index 36ac1d612..cbf55b8c1 100644 --- a/test/Integration/test-powershell/AddProductsNoPartialUpsert/function.json +++ b/test/Integration/test-powershell/AddProductsNoPartialUpsert/function.json @@ -2,7 +2,7 @@ "bindings": [ { "authLevel": "function", - "name": "req", + "name": "Request", "direction": "in", "type": "httpTrigger", "methods": [ diff --git a/test/Integration/test-powershell/GetProductsColumnTypesSerialization/function.json b/test/Integration/test-powershell/GetProductsColumnTypesSerialization/function.json index 8f1bd3b29..719e2a3c0 100644 --- a/test/Integration/test-powershell/GetProductsColumnTypesSerialization/function.json +++ b/test/Integration/test-powershell/GetProductsColumnTypesSerialization/function.json @@ -2,7 +2,7 @@ "bindings": [ { "authLevel": "function", - "name": "req", + "name": "Request", "type": "httpTrigger", "direction": "in", "methods": [ From 716a4c12b52c0b508630fa0b6ac837b456b25561 Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Thu, 27 Oct 2022 14:58:33 -0700 Subject: [PATCH 16/41] fix build --- test/Integration/SqlInputBindingIntegrationTests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Integration/SqlInputBindingIntegrationTests.cs b/test/Integration/SqlInputBindingIntegrationTests.cs index 4c8e394a0..95c561c82 100644 --- a/test/Integration/SqlInputBindingIntegrationTests.cs +++ b/test/Integration/SqlInputBindingIntegrationTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. +using System; using System.Net.Http; using Newtonsoft.Json; using Newtonsoft.Json.Linq; From a1834b76bd488b6a749fcf3253aa59f63e49861a Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Thu, 27 Oct 2022 15:01:35 -0700 Subject: [PATCH 17/41] add function.json fix --- .../AddProductMissingColumnsExceptionFunction/function.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Integration/test-powershell/AddProductMissingColumnsExceptionFunction/function.json b/test/Integration/test-powershell/AddProductMissingColumnsExceptionFunction/function.json index d038a4701..f3f49ea8e 100644 --- a/test/Integration/test-powershell/AddProductMissingColumnsExceptionFunction/function.json +++ b/test/Integration/test-powershell/AddProductMissingColumnsExceptionFunction/function.json @@ -2,7 +2,7 @@ "bindings": [ { "authLevel": "function", - "name": "req", + "name": "Request", "direction": "in", "type": "httpTrigger", "methods": [ From b184c13122d6888eed47132107227789a51aaebb Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Thu, 27 Oct 2022 17:03:10 -0700 Subject: [PATCH 18/41] test getProductNamesViewTes --- test/Integration/SqlInputBindingIntegrationTests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Integration/SqlInputBindingIntegrationTests.cs b/test/Integration/SqlInputBindingIntegrationTests.cs index 95c561c82..97c5d8a13 100644 --- a/test/Integration/SqlInputBindingIntegrationTests.cs +++ b/test/Integration/SqlInputBindingIntegrationTests.cs @@ -129,9 +129,9 @@ public async void GetProductNamesViewTest(SupportedLanguages lang) HttpResponseMessage response = await this.SendInputRequest("getproduct-namesview"); // Verify result - ProductName[] expectedResponse = JsonConvert.DeserializeObject("[{name:test}]"); + string expectedResponse = "[{\"name\":\"test\"}]"; string actualResponse = await response.Content.ReadAsStringAsync(); - ProductName[] actualProductResponse = JsonConvert.DeserializeObject(actualResponse); + string actualProductResponse = JsonConvert.DeserializeObject(actualResponse).ToString(); Assert.Equal(expectedResponse, actualProductResponse); } @@ -142,7 +142,7 @@ public async void GetProductNamesViewTest(SupportedLanguages lang) [Theory] [SqlInlineData("en-US")] [SqlInlineData("it-IT")] - [UnsupportedLanguages(SupportedLanguages.JavaScript)] // IAsyncEnumerable is only available in C# + [UnsupportedLanguages(SupportedLanguages.JavaScript, SupportedLanguages.PowerShell)] // IAsyncEnumerable is only available in C# public async void GetProductsColumnTypesSerializationAsyncEnumerableTest(string culture, SupportedLanguages lang) { this.StartFunctionHost(nameof(GetProductsColumnTypesSerializationAsyncEnumerable), lang, true); From b82bde4ecfe5f96f70eaba751158928b5f4a68e3 Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Thu, 27 Oct 2022 17:16:49 -0700 Subject: [PATCH 19/41] fixes --- test/Integration/SqlInputBindingIntegrationTests.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/Integration/SqlInputBindingIntegrationTests.cs b/test/Integration/SqlInputBindingIntegrationTests.cs index 97c5d8a13..a45071cba 100644 --- a/test/Integration/SqlInputBindingIntegrationTests.cs +++ b/test/Integration/SqlInputBindingIntegrationTests.cs @@ -4,7 +4,6 @@ using System; using System.Net.Http; using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using Microsoft.Azure.WebJobs.Extensions.Sql.Samples.Common; using Microsoft.Azure.WebJobs.Extensions.Sql.Samples.InputBindingSamples; using Xunit; @@ -129,9 +128,10 @@ public async void GetProductNamesViewTest(SupportedLanguages lang) HttpResponseMessage response = await this.SendInputRequest("getproduct-namesview"); // Verify result - string expectedResponse = "[{\"name\":\"test\"}]"; + string expectedResponse = "[{\"name\":\"test\"}]"; string actualResponse = await response.Content.ReadAsStringAsync(); string actualProductResponse = JsonConvert.DeserializeObject(actualResponse).ToString(); + Console.WriteLine(actualProductResponse); Assert.Equal(expectedResponse, actualProductResponse); } @@ -178,9 +178,10 @@ public async void GetProductsColumnTypesSerializationTest(SupportedLanguages lan HttpResponseMessage response = await this.SendInputRequest("getproducts-columntypesserialization"); // We expect the datetime and datetime2 fields to be returned in UTC format - var expectedResponse = JObject.Parse("[{ProductId:999,Datetime:2022-10-20T12:39:13.123Z,Datetime2:2022-10-20T12:39:13.123Z}]"); + string expectedResponse = "[{\"ProductId\":999,\"Datetime\":\"2022-10-20T12:39:13.123Z\",\"Datetime2\":\"2022-10-20T12:39:13.123Z\"}]"; string actualResponse = await response.Content.ReadAsStringAsync(); - JObject actualProductResponse = JsonConvert.DeserializeObject(actualResponse); + string actualProductResponse = JsonConvert.DeserializeObject(actualResponse).ToString(); + Console.WriteLine(actualProductResponse); Assert.Equal(expectedResponse, actualProductResponse); } From 0e66298bc94450678b1e319af347c8aa0631c422 Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Thu, 27 Oct 2022 17:51:49 -0700 Subject: [PATCH 20/41] fixes serialization problems --- test/Integration/SqlInputBindingIntegrationTests.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test/Integration/SqlInputBindingIntegrationTests.cs b/test/Integration/SqlInputBindingIntegrationTests.cs index a45071cba..3789dae1e 100644 --- a/test/Integration/SqlInputBindingIntegrationTests.cs +++ b/test/Integration/SqlInputBindingIntegrationTests.cs @@ -4,6 +4,7 @@ using System; using System.Net.Http; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using Microsoft.Azure.WebJobs.Extensions.Sql.Samples.Common; using Microsoft.Azure.WebJobs.Extensions.Sql.Samples.InputBindingSamples; using Xunit; @@ -128,10 +129,9 @@ public async void GetProductNamesViewTest(SupportedLanguages lang) HttpResponseMessage response = await this.SendInputRequest("getproduct-namesview"); // Verify result - string expectedResponse = "[{\"name\":\"test\"}]"; + ProductName[] expectedResponse = JsonConvert.DeserializeObject("[{name:test}]"); string actualResponse = await response.Content.ReadAsStringAsync(); - string actualProductResponse = JsonConvert.DeserializeObject(actualResponse).ToString(); - Console.WriteLine(actualProductResponse); + ProductName[] actualProductResponse = JsonConvert.DeserializeObject(actualResponse); Assert.Equal(expectedResponse, actualProductResponse); } @@ -178,10 +178,9 @@ public async void GetProductsColumnTypesSerializationTest(SupportedLanguages lan HttpResponseMessage response = await this.SendInputRequest("getproducts-columntypesserialization"); // We expect the datetime and datetime2 fields to be returned in UTC format - string expectedResponse = "[{\"ProductId\":999,\"Datetime\":\"2022-10-20T12:39:13.123Z\",\"Datetime2\":\"2022-10-20T12:39:13.123Z\"}]"; + var expectedResponse = JObject.Parse("[{ProductId:999,Datetime:2022-10-20T12:39:13.123Z,Datetime2:2022-10-20T12:39:13.123Z}]"); string actualResponse = await response.Content.ReadAsStringAsync(); - string actualProductResponse = JsonConvert.DeserializeObject(actualResponse).ToString(); - Console.WriteLine(actualProductResponse); + JObject actualProductResponse = JsonConvert.DeserializeObject(actualResponse); Assert.Equal(expectedResponse, actualProductResponse); } From dba174eb3df565db131d039201d7aaff58d4822f Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Fri, 28 Oct 2022 13:46:09 -0700 Subject: [PATCH 21/41] add debug test --- samples/samples-powershell/AddProductParams/run.ps1 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/samples/samples-powershell/AddProductParams/run.ps1 b/samples/samples-powershell/AddProductParams/run.ps1 index 345ad0feb..16011028e 100644 --- a/samples/samples-powershell/AddProductParams/run.ps1 +++ b/samples/samples-powershell/AddProductParams/run.ps1 @@ -15,6 +15,18 @@ $req_body = @{ "cost"= $Request.Body.cost; }; +Write-Host "REQUEST BODY" +Write-Host $req_body + +$req_query = @{ + "productId"= $Request.QUERY.productId; + "name"= $Request.QUERY.name; + "cost"= $Request.QUERY.cost; +}; +Write-Host "REQUEST QUERY" +Write-Host $req_query + + # 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_body From 351c8e21f52b73043d11fc72c1c8e05ff5bc05ca Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Mon, 31 Oct 2022 14:38:28 -0700 Subject: [PATCH 22/41] add debug tests --- samples/samples-powershell/AddProductParams/run.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/samples-powershell/AddProductParams/run.ps1 b/samples/samples-powershell/AddProductParams/run.ps1 index 16011028e..fb12fcf56 100644 --- a/samples/samples-powershell/AddProductParams/run.ps1 +++ b/samples/samples-powershell/AddProductParams/run.ps1 @@ -14,7 +14,7 @@ $req_body = @{ "name"= $Request.Body.name; "cost"= $Request.Body.cost; }; - + Write-Host "REQUEST BODY" Write-Host $req_body From 96b73c69a80074dcbc1110b9eac52bdfa80a7848 Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Mon, 31 Oct 2022 15:07:04 -0700 Subject: [PATCH 23/41] add debug add product test --- .../samples-powershell/AddProductParams/run.ps1 | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/samples/samples-powershell/AddProductParams/run.ps1 b/samples/samples-powershell/AddProductParams/run.ps1 index fb12fcf56..74aa1a2b0 100644 --- a/samples/samples-powershell/AddProductParams/run.ps1 +++ b/samples/samples-powershell/AddProductParams/run.ps1 @@ -6,18 +6,6 @@ param($Request) # Write to the Azure Functions log stream. Write-Host "PowerShell function with SQL 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 = @{ - "productId"= $Request.Body.productId; - "name"= $Request.Body.name; - "cost"= $Request.Body.cost; -}; - -Write-Host "REQUEST BODY" -Write-Host $req_body - $req_query = @{ "productId"= $Request.QUERY.productId; "name"= $Request.QUERY.name; @@ -26,10 +14,9 @@ $req_query = @{ Write-Host "REQUEST QUERY" Write-Host $req_query - # 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_body +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 From ddc1f82561971364719405d261557b4d10457c89 Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Mon, 31 Oct 2022 16:58:26 -0700 Subject: [PATCH 24/41] fixes serialization problems --- test/Integration/SqlInputBindingIntegrationTests.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/Integration/SqlInputBindingIntegrationTests.cs b/test/Integration/SqlInputBindingIntegrationTests.cs index 3789dae1e..0bbbd7e00 100644 --- a/test/Integration/SqlInputBindingIntegrationTests.cs +++ b/test/Integration/SqlInputBindingIntegrationTests.cs @@ -4,7 +4,6 @@ using System; using System.Net.Http; using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using Microsoft.Azure.WebJobs.Extensions.Sql.Samples.Common; using Microsoft.Azure.WebJobs.Extensions.Sql.Samples.InputBindingSamples; using Xunit; @@ -178,11 +177,10 @@ public async void GetProductsColumnTypesSerializationTest(SupportedLanguages lan HttpResponseMessage response = await this.SendInputRequest("getproducts-columntypesserialization"); // We expect the datetime and datetime2 fields to be returned in UTC format - var expectedResponse = JObject.Parse("[{ProductId:999,Datetime:2022-10-20T12:39:13.123Z,Datetime2:2022-10-20T12:39:13.123Z}]"); + string expectedResponse = "[{\"ProductId\":999,\"Datetime\":\"2022-10-20T12:39:13.123Z\",\"Datetime2\":\"2022-10-20T12:39:13.123Z\"}]"; string actualResponse = await response.Content.ReadAsStringAsync(); - JObject actualProductResponse = JsonConvert.DeserializeObject(actualResponse); - Assert.Equal(expectedResponse, actualProductResponse); + Assert.Equal(expectedResponse, TestUtils.CleanJsonString(actualResponse), StringComparer.OrdinalIgnoreCase); } } } From b8e57ab9c2474e96a4926e4c199c9d2e92053b9d Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Tue, 1 Nov 2022 17:24:41 -0700 Subject: [PATCH 25/41] fix output binding tests --- .../samples-powershell/AddProductParams/run.ps1 | 4 +--- .../AddProductWithDefaultPK/run.ps1 | 2 +- .../AddProductWithIdentityColumn/run.ps1 | 4 ++-- .../AddProductWithIdentityColumnIncluded/run.ps1 | 6 +++--- .../run.ps1 | 14 +++++++------- .../AddProductsWithIdentityColumnArray/run.ps1 | 8 ++++---- .../QueueTriggerProducts/run.ps1 | 4 ++-- .../TimerTriggerProducts/run.ps1 | 4 ++-- .../SqlOutputBindingIntegrationTests.cs | 2 +- .../test-powershell/AddProductColumnTypes/run.ps1 | 8 ++++---- .../AddProductMissingColumns/function.json | 2 +- .../AddProductMissingColumns/run.ps1 | 1 + .../run.ps1 | 3 ++- 13 files changed, 31 insertions(+), 31 deletions(-) diff --git a/samples/samples-powershell/AddProductParams/run.ps1 b/samples/samples-powershell/AddProductParams/run.ps1 index 74aa1a2b0..08b4f74cd 100644 --- a/samples/samples-powershell/AddProductParams/run.ps1 +++ b/samples/samples-powershell/AddProductParams/run.ps1 @@ -11,12 +11,10 @@ $req_query = @{ "name"= $Request.QUERY.name; "cost"= $Request.QUERY.cost; }; -Write-Host "REQUEST QUERY" -Write-Host $req_query # 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 ´ +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 diff --git a/samples/samples-powershell/AddProductWithDefaultPK/run.ps1 b/samples/samples-powershell/AddProductWithDefaultPK/run.ps1 index 8a7b7e402..a8823cce9 100644 --- a/samples/samples-powershell/AddProductWithDefaultPK/run.ps1 +++ b/samples/samples-powershell/AddProductWithDefaultPK/run.ps1 @@ -13,7 +13,7 @@ $req_body = $Request.Body # 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_body +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 diff --git a/samples/samples-powershell/AddProductWithIdentityColumn/run.ps1 b/samples/samples-powershell/AddProductWithIdentityColumn/run.ps1 index 71445e60a..eb5a7ddb1 100644 --- a/samples/samples-powershell/AddProductWithIdentityColumn/run.ps1 +++ b/samples/samples-powershell/AddProductWithIdentityColumn/run.ps1 @@ -10,8 +10,8 @@ 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. $req_body = @{ - name=$Request.Body?.name; - cost=$Request.Body?.cost; + name=$Request.QUERY.name; + cost=$Request.QUERY.cost; }; # Assign the value we want to pass to the SQL Output binding. diff --git a/samples/samples-powershell/AddProductWithIdentityColumnIncluded/run.ps1 b/samples/samples-powershell/AddProductWithIdentityColumnIncluded/run.ps1 index a66a38fd1..dce198785 100644 --- a/samples/samples-powershell/AddProductWithIdentityColumnIncluded/run.ps1 +++ b/samples/samples-powershell/AddProductWithIdentityColumnIncluded/run.ps1 @@ -10,9 +10,9 @@ 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. $req_body = @{ - productId=$Request.Body?.productId; - name=$Request.Body?.name; - cost=$Request.Body?.cost; + productId=$Request.QUERY.productId; + name=$Request.QUERY.name; + cost=$Request.QUERY.cost; }; # Assign the value we want to pass to the SQL Output binding. diff --git a/samples/samples-powershell/AddProductWithMultiplePrimaryColumnsAndIdentity/run.ps1 b/samples/samples-powershell/AddProductWithMultiplePrimaryColumnsAndIdentity/run.ps1 index 6dcaf7a95..878d4971d 100644 --- a/samples/samples-powershell/AddProductWithMultiplePrimaryColumnsAndIdentity/run.ps1 +++ b/samples/samples-powershell/AddProductWithMultiplePrimaryColumnsAndIdentity/run.ps1 @@ -6,22 +6,22 @@ param($Request) # Write to the Azure Functions log stream. Write-Host "PowerShell function with SQL Output Binding processed a request." -# Update req_body with the body of the request +# Update req_query 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 = @{ - externalId=$Request.Body?.externalId; - name=$Request.Body?.name; - cost=$Request.Body?.cost; +$req_query = @{ + externalId=$Request.QUERY.externalId; + name=$Request.QUERY.name; + cost=$Request.QUERY.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_body +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_body + Body = $req_query }) \ No newline at end of file diff --git a/samples/samples-powershell/AddProductsWithIdentityColumnArray/run.ps1 b/samples/samples-powershell/AddProductsWithIdentityColumnArray/run.ps1 index 5ccf7cb14..c66344076 100644 --- a/samples/samples-powershell/AddProductsWithIdentityColumnArray/run.ps1 +++ b/samples/samples-powershell/AddProductsWithIdentityColumnArray/run.ps1 @@ -9,12 +9,12 @@ Write-Host "PowerShell function with SQL 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 = (@{ +$req_body = @(@{ name="Cup"; - cost="2"; -}, { + cost=2; +}, @{ name="Glasses"; - cost="12"; + cost=12; }) # Assign the value we want to pass to the SQL Output binding. diff --git a/samples/samples-powershell/QueueTriggerProducts/run.ps1 b/samples/samples-powershell/QueueTriggerProducts/run.ps1 index 0a748feac..0dea29f51 100644 --- a/samples/samples-powershell/QueueTriggerProducts/run.ps1 +++ b/samples/samples-powershell/QueueTriggerProducts/run.ps1 @@ -1,7 +1,7 @@ using namespace System.Net # Trigger binding data passed in via param block -param($Request) +param($queueMessage) $totalUpserts = 100; # Write to the Azure Functions log stream. Write-Host "[QueueTrigger]: $Get-Date starting execution $queueMessage. Rows to generate=$totalUpserts." @@ -21,7 +21,7 @@ for ($i = 0; $i -lt $totalUpserts; $i++) { } # 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 $products +Push-OutputBinding -Name products -Value $products $duration = Get-Date - $start; Write-Host "[QueueTrigger]: $Get-Date finished execution $queueMessage. Total time to create $totalUpserts rows=$duration." \ No newline at end of file diff --git a/samples/samples-powershell/TimerTriggerProducts/run.ps1 b/samples/samples-powershell/TimerTriggerProducts/run.ps1 index bc75f510f..22f1df60b 100644 --- a/samples/samples-powershell/TimerTriggerProducts/run.ps1 +++ b/samples/samples-powershell/TimerTriggerProducts/run.ps1 @@ -2,7 +2,7 @@ using namespace System.Net # Trigger binding data passed in via param block $executionNumber = 0; -param($Request) +param($myTimer) $totalUpserts = 100; # Write to the Azure Functions log stream. Write-Host "[QueueTrigger]: $Get-Date starting execution $executionNumber. Rows to generate=$totalUpserts." @@ -24,7 +24,7 @@ $duration = Get-Date - $start; # 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 $products +Push-OutputBinding -Name products -Value $products Write-Host "[QueueTrigger]: $Get-Date finished execution $queueMessage. Total time to create $totalUpserts rows=$duration." diff --git a/test/Integration/SqlOutputBindingIntegrationTests.cs b/test/Integration/SqlOutputBindingIntegrationTests.cs index 6437a1118..8711cac37 100644 --- a/test/Integration/SqlOutputBindingIntegrationTests.cs +++ b/test/Integration/SqlOutputBindingIntegrationTests.cs @@ -244,7 +244,7 @@ public void AddProductsWithIdentityColumnArray(SupportedLanguages lang) } /// - /// Tests that for tables with multiple primary columns (including an itemtity column) we are able to + /// Tests that for tables with multiple primary columns (including an identity column) we are able to /// insert items. /// [Theory] diff --git a/test/Integration/test-powershell/AddProductColumnTypes/run.ps1 b/test/Integration/test-powershell/AddProductColumnTypes/run.ps1 index 7ee0b62ef..14e85b8da 100644 --- a/test/Integration/test-powershell/AddProductColumnTypes/run.ps1 +++ b/test/Integration/test-powershell/AddProductColumnTypes/run.ps1 @@ -9,19 +9,19 @@ Write-Host "PowerShell function with SQL 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 = @{ - productId=$Request.Body?.productId; +$req_query = @{ + productId=$Request.QUERY.productId; datetime= Get-Date; datetime2= Get-Date; }; # 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_body +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_body + Body = $req_query }) \ No newline at end of file diff --git a/test/Integration/test-powershell/AddProductMissingColumns/function.json b/test/Integration/test-powershell/AddProductMissingColumns/function.json index d4dffc0e4..4ea683c25 100644 --- a/test/Integration/test-powershell/AddProductMissingColumns/function.json +++ b/test/Integration/test-powershell/AddProductMissingColumns/function.json @@ -16,7 +16,7 @@ "direction": "out" }, { - "name": "products", + "name": "product", "type": "sql", "direction": "out", "commandText": "[dbo].[Products]", diff --git a/test/Integration/test-powershell/AddProductMissingColumns/run.ps1 b/test/Integration/test-powershell/AddProductMissingColumns/run.ps1 index 7fd866193..e56af3aa0 100644 --- a/test/Integration/test-powershell/AddProductMissingColumns/run.ps1 +++ b/test/Integration/test-powershell/AddProductMissingColumns/run.ps1 @@ -12,6 +12,7 @@ Write-Host "PowerShell function with SQL Output Binding processed a request." $req_body = @{ productId=1; name="MissingCost"; + # Cost is missing }; # Assign the value we want to pass to the SQL Output binding. diff --git a/test/Integration/test-powershell/AddProductMissingColumnsExceptionFunction/run.ps1 b/test/Integration/test-powershell/AddProductMissingColumnsExceptionFunction/run.ps1 index 7fd866193..6dbd959ac 100644 --- a/test/Integration/test-powershell/AddProductMissingColumnsExceptionFunction/run.ps1 +++ b/test/Integration/test-powershell/AddProductMissingColumnsExceptionFunction/run.ps1 @@ -12,11 +12,12 @@ Write-Host "PowerShell function with SQL Output Binding processed a request." $req_body = @{ productId=1; name="MissingCost"; + # Missing 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_body +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 From 0cd9e31c9aca16238432696556db20e2ff95379b Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Tue, 1 Nov 2022 17:28:40 -0700 Subject: [PATCH 26/41] small fixes --- samples/samples-csharp/Common/Product.cs | 19 ------------------- .../SqlInputBindingIntegrationTests.cs | 7 +++---- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/samples/samples-csharp/Common/Product.cs b/samples/samples-csharp/Common/Product.cs index 9eeda4ff3..75eb82c46 100644 --- a/samples/samples-csharp/Common/Product.cs +++ b/samples/samples-csharp/Common/Product.cs @@ -10,16 +10,6 @@ public class Product public string Name { get; set; } public int Cost { get; set; } - - public override bool Equals(object obj) - { - if (obj is Product) - { - var that = obj as Product; - return this.ProductID == that.ProductID && this.Name == that.Name && this.Cost == that.Cost; - } - return false; - } } public class ProductWithOptionalId @@ -35,15 +25,6 @@ public class ProductName { public string Name { get; set; } - public override bool Equals(object obj) - { - if (obj is Product) - { - var that = obj as Product; - return this.Name == that.Name; - } - return false; - } } public class ProductWithDefaultPK diff --git a/test/Integration/SqlInputBindingIntegrationTests.cs b/test/Integration/SqlInputBindingIntegrationTests.cs index 0bbbd7e00..5da2f3eee 100644 --- a/test/Integration/SqlInputBindingIntegrationTests.cs +++ b/test/Integration/SqlInputBindingIntegrationTests.cs @@ -82,7 +82,7 @@ public async void GetProductsNameEmptyTest(int n, int cost, SupportedLanguages l Assert.Equal(n, this.ExecuteScalar($"select count(1) from Products where name = '' and cost = {cost}")); // Run the function - HttpResponseMessage response = await this.SendInputRequest("getproducts-nameempty", cost.ToString()); + HttpResponseMessage response = await this.SendInputRequest("get`ts-nameempty", cost.ToString()); // Verify result Product[] expectedResponse = products; @@ -128,11 +128,10 @@ public async void GetProductNamesViewTest(SupportedLanguages lang) HttpResponseMessage response = await this.SendInputRequest("getproduct-namesview"); // Verify result - ProductName[] expectedResponse = JsonConvert.DeserializeObject("[{name:test}]"); + string expectedResponse = "[{\"name\":\"test\"}]"; string actualResponse = await response.Content.ReadAsStringAsync(); - ProductName[] actualProductResponse = JsonConvert.DeserializeObject(actualResponse); - Assert.Equal(expectedResponse, actualProductResponse); + Assert.Equal(expectedResponse, TestUtils.CleanJsonString(actualResponse), StringComparer.OrdinalIgnoreCase); } /// From 2b6907e0f02b34d04d20532f398095a57a5a7e3a Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Tue, 1 Nov 2022 23:38:28 -0700 Subject: [PATCH 27/41] product overide test --- samples/samples-csharp/Common/Product.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/samples/samples-csharp/Common/Product.cs b/samples/samples-csharp/Common/Product.cs index 75eb82c46..9eeda4ff3 100644 --- a/samples/samples-csharp/Common/Product.cs +++ b/samples/samples-csharp/Common/Product.cs @@ -10,6 +10,16 @@ public class Product public string Name { get; set; } public int Cost { get; set; } + + public override bool Equals(object obj) + { + if (obj is Product) + { + var that = obj as Product; + return this.ProductID == that.ProductID && this.Name == that.Name && this.Cost == that.Cost; + } + return false; + } } public class ProductWithOptionalId @@ -25,6 +35,15 @@ public class ProductName { public string Name { get; set; } + public override bool Equals(object obj) + { + if (obj is Product) + { + var that = obj as Product; + return this.Name == that.Name; + } + return false; + } } public class ProductWithDefaultPK From 33821b433da4ce2a802d02318b121ffa1dedeb7a Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Wed, 2 Nov 2022 01:05:11 -0700 Subject: [PATCH 28/41] fix product test --- test/Integration/SqlInputBindingIntegrationTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Integration/SqlInputBindingIntegrationTests.cs b/test/Integration/SqlInputBindingIntegrationTests.cs index 5da2f3eee..f97a600e1 100644 --- a/test/Integration/SqlInputBindingIntegrationTests.cs +++ b/test/Integration/SqlInputBindingIntegrationTests.cs @@ -82,7 +82,7 @@ public async void GetProductsNameEmptyTest(int n, int cost, SupportedLanguages l Assert.Equal(n, this.ExecuteScalar($"select count(1) from Products where name = '' and cost = {cost}")); // Run the function - HttpResponseMessage response = await this.SendInputRequest("get`ts-nameempty", cost.ToString()); + HttpResponseMessage response = await this.SendInputRequest("getproducts-nameempty", cost.ToString()); // Verify result Product[] expectedResponse = products; From 3ed6e294bf334446d3ee69ff1e41df5a4dc2921d Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Wed, 2 Nov 2022 04:26:56 -0700 Subject: [PATCH 29/41] fix tests --- samples/samples-powershell/AddProductWithDefaultPK/run.ps1 | 2 +- .../AddProductWithIdentityColumnIncluded/run.ps1 | 2 +- .../function.json | 3 ++- .../AddProductsWithIdentityColumnArray/run.ps1 | 2 +- samples/samples-powershell/TimerTriggerProducts/run.ps1 | 2 -- .../test-powershell/AddProductColumnTypes/run.ps1 | 6 +++--- .../test-powershell/AddProductsNoPartialUpsert/run.ps1 | 2 +- 7 files changed, 9 insertions(+), 10 deletions(-) diff --git a/samples/samples-powershell/AddProductWithDefaultPK/run.ps1 b/samples/samples-powershell/AddProductWithDefaultPK/run.ps1 index a8823cce9..1bf6b80e2 100644 --- a/samples/samples-powershell/AddProductWithDefaultPK/run.ps1 +++ b/samples/samples-powershell/AddProductWithDefaultPK/run.ps1 @@ -9,7 +9,7 @@ Write-Host "PowerShell function with SQL 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 +$req_body = $Request.QUERY # 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 diff --git a/samples/samples-powershell/AddProductWithIdentityColumnIncluded/run.ps1 b/samples/samples-powershell/AddProductWithIdentityColumnIncluded/run.ps1 index dce198785..602e48d27 100644 --- a/samples/samples-powershell/AddProductWithIdentityColumnIncluded/run.ps1 +++ b/samples/samples-powershell/AddProductWithIdentityColumnIncluded/run.ps1 @@ -10,7 +10,7 @@ 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. $req_body = @{ - productId=$Request.QUERY.productId; + productId= if($Request.QUERY.productId) { $Request.QUERY.productId } else { $null }; name=$Request.QUERY.name; cost=$Request.QUERY.cost; }; diff --git a/samples/samples-powershell/AddProductWithMultiplePrimaryColumnsAndIdentity/function.json b/samples/samples-powershell/AddProductWithMultiplePrimaryColumnsAndIdentity/function.json index 02252ebf3..983861d99 100644 --- a/samples/samples-powershell/AddProductWithMultiplePrimaryColumnsAndIdentity/function.json +++ b/samples/samples-powershell/AddProductWithMultiplePrimaryColumnsAndIdentity/function.json @@ -6,7 +6,8 @@ "direction": "in", "type": "httpTrigger", "methods": [ - "get" + "get", + "post" ], "route": "addproductwithmultipleprimarycolumnsandidentity" }, diff --git a/samples/samples-powershell/AddProductsWithIdentityColumnArray/run.ps1 b/samples/samples-powershell/AddProductsWithIdentityColumnArray/run.ps1 index c66344076..bb2e35d52 100644 --- a/samples/samples-powershell/AddProductsWithIdentityColumnArray/run.ps1 +++ b/samples/samples-powershell/AddProductsWithIdentityColumnArray/run.ps1 @@ -15,7 +15,7 @@ $req_body = @(@{ }, @{ 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 diff --git a/samples/samples-powershell/TimerTriggerProducts/run.ps1 b/samples/samples-powershell/TimerTriggerProducts/run.ps1 index 22f1df60b..9506a29b4 100644 --- a/samples/samples-powershell/TimerTriggerProducts/run.ps1 +++ b/samples/samples-powershell/TimerTriggerProducts/run.ps1 @@ -1,8 +1,6 @@ using namespace System.Net -# Trigger binding data passed in via param block $executionNumber = 0; -param($myTimer) $totalUpserts = 100; # Write to the Azure Functions log stream. Write-Host "[QueueTrigger]: $Get-Date starting execution $executionNumber. Rows to generate=$totalUpserts." diff --git a/test/Integration/test-powershell/AddProductColumnTypes/run.ps1 b/test/Integration/test-powershell/AddProductColumnTypes/run.ps1 index 14e85b8da..6647409e4 100644 --- a/test/Integration/test-powershell/AddProductColumnTypes/run.ps1 +++ b/test/Integration/test-powershell/AddProductColumnTypes/run.ps1 @@ -10,9 +10,9 @@ 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. $req_query = @{ - productId=$Request.QUERY.productId; - datetime= Get-Date; - datetime2= Get-Date; + ProductId=$Request.QUERY.productId; + Datetime=Get-Date -AsUTC; + Datetime2=Get-Date -AsUTC; }; # Assign the value we want to pass to the SQL Output binding. diff --git a/test/Integration/test-powershell/AddProductsNoPartialUpsert/run.ps1 b/test/Integration/test-powershell/AddProductsNoPartialUpsert/run.ps1 index ce1b50e96..c3e9725dd 100644 --- a/test/Integration/test-powershell/AddProductsNoPartialUpsert/run.ps1 +++ b/test/Integration/test-powershell/AddProductsNoPartialUpsert/run.ps1 @@ -30,7 +30,7 @@ $products += $invalidProduct # 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 $products +Push-OutputBinding -Name products -Value $products # Assign the value to return as the HTTP response. # The -Name value matches the name property in the function.json for the binding From bd14a67d6f81b59d7881c22ae6d258feaf5376e5 Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Wed, 2 Nov 2022 14:58:34 -0700 Subject: [PATCH 30/41] address fixes --- samples/samples-powershell/AddProductParams/function.json | 3 ++- .../samples-powershell/AddProductWithDefaultPK/function.json | 1 + samples/samples-powershell/AddProductWithDefaultPK/run.ps1 | 2 +- .../AddProductWithIdentityColumn/function.json | 3 ++- .../AddProductsWithIdentityColumnArray/function.json | 3 ++- samples/samples-powershell/TimerTriggerProducts/run.ps1 | 1 + test/Integration/SqlOutputBindingIntegrationTests.cs | 3 +++ 7 files changed, 12 insertions(+), 4 deletions(-) diff --git a/samples/samples-powershell/AddProductParams/function.json b/samples/samples-powershell/AddProductParams/function.json index 0ee720829..0623b9df8 100644 --- a/samples/samples-powershell/AddProductParams/function.json +++ b/samples/samples-powershell/AddProductParams/function.json @@ -6,7 +6,8 @@ "direction": "in", "type": "httpTrigger", "methods": [ - "get" + "get", + "post" ], "route": "addproduct-params" }, diff --git a/samples/samples-powershell/AddProductWithDefaultPK/function.json b/samples/samples-powershell/AddProductWithDefaultPK/function.json index c7d30f29f..ebd8af686 100644 --- a/samples/samples-powershell/AddProductWithDefaultPK/function.json +++ b/samples/samples-powershell/AddProductWithDefaultPK/function.json @@ -6,6 +6,7 @@ "direction": "in", "type": "httpTrigger", "methods": [ + "get", "post" ], "route": "addproductwithdefaultpk" diff --git a/samples/samples-powershell/AddProductWithDefaultPK/run.ps1 b/samples/samples-powershell/AddProductWithDefaultPK/run.ps1 index 1bf6b80e2..a8823cce9 100644 --- a/samples/samples-powershell/AddProductWithDefaultPK/run.ps1 +++ b/samples/samples-powershell/AddProductWithDefaultPK/run.ps1 @@ -9,7 +9,7 @@ Write-Host "PowerShell function with SQL 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.QUERY +$req_body = $Request.Body # 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 diff --git a/samples/samples-powershell/AddProductWithIdentityColumn/function.json b/samples/samples-powershell/AddProductWithIdentityColumn/function.json index a186392be..95e2598c4 100644 --- a/samples/samples-powershell/AddProductWithIdentityColumn/function.json +++ b/samples/samples-powershell/AddProductWithIdentityColumn/function.json @@ -6,7 +6,8 @@ "direction": "in", "type": "httpTrigger", "methods": [ - "get" + "get", + "post" ], "route": "addproductwithidentitycolumn" }, diff --git a/samples/samples-powershell/AddProductsWithIdentityColumnArray/function.json b/samples/samples-powershell/AddProductsWithIdentityColumnArray/function.json index 09e5ac77e..7bf34fc21 100644 --- a/samples/samples-powershell/AddProductsWithIdentityColumnArray/function.json +++ b/samples/samples-powershell/AddProductsWithIdentityColumnArray/function.json @@ -6,7 +6,8 @@ "direction": "in", "type": "httpTrigger", "methods": [ - "get" + "get", + "post" ], "route": "addproductswithidentitycolumnarray" }, diff --git a/samples/samples-powershell/TimerTriggerProducts/run.ps1 b/samples/samples-powershell/TimerTriggerProducts/run.ps1 index 9506a29b4..596117d62 100644 --- a/samples/samples-powershell/TimerTriggerProducts/run.ps1 +++ b/samples/samples-powershell/TimerTriggerProducts/run.ps1 @@ -1,5 +1,6 @@ using namespace System.Net +param($myTimer) $executionNumber = 0; $totalUpserts = 100; # Write to the Azure Functions log stream. diff --git a/test/Integration/SqlOutputBindingIntegrationTests.cs b/test/Integration/SqlOutputBindingIntegrationTests.cs index 8711cac37..d51b3fbfe 100644 --- a/test/Integration/SqlOutputBindingIntegrationTests.cs +++ b/test/Integration/SqlOutputBindingIntegrationTests.cs @@ -45,6 +45,9 @@ public void AddProductTest(int id, string name, int cost, SupportedLanguages lan [SqlInlineData(1, "Test", 5)] [SqlInlineData(0, "", 0)] [SqlInlineData(-500, "ABCD", 580)] + // Currently PowerShell returns null if the output + // Issue link: https://github.com/Azure/azure-functions-sql-extension/issues/443 + [UnsupportedLanguages(SupportedLanguages.PowerShell)] public void AddProductParamsTest(int id, string name, int cost, SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductParams), lang); From ea3b366d9eeba6309804e6a7357e4d8a20856c7a Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Thu, 3 Nov 2022 03:52:17 -0700 Subject: [PATCH 31/41] mark tests that are not currently working --- .../QueueTriggerProducts/run.ps1 | 3 ++- .../TimerTriggerProducts/run.ps1 | 15 ++++++--------- .../SqlInputBindingIntegrationTests.cs | 3 +++ .../SqlOutputBindingIntegrationTests.cs | 3 +++ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/samples/samples-powershell/QueueTriggerProducts/run.ps1 b/samples/samples-powershell/QueueTriggerProducts/run.ps1 index 0dea29f51..edba99505 100644 --- a/samples/samples-powershell/QueueTriggerProducts/run.ps1 +++ b/samples/samples-powershell/QueueTriggerProducts/run.ps1 @@ -22,6 +22,7 @@ for ($i = 0; $i -lt $totalUpserts; $i++) { # 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 $products -$duration = Get-Date - $start; +$end = Get-Date +$duration = New-TimeSpan -Start $start -End $end Write-Host "[QueueTrigger]: $Get-Date finished execution $queueMessage. Total time to create $totalUpserts rows=$duration." \ No newline at end of file diff --git a/samples/samples-powershell/TimerTriggerProducts/run.ps1 b/samples/samples-powershell/TimerTriggerProducts/run.ps1 index 596117d62..94d5b7934 100644 --- a/samples/samples-powershell/TimerTriggerProducts/run.ps1 +++ b/samples/samples-powershell/TimerTriggerProducts/run.ps1 @@ -2,14 +2,11 @@ using namespace System.Net param($myTimer) $executionNumber = 0; -$totalUpserts = 100; -# Write to the Azure Functions log stream. -Write-Host "[QueueTrigger]: $Get-Date starting execution $executionNumber. Rows to generate=$totalUpserts." +$totalUpserts = 1000; -# 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. +# Write to the Azure Functions log stream. $start = Get-Date +Write-Host "[QueueTrigger]: $start starting execution $executionNumber. Rows to generate=$totalUpserts." $products = @() for ($i = 0; $i -lt $totalUpserts; $i++) { @@ -19,12 +16,12 @@ for ($i = 0; $i -lt $totalUpserts; $i++) { cost = 100 * $i; } } -$duration = Get-Date - $start; +$end = Get-Date +$duration = New-TimeSpan -Start $start -End $end # 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 $products -Write-Host "[QueueTrigger]: $Get-Date finished execution $queueMessage. Total time to create $totalUpserts rows=$duration." - +Write-Host "[QueueTrigger]: $end finished execution $queueMessage. Total time to create $totalUpserts rows=$duration." $executionNumber += 1; \ No newline at end of file diff --git a/test/Integration/SqlInputBindingIntegrationTests.cs b/test/Integration/SqlInputBindingIntegrationTests.cs index f97a600e1..4ac7ee5f6 100644 --- a/test/Integration/SqlInputBindingIntegrationTests.cs +++ b/test/Integration/SqlInputBindingIntegrationTests.cs @@ -164,6 +164,9 @@ public async void GetProductsColumnTypesSerializationAsyncEnumerableTest(string /// [Theory] [SqlInlineData()] + // Currently PowerShell deseralization returns it back alphabetically (with same results) as such the assertion will fail + // Issue link: https://github.com/Azure/azure-functions-sql-extension/issues/448 + [UnsupportedLanguages(SupportedLanguages.PowerShell)] public async void GetProductsColumnTypesSerializationTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(GetProductsColumnTypesSerialization), lang, true); diff --git a/test/Integration/SqlOutputBindingIntegrationTests.cs b/test/Integration/SqlOutputBindingIntegrationTests.cs index d51b3fbfe..db1f42a5c 100644 --- a/test/Integration/SqlOutputBindingIntegrationTests.cs +++ b/test/Integration/SqlOutputBindingIntegrationTests.cs @@ -391,6 +391,9 @@ public void AddProductCaseSensitiveTest(SupportedLanguages lang) /// [Theory] [SqlInlineData()] + // Currently PowerShell gives an unknown error (when testing locally we get a missing primary key error) + // Issue link: https://github.com/Azure/azure-functions-sql-extension/issues/448 + [UnsupportedLanguages(SupportedLanguages.PowerShell)] public void AddProductWithDefaultPKTest(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductWithDefaultPK), lang); From 60a539e7cb097d9c9047683035c2c1af49e980b2 Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Thu, 3 Nov 2022 03:59:08 -0700 Subject: [PATCH 32/41] undo local.settings.json --- .gitignore | 2 +- samples/samples-csharp/.gitignore | 2 +- samples/samples-js/.gitignore | 2 +- samples/samples-python/.gitignore | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index c3db6171b..0278bab71 100644 --- a/.gitignore +++ b/.gitignore @@ -350,7 +350,7 @@ MigrationBackup/ .ionide/ # Azure Functions localsettings file -# local.settings.json +local.settings.json # Azurite artifacts __blobstorage__ diff --git a/samples/samples-csharp/.gitignore b/samples/samples-csharp/.gitignore index ad9b6e1b9..ff5b00c50 100644 --- a/samples/samples-csharp/.gitignore +++ b/samples/samples-csharp/.gitignore @@ -2,7 +2,7 @@ ## files generated by popular Visual Studio add-ons. # Azure Functions localsettings file -# local.settings.json +local.settings.json # User-specific files *.suo diff --git a/samples/samples-js/.gitignore b/samples/samples-js/.gitignore index 6120e81e7..01774db7f 100644 --- a/samples/samples-js/.gitignore +++ b/samples/samples-js/.gitignore @@ -91,7 +91,7 @@ out bin obj appsettings.json -# local.settings.json +local.settings.json # Azurite artifacts __blobstorage__ diff --git a/samples/samples-python/.gitignore b/samples/samples-python/.gitignore index e61abf6bc..304fe4ce6 100644 --- a/samples/samples-python/.gitignore +++ b/samples/samples-python/.gitignore @@ -1,5 +1,5 @@ # Azure Functions localsettings file -# local.settings.json +local.settings.json # Azurite artifacts __blobstorage__ From 1513c5570280bd5fbd8358184b20a04d6528426f Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Thu, 3 Nov 2022 13:48:26 -0700 Subject: [PATCH 33/41] AddProductWithMultiplePrimaryColumnsAndIdentity test --- samples/samples-powershell/.gitignore | 2 +- test/Integration/SqlOutputBindingIntegrationTests.cs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/samples/samples-powershell/.gitignore b/samples/samples-powershell/.gitignore index 6120e81e7..01774db7f 100644 --- a/samples/samples-powershell/.gitignore +++ b/samples/samples-powershell/.gitignore @@ -91,7 +91,7 @@ out bin obj appsettings.json -# local.settings.json +local.settings.json # Azurite artifacts __blobstorage__ diff --git a/test/Integration/SqlOutputBindingIntegrationTests.cs b/test/Integration/SqlOutputBindingIntegrationTests.cs index db1f42a5c..cac56c792 100644 --- a/test/Integration/SqlOutputBindingIntegrationTests.cs +++ b/test/Integration/SqlOutputBindingIntegrationTests.cs @@ -252,6 +252,9 @@ public void AddProductsWithIdentityColumnArray(SupportedLanguages lang) /// [Theory] [SqlInlineData()] + // Currently PowerShell gives an error due to the deserialization of the object + // Issue link: https://github.com/Azure/azure-functions-sql-extension/issues/448 + [UnsupportedLanguages(SupportedLanguages.PowerShell)] public void AddProductWithIdentity_MultiplePrimaryColumns(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductWithMultiplePrimaryColumnsAndIdentity), lang); From 188f40c8a7d0f5d5029bb918e74eb6981aef0474 Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Thu, 3 Nov 2022 14:35:00 -0700 Subject: [PATCH 34/41] identity tests are unstable --- test/Integration/SqlOutputBindingIntegrationTests.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/Integration/SqlOutputBindingIntegrationTests.cs b/test/Integration/SqlOutputBindingIntegrationTests.cs index cac56c792..833b8070f 100644 --- a/test/Integration/SqlOutputBindingIntegrationTests.cs +++ b/test/Integration/SqlOutputBindingIntegrationTests.cs @@ -217,6 +217,8 @@ public void AddProductNoPartialUpsertTest(SupportedLanguages lang) /// [Theory] [SqlInlineData()] + // Currently PowerShell gives an error due to the deserialization of the object + // Issue link: https://github.com/Azure/azure-functions-sql-extension/issues/448 public void AddProductWithIdentity(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductWithIdentityColumn), lang); @@ -237,6 +239,8 @@ public void AddProductWithIdentity(SupportedLanguages lang) /// [Theory] [SqlInlineData()] + // Currently PowerShell gives an error due to the deserialization of the object + // Issue link: https://github.com/Azure/azure-functions-sql-extension/issues/448 public void AddProductsWithIdentityColumnArray(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductsWithIdentityColumnArray), lang); From 41aec735ce6b16d70d413fd8d6b86595a581ea7d Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Thu, 3 Nov 2022 18:13:51 -0700 Subject: [PATCH 35/41] other identity tests unstable --- test/Integration/SqlOutputBindingIntegrationTests.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/Integration/SqlOutputBindingIntegrationTests.cs b/test/Integration/SqlOutputBindingIntegrationTests.cs index 833b8070f..3816705ef 100644 --- a/test/Integration/SqlOutputBindingIntegrationTests.cs +++ b/test/Integration/SqlOutputBindingIntegrationTests.cs @@ -219,6 +219,7 @@ public void AddProductNoPartialUpsertTest(SupportedLanguages lang) [SqlInlineData()] // Currently PowerShell gives an error due to the deserialization of the object // Issue link: https://github.com/Azure/azure-functions-sql-extension/issues/448 + [UnsupportedLanguages(SupportedLanguages.PowerShell)] public void AddProductWithIdentity(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductWithIdentityColumn), lang); @@ -241,6 +242,7 @@ public void AddProductWithIdentity(SupportedLanguages lang) [SqlInlineData()] // Currently PowerShell gives an error due to the deserialization of the object // Issue link: https://github.com/Azure/azure-functions-sql-extension/issues/448 + [UnsupportedLanguages(SupportedLanguages.PowerShell)] public void AddProductsWithIdentityColumnArray(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductsWithIdentityColumnArray), lang); @@ -338,6 +340,9 @@ public void AddProductWithIdentity_NoIdentityColumn(SupportedLanguages lang) /// [Theory] [SqlInlineData()] + // Currently PowerShell gives an error due to the deserialization of the object + // Issue link: https://github.com/Azure/azure-functions-sql-extension/issues/448 + [UnsupportedLanguages(SupportedLanguages.PowerShell)] public void AddProductWithIdentity_MissingPrimaryColumn(SupportedLanguages lang) { this.StartFunctionHost(nameof(AddProductWithMultiplePrimaryColumnsAndIdentity), lang); From c3e98feaa109713f3e86256c7a1f6839ae6c99da Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Mon, 7 Nov 2022 01:50:29 -0800 Subject: [PATCH 36/41] address comments --- samples/samples-powershell/.eslintrc.json | 19 ----- samples/samples-powershell/.funcignore | 2 - samples/samples-powershell/.gitignore | 88 +---------------------- 3 files changed, 1 insertion(+), 108 deletions(-) delete mode 100644 samples/samples-powershell/.eslintrc.json diff --git a/samples/samples-powershell/.eslintrc.json b/samples/samples-powershell/.eslintrc.json deleted file mode 100644 index 48e60a390..000000000 --- a/samples/samples-powershell/.eslintrc.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "root": true, - "parserOptions": { - "ecmaVersion": "latest" - }, - "plugins": [ - "header" - ], - "rules": { - "header/header": [ - 2, - "line", - [ - " Copyright (c) Microsoft Corporation. All rights reserved.", - " Licensed under the MIT License. See License.txt in the project root for license information." - ] - ] - } -} \ No newline at end of file diff --git a/samples/samples-powershell/.funcignore b/samples/samples-powershell/.funcignore index 6970d441b..fe7c2bfa4 100644 --- a/samples/samples-powershell/.funcignore +++ b/samples/samples-powershell/.funcignore @@ -1,5 +1,3 @@ -*.js.map -*.ts .git* .vscode test diff --git a/samples/samples-powershell/.gitignore b/samples/samples-powershell/.gitignore index 01774db7f..bd663b5ea 100644 --- a/samples/samples-powershell/.gitignore +++ b/samples/samples-powershell/.gitignore @@ -6,94 +6,8 @@ yarn-debug.log* yarn-error.log* lerna-debug.log* -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# TypeScript v1 declaration files -typings/ - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file -.env -.env.test - -# parcel-bundler cache (https://parceljs.org/) -.cache - -# next.js build output -.next - -# nuxt.js build output -.nuxt - -# vuepress build output -.vuepress/dist - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# TypeScript output -dist -out - # Azure Functions artifacts bin obj appsettings.json -local.settings.json - -# Azurite artifacts -__blobstorage__ -__queuestorage__ -__azurite_db*__.json \ No newline at end of file +local.settings.json \ No newline at end of file From 4a9e9d7b8ecbc06fdd73c4abfc1b81c84e6e2fd7 Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Mon, 7 Nov 2022 10:47:37 -0800 Subject: [PATCH 37/41] address comments: --- .gitignore | 5 ++++- samples/samples-powershell/.funcignore | 4 ---- samples/samples-powershell/.gitignore | 13 ------------- samples/samples-powershell/.vscode/extensions.json | 6 ++++++ .../run.ps1 | 2 +- .../AddProductsNoPartialUpsert/run.ps1 | 11 ++--------- 6 files changed, 13 insertions(+), 28 deletions(-) delete mode 100644 samples/samples-powershell/.funcignore delete mode 100644 samples/samples-powershell/.gitignore create mode 100644 samples/samples-powershell/.vscode/extensions.json diff --git a/.gitignore b/.gitignore index 0278bab71..259b25be9 100644 --- a/.gitignore +++ b/.gitignore @@ -358,4 +358,7 @@ __queuestorage__ __azurite_db*__.json # Python virtual environment -.venv \ No newline at end of file +.venv + +# Mac OS X +.DS_Store \ No newline at end of file diff --git a/samples/samples-powershell/.funcignore b/samples/samples-powershell/.funcignore deleted file mode 100644 index fe7c2bfa4..000000000 --- a/samples/samples-powershell/.funcignore +++ /dev/null @@ -1,4 +0,0 @@ -.git* -.vscode -test -tsconfig.json \ No newline at end of file diff --git a/samples/samples-powershell/.gitignore b/samples/samples-powershell/.gitignore deleted file mode 100644 index bd663b5ea..000000000 --- a/samples/samples-powershell/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* - -# Azure Functions artifacts -bin -obj -appsettings.json -local.settings.json \ No newline at end of file diff --git a/samples/samples-powershell/.vscode/extensions.json b/samples/samples-powershell/.vscode/extensions.json new file mode 100644 index 000000000..57fa07bd9 --- /dev/null +++ b/samples/samples-powershell/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "ms-azuretools.vscode-azurefunctions", + "ms-vscode.powershell" + ] +} \ No newline at end of file diff --git a/test/Integration/test-powershell/AddProductMissingColumnsExceptionFunction/run.ps1 b/test/Integration/test-powershell/AddProductMissingColumnsExceptionFunction/run.ps1 index 6dbd959ac..87bb12c20 100644 --- a/test/Integration/test-powershell/AddProductMissingColumnsExceptionFunction/run.ps1 +++ b/test/Integration/test-powershell/AddProductMissingColumnsExceptionFunction/run.ps1 @@ -12,7 +12,7 @@ Write-Host "PowerShell function with SQL Output Binding processed a request." $req_body = @{ productId=1; name="MissingCost"; - # Missing Cost + # Cost is missing }; # Assign the value we want to pass to the SQL Output binding. diff --git a/test/Integration/test-powershell/AddProductsNoPartialUpsert/run.ps1 b/test/Integration/test-powershell/AddProductsNoPartialUpsert/run.ps1 index c3e9725dd..844318d7f 100644 --- a/test/Integration/test-powershell/AddProductsNoPartialUpsert/run.ps1 +++ b/test/Integration/test-powershell/AddProductsNoPartialUpsert/run.ps1 @@ -2,17 +2,10 @@ using namespace System.Net # Trigger binding data passed in via param block param($Request) -$totalUpserts = 100; -# Write to the Azure Functions log stream. -Write-Host "[QueueTrigger]: $Get-Date starting execution $queueMessage. Rows to generate=$totalUpserts." - -# 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. -$start = Get-Date +$totalUpserts = 1000; $products = @() -for ($i = 0; $i -lt 1000; $i++) { +for($i = 0; $i -lt $totalUpserts; $i++) { $products += [PSCustomObject]@{ productId = $i; name = "test"; From 9d006a5bb053f3a1d19e25a939120521ad7f363c Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Mon, 7 Nov 2022 13:13:33 -0800 Subject: [PATCH 38/41] add generic default files --- samples/samples-powershell/.funcignore | 3 +++ samples/samples-powershell/.gitignore | 10 +++++++++ .../samples-powershell/.vscode/launch.json | 13 +++++++++++ .../samples-powershell/.vscode/settings.json | 7 ++++++ samples/samples-powershell/.vscode/tasks.json | 11 ++++++++++ samples/samples-powershell/profile.ps1 | 22 +++++++++++++++++++ samples/samples-powershell/requirements.psd1 | 8 +++++++ 7 files changed, 74 insertions(+) create mode 100644 samples/samples-powershell/.funcignore create mode 100644 samples/samples-powershell/.gitignore create mode 100644 samples/samples-powershell/.vscode/launch.json create mode 100644 samples/samples-powershell/.vscode/settings.json create mode 100644 samples/samples-powershell/.vscode/tasks.json create mode 100644 samples/samples-powershell/profile.ps1 create mode 100644 samples/samples-powershell/requirements.psd1 diff --git a/samples/samples-powershell/.funcignore b/samples/samples-powershell/.funcignore new file mode 100644 index 000000000..e12aca981 --- /dev/null +++ b/samples/samples-powershell/.funcignore @@ -0,0 +1,3 @@ +.git* +.vscode +local.settings.json \ No newline at end of file diff --git a/samples/samples-powershell/.gitignore b/samples/samples-powershell/.gitignore new file mode 100644 index 000000000..820e1d424 --- /dev/null +++ b/samples/samples-powershell/.gitignore @@ -0,0 +1,10 @@ +# Azure Functions artifacts +bin +obj +appsettings.json +local.settings.json + +# Azurite artifacts +__blobstorage__ +__queuestorage__ +__azurite_db*__.json \ No newline at end of file diff --git a/samples/samples-powershell/.vscode/launch.json b/samples/samples-powershell/.vscode/launch.json new file mode 100644 index 000000000..1cddecf45 --- /dev/null +++ b/samples/samples-powershell/.vscode/launch.json @@ -0,0 +1,13 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Attach to PowerShell Functions", + "type": "PowerShell", + "request": "attach", + "customPipeName": "AzureFunctionsPSWorker", + "runspaceId": 1, + "preLaunchTask": "func: host start" + } + ] +} \ No newline at end of file diff --git a/samples/samples-powershell/.vscode/settings.json b/samples/samples-powershell/.vscode/settings.json new file mode 100644 index 000000000..49300c80a --- /dev/null +++ b/samples/samples-powershell/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "azureFunctions.templateFilter": "All", + "azureFunctions.deploySubpath": ".", + "azureFunctions.projectLanguage": "PowerShell", + "azureFunctions.projectRuntime": "~4", + "debug.internalConsoleOptions": "neverOpen" +} \ No newline at end of file diff --git a/samples/samples-powershell/.vscode/tasks.json b/samples/samples-powershell/.vscode/tasks.json new file mode 100644 index 000000000..64da1ce15 --- /dev/null +++ b/samples/samples-powershell/.vscode/tasks.json @@ -0,0 +1,11 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "func", + "command": "host start", + "problemMatcher": "$func-powershell-watch", + "isBackground": true + } + ] +} \ No newline at end of file diff --git a/samples/samples-powershell/profile.ps1 b/samples/samples-powershell/profile.ps1 new file mode 100644 index 000000000..1670fc99c --- /dev/null +++ b/samples/samples-powershell/profile.ps1 @@ -0,0 +1,22 @@ +# Azure Functions profile.ps1 +# +# This profile.ps1 will get executed every "cold start" of your Function App. +# "cold start" occurs when: +# +# * A Function App starts up for the very first time +# * A Function App starts up after being de-allocated due to inactivity +# +# You can define helper functions, run commands, or specify environment variables +# NOTE: any variables defined that are not environment variables will get reset after the first execution + +# Authenticate with Azure PowerShell using MSI. +# Remove this if you are not planning on using MSI or Azure PowerShell. +if ($env:MSI_SECRET) { + Disable-AzContextAutosave -Scope Process | Out-Null + Connect-AzAccount -Identity +} + +# Uncomment the next line to enable legacy AzureRm alias in Azure PowerShell. +# Enable-AzureRmAlias + +# You can also define functions or aliases that can be referenced in any of your PowerShell functions. diff --git a/samples/samples-powershell/requirements.psd1 b/samples/samples-powershell/requirements.psd1 new file mode 100644 index 000000000..58d3be713 --- /dev/null +++ b/samples/samples-powershell/requirements.psd1 @@ -0,0 +1,8 @@ +# This file enables modules to be automatically managed by the Functions service. +# See https://aka.ms/functionsmanageddependency for additional information. +# +@{ + # For latest supported version, go to 'https://www.powershellgallery.com/packages/Az'. + # To use the Az module in your function app, please uncomment the line below. + # 'Az' = '9.*' +} \ No newline at end of file From 985540e47f98697f485de959632599a2706d14ea Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Mon, 7 Nov 2022 15:03:08 -0800 Subject: [PATCH 39/41] add pipeline task --- builds/azure-pipelines/template-steps-build-test.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/builds/azure-pipelines/template-steps-build-test.yml b/builds/azure-pipelines/template-steps-build-test.yml index c8dd777f0..6f540d950 100644 --- a/builds/azure-pipelines/template-steps-build-test.yml +++ b/builds/azure-pipelines/template-steps-build-test.yml @@ -12,6 +12,13 @@ steps: inputs: useGlobalJson: true +# Install .Net Core 3.1.0 as PowerShell tests are unable to find 3.1.0 framework to run tests +- task: UseDotNet@2 + displayName: 'Install .NET Core 3.1 sdk' + inputs: + packageType: sdk + version: '3.1.0' + # Run Policheck early to avoid scanning dependency folders - task: securedevelopmentteam.vss-secure-development-tools.build-task-policheck.PoliCheck@2 displayName: 'Run PoliCheck' From 5c9b31cc5a76e1fae2c457041febd223cf4cd133 Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Mon, 7 Nov 2022 15:14:20 -0800 Subject: [PATCH 40/41] add/edit comments --- samples/samples-powershell/AddProductParams/run.ps1 | 3 ++- .../AddProductWithDefaultPK/function.json | 1 - .../AddProductWithIdentityColumn/run.ps1 | 10 ++++------ .../AddProductWithIdentityColumnIncluded/run.ps1 | 10 ++++------ .../run.ps1 | 2 -- test/Integration/SqlOutputBindingIntegrationTests.cs | 2 +- 6 files changed, 11 insertions(+), 17 deletions(-) diff --git a/samples/samples-powershell/AddProductParams/run.ps1 b/samples/samples-powershell/AddProductParams/run.ps1 index 08b4f74cd..dad483cda 100644 --- a/samples/samples-powershell/AddProductParams/run.ps1 +++ b/samples/samples-powershell/AddProductParams/run.ps1 @@ -6,6 +6,7 @@ param($Request) # Write to the Azure Functions log stream. Write-Host "PowerShell function with SQL Output Binding processed a request." +# Update req_query with the query of the request $req_query = @{ "productId"= $Request.QUERY.productId; "name"= $Request.QUERY.name; @@ -20,5 +21,5 @@ Push-OutputBinding -Name product -Value $req_query # 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 + Body = $req_query }) \ No newline at end of file diff --git a/samples/samples-powershell/AddProductWithDefaultPK/function.json b/samples/samples-powershell/AddProductWithDefaultPK/function.json index ebd8af686..c7d30f29f 100644 --- a/samples/samples-powershell/AddProductWithDefaultPK/function.json +++ b/samples/samples-powershell/AddProductWithDefaultPK/function.json @@ -6,7 +6,6 @@ "direction": "in", "type": "httpTrigger", "methods": [ - "get", "post" ], "route": "addproductwithdefaultpk" diff --git a/samples/samples-powershell/AddProductWithIdentityColumn/run.ps1 b/samples/samples-powershell/AddProductWithIdentityColumn/run.ps1 index eb5a7ddb1..4238efdac 100644 --- a/samples/samples-powershell/AddProductWithIdentityColumn/run.ps1 +++ b/samples/samples-powershell/AddProductWithIdentityColumn/run.ps1 @@ -6,21 +6,19 @@ param($Request) # Write to the Azure Functions log stream. Write-Host "PowerShell function with SQL 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 = @{ +# Update req_query with the query of the request +$req_query = @{ name=$Request.QUERY.name; cost=$Request.QUERY.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_body +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_body + Body = $req_query }) \ No newline at end of file diff --git a/samples/samples-powershell/AddProductWithIdentityColumnIncluded/run.ps1 b/samples/samples-powershell/AddProductWithIdentityColumnIncluded/run.ps1 index 602e48d27..421c51dd9 100644 --- a/samples/samples-powershell/AddProductWithIdentityColumnIncluded/run.ps1 +++ b/samples/samples-powershell/AddProductWithIdentityColumnIncluded/run.ps1 @@ -6,10 +6,8 @@ param($Request) # Write to the Azure Functions log stream. Write-Host "PowerShell function with SQL 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 = @{ +# Update req_query with the body of the request +$req_query = @{ productId= if($Request.QUERY.productId) { $Request.QUERY.productId } else { $null }; name=$Request.QUERY.name; cost=$Request.QUERY.cost; @@ -17,11 +15,11 @@ $req_body = @{ # 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_body +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_body + Body = $req_query }) \ No newline at end of file diff --git a/samples/samples-powershell/AddProductWithMultiplePrimaryColumnsAndIdentity/run.ps1 b/samples/samples-powershell/AddProductWithMultiplePrimaryColumnsAndIdentity/run.ps1 index 878d4971d..c5dc81441 100644 --- a/samples/samples-powershell/AddProductWithMultiplePrimaryColumnsAndIdentity/run.ps1 +++ b/samples/samples-powershell/AddProductWithMultiplePrimaryColumnsAndIdentity/run.ps1 @@ -7,8 +7,6 @@ param($Request) Write-Host "PowerShell function with SQL Output Binding processed a request." # Update req_query 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_query = @{ externalId=$Request.QUERY.externalId; name=$Request.QUERY.name; diff --git a/test/Integration/SqlOutputBindingIntegrationTests.cs b/test/Integration/SqlOutputBindingIntegrationTests.cs index 3816705ef..279e339b8 100644 --- a/test/Integration/SqlOutputBindingIntegrationTests.cs +++ b/test/Integration/SqlOutputBindingIntegrationTests.cs @@ -45,7 +45,7 @@ public void AddProductTest(int id, string name, int cost, SupportedLanguages lan [SqlInlineData(1, "Test", 5)] [SqlInlineData(0, "", 0)] [SqlInlineData(-500, "ABCD", 580)] - // Currently PowerShell returns null if the output + // Currently PowerShell returns null when the parameter for name is an empty string // Issue link: https://github.com/Azure/azure-functions-sql-extension/issues/443 [UnsupportedLanguages(SupportedLanguages.PowerShell)] public void AddProductParamsTest(int id, string name, int cost, SupportedLanguages lang) From 67980c44d87ebfe678379557bf8a44731cddca41 Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Mon, 7 Nov 2022 15:18:37 -0800 Subject: [PATCH 41/41] fix pipeline dotnet task --- builds/azure-pipelines/template-steps-build-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builds/azure-pipelines/template-steps-build-test.yml b/builds/azure-pipelines/template-steps-build-test.yml index 6f540d950..0473af8b4 100644 --- a/builds/azure-pipelines/template-steps-build-test.yml +++ b/builds/azure-pipelines/template-steps-build-test.yml @@ -17,7 +17,7 @@ steps: displayName: 'Install .NET Core 3.1 sdk' inputs: packageType: sdk - version: '3.1.0' + version: '3.1.x' # Run Policheck early to avoid scanning dependency folders - task: securedevelopmentteam.vss-secure-development-tools.build-task-policheck.PoliCheck@2