Problem
I have setup an Azure Pipeline, and the problem I have is that during the Test Assemblies part of the Pipeline it is failing as it can't resolve the connection string/find my SQL Server.
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) ---> System.ComponentModel.Win32Exception: The network path was not found
In this scenario, I want to avoid creating a mock and ideally have the code directly communicate with SQL Server.
The SQL Server is sat on an Azure VM, so it's not a 'Azure SQL Database' service.
What I've Tried
I have opened the ports on the Azure VM to allow traffic from all regions/IP ranges used by Azure DevOps (I have found online that this is required). I have also tried pointing the connection string inside the Pipeline 'Test Assemblies' to a different (on-premise) windows server which holds an instance of SQL Server, but it is still not able to find/connect to SQL.
When connecting to SQL from my local (both the Azure VM and on-premise server) I can connect. We also have a few other services using the SQL Server sat on the Azure VM, so I am confident that the connectivity issue is with connecting from an Azure Pipeline.
Has anyone had this issue before?
Update
I have updated the connection string to directly refer to the port i.e.
**.***.**.***,1433
And the error message has now changed to:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - The wait operation timed out.) ---> System.ComponentModel.Win32Exception: The wait operation timed out
Windows machine file copy
to check if your pipeline could access the SQL Server. – Leo Liu-MSFT