Skip to content

PowerShell NULL and function file updates #531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion samples/samples-powershell/AddProduct/run.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using namespace System.Net

# Trigger binding data passed in via param block
param($Request)
param($Request, $TriggerMetadata)

# Write to the Azure Functions log stream.
Write-Host "PowerShell function with SQL Output Binding processed a request."
Expand Down
11 changes: 7 additions & 4 deletions samples/samples-powershell/AddProductParams/run.ps1
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
using namespace System.Net

# Trigger binding data passed in via param block
param($Request)
param($Request, $TriggerMetadata)

# 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
# Currently the Powershell worker does not allow empty/null values to be passed through the
# query parameters. We use TriggerMetadata here as a workaround for that issue.
# Issue link: https://github.com/Azure/azure-functions-powershell-worker/issues/895
$req_query = @{
"productId"= $Request.QUERY.productId;
"name"= $Request.QUERY.name;
"cost"= $Request.QUERY.cost;
"productId"= $TriggerMetadata["productId"];
"name"= $TriggerMetadata["name"];
"cost"= $TriggerMetadata["cost"];
};

# Assign the value we want to pass to the SQL Output binding.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using namespace System.Net

# Trigger binding data passed in via param block
param($Request)
param($Request, $TriggerMetadata)

# Write to the Azure Functions log stream.
Write-Host "PowerShell function with SQL Output Binding processed a request."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using namespace System.Net

# Trigger binding data passed in via param block
param($Request)
param($Request, $TriggerMetadata)

# Write to the Azure Functions log stream.
Write-Host "PowerShell function with SQL Output Binding processed a request."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using namespace System.Net

# Trigger binding data passed in via param block
param($Request)
param($Request, $TriggerMetadata)

# Write to the Azure Functions log stream.
Write-Host "PowerShell function with SQL Output Binding processed a request."

# Update req_query with the body of the request
$req_query = @{
productId= if($Request.QUERY.productId) { $Request.QUERY.productId } else { $null };
productId= if($Request.QUERY.productId) { [int]$Request.QUERY.productId } else { $null };
name=$Request.QUERY.name;
cost=$Request.QUERY.cost;
cost=[int]$Request.QUERY.cost;
};

# Assign the value we want to pass to the SQL Output binding.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"direction": "in",
"type": "httpTrigger",
"methods": [
"get",
"post"
"get"
],
"route": "addproductwithmultipleprimarycolumnsandidentity"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using namespace System.Net

# Trigger binding data passed in via param block
param($Request)
param($Request, $TriggerMetadata)

# Write to the Azure Functions log stream.
Write-Host "PowerShell function with SQL Output Binding processed a request."
Expand Down
2 changes: 1 addition & 1 deletion samples/samples-powershell/AddProductsArray/run.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using namespace System.Net

# Trigger binding data passed in via param block
param($Request)
param($Request, $TriggerMetadata)

# Write to the Azure Functions log stream.
Write-Host "PowerShell function with SQL Output Binding processed a request."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"direction": "in",
"type": "httpTrigger",
"methods": [
"get",
"post"
"get"
],
"route": "addproductswithidentitycolumnarray"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using namespace System.Net

# Trigger binding data passed in via param block
param($Request)
param($Request, $TriggerMetadata)

# Write to the Azure Functions log stream.
Write-Host "PowerShell function with SQL Output Binding processed a request."
Expand Down
2 changes: 1 addition & 1 deletion samples/samples-powershell/GetProductNamesView/run.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using namespace System.Net

# Trigger and input binding data are passed in via the param block.
param($Request, $products)
param($Request, $TriggerMetadata, $products)

# Write to the Azure Functions log stream.
Write-Host "PowerShell function with SQL Input Binding processed a request."
Expand Down
2 changes: 1 addition & 1 deletion samples/samples-powershell/GetProducts/run.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using namespace System.Net

# Trigger and input binding data are passed in via the param block.
param($Request, $products)
param($Request, $TriggerMetadata, $products)

# Write to the Azure Functions log stream.
Write-Host "PowerShell function with SQL Input Binding processed a request."
Expand Down
2 changes: 1 addition & 1 deletion samples/samples-powershell/GetProductsNameEmpty/run.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using namespace System.Net

# Trigger and input binding data are passed in via the param block.
param($Request, $products)
param($Request, $TriggerMetadata, $products)

# Write to the Azure Functions log stream.
Write-Host "PowerShell function with SQL Input Binding processed a request."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using namespace System.Net

# Trigger and input binding data are passed in via the param block.
param($Request, $products)
param($Request, $TriggerMetadata, $products)

# Write to the Azure Functions log stream.
Write-Host "PowerShell function with SQL Input Binding processed a request."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using namespace System.Net

# Trigger and input binding data are passed in via the param block.
param($Request, $products)
param($Request, $TriggerMetadata, $products)

# Write to the Azure Functions log stream.
Write-Host "PowerShell function with SQL Input Binding processed a request."
Expand Down
2 changes: 1 addition & 1 deletion samples/samples-powershell/QueueTriggerProducts/run.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using namespace System.Net

# Trigger binding data passed in via param block
param($queueMessage)
param($queueMessage, $TriggerMetadata)
$totalUpserts = 100;
# Write to the Azure Functions log stream.
Write-Host "[QueueTrigger]: $Get-Date starting execution $queueMessage. Rows to generate=$totalUpserts."
Expand Down
2 changes: 1 addition & 1 deletion samples/samples-powershell/TimerTriggerProducts/run.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using namespace System.Net

param($myTimer)
param($myTimer, $TriggerMetadata)
$executionNumber = 0;
$totalUpserts = 1000;

Expand Down
2 changes: 1 addition & 1 deletion samples/samples-powershell/local.settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "powershell",
"FUNCTIONS_WORKER_RUNTIME_VERSION" : "~7",
"FUNCTIONS_WORKER_RUNTIME_VERSION" : "~7.2",
"SqlConnectionString": "",
"Sp_SelectCost": "SelectProductsCost",
"ProductCost": 100
Expand Down
6 changes: 3 additions & 3 deletions test/Integration/SqlOutputBindingIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public void AddProductTest(int id, string name, int cost, SupportedLanguages lan
[SqlInlineData(1, "Test", 5)]
[SqlInlineData(0, "", 0)]
[SqlInlineData(-500, "ABCD", 580)]
// Currently PowerShell and Java functions return null when the parameter for name is an empty string
// Issue link: https://github.com/Azure/azure-functions-sql-extension/issues/443
// Currently Java functions return null when the parameter for name is an empty string
// Issue link: https://github.com/Azure/azure-functions-sql-extension/issues/517
[UnsupportedLanguages(SupportedLanguages.PowerShell, SupportedLanguages.Java)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are still failing for Java it seems.

@lucyzhang929 - possibly a similar issue for their worker. So something to follow up with them about when you get around to investigating this.

public void AddProductParamsTest(int id, string name, int cost, SupportedLanguages lang)
{
Expand Down Expand Up @@ -116,7 +116,7 @@ public void AddProductArrayTest(SupportedLanguages lang)
[SqlInlineData()]
// This test is currrently failing in the Linux pipeline for Java
// https://github.com/Azure/azure-functions-sql-extension/issues/521
[UnsupportedLanguages(SupportedLanguages.Java)]
[UnsupportedLanguages(SupportedLanguages.Java, SupportedLanguages.PowerShell)]
public void AddProductColumnTypesTest(SupportedLanguages lang)
{
this.StartFunctionHost(nameof(AddProductColumnTypes), lang, true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using namespace System.Net

# Trigger binding data passed in via param block
param($Request)
param($Request, $TriggerMetadata)

# Write to the Azure Functions log stream.
Write-Host "PowerShell function with SQL Output Binding processed a request."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using namespace System.Net

# Trigger binding data passed in via param block
param($Request)
param($Request, $TriggerMetadata)

# Write to the Azure Functions log stream.
Write-Host "PowerShell function with SQL Output Binding processed a request."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using namespace System.Net

# Trigger binding data passed in via param block
param($Request)
param($Request, $TriggerMetadata)

# Write to the Azure Functions log stream.
Write-Host "PowerShell function with SQL Output Binding processed a request."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using namespace System.Net

# Trigger binding data passed in via param block
param($Request)
param($Request, $TriggerMetadata)

# Write to the Azure Functions log stream.
Write-Host "PowerShell function with SQL Output Binding processed a request."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using namespace System.Net

# Trigger binding data passed in via param block
param($Request)
param($Request, $TriggerMetadata)
$totalUpserts = 1000;

$products = @()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using namespace System.Net

# Trigger and input binding data are passed in via the param block.
param($Request, $products)
param($Request, $TriggerMetadata, $products)

# Write to the Azure Functions log stream.
Write-Host "PowerShell function with SQL Input Binding processed a request."
Expand Down