Unable to create ADF Linked Service to Azure SQL database using Self-Hosted Integrated Runtime

Ricardo-2519 20 Reputation points
2024-06-07T21:59:28.4466667+00:00

Hi all,

I am having trouble creating a Linked Service that connects to one of our Azure SQL databases. After entering all required Linked Service fields and testing the connection using our self-hosted integration runtime, I received the following error message below. The credentials were correct and valid. I also noticed that the connection worked when I switched the runtime from self to AutoResolveIntegrationRuntime.

ADF Linked Service test connection error message

When setting up the Linked Service, I configured it to use a self-hosted integration runtime. Given that the Azure SQL database does have a default firewall to only allow access from specific IP addresses, I added the IP address of the VM where our integration runtime is being hosted. I also checked the option to Allow Azure services and resources to access this server (see image below).

Azure SQL firewall rules

To verify if the VM's IP address was being whitelisted. I RDP'd into the VM and opened up the Integration Runtime Configuration Manager. I tested a connection to the Azure SQL database from the Diagnostics tab in the Configuration Manager. The connection was successful (see image below).

Successful connection from IR Config Manager on VM

I also checked the logs from the configuration manager and noticed an Error message, which is shown below.

TraceComponentId: QueryTask
TraceMessageId: QueryRuntimeTestConnectionV2Exception
@logId: Error
FunctionName: TestConnection
jobId: 00000000-0000-0000-0000-000000000000
activityId: 4abda1ff-35d7-450d-8713-0726edda2ff1
eventId: QueryRuntimeTestConnectionV2Exception
message: TestConnection failed, error message: 'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Cannot connect to SQL Database. Please contact SQL server team for further support. Server: '', Database: User: Check the linked service configuration is correct, and make sure the SQL Database firewall allows the integration runtime to access.,Source=Microsoft.DataTransfer.ClientLibrary,StackTrace=   at Microsoft.DataTransfer.ClientLibrary.SqlProviderHandler.OpenConnection(RetryPolicy retry, Guid transferId, Guid activityId)
   at Microsoft.DataTransfer.Runtime.SqlConnection.TestConnection()
   at Microsoft.DataTransfer.TransferTask.InteractiveTaskFactoryV2.ConnectorTestConnection(ConnectionSetting connectionSetting, TestConnectionV2Response response)
   at Microsoft.DataTransfer.TransferTask.InteractiveTaskFactoryV2.TestConnection(TestConnectionV2Request request, TestConnectionV2Response response, CancellationToken token)
   at Microsoft.DataTransfer.TransferTask.InteractiveTask`2.Execute(),''Type=System.Data.SqlClient.SqlException,Message=Login failed for user ''.,Source=.Net SqlClient Data Provider,SqlErrorNumber=18456,Class=14,ErrorCode=-2146232060,State=1,Errors=[{Class=14,Number=18456,State=1,Message=Login failed for user ''.,},],StackTrace=   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.Open()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.DataTransfer.Common.Shared.HelperMethod.ExecuteWithTimeout(Action action, TimeSpan timeout, String timeoutErrorMessage)
   at Microsoft.Practices.TransientFaultHandling.RetryPolicy.<>c__DisplayClass1.<ExecuteAction>b__0()
   at Microsoft.Practices.TransientFaultHandling.RetryPolicy.ExecuteAction[TResult](Func`1 func)
   at Microsoft.DataTransfer.ClientLibrary.RetryPolicyExtensionMethods.ExecuteActionWithTimeout(RetryPolicy retryPolicy, Action action, TimeSpan timeout, String timeoutErrorMessage)
   at Microsoft.DataTransfer.ClientLibrary.RetryPolicyExtensionMethods.ExecuteActionWithTimeout(RetryPolicy retryPolicy, Action action, TimeSpan timeout, HybridDeliveryExceptionCode errorCode, String timeoutErrorMessageFormat)
   at Microsoft.DataTransfer.ClientLibrary.SqlProviderHandler.OpenConnection(RetryPolicy retry, Guid transferId, Guid activityId),'.

I am not sure if I am configuring something wrong on my end or if this might be a Microsoft issue. Has anyone else encountered this issue and if so how did you resolve it? Any help is appreciated. Thanks!

Azure SQL Database
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,121 questions
{count} votes

Accepted answer
  1. phemanth 8,485 Reputation points Microsoft Vendor
    2024-06-12T03:41:13.8033333+00:00

    @Ricardo-2519

    Welcome to Microsoft Q&A platform and thanks for posting your question.

    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others "I'll repost your solution in case you'd like to accept the answer.

    **Ask:**I am having trouble creating a Linked Service that connects to one of our Azure SQL databases. After entering all required Linked Service fields and testing the connection using our self-hosted integration runtime, I received the following error message below. The credentials were correct and valid. I also noticed that the connection worked when I switched the runtime from self to AutoResolveIntegrationRuntime.

    ADF Linked Service test connection error message

    When setting up the Linked Service, I configured it to use a self-hosted integration runtime. Given that the Azure SQL database does have a default firewall to only allow access from specific IP addresses, I added the IP address of the VM where our integration runtime is being hosted. I also checked the option to Allow Azure services and resources to access this server (see image below).

    Azure SQL firewall rules

    To verify if the VM's IP address was being whitelisted. I RDP'd into the VM and opened up the Integration Runtime Configuration Manager. I tested a connection to the Azure SQL database from the Diagnostics tab in the Configuration Manager. The connection was successful (see image below).

    Successful connection from IR Config Manager on VM

    I also checked the logs from the configuration manager and noticed an Error message, which is shown below.

    PowerShellCopy

    TraceComponentId: QueryTask
    TraceMessageId: QueryRuntimeTestConnectionV2Exception
    @logId: Error
    FunctionName: TestConnection
    jobId: 00000000-0000-0000-0000-000000000000
    activityId: 4abda1ff-35d7-450d-8713-0726edda2ff1
    eventId: QueryRuntimeTestConnectionV2Exception
    message: TestConnection failed, error message: 'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Cannot connect to SQL Database. Please contact SQL server team for further support. Server: '', Database: User: Check the linked service configuration is correct, and make sure the SQL Database firewall allows the integration runtime to access.,Source=Microsoft.DataTransfer.ClientLibrary,StackTrace=   at Microsoft.DataTransfer.ClientLibrary.SqlProviderHandler.OpenConnection(RetryPolicy retry, Guid transferId, Guid activityId)
       at Microsoft.DataTransfer.Runtime.SqlConnection.TestConnection()
       at Microsoft.DataTransfer.TransferTask.InteractiveTaskFactoryV2.ConnectorTestConnection(ConnectionSetting connectionSetting, TestConnectionV2Response response)
       at Microsoft.DataTransfer.TransferTask.InteractiveTaskFactoryV2.TestConnection(TestConnectionV2Request request, TestConnectionV2Response response, CancellationToken token)
       at Microsoft.DataTransfer.TransferTask.InteractiveTask`2.Execute(),''Type=System.Data.SqlClient.SqlException,Message=Login failed for user ''.,Source=.Net SqlClient Data Provider,SqlErrorNumber=18456,Class=14,ErrorCode=-2146232060,State=1,Errors=[{Class=14,Number=18456,State=1,Message=Login failed for user ''.,},],StackTrace=   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager)
       at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
       at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
       at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
       at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
       at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
       at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
       at System.Data.SqlClient.SqlConnection.Open()
       at System.Threading.Tasks.Task.Execute()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at Microsoft.DataTransfer.Common.Shared.HelperMethod.ExecuteWithTimeout(Action action, TimeSpan timeout, String timeoutErrorMessage)
       at Microsoft.Practices.TransientFaultHandling.RetryPolicy.<>c__DisplayClass1.<ExecuteAction>b__0()
       at Microsoft.Practices.TransientFaultHandling.RetryPolicy.ExecuteAction[TResult](Func`1 func)
       at Microsoft.DataTransfer.ClientLibrary.RetryPolicyExtensionMethods.ExecuteActionWithTimeout(RetryPolicy retryPolicy, Action action, TimeSpan timeout, String timeoutErrorMessage)
       at Microsoft.DataTransfer.ClientLibrary.RetryPolicyExtensionMethods.ExecuteActionWithTimeout(RetryPolicy retryPolicy, Action action, TimeSpan timeout, HybridDeliveryExceptionCode errorCode, String timeoutErrorMessageFormat)
       at Microsoft.DataTransfer.ClientLibrary.SqlProviderHandler.OpenConnection(RetryPolicy retry, Guid transferId, Guid activityId),'.
    
    

    I am not sure if I am configuring something wrong on my end or if this might be a Microsoft issue. Has anyone else encountered this issue and if so how did you resolve it? Any help is appreciated.

    Solution: I was able to resolve the issue. I am not sure why I never tried this but switching the connection version from Recommended to Legacy fixed the issue.

    linked service connection version

    If I missed anything please let me know and I'd be happy to add it to my answer, or feel free to comment below with any additional information.

    If you have any other questions, please let me know. Thank you again for your time and patience throughout this issue.


    Please don’t forget to Accept Answer and Yes for "was this answer helpful" wherever the information provided helps you, this can be beneficial to other community members.


1 additional answer

Sort by: Most helpful
  1. Ricardo-2519 20 Reputation points
    2024-06-11T22:04:25.1666667+00:00

    I was able to resolve the issue. I am not sure why I never tried this but switching the connection version from Recommended to Legacy fixed the issue.

    linked service connection version