Skip to content

Add Azure auth sample app#3988

Open
paulmedynski wants to merge 4 commits intomainfrom
dev/paul/azure-samples
Open

Add Azure auth sample app#3988
paulmedynski wants to merge 4 commits intomainfrom
dev/paul/azure-samples

Conversation

@paulmedynski
Copy link
Contributor

Description

Adds a sample app for testing Azure authentication with flexibility to supply published and local SqlClient packages.

@paulmedynski paulmedynski added this to the 7.0.0 milestone Feb 26, 2026
Copilot AI review requested due to automatic review settings February 26, 2026 20:17
@paulmedynski paulmedynski requested a review from a team as a code owner February 26, 2026 20:17
@paulmedynski paulmedynski added Area\Tests Issues that are targeted to tests or test projects Area\Documentation Use this for issues that requires changes in public documentations/samples. labels Feb 26, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new sample console application for testing Azure authentication with Microsoft.Data.SqlClient. The app is designed as a smoke test to verify package compatibility and Azure AD authentication functionality, with support for testing against both published NuGet packages and locally-built packages from the packages/ directory.

Changes:

  • Adds AzureAuthentication sample app in doc/apps/AzureAuthentication/ with flexible package version configuration
  • Includes comprehensive documentation with usage examples and build instructions
  • Updates doc/Directory.Packages.props to reference the latest stable SqlClient version (6.1.4)

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/Microsoft.Data.SqlClient.sln Adds the new AzureAuthentication project to the solution
doc/apps/AzureAuthentication/AzureAuthentication.csproj Project file targeting net481 and net10.0 with conditional Azure package references
doc/apps/AzureAuthentication/Program.cs Main application implementing command-line interface with connection testing and event logging
doc/apps/AzureAuthentication/README.md Comprehensive documentation covering purpose, usage, examples, and prerequisites
doc/apps/AzureAuthentication/Directory.Build.props Enables Central Package Management for the sample app
doc/apps/AzureAuthentication/Directory.Packages.props Defines default package versions with overridable MSBuild properties
doc/apps/AzureAuthentication/NuGet.config Configures local packages/ directory as a package source
doc/apps/AzureAuthentication/GeneratePackageVersions.targets MSBuild task to generate code exposing package versions at runtime
doc/apps/AzureAuthentication/packages/.gitkeep Ensures git tracks the empty packages directory
doc/Directory.Packages.props Updates SqlClient reference to latest stable version 6.1.4

"Supply specific package versions when building to test different versions of the " +
"SqlClient suite, for example:" + Environment.NewLine +
Environment.NewLine +
" -p:SqlClientVersion=7.0.0.preview4" + Environment.NewLine +
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version format in the example is incorrect. The example shows 7.0.0.preview4 but valid NuGet version formats use a hyphen, not a period, before the pre-release label (e.g., 7.0.0-preview4).

Suggested change
" -p:SqlClientVersion=7.0.0.preview4" + Environment.NewLine +
" -p:SqlClientVersion=7.0.0-preview4" + Environment.NewLine +

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,2 @@
# This presence of this file ensures that git creates the packages/ directory, which must exist
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammatical error: "This presence of this file" should be "The presence of this file".

Suggested change
# This presence of this file ensures that git creates the packages/ directory, which must exist
# The presence of this file ensures that git creates the packages/ directory, which must exist

Copilot uses AI. Check for mistakes.

Supply specific package versions when building to test different versions of the SqlClient suite, for example:

-p:SqlClientVersion=7.0.0.preview4
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version format in the example is incorrect. The example shows 7.0.0.preview4 but valid NuGet version formats use a hyphen, not a period, before the pre-release label (e.g., 7.0.0-preview4). The same issue appears on lines 72 and 145.

Suggested change
-p:SqlClientVersion=7.0.0.preview4
-p:SqlClientVersion=7.0.0-preview4

Copilot uses AI. Check for mistakes.
<PackageReference Include="System.CommandLine" />
</ItemGroup>

<!-- Generate code with the SqlClient package versions. -->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason not to make the package version strings that are already embedded in our assemblies available as a public API? It would be nice to just access them as:

Microsoft.Data.SqlClient.VersionInfo.PackageVersion
Microsoft.Data.SqlClient.Extensions.Logging.VersionInfo.PackageVersion
...

Thoughts? We would have to make sure each package contains an assembly with a sensible namespace. Avoiding type ambiguity due to using declarations would be an issue though.

@@ -0,0 +1,111 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bunch of Copilot foo that appears to work. I'm not sure if it actually regenerates on every build though.

@paulmedynski Can this be simplified and guaranteed to always generate the C# file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There didn't seem to be a suitable existing location for things like this other than tools/, which seems a bit cluttered and unfocused. We can discuss where to put this app.

@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.05%. Comparing base (a68e00f) to head (66bbe3e).
⚠️ Report is 20 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (a68e00f) and HEAD (66bbe3e). Click for more details.

HEAD has 6 uploads less than BASE
Flag BASE (a68e00f) HEAD (66bbe3e)
netfx 2 0
netcore 2 0
addons 2 0
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3988      +/-   ##
==========================================
- Coverage   75.22%   67.05%   -8.17%     
==========================================
  Files         266      282      +16     
  Lines       42932    67049   +24117     
==========================================
+ Hits        32294    44963   +12669     
- Misses      10638    22086   +11448     
Flag Coverage Δ
PR-SqlClient-Project 67.05% <ø> (?)
addons ?
netcore ?
netfx ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@priyankatiwari08 priyankatiwari08 self-assigned this Feb 27, 2026
}

// Instantiate the AKV Provider to ensure its assembly is present.
#pragma warning disable CA1806
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: The only purpose of this instantiation is to force-load the AKV assembly and catch dependency conflicts. Creating a full SqlColumnEncryptionAzureKeyVaultProvider with a DefaultAzureCredential is heavier than needed — it allocates a credential object that's never used and requires suppressing CA1806.

A lighter alternative that makes the intent more explicit:

// Force-load the AKV provider assembly to detect transitive dependency conflicts.
_ = typeof(SqlColumnEncryptionAzureKeyVaultProvider).Assembly;

No warning suppression needed, no credential created, and the comment explains why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area\Documentation Use this for issues that requires changes in public documentations/samples. Area\Tests Issues that are targeted to tests or test projects

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants