TaeV
TaeV

Reputation: 738

Windows Azure Website connect external SQL server

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.

Upvotes: 1

Views: 4842

Answers (3)

joelmdev
joelmdev

Reputation: 11773

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.

Upvotes: 0

amhed
amhed

Reputation: 3659

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.

Upvotes: 4

levelnis
levelnis

Reputation: 7705

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.

Upvotes: 0

Related Questions