Skip to content

Commit 78328c6

Browse files
Charles-Gagnonlucyzhang929JatinSanghviAmeyaReleMaddyDev
authored
Sync LA release with latest from triggerbindings feature branch (#366)
* Don't publish TSA results on PRs (#327) * Don't publish TSA results on PRs * fix * Add more debug logging (#328) * add debug logging * pr comments + fix test * log queries * Add benchmark project for performance tests (#294) * add benchmark project * fix logger * fix logger * copy functions to benchmark output folder * cleanup * move setup methods to base * add output binding perf * clean up * add README * fix readme * add link to integration tests * typo * cleanup + comments * address pr comments * fix readme * fix integration test base * pr comments * Fix localization/serialization issues (#329) * Fix localization issues * split tests & cleanup * Replace file copy with itemgroup * Add policheck and var for uploading to TSA (#332) * Add policheck * Upload policheck to TSA codebase * Try globbing files * Scan all * Only upload when var set * post analysis * Only on windows * break on warn * testing * re-enable and break on error * Update notification alias * Fix local build errors (#334) * Fix local build errors * Update comments * Fix log error not printing out primary key name (#335) * Don't run Roslyn analyzers on PRs (#336) * Don't run Roslyn analyzers on PRs * fix * Do not process rows if lease acquisition fails (#339) * Fix README link (#342) * Escape special characters in Readme file (#346) * Wait for error inside `StartFunctionsHostAndWaitForError` method (#349) * Add test for multiple triggered functions (#343) * Add retry when attempting to release leases (#340) * Add retry when attempting to release leases * Address comments * Address more comments * Change loop structure according to comment * sql version telemetry data from input bindings (#337) * connection info telemetry data frm input bindings * capture convert event after collecting connection * remove event * first collect telemetry * fix tests * make convert type optional * update xml * add telemetry service * clean up * remove ITelemetryService * undo changes * merge conflict * missed merge conflict * extra line * add null check * capture telemetry after opening connection * correct connection * move telemtery after connection.OpenAsync * open connection on initialize * add xml * address comments * refactor test * add xml comment * update xml * add check back * add connection state check * remove explicit checks * add isDisposed * add comments * revert isDisposed changes * add comment with github issue link * Refactor locking logic in class `SqlTableChangeMonitor` (#357) * cherry-pick 6f23a5a * Merge commit 'd594efe88f0f7d32e4dcd31faad22885291d4902' into chgagnon/mergeFromMain1 # Conflicts: # src/SqlAsyncCollector.cs # test/GlobalSuppressions.cs * Add comments to explain LastSyncVersion selection (#358) * Fix * Move test scripts * Constructor cleanup (#362) * Initialize vars at declaration * Remove extra ; * More cleanup * Remove configuration * Add configuration for batch size/polling interval (#364) * Add configuration for batch size/polling interval * PR comments Co-authored-by: Lucy Zhang <luczhan@microsoft.com> Co-authored-by: Jatin Sanghvi <20547963+JatinSanghvi@users.noreply.github.com> Co-authored-by: AmeyaRele <35621237+AmeyaRele@users.noreply.github.com> Co-authored-by: Maddy <12754347+MaddyDev@users.noreply.github.com>
1 parent 077caf4 commit 78328c6

File tree

52 files changed

+3456
-388
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+3456
-388
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ dotnet_analyzer_diagnostic.severity = error
1010
# Namespace does not match folder structure - Ideally this should be enabled but it seems to have issues with root level files so disabling for now
1111
dotnet_diagnostic.IDE0130.severity = none
1212

13+
# CA1805: Do not initialize unnecessarily - It's better to be explicit when initializing vars to ensure correct value is used
14+
dotnet_diagnostic.CA1805.severity = none
15+
1316
# Documentation related errors, remove once they are fixed
1417
dotnet_diagnostic.CS1591.severity = none
1518
dotnet_diagnostic.CS1573.severity = none

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
<PackageVersion Include="Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator" Version="1.2.3" />
1616
<PackageVersion Include="Newtonsoft.Json" Version="11.0.2" />
1717
<PackageVersion Include="Microsoft.AspNetCore.Http" Version="2.1.22" />
18+
<PackageVersion Include="BenchmarkDotNet" Version="0.13.1" />
1819
</ItemGroup>
1920
</Project>

README.md

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ Azure SQL bindings for Azure Functions are supported for:
4040
- [Python functions](#python-functions)
4141
- [Input Binding Tutorial](#input-binding-tutorial-2)
4242
- [Output Binding Tutorial](#output-binding-tutorial-2)
43+
- [Configuration](#configuration)
44+
- [Trigger Binding Configuration](#trigger-binding-configuration)
45+
- [Sql_Trigger_BatchSize](#sql_trigger_batchsize)
46+
- [Sql_Trigger_PollingIntervalMs](#sql_trigger_pollingintervalms)
4347
- [More Samples](#more-samples)
4448
- [Input Binding](#input-binding)
4549
- [Query String](#query-string)
@@ -48,7 +52,7 @@ Azure SQL bindings for Azure Functions are supported for:
4852
- [Stored Procedure](#stored-procedure)
4953
- [IAsyncEnumerable](#iasyncenumerable)
5054
- [Output Binding](#output-binding)
51-
- [ICollector<T>/IAsyncCollector<T>](#icollectortiasynccollectort)
55+
- [ICollector&lt;T&gt;/IAsyncCollector&lt;T&gt;](#icollectortiasynccollectort)
5256
- [Array](#array)
5357
- [Single Row](#single-row)
5458
- [Primary Keys and Identity Columns](#primary-keys-and-identity-columns)
@@ -240,7 +244,7 @@ Note: This tutorial requires that a SQL database is setup as shown in [Create a
240244
- Open your app that you created in [Create a Function App](#create-a-function-app) in VSCode
241245
- Press 'F1' and search for 'Azure Functions: Create Function'
242246
- Choose HttpTrigger -> (Provide a function name) -> Company.namespace -> anonymous
243-
- In the file that opens, replace the 'public static async Task< IActionResult > Run' block with the below code.
247+
- In the file that opens, replace the `public static async Task<IActionResult> Run` block with the below code.
244248

245249
```csharp
246250
public static async Task<IActionResult> Run(
@@ -288,7 +292,7 @@ Note: This tutorial requires that a SQL database is setup as shown in [Create a
288292
- Open your app in VSCode
289293
- Press 'F1' and search for 'Azure Functions: Create Function'
290294
- Choose HttpTrigger -> (Provide a function name) -> Company.namespace is fine -> anonymous
291-
- In the file that opens, replace the 'public static async Task<IActionResult> Run' block with the below code
295+
- In the file that opens, replace the `public static async Task<IActionResult> Run` block with the below code
292296
293297
```csharp
294298
public static IActionResult Run(
@@ -377,7 +381,7 @@ Note: This tutorial requires that a SQL database is setup as shown in [Create a
377381
- Open your app that you created in [Create a Function App](#create-a-function-app) in VSCode
378382
- Press 'F1' and search for 'Azure Functions: Create Function'
379383
- Choose HttpTrigger -> (Provide a function name) -> anonymous
380-
- In the file that opens (index.js), replace the 'module.exports = async function (context, req)' block with the below code.
384+
- In the file that opens (`index.js`), replace the `module.exports = async function (context, req)` block with the below code.
381385
382386
```javascript
383387
module.exports = async function (context, req, employee) {
@@ -417,7 +421,7 @@ Note: This tutorial requires that a SQL database is setup as shown in [Create a
417421
- Open your app in VSCode
418422
- Press 'F1' and search for 'Azure Functions: Create Function'
419423
- Choose HttpTrigger -> (Provide a function name) -> anonymous
420-
- In the file that opens (index.js), replace the 'module.exports = async function (context, req)' block with the below code.
424+
- In the file that opens (`index.js`), replace the `module.exports = async function (context, req)` block with the below code.
421425
422426
```javascript
423427
module.exports = async function (context, req) {
@@ -472,7 +476,7 @@ Note: This tutorial requires that a SQL database is setup as shown in [Create a
472476
- Open your app that you created in [Create a Function App](#create-a-function-app) in VSCode
473477
- Press 'F1' and search for 'Azure Functions: Create Function'
474478
- Choose HttpTrigger -> (Provide a function name) -> anonymous
475-
- In the file that opens (__init__.py), replace the 'def main(req: func.HttpRequest) -> func.HttpResponse:' block with the below code.
479+
- In the file that opens (`__init__.py`), replace the `def main(req: func.HttpRequest) -> func.HttpResponse:` block with the below code.
476480
477481
```python
478482
def main(req: func.HttpRequest, employee: func.SqlRowList) -> func.HttpResponse:
@@ -515,7 +519,7 @@ Note: This tutorial requires that a SQL database is setup as shown in [Create a
515519
- Open your app in VSCode
516520
- Press 'F1' and search for 'Azure Functions: Create Function'
517521
- Choose HttpTrigger -> (Provide a function name) -> anonymous
518-
- In the file that opens (__init__.py), replace the 'def main(req: func.HttpRequest) -> func.HttpResponse:' block with the below code.
522+
- In the file that opens (`__init__.py`), replace the `def main(req: func.HttpRequest) -> func.HttpResponse:` block with the below code.
519523
520524
```python
521525
def main(req: func.HttpRequest, employee: func.Out[func.SqlRow]) -> func.HttpResponse:
@@ -554,6 +558,20 @@ Note: This tutorial requires that a SQL database is setup as shown in [Create a
554558
- Hit 'F5' to run your code. Click the link to upsert the output array values in your SQL table. Your upserted values should launch in the browser.
555559
- Congratulations! You have successfully created your first SQL output binding! Checkout [Output Binding](#Output-Binding) for more information on how to use it and explore on your own!
556560
561+
## Configuration
562+
563+
This section goes over some of the configuration values you can use to customize the SQL bindings. See [How to Use Azure Function App Settings](https://learn.microsoft.com/azure/azure-functions/functions-how-to-use-azure-function-app-settings) to learn more.
564+
565+
### Trigger Binding Configuration
566+
567+
#### Sql_Trigger_BatchSize
568+
569+
This controls the number of changes processed at once before being sent to the triggered function.
570+
571+
#### Sql_Trigger_PollingIntervalMs
572+
573+
This controls the delay in milliseconds between processing each batch of changes.
574+
557575
## More Samples
558576
559577
### Input Binding
@@ -567,8 +585,8 @@ The input binding takes four [arguments](https://github.com/Azure/azure-function
567585
568586
The following are valid binding types for the result of the query/stored procedure execution:
569587
570-
- **IEnumerable<T>**: Each element is a row of the result represented by `T`, where `T` is a user-defined POCO, or Plain Old C# Object. `T` should follow the structure of a row in the queried table. See the [Query String](#query-string) section for an example of what `T` should look like.
571-
- **IAsyncEnumerable<T>**: Each element is again a row of the result represented by `T`, but the rows are retrieved "lazily". A row of the result is only retrieved when `MoveNextAsync` is called on the enumerator. This is useful in the case that the query can return a very large amount of rows.
588+
- **IEnumerable&lt;T&gt;**: Each element is a row of the result represented by `T`, where `T` is a user-defined POCO, or Plain Old C# Object. `T` should follow the structure of a row in the queried table. See the [Query String](#query-string) section for an example of what `T` should look like.
589+
- **IAsyncEnumerable&lt;T&gt;**: Each element is again a row of the result represented by `T`, but the rows are retrieved "lazily". A row of the result is only retrieved when `MoveNextAsync` is called on the enumerator. This is useful in the case that the query can return a very large amount of rows.
572590
- **String**: A JSON string representation of the rows of the result (an example is provided [here](https://github.com/Azure/azure-functions-sql-extension/blob/main/samples/samples-csharp/InputBindingSamples/GetProductsString.cs)).
573591
- **SqlCommand**: The SqlCommand is populated with the appropriate query and parameters, but the associated connection is not opened. It is the responsiblity of the user to execute the command and read in the results. This is useful in the case that the user wants more control over how the results are read in. An example is provided [here](https://github.com/Azure/azure-functions-sql-extension/blob/main/samples/samples-csharp/InputBindingSamples/GetProductsSqlCommand.cs).
574592
@@ -708,13 +726,13 @@ The output binding takes two [arguments](https://github.com/Azure/azure-function
708726
709727
The following are valid binding types for the rows to be upserted into the table:
710728
711-
- **ICollector<T>/IAsyncCollector<T>**: Each element is a row represented by `T`, where `T` is a user-defined POCO, or Plain Old C# Object. `T` should follow the structure of a row in the queried table. See the [Query String](#query-string) for an example of what `T` should look like.
729+
- **ICollector&lt;T&gt;/IAsyncCollector&lt;T&gt;**: Each element is a row represented by `T`, where `T` is a user-defined POCO, or Plain Old C# Object. `T` should follow the structure of a row in the queried table. See the [Query String](#query-string) for an example of what `T` should look like.
712730
- **T**: Used when just one row is to be upserted into the table.
713731
- **T[]**: Each element is again a row of the result represented by `T`. This output binding type requires manual instantiation of the array in the function.
714732
715733
The repo contains examples of each of these binding types [here](https://github.com/Azure/azure-functions-sql-extension/tree/main/samples/samples-csharp/OutputBindingSamples). A few examples are also included below.
716734
717-
#### ICollector<T>/IAsyncCollector<T>
735+
#### ICollector&lt;T&gt;/IAsyncCollector&lt;T&gt;
718736
719737
When using an `ICollector`, it is not necessary to instantiate it. The function can add rows to the `ICollector` directly, and its contents are automatically upserted once the function exits.
720738

WebJobs.Extensions.Sql.sln

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
2020
.editorconfig = .editorconfig
2121
EndProjectSection
2222
EndProject
23+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.WebJobs.Extensions.Sql.Performance", "performance\Microsoft.Azure.WebJobs.Extensions.Sql.Performance.csproj", "{1A5148B7-F877-4813-852C-F94D6EF795E8}"
24+
EndProject
25+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "performance", "performance", "{F0F3562F-9176-4461-98E4-13D38D3DD056}"
26+
EndProject
2327
Global
2428
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2529
Debug|Any CPU = Debug|Any CPU
@@ -38,6 +42,10 @@ Global
3842
{A5B55530-71C8-4A9A-92AD-1D33A5E80FC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
3943
{A5B55530-71C8-4A9A-92AD-1D33A5E80FC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
4044
{A5B55530-71C8-4A9A-92AD-1D33A5E80FC1}.Release|Any CPU.Build.0 = Release|Any CPU
45+
{1A5148B7-F877-4813-852C-F94D6EF795E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
46+
{1A5148B7-F877-4813-852C-F94D6EF795E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
47+
{1A5148B7-F877-4813-852C-F94D6EF795E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
48+
{1A5148B7-F877-4813-852C-F94D6EF795E8}.Release|Any CPU.Build.0 = Release|Any CPU
4149
EndGlobalSection
4250
GlobalSection(SolutionProperties) = preSolution
4351
HideSolutionNode = FALSE
@@ -46,6 +54,7 @@ Global
4654
{B2E0EFB9-BEDB-48F7-BD5A-0E1010333475} = {3691FB44-971D-43FD-9B2F-916B8CE689DB}
4755
{4453B407-2CA3-4011-BDE5-247FCE5C1974} = {21CDC01C-247B-46B0-A8F5-9D35686C628B}
4856
{A5B55530-71C8-4A9A-92AD-1D33A5E80FC1} = {F7E99EB5-47D3-4B50-A6AA-D8D5508A121A}
57+
{1A5148B7-F877-4813-852C-F94D6EF795E8} = {F0F3562F-9176-4461-98E4-13D38D3DD056}
4958
EndGlobalSection
5059
GlobalSection(ExtensibilityGlobals) = postSolution
5160
SolutionGuid = {49902AA5-150F-4567-B562-4AA8549B2CF4}

builds/TSAConfig.gdntsa

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"codebaseName": "Sql Bindings",
33
"notificationAliases": [
4-
"sqltools@service.microsoft.com"
4+
"sqlbindings@microsoft.com"
55
],
66
"codebaseAdmins": [
77
"REDMOND\\chlafren",
@@ -14,6 +14,7 @@
1414
"tools": [
1515
"BinSkim",
1616
"RoslynAnalyzers",
17-
"CredScan"
17+
"CredScan",
18+
"Policheck"
1819
]
1920
}

builds/azure-pipelines/template-steps-build-test.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ steps:
1212
inputs:
1313
useGlobalJson: true
1414

15+
# Run Policheck early to avoid scanning dependency folders
16+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-policheck.PoliCheck@2
17+
displayName: 'Run PoliCheck'
18+
inputs:
19+
targetType: F
20+
result: PoliCheck.xml
21+
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
22+
1523
- script: npm install -g azure-functions-core-tools
1624
displayName: 'Install Azure Functions Core Tools'
1725

@@ -84,12 +92,13 @@ steps:
8492
arguments: 'analyze $(Build.SourcesDirectory)\src\bin\${{ parameters.configuration }}\* --recurse --verbose'
8593
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
8694

95+
# Don't run for PRs since this currently breaks on runs from forks. We run this daily ourselves anyways.
8796
- task: securedevelopmentteam.vss-secure-development-tools.build-task-roslynanalyzers.RoslynAnalyzers@3
8897
inputs:
8998
userProvideBuildInfo: 'autoMsBuildInfo'
9099
env:
91100
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
92-
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
101+
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'), ne(variables['Build.Reason'], 'PullRequest'))
93102

94103
- task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2
95104
inputs:
@@ -135,7 +144,7 @@ steps:
135144
inputs:
136145
GdnPublishTsaOnboard: true
137146
GdnPublishTsaConfigFile: '$(Build.SourcesDirectory)\builds\TSAConfig.gdntsa'
138-
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
147+
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'), eq(variables['TSA_UPLOAD'], 'true'))
139148

140149
# 5.0 isn't supported on Mac yet
141150
- task: UseDotNet@2
@@ -253,3 +262,9 @@ steps:
253262
displayName: 'Component Detection'
254263
inputs:
255264
failOnAlert: true
265+
266+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-postanalysis.PostAnalysis@2
267+
displayName: 'Post Analysis'
268+
inputs:
269+
GdnBreakPolicyMinSev: Error
270+
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
6+
<!-- Need to set root namespace to empty for IDE0130 to work properly - otherwise it errors out on top-level namespaces for some reason -->
7+
<RootNamespace></RootNamespace>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="BenchmarkDotNet" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<ProjectReference Include="..\test\Microsoft.Azure.WebJobs.Extensions.Sql.Tests.csproj" />
16+
<ProjectReference Include="..\samples\samples-csharp\Microsoft.Azure.WebJobs.Extensions.Sql.Samples.csproj" />
17+
</ItemGroup>
18+
19+
<Target Name="CopySamples" AfterTargets="Build">
20+
<ItemGroup>
21+
<_CSharpCopyItems Include="..\samples\samples-csharp\bin\$(Configuration)\$(TargetFramework)\**\*.*" />
22+
</ItemGroup>
23+
<Copy SourceFiles="@(_CSharpCopyItems)" DestinationFolder="$(OutDir)\SqlExtensionSamples\CSharp\%(RecursiveDir)" />
24+
<Message Text="Copied C# Samples output to $(OutDir)\SqlExtensionSamples\CSharp" Importance="high" />
25+
</Target>
26+
27+
<!-- Copy C# Samples output to BenchmarkDotNet project bin (https://github.com/dotnet/BenchmarkDotNet/issues/946) -->
28+
<ItemGroup>
29+
<None Include="$(OutDir)\**\*">
30+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
31+
<Link>%(RecursiveDir)\%(Filename)%(Extension)</Link>
32+
<Visible>True</Visible>
33+
</None>
34+
</ItemGroup>
35+
36+
</Project>

performance/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Running Performance Tests
2+
3+
## Pre-requisites
4+
The performance tests are based on the IntegrationTestBase class. Follow the instructions to set up the pre-requisites for integration tests [here](../test/README.md#running-integration-tests).
5+
6+
## Run
7+
The performance tests use BenchmarkDotNet to benchmark performance for input and output bindings.
8+
9+
Run the tests from the terminal.
10+
```
11+
cd performance
12+
dotnet run -c Release
13+
```
14+
15+
## Results
16+
The test results will be generated in the BenchmarkDotNet.Artifacts folder.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See License.txt in the project root for license information.
3+
4+
using BenchmarkDotNet.Running;
5+
6+
namespace Microsoft.Azure.WebJobs.Extensions.Sql.Performance
7+
{
8+
public class SqlBindingPerformance
9+
{
10+
public static void Main()
11+
{
12+
BenchmarkRunner.Run<SqlInputBindingPerformance>();
13+
BenchmarkRunner.Run<SqlOutputBindingPerformance>();
14+
}
15+
}
16+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See License.txt in the project root for license information.
3+
4+
using System.Net.Http;
5+
using System.Threading.Tasks;
6+
using Microsoft.Azure.WebJobs.Extensions.Sql.Samples.Common;
7+
using Microsoft.Azure.WebJobs.Extensions.Sql.Samples.InputBindingSamples;
8+
using Microsoft.Azure.WebJobs.Extensions.Sql.Tests.Common;
9+
using Microsoft.Azure.WebJobs.Extensions.Sql.Tests.Integration;
10+
using BenchmarkDotNet.Attributes;
11+
12+
namespace Microsoft.Azure.WebJobs.Extensions.Sql.Performance
13+
{
14+
public class SqlInputBindingPerformance : IntegrationTestBase
15+
{
16+
[GlobalSetup]
17+
public void GlobalSetup()
18+
{
19+
this.StartFunctionHost(nameof(GetProductsTopN), SupportedLanguages.CSharp);
20+
Product[] products = GetProductsWithSameCost(10000, 100);
21+
this.InsertProducts(products);
22+
}
23+
24+
[Benchmark]
25+
[Arguments("1")]
26+
[Arguments("10")]
27+
[Arguments("100")]
28+
[Arguments("1000")]
29+
[Arguments("10000")]
30+
public async Task<HttpResponseMessage> GetProductsTest(string count)
31+
{
32+
return await this.SendInputRequest("getproductstopn", count);
33+
}
34+
35+
[GlobalCleanup]
36+
public void GlobalCleanup()
37+
{
38+
this.Dispose();
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)