Venki
Venki

Reputation: 2169

SQL Azure : Connection to SQL Azure throws exception

When I connect to SQL Azure from my code, I get the following error.. I am able to connect to SQL Azure from SQL Server Management Studio successfully.

System.Data.SqlClient.SqlException: 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: TCP Provider, error: 0 - The requested name is valid, but no data of the requested type was found.)

I also tried connecting using sqlCMD and that connects without any issue. Only issue arises is during runtime when I get this exception.

Upvotes: 7

Views: 7451

Answers (5)

Kaushik Ghosh
Kaushik Ghosh

Reputation: 15030

There can be numerous reasons for this failure, I am listing out the scenarios and the options that needs to be allowed on the server.

  1. If you are connecting an Azure SQL Instance using Sql server management studio while inside you company's network/firewall, first of all you will need to check if your company's firewall rules allow that or not.

  2. On the AZURE SQL Server, make sure your IP address is in the allowed list.

Upvotes: 1

Mitesh Prajapati
Mitesh Prajapati

Reputation: 53

If you have your IP added into firewall rules and allowing SQL connection to Azure Services Enabled. It should work fine!

Upvotes: 0

Kakira
Kakira

Reputation: 856

It would be helpful if you post your connection string here. Also a sample app on connecting to sql azure using ado.net: http://msdn.microsoft.com/en-us/library/windowsazure/ee336243.aspx Makesure you pay attention to the SqlConnectionStringBuilder properties.

Upvotes: 0

Voclare
Voclare

Reputation: 251

You might also want to check to make sure your firewall allows outbound connections on port 1433.

Upvotes: 1

Denis Ivin
Denis Ivin

Reputation: 5644

I believe you just need to tick the checkbox "Allow other Windows Azure services to access this server" in Firewall Rules on your SQL Azure account (this will allow connecting to the db server from your deployed Azure application). Hope this helps.

Upvotes: 0

Related Questions