1
votes

I just upload my project to Windows Azure website free version.

My website need to connect to external SQL server on another web hosting.(not SQL server on windows azure).

When i develop on my PC. Everything works well (that mean my connection string is correct).

But when i upload to windows azure. It can't connect to that database.

And throw exception like this.

Access is denied

when i do the following this answer, error show like this Connecting to remote SQL Server 2008 from Windows Azure

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

and both show stack trace like this

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.

[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.

how can i solve this issue, please help.

3
Is your database locking down access to certain IPs on port 1433? The link you included in your post relates to accessing from a web-role instance rather than a website. - QFDev
I think its not locking. Because i can connect from my developing machine. - TaeV
But is your dev machine on the same network as the SQL Server? - Mike Goodwin
No, not same machine. Target database is on web hosting. - TaeV
Have you considered moving the database to SQL Azure? Then you can simply add the database as a linked resource under the website profile. It should also run much faster. It looks like the problems you are encountering here relate to the endpoints within the website instance being closed, specifically port 1433. - QFDev

3 Answers

4
votes

You're uploading your application to a Windows Azure Website. Most probably port 1433 that connects to SQL Server is blocked by default on their firewall. Since you're using an azure website you will have no control over this firewall setting.

You can either:

  1. Migrate your existing SQL Server database into SQL Azure and consume it from there
  2. Upgrade your application to a Cloud Service where you can define the endpoints you need to connect to the external database (which I wouldn't recommend anyway because it would be very slow on deployment)
  3. Find a way to publish your existing database as web services so you can consume them from your application, but you would probably have to rewrite your app's data access layer.

I would simply move everything to SQL Azure, it's pretty straightforward.

0
votes

If you can add a website to the remote host where the database is hosted, can you create a service (e.g. WCF or Rest) on that same host that allows you to talk to the database? That way you can still host the database on the external host and communicate with it via the service from the Azure Website.

0
votes

Looks like there's a new way to allow Azure webapps to connect to on premises SQL Servers using Hybrid Connections. Google leads me to believe that this feature became available sometime in 2016. It will require that you install additional software on the machine that hosts your SQL Server instance.

More information available here.