0
votes

I am trying to connect from an Azure virtual server (windows 10) to an Azure Managed SQL instance. From the command line on the virtual server I can connect to the managed SQL instance using:

sqlcmd -S aserver-data01.public.abc123.database.windows.net,3342 -U User01 -P password

This connects fine.

I am running a compiled .NET executable on the same virtual server that attempts to connect to the managed SQL server using the following connection string:

DataBaseConnectionString, Data Source=aserver-data01.public.abc123.database.windows.net,3342; Database=MyDB; Integrated Security=false; User ID=User01; Password=password

It fails with:

System.Data.SqlClient.SqlException (0x80131904): 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 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.) ---> System.ComponentModel.Win32Exception (0x80004005): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

Can anyone help, I can't seem to get it to connect.

1

1 Answers

0
votes

The problem was the .net executable was pulling the connection string from a comma separated config file and so was splitting the connection string in half at the comma before the port number.