SqlServerCustomBinding 1.0.3

dotnet add package SqlServerCustomBinding --version 1.0.3                
NuGet\Install-Package SqlServerCustomBinding -Version 1.0.3                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SqlServerCustomBinding" Version="1.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SqlServerCustomBinding --version 1.0.3                
#r "nuget: SqlServerCustomBinding, 1.0.3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SqlServerCustomBinding as a Cake Addin
#addin nuget:?package=SqlServerCustomBinding&version=1.0.3

// Install SqlServerCustomBinding as a Cake Tool
#tool nuget:?package=SqlServerCustomBinding&version=1.0.3                

Sql Server Custom Binding

A custom binding for Sql Server in Azure function

Features

  • output binding for Sql Server commands
  • Input / output binding for Sql Server Connection

Dependencies

  • .Net 6.x
  • Microsoft.Azure.WebJob 3.0.33+
  • Microsoft.Azure.WebJob.Core 3.0.33+
  • Microsoft.Data.SqlClient 5.0.0+

Installation

It is available from public Nuget source

Install the package and all dependencies.

PM> Install-Package SqlServerCustomBinding -version <latest_version>

Samples

SQL Server Output Binding can be used as in the following sample

[FunctionName("<your_function_name>")]
public static async Task<IActionResult> <your_function_name>(
    <your_function_trigger>,
    [SqlServerOutput("%<your_sql_conn_string>%", UseTransaction = false)] IAsyncCollector<SqlCommand> requests,
    ILogger log)
{
    log.LogInformation("C# HTTP trigger function processed a request.");
    SqlCommand comm = new SqlCommand("Insert Into books(ID, [Name]) values(2, 'book2')");
    await requests.AddAsync(comm);
    return new OkObjectResult("All good!");
}

For connection string information, please refer to https://docs.microsoft.com/en-us/dotnet/api/microsoft.data.sqlclient.sqlconnection.connectionstring?view=sqlclient-dotnet-standard-5.0, and for SqlCommand please refer to https://docs.microsoft.com/en-us/dotnet/api/microsoft.data.sqlclient.sqlcommand?view=sqlclient-dotnet-standard-5.0. You do not have to set up Connection property for the SqlCommands, and it will be automatically populated with your connection string. All SqlCommands will NOT return anything, such as reader or etc. If you need more complicated operation, please see the following sample for input / output binding.

[FunctionName("<your_function_name>")]
public static async Task<IActionResult> your_function_name(
    <your_function_trigger>,
    [SqlServerClient("%<your_sql_conn_string>%")] SqlConnection conn,
    ILogger log)
{
    log.LogInformation("C# HTTP trigger function processed a request.");
    using(conn)
    {
        SqlCommand comm = new SqlCommand("select * from books", conn);
        conn.Open();
        SqlDataReader reader = comm.ExecuteReader();
        while (reader.Read())
        {
            // your actions with the record
        }
    }
    return new OkObjectResult("All good!");
}

You can use input / output binding to read / write data from Sql Server or whatever you can do with SqlConnection. For more SQL Server related information, please refer to https://docs.microsoft.com/en-us/dotnet/api/microsoft.data.sqlclient?view=sqlclient-dotnet-standard-5.0.

License

Free software, absolutely no warranty, use at your own risk!

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.3 474 9/14/2022
1.0.2 406 7/8/2022
1.0.1 428 4/29/2022
1.0.0 451 4/1/2022

Updated Nuget package version