0

I have a Web Forms .NET 4.5+ application running on an Azure VM web server (Windows Server 2019) using IIS 8.

The site will load with an index.html page in production (In other words, the web server connection is good LIVE, without a DB connection). The site fully loads locally, database included (Locally means running the site through Visual Studio 2019 / Chrome on my desktop)

My web.config is the same locally as it is in prod -> it has the same connection string, etc.

My SQL database is not on a traditional SQL Server instance, through a VM on a server. It is technically an "Azure SQL DB"

The problem, and error: when I enter the site URL, the page times-out and fails to connect to the SQL Server/DB. Here is the full error text:

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)

  • I have added an inbound AND outbound rule to my firewall for Port 1433
  • I have a valid login for my connectionString (again, the same SQL connection works locally
  • Again, the site loads without any attempt at a DB connection
  • I have attempted a "dumbed-down" version of the connection string (full string seen below). Meaning, removed certain qualifiers and flags. Tried different combinations

Here's the full connection string that Azure provides. This is what I'm using:

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

Excess/redundant information:

  • Entering the website's IP address or URL in my web browser is what fails
  • It does NOT fail when I am NOT making a database connection (example: When index.html is the ONLY file in the web site's folder on the server)
  • This is my first time deploying/publishing a web app to a public domain. I have 5-6 years of .NET full-stack experience, but I have always worked on intranet only, and on pre-configured servers. I chose Azure because it was free with a trial. I thought it would be easy. I was wrong. I'm considering other options.
19
  • 1
    @Mike, this is so common its unfair for us to keep guessing what it could be. Can you detail what you've tried that doesn't work looking at: stackoverflow.com/questions/1391503 stackoverflow.com/questions/16256533 stackoverflow.com/questions/18060667 dba.stackexchange.com/questions/49365 Commented Jul 4, 2019 at 1:16
  • 1
    Reading through all that text carefully, it seems like your Azure VM cannot connect to the Azure SQL. Can you remote on to your Azure VM and try some bsaica connectivity tests to Azure SQL. Most likely you need to add a firewall exception to your Azure SQL to allow the VM to connect. Commented Jul 4, 2019 at 1:18
  • 1
    We can solve this and I will try to be a bit more polite about it :) Commented Jul 4, 2019 at 1:54
  • 1
    Can you confirm this is from the VM running the web server? Interesting. This would indicate that there is no connectivity issue from the VM to Azure SQL, but there is when you try and connect from within the web application that is running on the web server. PS don't give up on Azure, there's just a few new things to learn first. Commented Jul 4, 2019 at 2:07
  • 1
    I can't get to the picture but I believe you. Is it possible that you can echo the connection string within your web app just to be absolutely certain you are connecting to the server that you think you are connecting to from within the web app? My suspicion now is that the app running on the web server is not using the connection string that you think it is, in particularly the server name. Could you possibly also try temporarily removing the ,1433 part from your web app connection string and see if that makes a difference. Commented Jul 4, 2019 at 3:18

3 Answers 3

0

This error occurs if your asset didn't load.

You need to try and check your base url inside your project,

Sign up to request clarification or add additional context in comments.

1 Comment

The base URL works locally (when I run through VS), and it works on the web server when I change the base URL to index.html (a blank html page)
0

Did you add your server IP address at SQL server FW config, https://learn.microsoft.com/en-us/azure/sql-database/sql-database-firewall-configure#creating-and-managing-ip-firewall-rules

1 Comment

If I understand correctly, are you saying that I need to add the Web Server's IP address to the "allowed" SQL Firewall IP addresses? If so, I tried that and it did not work. TY
-1

The server that SQL is installed on, should allow incoming connections on port 1433.

Check out this article here. I know it is for 2008 R2 but some of the settings are similar

9 Comments

I don't know how to find out through Azure. I'm assuming you mean the SQL Server? I don't see anything through Azure's web portal about ports/networking on the SQL Server, only on the Web Server. On the web server, I have added inbound and outbound rules for 1433 (to allow)
Unfortunately, when I connect to the Azure server through SSMS, I do not have the same context menu when I right-click the server in the Object Explorer, as your msdn link shows. I'm not sure why that is, but it means that I cannot access the SQL Server's "Properties", at least not through SSMS
Hi Mike, Unfortunately I haven't had a lot to do with the Azure SQL on a VM but I did find this article which may be of some help learn.microsoft.com/en-us/azure/virtual-machines/windows/sql/…
Per this suggestion, I have "Allow access to Azure Services" turned ON already: social.msdn.microsoft.com/Forums/sqlserver/en-US/…
I'll repeat my comment from 10 minutes ago: remote on to your VM (the one running the web server) and perform a basic SQL Server connectivity test.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.