Assume Microsoft.Data.SqlClient has been updated and the azure extensions dependency hasn't been added. Now get the following exception on startup
What is the recommendation for connecting SC to an Azure SQL database using managed identity?
Install SC 6.19.2 and configure to use an Azure SQL database using managed identity.
Unhandled exception was caught|System.ArgumentException: Cannot find an authentication provider for 'ActiveDirectoryManagedIdentity'. Install the 'Microsoft.Data.SqlClient.Extensions.Azure' NuGet package (https://www.nuget.org/packages/Microsoft.Data.SqlClient.Extensions.Azure) to use Active Directory (Entra ID) authentication methods.
at Microsoft.Data.SqlClient.Connection.SqlConnectionInternal.GetFedAuthToken(SqlFedAuthInfo fedAuthInfo)
at Microsoft.Data.SqlClient.Connection.SqlConnectionInternal.OnFedAuthInfo(SqlFedAuthInfo fedAuthInfo)
at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at Microsoft.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at Microsoft.Data.SqlClient.Connection.SqlConnectionInternal.CompleteLogin(Boolean enlistOK)
at Microsoft.Data.SqlClient.Connection.SqlConnectionInternal.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, TimeoutTimer timeout, Boolean withFailover)
at Microsoft.Data.SqlClient.Connection.SqlConnectionInternal.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
at Microsoft.Data.SqlClient.Connection.SqlConnectionInternal.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
at Microsoft.Data.SqlClient.Connection.SqlConnectionInternal..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, DbConnectionPoolGroupProviderInfo providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken, IDbConnectionPool pool, Func`3 accessTokenCallback, SspiContextProvider sspiContextProvider)
at Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionPoolGroupProviderInfo poolGroupProviderInfo, IDbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
at Microsoft.Data.SqlClient.SqlConnectionFactory.CreatePooledConnection(DbConnection owningConnection, IDbConnectionPool pool, DbConnectionPoolKey poolKey, DbConnectionOptions options, DbConnectionOptions userOptions)
at Microsoft.Data.SqlClient.ConnectionPool.WaitHandleDbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
at Microsoft.Data.SqlClient.ConnectionPool.WaitHandleDbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
at Microsoft.Data.SqlClient.ConnectionPool.WaitHandleDbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at Microsoft.Data.SqlClient.ConnectionPool.WaitHandleDbConnectionPool.WaitForPendingOpen()
--- End of stack trace from previous location ---
at NServiceBus.Transport.SqlServer.SqlServerDbConnectionFactory.<>c__DisplayClass1_0.<<-ctor>b__0>d.MoveNext() in /_/src/NServiceBus.Transport.SqlServer/Configuration/SqlServerDbConnectionFactory.cs:line 24
--- End of stack trace from previous location ---
at NServiceBus.Transport.SqlServer.SubscriptionTableCreator.CreateIfNecessary(CancellationToken cancellationToken) in /_/src/NServiceBus.Transport.SqlServer/SubscriptionTableCreator.cs:line 23
at NServiceBus.Transport.SqlServer.SqlServerTransportInfrastructure.ConfigureSubscriptions(CancellationToken cancellationToken) in /_/src/NServiceBus.Transport.SqlServer/SqlServerTransportInfrastructure.cs:line 92
at NServiceBus.Transport.SqlServer.SqlServerTransportInfrastructure.Initialize(CancellationToken cancellationToken) in /_/src/NServiceBus.Transport.SqlServer/SqlServerTransportInfrastructure.cs:line 59
at NServiceBus.SqlServerTransport.Initialize(HostSettings hostSettings, ReceiveSettings[] receivers, String[] sendingAddresses, CancellationToken cancellationToken) in /_/src/NServiceBus.Transport.SqlServer/SqlServerTransport.cs:line 66
at ServiceControl.Transports.TransportCustomization`1.ProvisionQueues(TransportSettings transportSettings, IEnumerable`1 additionalQueues) in /_/src/ServiceControl.Transports/TransportCustomization.cs:line 158
at ServiceControl.Audit.Infrastructure.Hosting.Commands.SetupCommand.Execute(HostArguments args, Settings settings) in /_/src/ServiceControl.Audit/Infrastructure/Hosting/Commands/SetupCommand.cs:line 35
at ServiceControl.Audit.Infrastructure.Hosting.Commands.CommandRunner.Execute(HostArguments args, Settings settings) in /_/src/ServiceControl.Audit/Infrastructure/Hosting/Commands/CommandRunner.cs:line 12
at Program.<Main>$(String[] args) in /_/src/ServiceControl.Audit/Program.cs:line 41
at Program.<Main>(String[] args)
Symptoms
ServiceControl 6.19 and above throws an ArgumentException when using Azure SQL Transport with Managed Identity
Who's affected
Anyone using ServiceControl 6.19 and above with Azure SQL Transport and Managed Identity
Root cause
Missing 'Microsoft.Data.SqlClient.Extensions.Azure' NuGet package. This only become required as of v7 of the SqlClient
Confirmed workarounds
Use ServiceControl 6.18.3
Backported to
Original bug report
Describe the bug
I have just updated from 6.18.2 to 6.19.2
Assume Microsoft.Data.SqlClient has been updated and the azure extensions dependency hasn't been added. Now get the following exception on startup
What is the recommendation for connecting SC to an Azure SQL database using managed identity?
Steps to reproduce
Install SC 6.19.2 and configure to use an Azure SQL database using managed identity.
Relevant log output