3
votes

We have an Azure SQL server running which we use for our Azure Web App. The Web App can connect without a problem. We're trying to remotely update the database with the latest EF migrations via a C# console application. However we get the following exception.

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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

We tried connecting from the same PC with SSMS and we got in without any problems. And yes, before anyone asks we whitelisted the IP in Azure, else we wouldn't even had access via SSMS. We also tried with and without "tcp:" in the connectionstring.

This is the connectionstring we use in the Web and Console Application:

Server=tcp:{servername}.database.windows.net;Database={dbname};user id = {userid};password = {password};MultipleActiveResultSets=True;

In SSMS we just use {servername}.database.windows.net and use the credentials.

Thanks in advance.

2
Can you post your connection String (without sensitve information) ? Have you check if your IP address and instance name are same with SSMS ?Cedric
I updated my question. Yes, no doubt it's the same IP.Stephan Bisschop
Is the firewall shutdown during test ? So you use the same connection string with Web App and Consol App. So it's look like your system block the connection for this console.Cedric
Firewall is turned off completely while testing.Stephan Bisschop
Try to add the following to your connection string: Trusted_Connection=False;Encrypt=True; SSMS may have these options checked by default, while your app is not.Pavel Kutakov

2 Answers

3
votes

We haven't been able to solve this issue. We instead chose to go with ReadyRoll, which suits us fine.

0
votes

Azure SQL requires secured connection. You have to add the following to your connection string:

Trusted_Connection=False;Encrypt=True;