From 191cdfc3e646bdc099282771abbea823f7832223 Mon Sep 17 00:00:00 2001 From: jacqueskangforvia Date: Mon, 26 Jan 2026 16:57:11 +0100 Subject: [PATCH 1/2] fix: UserAssignedIdentityClientId is always empty --- AzureSQLConnectivityChecker.ps1 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/AzureSQLConnectivityChecker.ps1 b/AzureSQLConnectivityChecker.ps1 index ada1f97..a8cd46b 100644 --- a/AzureSQLConnectivityChecker.ps1 +++ b/AzureSQLConnectivityChecker.ps1 @@ -84,6 +84,9 @@ if ($null -ne $parameters) { if ($null -ne $parameters['DelayBetweenConnections']) { $DelayBetweenConnections = $parameters['DelayBetweenConnections'] } + if ($null -ne $parameters['UserAssignedIdentityClientId']) { + $UserAssignedIdentityClientId = $parameters['UserAssignedIdentityClientId'] + } if ($null -ne $parameters['TrustServerCertificate']) { $TrustServerCertificate = $parameters['TrustServerCertificate'] } @@ -1482,6 +1485,10 @@ try { TrackWarningAnonymously ('Authentication library:' + $AuthenticationLibrary) } + if ($null -ne $UserAssignedIdentityClientId -and $UserAssignedIdentityClientId -ne '') { + Write-Host ' UserAssignedIdentityClientId:' $UserAssignedIdentityClientId -ForegroundColor Yellow + } + Write-Host ' Server:' $Server -ForegroundColor Yellow if ($null -ne $Database) { From b76d188bd18f2589baa4921c15f1416f84286552 Mon Sep 17 00:00:00 2001 From: jacqueskangforvia Date: Mon, 26 Jan 2026 17:01:23 +0100 Subject: [PATCH 2/2] fix: wrong parameter provided when getting access token for managed identity --- .../AuthenticationProvider/AuthenticationProvider.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TDSClient/TDSClient/AuthenticationProvider/AuthenticationProvider.cs b/TDSClient/TDSClient/AuthenticationProvider/AuthenticationProvider.cs index dabbe5e..be1f49d 100644 --- a/TDSClient/TDSClient/AuthenticationProvider/AuthenticationProvider.cs +++ b/TDSClient/TDSClient/AuthenticationProvider/AuthenticationProvider.cs @@ -151,9 +151,9 @@ private async Task GetAccessTokenForInteractiveAuth() /// private async Task GetAccessTokenForMSIAuth() { - return IdentityClientId != null ? - await MSALHelper.GetSQLAccessTokenFromMSALUsingUserAssignedManagedIdentity(Authority, IdentityClientId) : - await MSALHelper.GetSQLAccessTokenFromMSALUsingSystemAssignedManagedIdentity(Authority); + return string.IsNullOrEmpty(IdentityClientId) ? + await MSALHelper.GetSQLAccessTokenFromMSALUsingSystemAssignedManagedIdentity(Resource) : + await MSALHelper.GetSQLAccessTokenFromMSALUsingUserAssignedManagedIdentity(Resource, IdentityClientId); } } }