Skip to content
Open
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
18 changes: 2 additions & 16 deletions src/Directory.Packages.props → Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
</PropertyGroup>

<!-- ===================================================================== -->
<!-- Shared Dependencies -->

<!-- Published -->
<ItemGroup>
<!-- MDS and AKV -->
<PackageVersion Include="Azure.Core" Version="1.49.0" />
<PackageVersion Include="Microsoft.Identity.Client" Version="4.78.0" />
</ItemGroup>

<!-- Published - Target Framework Specific Dependencies -->
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<!-- MDS and AKV -->
Expand All @@ -22,7 +20,6 @@
<!-- MDS and AKV -->
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
</ItemGroup>

<!-- Internal -->
<ItemGroup>
<!-- MDS and AKV Tests -->
Expand All @@ -44,7 +41,6 @@
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="xunit.runner.console" Version="2.9.3" />
</ItemGroup>

<!-- Internal - Target Framework Specific Dependencies -->
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<!-- MDS and AKV Tests -->
Expand All @@ -59,18 +55,15 @@
-->
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
</ItemGroup>

<!-- ===================================================================== -->
<!-- MDS Dependencies -->

<!-- Common Dependencies (.NET and .NET Framework) -->
<ItemGroup>
<PackageVersion Include="Azure.Identity" Version="1.16.0" />
<PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.14.0" />
<PackageVersion Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="8.14.0" />
<PackageVersion Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" />
</ItemGroup>

<!-- Common Target Framework Specific Dependencies -->
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageVersion Include="Microsoft.Bcl.Cryptography" Version="9.0.9" />
Expand All @@ -84,13 +77,11 @@
<PackageVersion Include="System.Security.Cryptography.Pkcs" Version="8.0.1" />
<PackageVersion Include="System.Text.Json" Version="8.0.6" />
</ItemGroup>

<!-- .NET Dependencies -->
<ItemGroup>
<PackageVersion Include="Microsoft.Data.SqlClient.SNI.runtime" Version="6.0.2" />
<PackageVersion Include="Microsoft.SqlServer.Server" Version="1.0.0" />
</ItemGroup>

<!-- .NET Framework Dependencies -->
<ItemGroup>
<PackageVersion Include="Microsoft.Data.SqlClient.SNI" Version="6.0.2" />
Expand All @@ -102,17 +93,12 @@
<PackageVersion Include="System.ValueTuple" Version="4.6.1" />
<PackageVersion Include="System.Threading.Channels" Version="8.0.0" />
</ItemGroup>

<!-- =================================================================== -->
<!-- AKV Dependencies -->

<ItemGroup>
<PackageVersion Include="Azure.Security.KeyVault.Keys" Version="4.8.0" />
</ItemGroup>

<!-- =================================================================== -->
<!-- MSS Dependencies -->

<!-- None -->

</Project>
</Project>
9 changes: 9 additions & 0 deletions doc/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project>
<!-- Import parent Directory.Packages.props -->
<Import Project="..\Directory.Packages.props" />
<ItemGroup>
<!-- Reference latest stable version of MDS and AKV provider -->
<PackageVersion Include="Microsoft.Data.SqlClient" Version="6.1.2" />
<PackageVersion Include="Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider" Version="6.1.2" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion doc/samples/AADAuthenticationCustomDeviceFlowCallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Microsoft.Identity.Client;
using Microsoft.Data.SqlClient;

namespace CustomAuthenticationProviderExamples
namespace CustomDeviceCodeFlowAuthProviderExample
{
public class Program
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System;
using Microsoft.Data.SqlClient;

namespace CustomAuthenticationProviderExamples
namespace CustomAppIdAuthProviderExample
{
public class Program
{
Expand Down
8 changes: 7 additions & 1 deletion doc/samples/AzureKeyVaultProviderExample.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* TODO: This sample file should be deleted as the AKV Provider Ctor API is no longer supported with supported versions of AKV provider and MDS.
* Depends on: Delete documentation and sample reference in MS Docs first: https://learn.microsoft.com/en-us/sql/connect/ado-net/sql/azure-key-vault-example?view=sql-server-ver17#legacy-callback-implementation-design-example-with-v20
*

using System;
//<Snippet1>
using System.Collections.Generic;
Expand All @@ -23,7 +28,7 @@ public class AzureKeyVaultProviderExample
public static void Main(string[] args)
{
// Initialize AKV provider
SqlColumnEncryptionAzureKeyVaultProvider sqlColumnEncryptionAzureKeyVaultProvider = new SqlColumnEncryptionAzureKeyVaultProvider(AzureActiveDirectoryAuthenticationCallback);
SqlColumnEncryptionAzureKeyVaultProvider sqlColumnEncryptionAzureKeyVaultProvider = new(AzureActiveDirectoryAuthenticationCallback);

// Register AKV provider
SqlConnection.RegisterColumnEncryptionKeyStoreProviders(customProviders: new Dictionary<string, SqlColumnEncryptionKeyStoreProvider>(capacity: 1, comparer: StringComparer.OrdinalIgnoreCase)
Expand Down Expand Up @@ -258,3 +263,4 @@ public CustomerRecord(int id, string fName, string lName)
}
}
//</Snippet1>
*/
18 changes: 15 additions & 3 deletions doc/samples/AzureKeyVaultProviderLegacyExample_2_0.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
//<Snippet1>
/**
* TODO: This sample file should be deleted as the AKV Provider Ctor API is no longer supported with supported versions of AKV provider and MDS.
* Depends on: Delete documentation and sample reference in MS Docs first: https://learn.microsoft.com/en-us/sql/connect/ado-net/sql/azure-key-vault-example?view=sql-server-ver17#legacy-callback-implementation-design-example-with-v20
*

//< Snippet1>
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.Linq;
using System.Net.Http;
using System.Security.Cryptography;
using Azure.Identity;
using Microsoft.Data.SqlClient;
using System.Threading;
using System.Threading.Tasks;
using Azure.Core;
using Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace Microsoft.Data.SqlClient.Samples
{
Expand Down Expand Up @@ -366,3 +377,4 @@ public static async Task<string> AzureActiveDirectoryAuthenticationCallback(stri
}
}
//</Snippet1>
*/
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
//<Snippet1>
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Threading.Tasks;
using Azure.Identity;
using Microsoft.Data.SqlClient;
using Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider;

namespace AKVEnclaveExample
namespace AKVEnclaveExample_2_0
{
class Program
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
// <Snippet1>
class Program
using System.Collections.Generic;
using Azure.Identity;
using Microsoft.Data.SqlClient;
using Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider;

namespace AzureKeyVaultProviderExample
{
static void Main()
// <Snippet1>
class Program
{
using (SqlConnection connection = new SqlConnection(connectionString))
private static string connectionString;

static void Main()
{
using (SqlCommand command = connection.CreateCommand())
using (SqlConnection connection = new SqlConnection(connectionString))
{
Dictionary<string, SqlColumnEncryptionKeyStoreProvider> customKeyStoreProviders = new Dictionary<string, SqlColumnEncryptionKeyStoreProvider>();
SqlColumnEncryptionAzureKeyVaultProvider azureKeyVaultProvider = new SqlColumnEncryptionAzureKeyVaultProvider();
customKeyStoreProviders.Add(SqlColumnEncryptionAzureKeyVaultProvider.ProviderName, azureKeyVaultProvider);
command.RegisterColumnEncryptionKeyStoreProvidersOnCommand(customKeyStoreProviders);
// Perform database operation using Azure Key Vault Provider
// Any decrypted column encryption keys will be cached
} // Column encryption key cache of "azureKeyVaultProvider" is cleared when "azureKeyVaultProvider" goes out of scope
using (SqlCommand command = connection.CreateCommand())
{
Dictionary<string, SqlColumnEncryptionKeyStoreProvider> customKeyStoreProviders = new Dictionary<string, SqlColumnEncryptionKeyStoreProvider>();
SqlColumnEncryptionAzureKeyVaultProvider azureKeyVaultProvider = new SqlColumnEncryptionAzureKeyVaultProvider(new DefaultAzureCredential());
customKeyStoreProviders.Add(SqlColumnEncryptionAzureKeyVaultProvider.ProviderName, azureKeyVaultProvider);
command.RegisterColumnEncryptionKeyStoreProvidersOnCommand(customKeyStoreProviders);
// Perform database operation using Azure Key Vault Provider
// Any decrypted column encryption keys will be cached
} // Column encryption key cache of "azureKeyVaultProvider" is cleared when "azureKeyVaultProvider" goes out of scope
}
}
}
// </Snippet1>
}
// </Snippet1>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Microsoft.Data.SqlClient;
using Microsoft.Identity.Client;

namespace CustomAuthenticationProviderExamples
namespace CustomDeviceCodeFlowAuthProviderExample
{
/// <summary>
/// Example demonstrating creating a custom device code flow authentication provider and attaching it to the driver.
Expand Down
28 changes: 28 additions & 0 deletions doc/samples/Microsoft.Data.SqlClient.Samples.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Library</OutputType>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>Latest</LangVersion>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Identity" />
<PackageReference Include="Azure.Core" />
<PackageReference Include="Microsoft.Identity.Client" />
<PackageReference Include="Microsoft.SqlServer.Server" />
<PackageReference Include="Microsoft.Data.SqlClient" />
<PackageReference Include="Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider" />
<PackageReference Include="Newtonsoft.Json" />
</ItemGroup>

<!-- .NET Framework references -->
<ItemGroup Condition="$(TargetGroup) == 'netfx'">
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" />
<Reference Include="System.Transactions" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>

</Project>
21 changes: 18 additions & 3 deletions doc/samples/SqlCommand_BeginExecuteReaderAsyncBehavior.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if NETFRAMEWORK

// <Snippet1>
using System;
using System.Collections.Generic;
Expand All @@ -8,14 +10,20 @@
using System.Windows.Forms;
using Microsoft.Data.SqlClient;

namespace Microsoft.AdoDotNet.CodeSamples
namespace Microsoft.Data.SqlClient.Samples
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.label1 = new Label();
this.dataGridView1 = new DataGridView();
this.button1 = new Button();
}

private void InitializeComponent() { }

// Hook up the form's Load event handler (you can double-click on
// the form's design surface in Visual Studio), and then add
// this code to the form's class:
Expand All @@ -32,6 +40,12 @@ public Form1()
// asynchronous command is executing.
private bool isExecuting;

private Label label1 { get; set; }

private DataGridView dataGridView1 { get; set; }

private Button button1 { get; set; }

private void DisplayStatus(string Text)
{
this.label1.Text = Text;
Expand Down Expand Up @@ -133,8 +147,8 @@ private void button1_Click(object sender, System.EventArgs e)
}
else
{
SqlCommand command = null;
SqlConnection connection = null;
SqlCommand? command = null;
SqlConnection? connection = null;
try
{
DisplayStatus("Connecting...");
Expand Down Expand Up @@ -185,3 +199,4 @@ void Form1_FormClosing(object sender, FormClosingEventArgs e)
}
}
// </Snippet1>
#endif
9 changes: 9 additions & 0 deletions src/Microsoft.Data.SqlClient.sln
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SqlClient.Stress.Runner", "
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SqlClient.Stress.Tests", "Microsoft.Data.SqlClient\tests\StressTests\SqlClient.Stress.Tests\SqlClient.Stress.Tests.csproj", "{FAA1E517-581A-D3DC-BAC9-FAD1D5A5142C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Data.SqlClient.Samples", "..\doc\Samples\Microsoft.Data.SqlClient.Samples.csproj", "{C09B9D2F-E463-BEBD-34E4-E8F2C201A277}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -643,6 +645,12 @@ Global
{FAA1E517-581A-D3DC-BAC9-FAD1D5A5142C}.Release|x64.Build.0 = Release|Any CPU
{FAA1E517-581A-D3DC-BAC9-FAD1D5A5142C}.Release|x86.ActiveCfg = Release|Any CPU
{FAA1E517-581A-D3DC-BAC9-FAD1D5A5142C}.Release|x86.Build.0 = Release|Any CPU
{C09B9D2F-E463-BEBD-34E4-E8F2C201A277}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C09B9D2F-E463-BEBD-34E4-E8F2C201A277}.Debug|x64.ActiveCfg = Debug|x64
{C09B9D2F-E463-BEBD-34E4-E8F2C201A277}.Debug|x86.ActiveCfg = Debug|x86
{C09B9D2F-E463-BEBD-34E4-E8F2C201A277}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C09B9D2F-E463-BEBD-34E4-E8F2C201A277}.Release|x64.ActiveCfg = Release|x64
{C09B9D2F-E463-BEBD-34E4-E8F2C201A277}.Release|x86.ActiveCfg = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -699,6 +707,7 @@ Global
{92D9C6D6-6925-1AD1-69FA-485F83943BD2} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{4A9C11F4-9577-ABEC-C070-83A194746D9B} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{FAA1E517-581A-D3DC-BAC9-FAD1D5A5142C} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{C09B9D2F-E463-BEBD-34E4-E8F2C201A277} = {ED952CF7-84DF-437A-B066-F516E9BE1C2C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {01D48116-37A2-4D33-B9EC-94793C702431}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<Import Project="..\..\Directory.Packages.props" />
<Import Project="..\..\..\Directory.Packages.props" />
<ItemGroup Condition="$(ReferenceType) == 'Package'">
<PackageVersion Include="Microsoft.Data.SqlClient" Version="$(TestMicrosoftDataSqlClientVersion)" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<Import Project="..\..\Directory.Packages.props" />
<Import Project="..\..\..\Directory.Packages.props" />

<!-- Test Project Dependencies for all targets. -->
<ItemGroup>
Expand Down
Loading