Skip to content

Set DataApiBuilder as the SqlClient registered application - #3926

Open
Cheena Malhotra (cheenamalhotra) wants to merge 2 commits into
mainfrom
dev/cheena/sqlconnection-telemetry
Open

Cheena Malhotra (cheenamalhotra) wants to merge 2 commits into
mainfrom
dev/cheena/sqlconnection-telemetry

Conversation

@cheenamalhotra

Copy link
Copy Markdown
Member

Why make this change?

Identify Data API builder in SQL Server client telemetry using SqlClient's registered application identity, rather than relying only on the connection string's Application Name.

API reference: https://learn.microsoft.com/en-us/dotnet/api/microsoft.data.sqlclient.sqlconnection.registeredapplication?view=sqlclient-dotnet-7.1

What is this change?

  • Set RegisteredApplication.DataApiBuilder before SQL Server and DWSQL connections open, covering query execution, metadata discovery/validation, and CLI autoentity discovery.
  • Upgrade SqlClient to 7.1.2, include its separate Azure authentication extension, and align IdentityModel dependencies to the required 8.16.0 version. Update the native SNI license reference; the license text is unchanged.
  • Preserve connection strings and per-user pooling. This fixed product identifier is independent of the existing Application Name telemetry opt-out and is not part of the connection-pool key.
  • Add regression coverage and document physical-connection/pooling limitations.

How was this tested?

  • Integration Tests
  • Unit Tests

Passed: CLI build, 368 focused SQL connection/metadata/telemetry and JWT authentication tests, and formatting verification.

Database validation limitation: The broader focused run passed 353 tests but failed TestRetryPolicySuccessfullyExecutingQueryAfterNAttempts because the local SQL Server certificate chain is not trusted. The successful run below excludes that database-dependent test. Full database integration suites were not run.

The configured package feed returned 401 for the new SqlClient packages, so local restore used Microsoft's public mirror. Repository feed configuration is unchanged.

Exact commands and results:

# Passed: dependency restore using Microsoft's public mirror.
dotnet restore src\Cli\Cli.csproj --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json --verbosity quiet

# Passed: 0 warnings, 0 errors.
dotnet build src\Cli\Cli.csproj --no-restore --verbosity quiet

# Passed: 368 tests.
dotnet test src\Service.Tests\Azure.DataApiBuilder.Service.Tests.csproj --no-restore --filter "(FullyQualifiedName~SqlQueryExecutorUnitTests|FullyQualifiedName~ApplicationNameGeneralTelemetryTests|FullyQualifiedName~SqlMetadataProviderHelperTests|FullyQualifiedName~JwtTokenAuthenticationUnitTests)&FullyQualifiedName!~TestRetryPolicySuccessfullyExecutingQueryAfterNAttempts" --verbosity minimal --logger "console;verbosity=minimal"

# Failed: 353 passed, 1 failed due to the untrusted SQL Server certificate.
dotnet test src\Service.Tests\Azure.DataApiBuilder.Service.Tests.csproj --no-build --no-restore --filter "FullyQualifiedName~SqlQueryExecutorUnitTests|FullyQualifiedName~ApplicationNameGeneralTelemetryTests|FullyQualifiedName~SqlMetadataProviderHelperTests" --verbosity minimal --logger "console;verbosity=minimal"

# Passed: modified C# files meet formatting requirements.
dotnet format src\Azure.DataApiBuilder.sln --no-restore --verify-no-changes --include src\Cli\ConfigGenerator.cs src\Config\Telemetry\ApplicationNameTelemetry.cs src\Core\Resolvers\MsSqlQueryExecutor.cs src\Core\Services\MetadataProviders\MsSqlMetadataProvider.cs src\Core\Services\MetadataProviders\SqlMetadataProvider.cs src\Service.Tests\UnitTests\ApplicationNameGeneralTelemetryTests.cs src\Service.Tests\UnitTests\SqlMetadataProviderHelperTests.cs src\Service.Tests\UnitTests\SqlQueryExecutorUnitTests.cs --verbosity quiet

Sample Request(s)

N/A. No REST, GraphQL, or CLI request syntax changes. The identity is assigned automatically when SQL connections are initialized.

Identify query, metadata, and CLI SQL connections before login. Upgrade SqlClient and aligned dependencies while preserving Azure authentication support.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The SqlClient 6.1→7.1 driver and Entra packaging changes require human validation of live SQL Server/DWSQL logins and published-artifact authentication, which reported testing does not cover.

No open issues 🎉

What changed in this PR

This PR identifies Data API builder in SQL Server client telemetry through SqlClient’s registered application identity, covering SQL Server and DWSQL connections without changing connection strings or per-user pooling.

Changes:

  • Set the registered identity before connections open for query execution, metadata operations, and CLI autoentity discovery.
  • Upgrade SqlClient and IdentityModel dependencies, include the Azure authentication extension, and update the native SNI license reference.
  • Add regression coverage and document the identity’s independence from application-name telemetry opt-out and its pooling limitations.
File Description
src/​Service.Tests/​UnitTests/​SqlQueryExecutorUnitTests.cs Test registered identity and Azure authentication provider availability.
src/​Service.Tests/​UnitTests/​SqlMetadataProviderHelperTests.cs Test identity assignment on unopened metadata connections.
src/​Service.Tests/​UnitTests/​ApplicationNameGeneralTelemetryTests.cs Assert identity on metadata and per-user request connections.
src/​Directory.Packages.props Upgrade SqlClient and IdentityModel; add the Azure extension version.
src/​Core/​Services/​MetadataProviders/​SqlMetadataProvider.cs Route metadata connection creation through an overridable factory.
src/​Core/​Services/​MetadataProviders/​MsSqlMetadataProvider.cs Assign the registered identity to metadata connections.
src/​Core/​Resolvers/​MsSqlQueryExecutor.cs Assign the registered identity to query connections.
src/​Core/​Azure.DataApiBuilder.Core.csproj Reference the Azure authentication extension.
src/​Config/​Telemetry/​ApplicationNameTelemetry.cs Suppress the obsolete warning when classifying legacy authentication.
src/​Config/​Azure.DataApiBuilder.Config.csproj Reference the Azure authentication extension.
src/​Cli/​ConfigGenerator.cs Assign the identity before CLI autoentity discovery connects.
scripts/​notice-generation.ps1 Point notice generation to the updated SNI license filename.
external_licenses/​Microsoft.Data.SqlClient.SNI.7.1.2.License.txt Include the unchanged SNI license under the updated filename.
docs/​design/​application-name-telemetry.md Document registered identity, opt-out independence, and pooling limitations.

Review effort: Balanced

The configured feed resolves System.IdentityModel.Tokens.Jwt 8.16.0 to 8.17.0, causing NU1605 downgrades against JsonWebTokens 8.16.0. Align the IdentityModel package family to 8.17.0.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants