Skip to content
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

replace read async with read of SqlReader for perf #904

Merged
merged 96 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from 88 commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
dcbf3ea
Merge pull request #736 from Azure/chgagnon/syncMain
Charles-Gagnon Mar 15, 2023
d323132
Revert "Remove trigger binding for GA release (#732)" (#733)
Charles-Gagnon Mar 15, 2023
2a82a61
vBump release/trigger 2.* -> 3.* (#738)
Charles-Gagnon Mar 15, 2023
cf18917
Add JObject support for SQL trigger (#722)
lucyzhang929 Mar 15, 2023
9d6988c
Fix trigger connection not being retried when connection is closed (#…
Charles-Gagnon Mar 15, 2023
9819cea
Add Privacy Statement to README and telemetry message (#751)
Charles-Gagnon Mar 21, 2023
5cce9d6
enable trigger oop (#750)
MaddyDev Mar 21, 2023
a424e03
Merge pull request #752 from Azure/chgagnon/portTelemetryUpdates
Charles-Gagnon Mar 22, 2023
febf17d
Enable debug logging for Python and PS samples (#754)
lucyzhang929 Mar 22, 2023
717fe16
Add docs & logging information for Leases table info (#756)
Charles-Gagnon Mar 23, 2023
cc0218f
Add ProductsTriggerWithValidation tests for Python, JS, PS (#753)
lucyzhang929 Mar 23, 2023
bc87f7e
Further clarifications to trigger retry docs (#770)
Charles-Gagnon Mar 28, 2023
e683dce
increase timeout to 120 minutes (#776)
lucyzhang929 Mar 29, 2023
f035e92
Enable more tests for OOP trigger (#777)
MaddyDev Mar 30, 2023
bbbe543
bump jackson dependency (#782)
lucyzhang929 Apr 3, 2023
5eed998
Add detailed trigger docs (#780)
Charles-Gagnon Apr 3, 2023
e367aa3
Filter out more default telemetry properties
Charles-Gagnon Mar 31, 2023
90d0ea5
Merge pull request #784 from Azure/chgagnon/portTelemetry
Charles-Gagnon Apr 3, 2023
33ee38c
Merge branch 'main' into chgagnon/mergeMain
Charles-Gagnon Apr 4, 2023
b7a76b8
bring back trigger text
Charles-Gagnon Apr 4, 2023
e8fe283
Fixes
Charles-Gagnon Apr 4, 2023
d6aa85d
Add SQLTrigger annotation to java library (#783)
lucyzhang929 Apr 4, 2023
5bdb495
Disable CSX trigger tests
Charles-Gagnon Apr 4, 2023
290fbbc
fix regex for java library version (#788)
lucyzhang929 Apr 5, 2023
b14070a
Adding rest of Trigger integration tests for Python, PS, JS (#763)
lucyzhang929 Apr 5, 2023
21837bb
Merge pull request #785 from Azure/chgagnon/mergeMain
Charles-Gagnon Apr 6, 2023
621ef15
Skip more trigger tests for CSX (#791)
Charles-Gagnon Apr 6, 2023
ff6e739
Introduce Target Based Scaling (#598)
AmeyaRele Apr 10, 2023
c414f9b
Merge branch 'main' into chgagnon/mergeMain
Charles-Gagnon Apr 10, 2023
a13da52
Merge pull request #794 from Azure/chgagnon/mergeMain
Charles-Gagnon Apr 10, 2023
0f8bdf6
Enable trace level logging for tests (#795)
Charles-Gagnon Apr 10, 2023
26d7d2e
Add java trigger samples (#793)
lucyzhang929 Apr 10, 2023
5ea34ef
Fix up performance tests & enable schedule (#799)
Charles-Gagnon Apr 11, 2023
3c1b41f
Minor trigger doc updates (#800)
Charles-Gagnon Apr 11, 2023
b56fff0
enable rest of the trigger tests for oop (#798)
MaddyDev Apr 12, 2023
3faffa6
add sample for python v2 model (#803)
lucyzhang929 Apr 14, 2023
0113f93
Merge branch 'main' into chgagnon/mergeMain
Charles-Gagnon Apr 14, 2023
0a2ec0c
Fix logs
Charles-Gagnon Apr 14, 2023
0e3a9cb
fix compile
Charles-Gagnon Apr 14, 2023
9addf97
Merge pull request #807 from Azure/chgagnon/mergeMain
Charles-Gagnon Apr 14, 2023
5c54df6
remove delegate (#809)
MaddyDev Apr 17, 2023
feaf36f
add csx trigger samples (#806)
MaddyDev Apr 18, 2023
76289eb
Cleanup trigger logging (#808)
Charles-Gagnon Apr 18, 2023
7fc9cda
[Trigger] Update from main (#820)
Charles-Gagnon Apr 21, 2023
7708a7f
Merge branch 'main' into chgagnon/mergeCommits
Charles-Gagnon Apr 21, 2023
5833327
Merge pull request #822 from Azure/chgagnon/mergeCommits
Charles-Gagnon Apr 21, 2023
8605ed6
[Trigger] Rename csharpscript and align host.json (#825)
Charles-Gagnon Apr 21, 2023
430d0cb
Fix java version in setup guide (#821)
Charles-Gagnon Apr 24, 2023
cb51425
Refactor integration tests (#813)
lucyzhang929 Apr 24, 2023
3cc33cc
Clean csx samples (#812)
MaddyDev Apr 26, 2023
845a27f
remove TriggerSamples folder
MaddyDev Apr 26, 2023
d2e41f6
update trigger docs for csx
MaddyDev Apr 26, 2023
a215097
Merge pull request #833 from Azure/maddy/mergeCsxCleanUp
Charles-Gagnon Apr 26, 2023
a0bedd2
Fix compilation error (#835)
MaddyDev Apr 28, 2023
b58a316
Add retry for Trigger tests (#836)
MaddyDev May 1, 2023
c595da7
Merge branch 'main' into chgagnon/portRevertNodePinning
Charles-Gagnon May 2, 2023
1faaac9
Merge pull request #843 from Azure/chgagnon/portRevertNodePinning
Charles-Gagnon May 3, 2023
b5966a0
Update Trigger Binding set up in SetupGuide_DotnetOutOfProc.md (#845)
lucyzhang929 May 4, 2023
a062d90
Update Trigger Binding set up in SetupGuide_Java.md (#846)
lucyzhang929 May 4, 2023
fa62795
Update SetupGuide_Javascript.md (#847)
lucyzhang929 May 4, 2023
7bdc3d8
FIx perf pipeline (#838)
lucyzhang929 May 4, 2023
4b0f96d
Update SetupGuide_PowerShell.md (#848)
lucyzhang929 May 4, 2023
cbc2f9c
Update SetupGuide_Python.md (#849)
lucyzhang929 May 4, 2023
891bda5
enable test TriggerWithException (#801)
MaddyDev May 12, 2023
c2e8116
Add additional check for closed/broken connection errors (#862)
Charles-Gagnon May 30, 2023
6274cc0
add timestamp to global state table for lease table cleanup (#861)
MaddyDev May 30, 2023
fbb87b1
add test to check LastAccessTime column creation for existing trigger…
MaddyDev May 31, 2023
c1f4671
Merge latest from main into trigger (#866)
Charles-Gagnon Jun 2, 2023
30d3610
Merge branch 'main' into chgagnon/portFix
Charles-Gagnon Jun 2, 2023
31a7c7a
Revert "Remove doc/sample references to preview bundle (#744)"
Charles-Gagnon Jun 2, 2023
9be6144
Merge pull request #869 from Azure/chgagnon/portFix
Charles-Gagnon Jun 2, 2023
cb902d1
add troubleshooting information to the overview doc (#871)
MaddyDev Jun 8, 2023
1c0b9dc
clarifying view change tracking command (#873)
dzsquared Jun 12, 2023
02dca71
Add sql trigger test for different data types (#876)
lucyzhang929 Jun 28, 2023
9759915
Bump Version of Grpc.Net.Client (#877)
chlafreniere Jul 6, 2023
1a0fe10
Merge pull request #879 from Azure/chlafren/triggergrpc
Charles-Gagnon Jul 6, 2023
f3eafb0
Fix code coverage in trigger branch (#880)
lucyzhang929 Jul 10, 2023
f5b5b9c
Fix schema parse error when using reserved keys as table names (#881)
MaddyDev Jul 17, 2023
04f64be
Add LeasesTableName to SqlTriggerAttribute (#893)
lucyzhang929 Jul 28, 2023
824e046
Add leasesTableName to SqlTrigger Java annotation (#897)
lucyzhang929 Aug 2, 2023
89ab16d
update java library to 2.1.0-preview (#899)
lucyzhang929 Aug 3, 2023
d77979f
Update docs with LeasesTableName (#898)
lucyzhang929 Aug 3, 2023
4baf194
GetLeaseLockedRows for debug logging (#900)
MaddyDev Aug 5, 2023
0ec2e69
rename leasesTableName to bracketedLeasesTableName (#902)
MaddyDev Aug 7, 2023
0e63e27
update ReadAsync with Read
MaddyDev Aug 9, 2023
92faba7
replace ExecuteReaderAsync
MaddyDev Aug 10, 2023
7c5e00f
remove missed ExecuteReaderAsync
MaddyDev Aug 10, 2023
b1a8847
remove ReadAsync
MaddyDev Aug 11, 2023
cd56e02
remove async from updated methods
MaddyDev Aug 15, 2023
3df7449
Merge branch 'main' into maddy/replaceReadAsync
MaddyDev Sep 22, 2023
714c052
merge main
MaddyDev Sep 27, 2023
4b86623
fix perf uml
MaddyDev Sep 27, 2023
fe16e4d
resolve doc conflicts
MaddyDev Sep 27, 2023
6173667
resolve remaining conflicts
MaddyDev Sep 27, 2023
7e904b1
fix incomplete merge
MaddyDev Sep 27, 2023
6fc306d
Merge branch 'main' into maddy/replaceReadAsync
MaddyDev Oct 12, 2023
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
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"omnisharp.enableEditorConfigSupport": true,
"omnisharp.enableRoslynAnalyzers": true,
"yaml.schemas": {
"https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/master/service-schema.json": "builds/azure-pipelines/**/*.yml"
},
"https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/master/service-schema.json": "builds/azure-pipelines/**/*.yml"
},
}
4 changes: 3 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<PackageVersion Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="5.0.1" />
<PackageVersion Include="Microsoft.NET.Sdk.Functions" Version="4.1.3" />
<PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.Abstractions" Version="1.1.0" />
<PackageVersion Include="Microsoft.Azure.WebJobs" Version="3.0.36" />
<PackageVersion Include="Microsoft.ApplicationInsights" Version="2.21.0" />
<PackageVersion Include="Microsoft.Azure.WebJobs" Version="3.0.33" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="5.0.1" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<PackageVersion Include="morelinq" Version="3.3.2" />
Expand All @@ -15,6 +15,7 @@
<PackageVersion Include="Moq" Version="4.18.2" />
<PackageVersion Include="xunit" Version="2.4.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.5" />
<PackageVersion Include="xRetry" Version="1.9.0" />
<PackageVersion Include="Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator" Version="4.0.1" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.2" />
<PackageVersion Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
Expand All @@ -28,5 +29,6 @@
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="6.0.1" />
<PackageVersion Include="Microsoft.SqlServer.TransactSql.ScriptDom" Version="161.8817.2" />
<PackageVersion Include="Grpc.Net.Client" Version="2.55.0"/>
</ItemGroup>
</Project>
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Azure SQL bindings for Azure Functions
# Azure SQL bindings for Azure Functions - Preview

## Table of Contents

- [Azure SQL bindings for Azure Functions](#azure-sql-bindings-for-azure-functions)
- [Azure SQL bindings for Azure Functions - Preview](#azure-sql-bindings-for-azure-functions---preview)
- [Table of Contents](#table-of-contents)
- [Introduction](#introduction)
- [Supported SQL Server Versions](#supported-sql-server-versions)
- [Known Issues](#known-issues)
- [Output Bindings](#output-bindings)
- [Trigger Bindings](#trigger-bindings)
- [Telemetry](#telemetry)
- [Trademarks](#trademarks)

Expand All @@ -17,7 +18,7 @@ This repository contains the Azure SQL bindings for Azure Functions extension co

- **Input Binding**: takes a SQL query or stored procedure to run and returns the output to the function.
- **Output Binding**: takes a list of rows and upserts them into the user table (i.e. If a row doesn't already exist, it is added. If it does, it is updated).
- **Trigger (preview)**: monitors the user table for changes (i.e., row inserts, updates, and deletes) and invokes the function with updated rows. Note: This is a preview feature and is available only in preview packages. More information is available on the [trigger branch](https://github.com/Azure/azure-functions-sql-extension/tree/release/trigger) and on the [documentation](https://aka.ms/sqltrigger).
- **Trigger Binding**: monitors the user table for changes (i.e., row inserts, updates, and deletes) and invokes the function with updated rows.

For a more detailed overview of the different types of bindings see the [Bindings Overview](https://github.com/Azure/azure-functions-sql-extension/blob/main/docs/BindingsOverview.md).

Expand All @@ -42,7 +43,7 @@ Databases on SQL Server, Azure SQL Database, or Azure SQL Managed Instance which

> **Note:** While we are actively working on resolving these issues, some may not be supported at this time. We appreciate your patience as we work to improve the Azure Functions SQL Extension.

- **By Design:** The table used by a SQL binding cannot contain two columns that only differ by casing (Ex. 'Name' and 'name').
- **By Design:** The table used by a SQL binding or SQL trigger cannot contain two columns that only differ by casing (Ex. 'Name' and 'name').
- **By Design:** Non-CSharp functions using SQL bindings against tables with columns of data types `BINARY` or `VARBINARY` need to map those columns to a string type. Input bindings will return the binary value as a base64 encoded string. Output bindings require the value upserted to binary columns to be a base64 encoded string.
- **Planned for Future Support:** SQL bindings against tables with columns of data types `GEOMETRY` and `GEOGRAPHY` are not supported. Issue is tracked [here](https://github.com/Azure/azure-functions-sql-extension/issues/654).
- Issues resulting from upstream dependencies can be found [here](https://github.com/Azure/azure-functions-sql-extension/issues?q=is%3Aopen+is%3Aissue+label%3Aupstream).
Expand All @@ -63,6 +64,10 @@ Databases on SQL Server, Azure SQL Database, or Azure SQL Managed Instance which
- PowerShell: The workaround is to use the `$TriggerMetadata[$keyName]` to retrieve the query property - an example can be found [here](https://github.com/Azure/azure-functions-sql-extension/blob/main/samples/samples-powershell/AddProductParams/run.ps1). Issue is tracked [here](https://github.com/Azure/azure-functions-powershell-worker/issues/895).
- Python: The workaround is to use `parse_qs` - an example can be found [here](https://github.com/Azure/azure-functions-sql-extension/blob/main/samples/samples-python/AddProductParams/__init__.py). Issue is tracked [here](https://github.com/Azure/azure-functions-python-worker/issues/894).

### Trigger Bindings

- **By Design:** Trigger bindings will exhibit undefined behavior if the SQL table schema gets modified while the user application is running, for example, if a column is added, renamed or deleted or if the primary key is modified or deleted. In such cases, restarting the application should help resolve any errors.

## Telemetry

This extension collects usage data in order to help us improve your experience. The data is anonymous and doesn't include any personal information. You can opt-out of telemetry by setting the `AZUREFUNCTIONS_SQLBINDINGS_TELEMETRY_OPTOUT` environment variable or the `AzureFunctionsSqlBindingsTelemetryOptOut` app setting (in your `*.settings.json` file) to '1', 'true' or 'yes';
Expand Down
45 changes: 45 additions & 0 deletions Worker.Extensions.Sql/src/SqlChange.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

namespace Microsoft.Azure.Functions.Worker.Extensions.Sql
{
/// <summary>
/// Represents the changed row in the user table.
/// </summary>
/// <typeparam name="T">POCO class representing the row in the user table</typeparam>
public sealed class SqlChange<T>
{
/// <summary>
/// Initializes a new instance of the <see cref="SqlChange{T}"/> class.
/// </summary>
/// <param name="operation">Change operation</param>
/// <param name="item">POCO representing the row in the user table on which the change operation took place</param>
public SqlChange(SqlChangeOperation operation, T item)
{
this.Operation = operation;
this.Item = item;
}

/// <summary>
/// Change operation (insert, update, or delete).
/// </summary>
public SqlChangeOperation Operation { get; }

/// <summary>
/// POCO representing the row in the user table on which the change operation took place. If the change
/// operation is <see cref="SqlChangeOperation.Delete" />, then only the properties corresponding to the primary
/// keys will be populated.
/// </summary>
public T Item { get; }
}

/// <summary>
/// Represents the type of change operation in the table row.
/// </summary>
public enum SqlChangeOperation
{
Insert,
Update,
Delete
}
}
49 changes: 49 additions & 0 deletions Worker.Extensions.Sql/src/SqlTriggerAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// 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 Microsoft.Azure.Functions.Worker.Extensions.Abstractions;

namespace Microsoft.Azure.Functions.Worker.Extensions.Sql
{
public sealed class SqlTriggerAttribute : TriggerBindingAttribute
{
/// <summary>
/// Initializes a new instance of the <see cref="SqlTriggerAttribute"/> class, which triggers the function when any changes on the specified table are detected.
/// </summary>
/// <param name="tableName">Name of the table to watch for changes.</param>
/// <param name="connectionStringSetting">The name of the app setting where the SQL connection string is stored</param>
/// <param name="leasesTableName">Optional - The name of the table used to store leases. If not specified, the leases table name will be Leases_{FunctionId}_{TableId}</param>
public SqlTriggerAttribute(string tableName, string connectionStringSetting, string leasesTableName = null)
{
this.TableName = tableName ?? throw new ArgumentNullException(nameof(tableName));
this.ConnectionStringSetting = connectionStringSetting ?? throw new ArgumentNullException(nameof(connectionStringSetting));
this.LeasesTableName = leasesTableName;
}

/// <summary>
/// Initializes a new instance of the <see cref="SqlTriggerAttribute"/> class with null value for LeasesTableName.
/// </summary>
/// <param name="tableName">Name of the table to watch for changes.</param>
/// <param name="connectionStringSetting">The name of the app setting where the SQL connection string is stored</param>
public SqlTriggerAttribute(string tableName, string connectionStringSetting) : this(tableName, connectionStringSetting, null) { }

/// <summary>
/// Name of the app setting containing the SQL connection string.
/// </summary>
public string ConnectionStringSetting { get; }

/// <summary>
/// Name of the table to watch for changes.
/// </summary>
public string TableName { get; }

/// <summary>
/// Name of the table used to store leases.
/// If not specified, the leases table name will be Leases_{FunctionId}_{TableId}
/// More information on how this is generated can be found here
/// https://github.com/Azure/azure-functions-sql-extension/blob/release/trigger/docs/TriggerBinding.md#az_funcleasestablename
/// </summary>
public string LeasesTableName { get; }
}
}
2 changes: 1 addition & 1 deletion builds/azure-pipelines/build-release-java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ steps:
$source = 'java-library'
$destination = '$(Build.ArtifactStagingDirectory)/java-library'
$jar = Get-ChildItem $source/target/*.jar | Select-Object -First 1 | Select Name
$jar -match '\d+\.\d+\.\d+'
$jar -match '\d+\.\d+\.\d+(-preview)?'
$version = $matches[0]
$prefix = 'azure-functions-java-library-sql-'+$version
New-Item $destination -ItemType Directory
Expand Down
4 changes: 2 additions & 2 deletions builds/azure-pipelines/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ parameters: # parameters are shown up in ADO UI in a build queue time
- name: 'ReleaseType'
displayName: 'Type of release'
type: string
default: full
default: preview
values:
- full
- preview
Expand All @@ -22,7 +22,7 @@ schedules:
variables:
solution: '**/*.sln'
configuration: 'Release'
versionMajor: 2
versionMajor: 3
versionMinor: 0
versionMajorMinor: '$(versionMajor).$(versionMinor)' # This variable is only used for the counter so we reset properly when either major or minor is bumped
versionPatch: $[counter(variables['versionMajorMinor'], 0)] # This will reset when we bump minor version
Expand Down
8 changes: 7 additions & 1 deletion builds/azure-pipelines/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ trigger: none

pr: none

schedules: [ ]
schedules:
- cron: "0 0 * * *"
displayName: Mon-Fri at Midnight
branches:
include:
- release/trigger
always: true

variables:
configuration: 'Release'
Expand Down
5 changes: 5 additions & 0 deletions builds/azure-pipelines/template-steps-performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ parameters:
default:
- input
- output
- trigger
- trigger_batch
- trigger_poll
- trigger_overrides
- trigger_parallel

steps:
- task: UseDotNet@2
Expand Down
Loading