Skip to content

Commit 8efeacb

Browse files
Merge pull request Azure#429 from Azure/chgagnon/triggerMDS5
Merge main -> triggerbindings
2 parents 2e8266f + dd0c7cf commit 8efeacb

37 files changed

+1449
-727
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<TargetFramework>netcoreapp3.1</TargetFramework>
3+
<TargetFramework>net6</TargetFramework>
44
<EnableNETAnalyzers>true</EnableNETAnalyzers>
55
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
66
<GenerateDocumentationFile>true</GenerateDocumentationFile>

Directory.Packages.props

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
<Project>
22
<ItemGroup>
33
<PackageVersion Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="5.0.0" />
4-
<PackageVersion Include="Microsoft.NET.Sdk.Functions" Version="3.1.1" />
4+
<PackageVersion Include="Microsoft.NET.Sdk.Functions" Version="4.1.1" />
5+
<PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.Abstractions" Version="1.1.0" />
56
<PackageVersion Include="Microsoft.ApplicationInsights" Version="2.14.0" />
6-
<PackageVersion Include="Microsoft.Azure.WebJobs" Version="3.0.31" />
7-
<PackageVersion Include="Microsoft.Data.SqlClient" Version="3.0.1" />
7+
<PackageVersion Include="Microsoft.Azure.WebJobs" Version="3.0.32" />
8+
<PackageVersion Include="Microsoft.Data.SqlClient" Version="5.0.1" />
89
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
910
<PackageVersion Include="morelinq" Version="3.3.2" />
10-
<PackageVersion Include="System.Runtime.Caching" Version="4.7.0" />
11+
<PackageVersion Include="System.Drawing.Common" Version="5.0.3" />
12+
<PackageVersion Include="System.Runtime.Caching" Version="5.0.0" />
1113
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
1214
<PackageVersion Include="Moq" Version="4.14.3" />
1315
<PackageVersion Include="xunit" Version="2.4.0" />
1416
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.0" />
15-
<PackageVersion Include="Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator" Version="1.2.3" />
17+
<PackageVersion Include="Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator" Version="4.0.1" />
1618
<PackageVersion Include="Newtonsoft.Json" Version="11.0.2" />
17-
<PackageVersion Include="Microsoft.AspNetCore.Http" Version="2.1.22" />
19+
<PackageVersion Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
1820
<PackageVersion Include="BenchmarkDotNet" Version="0.13.1" />
1921
</ItemGroup>
2022
</Project>

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -434,18 +434,18 @@ Note: This tutorial requires that a SQL database is setup as shown in [Create a
434434
module.exports = async function (context, req) {
435435
const employees = [
436436
{
437-
EmployeeId = 1,
438-
FirstName = "Hello",
439-
LastName = "World",
440-
Company = "Microsoft",
441-
Team = "Functions"
437+
EmployeeId : 1,
438+
FirstName : "Hello",
439+
LastName : "World",
440+
Company : "Microsoft",
441+
Team : "Functions"
442442
},
443443
{
444-
EmployeeId = 2,
445-
FirstName = "Hi",
446-
LastName = "SQLupdate",
447-
Company = "Microsoft",
448-
Team = "Functions"
444+
EmployeeId : 2,
445+
FirstName : "Hi",
446+
LastName : "SQLupdate",
447+
Company : "Microsoft",
448+
Team : "Functions"
449449
}
450450
];
451451
context.bindings.employee = employees;
@@ -953,6 +953,7 @@ public static void Run(
953953
## Known Issues
954954
955955
- Output bindings against tables with columns of data types `NTEXT`, `TEXT`, or `IMAGE` are not supported and data upserts will fail. These types [will be removed](https://docs.microsoft.com/sql/t-sql/data-types/ntext-text-and-image-transact-sql) in a future version of SQL Server and are not compatible with the `OPENJSON` function used by this Azure Functions binding.
956+
- Input bindings against tables with columns of data types 'DATETIME', 'DATETIME2', or 'SMALLDATETIME' will assume that the values are in UTC format.
956957
957958
- 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.
958959

WebJobs.Extensions.Sql.sln

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.WebJobs.Ext
2424
EndProject
2525
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "performance", "performance", "{F0F3562F-9176-4461-98E4-13D38D3DD056}"
2626
EndProject
27+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Worker.Extension.Sql", "Worker.Extension.Sql", "{605E19C0-3A77-477F-928E-85B8972B734D}"
28+
EndProject
29+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Azure.Functions.Worker.Extension.Sql", "Worker.Extension.Sql\src\Microsoft.Azure.Functions.Worker.Extension.Sql.csproj", "{84D97605-F1BF-4083-9C93-2B68A9FBB00F}"
30+
EndProject
2731
Global
2832
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2933
Debug|Any CPU = Debug|Any CPU
@@ -46,6 +50,10 @@ Global
4650
{1A5148B7-F877-4813-852C-F94D6EF795E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
4751
{1A5148B7-F877-4813-852C-F94D6EF795E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
4852
{1A5148B7-F877-4813-852C-F94D6EF795E8}.Release|Any CPU.Build.0 = Release|Any CPU
53+
{84D97605-F1BF-4083-9C93-2B68A9FBB00F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
54+
{84D97605-F1BF-4083-9C93-2B68A9FBB00F}.Debug|Any CPU.Build.0 = Debug|Any CPU
55+
{84D97605-F1BF-4083-9C93-2B68A9FBB00F}.Release|Any CPU.ActiveCfg = Release|Any CPU
56+
{84D97605-F1BF-4083-9C93-2B68A9FBB00F}.Release|Any CPU.Build.0 = Release|Any CPU
4957
EndGlobalSection
5058
GlobalSection(SolutionProperties) = preSolution
5159
HideSolutionNode = FALSE
@@ -55,6 +63,7 @@ Global
5563
{4453B407-2CA3-4011-BDE5-247FCE5C1974} = {21CDC01C-247B-46B0-A8F5-9D35686C628B}
5664
{A5B55530-71C8-4A9A-92AD-1D33A5E80FC1} = {F7E99EB5-47D3-4B50-A6AA-D8D5508A121A}
5765
{1A5148B7-F877-4813-852C-F94D6EF795E8} = {F0F3562F-9176-4461-98E4-13D38D3DD056}
66+
{84D97605-F1BF-4083-9C93-2B68A9FBB00F} = {605E19C0-3A77-477F-928E-85B8972B734D}
5867
EndGlobalSection
5968
GlobalSection(ExtensibilityGlobals) = postSolution
6069
SolutionGuid = {49902AA5-150F-4567-B562-4AA8549B2CF4}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<AssemblyName>Microsoft.Azure.Functions.Worker.Extension.Sql</AssemblyName>
5+
<RootNamespace>Microsoft.Azure.Functions.Worker.Extension.Sql</RootNamespace>
6+
<Description>Sql extension for .NET isolated Azure Functions</Description>
7+
8+
<!--Version information-->
9+
<VersionPrefix>99.99.99</VersionPrefix>
10+
11+
<!--Temporarily opting out of documentation. Pending documentation-->
12+
<GenerateDocumentationFile>false</GenerateDocumentationFile>
13+
</PropertyGroup>
14+
15+
<ItemGroup>
16+
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Abstractions"/>
17+
<PackageReference Include="Microsoft.Data.SqlClient" />
18+
<PackageReference Include="System.Drawing.Common" />
19+
</ItemGroup>
20+
21+
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
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 Microsoft.Azure.Functions.Worker.Extensions.Abstractions;
5+
6+
[assembly: ExtensionInformation("Microsoft.Azure.WebJobs.Extensions.Sql", "0.*-preview")]
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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 Microsoft.Azure.Functions.Worker.Extensions.Abstractions;
5+
6+
namespace Microsoft.Azure.Functions.Worker.Extension.Sql
7+
{
8+
public sealed class SqlInputAttribute : InputBindingAttribute
9+
{
10+
/// <summary>
11+
/// Creates an instance of the <see cref="SqlAttribute"/>, specifying the Sql attributes
12+
/// the function supports.
13+
/// </summary>
14+
/// <param name="commandText">The text of the command.</param>
15+
public SqlInputAttribute(string commandText)
16+
{
17+
this.CommandText = commandText;
18+
}
19+
20+
/// <summary>
21+
/// The name of the app setting where the SQL connection string is stored
22+
/// (see https://docs.microsoft.com/dotnet/api/microsoft.data.sqlclient.sqlconnection).
23+
/// The attributes specified in the connection string are listed here
24+
/// https://docs.microsoft.com/dotnet/api/microsoft.data.sqlclient.sqlconnection.connectionstring
25+
/// For example, to create a connection to the "TestDB" located at the URL "test.database.windows.net" using a User ID and password,
26+
/// create a ConnectionStringSetting with a name like SqlServerAuthentication. The value of the SqlServerAuthentication app setting
27+
/// would look like "Data Source=test.database.windows.net;Database=TestDB;User ID={userid};Password={password}".
28+
/// </summary>
29+
public string ConnectionStringSetting { get; set; }
30+
31+
/// <summary>
32+
/// Either a SQL query or stored procedure that will be run in the database referred to in the ConnectionString.
33+
/// </summary>
34+
public string CommandText { get; set; }
35+
36+
/// <summary>
37+
/// Specifies whether <see cref="CommandText"/> refers to a stored procedure or SQL query string.
38+
/// Use <see cref="CommandType.StoredProcedure"/> for the former, <see cref="CommandType.Text"/> for the latter
39+
/// </summary>
40+
public System.Data.CommandType CommandType { get; set; } = System.Data.CommandType.Text;
41+
42+
/// <summary>
43+
/// Specifies the parameters that will be used to execute the SQL query or stored procedure specified in <see cref="CommandText"/>.
44+
/// Must follow the format "@param1=param1,@param2=param2". For example, if your SQL query looks like
45+
/// "select * from Products where cost = @Cost and name = @Name", then Parameters must have the form "@Cost=100,@Name={Name}"
46+
/// If the value of a parameter should be null, use "null", as in @param1=null,@param2=param2".
47+
/// If the value of a parameter should be an empty string, do not add anything after the equals sign and before the comma,
48+
/// as in "@param1=,@param2=param2"
49+
/// Note that neither the parameter name nor the parameter value can have ',' or '='
50+
/// </summary>
51+
public string Parameters { get; set; }
52+
}
53+
}
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 Microsoft.Azure.Functions.Worker.Extensions.Abstractions;
5+
6+
namespace Microsoft.Azure.Functions.Worker.Extension.Sql
7+
{
8+
public class SqlOutputAttribute : OutputBindingAttribute
9+
{
10+
/// <summary>
11+
/// Creates an instance of the <see cref="SqlAttribute"/>, specifying the Sql attributes
12+
/// the function supports.
13+
/// </summary>
14+
/// <param name="commandText">The text of the command.</param>
15+
public SqlOutputAttribute(string commandText)
16+
{
17+
this.CommandText = commandText;
18+
}
19+
20+
/// <summary>
21+
/// The name of the app setting where the SQL connection string is stored
22+
/// (see https://docs.microsoft.com/dotnet/api/microsoft.data.sqlclient.sqlconnection).
23+
/// The attributes specified in the connection string are listed here
24+
/// https://docs.microsoft.com/dotnet/api/microsoft.data.sqlclient.sqlconnection.connectionstring
25+
/// For example, to create a connection to the "TestDB" located at the URL "test.database.windows.net" using a User ID and password,
26+
/// create a ConnectionStringSetting with a name like SqlServerAuthentication. The value of the SqlServerAuthentication app setting
27+
/// would look like "Data Source=test.database.windows.net;Database=TestDB;User ID={userid};Password={password}".
28+
/// </summary>
29+
public string ConnectionStringSetting { get; set; }
30+
31+
/// <summary>
32+
/// The table name to upsert the values to.
33+
/// </summary>
34+
public string CommandText { get; set; }
35+
36+
/// <summary>
37+
/// Specifies <see cref="CommandText"/> as Text.
38+
/// </summary>
39+
public System.Data.CommandType CommandType { get; } = System.Data.CommandType.Text;
40+
}
41+
}

0 commit comments

Comments
 (0)