1

I followed every instruction to publish and deploy my project into AZURE my web-app from Visual Studio and my SQL database from Microsoft SQL server management. It shows successful for everything and the web-app runs. The following error shows whenever any interaction happens with the database:

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)?.

the output

However, I did reconfigure the Connection string in the web-app before publishing it and the problem still showing. here is the connection string that I am using. and I got it from Azure using the same name of the database as it mentions.

Server=tcp:apuldb.database.windows.net,1433;Initial Catalog=apuldb;Persist Security Info=False;User ID=*****;Password=*****;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;

Update: the app fully works via the above connection string only when I run it from Visual Studio locally. So, the app can be connected successfully to the online database in the cloud if I run it locally using AZURE database.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • I'm sure your publish and deploy worked perfectly, but your published app is using a different database, and your connection details are either wrong or the database is configured incorrectly. We might be able to assist if you show us your connection string with the sensitive information removed. But really its just a case of double checking that and double checking your database is configured to allow remote connections (as it says in the error). – Dale K Jul 16 '20 at 01:41
  • hi dale, here is the connection string that iam using. and i got it from azure using the same name of the database as it mentions. SqlConnection sqlCon = new SqlConnection ("Server=tcp:apuldb.database.windows.net,1433;Initial Catalog=apuldb;Persist Security Info=False;User ID=*****;Password=*****;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"); – ahmed selim Jul 16 '20 at 01:47
  • The other thing is your SQL Server needs to allow permissions to the app pool identity that your runs under - have you done that? – Dale K Jul 16 '20 at 01:48
  • i just tried to run the app from visual studio using the online database and the connection string mentioned above and it works perfectly!. the problem only occurs when i run the app online along with online database. – ahmed selim Jul 16 '20 at 02:19

0 Answers0