Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 714
Venki Avatar asked Feb 21 '11 13:02

Venki


People also ask

Can't connect to SQL Server on Azure?

Steps to resolve persistent connectivity issuesSet up firewall rules to allow the client IP address. On all firewalls between the client and the Internet, make sure that port 1433 is open for outbound connections. Review Configure the Windows Firewall to Allow SQL Server Access for additional pointers.

Can't connect to Azure SQL managed instance?

If you are unable to connect to SQL Managed Instance from an Azure virtual machine within the same virtual network but a different subnet, check if you have a Network Security Group set on VM subnet that might be blocking access.

Can't connect to Azure SQL Database from SSMS?

SSMS cannot connect to azure sql databaseYour client IP address does not have access to the server azure. Sign in to an Azure account and create a new firewall rule to enable access. This is for obvious security reasons. You don't want to allow everyone to be able to connect to your sql database in azure.


2 Answers

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

like image 130
Voclare Avatar answered Nov 15 '22 05:11

Voclare


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.

like image 41
Kaushik Ghosh Avatar answered Nov 15 '22 04:11

Kaushik Ghosh