Javascript required
Skip to content Skip to sidebar Skip to footer

Cannot Connect to Azure Sql Database

we've been running our azure hands on experience labs throughout the us central region for the last month or so and the sql azure exercises require the user to connect a newly created sql azure database from their development workstation.

inevitably, at least one machine is configured with one or more settings that prevent a connection from succeeding, either from sql server management studio or visual studio's data connections tree in server explorer (my preferred method btw).

here are the troubleshooting tips we've been using in the labs:

1. double check your software versions.

if you're using sql server management studio , it needs to be sql server management studio 2008 r2 (the free express or full edition). if you go to the help | about menu, the dialog will say r2 in the logo product logo.

image

if you want to connect from directly inside visual studio 2010 , make sure you have visual studio 2010 service pack sp1 installed as well. if you go to the help | about menu item in visual studio 2010, the popup dialog will say sp1 immediately after the product version number. also, make sure you have the latest windows azure sdk installed. it will set up the hooks for azure database connectivity from within visual studio 2010.

image

2. double check your sql server native client configuration

if you're getting an error that mentions named pipes it means the sql client networking protocol settings on your development machine are set to connect to servers using the named pipes protocol by default. this won't work with sql azure because named pipes is a network protocol optimized for local lan traffic. all connections to sql azure are done using tcp/ip so you need tcp/ip enabled.

to do this, run sql server configuration manager go to your start menu and select all programs | sql server 2008 r2 | configuration tools | sql server configuration manager .

image

you need to make sure the tcp/ip protocol is enabled under the sql native client 10.0 configuration tree item.  (on 64 bit machines you might have both 32 bit and 64 bit tree branches – be sure to enable tcp/ip in both). it's generally a good ide to set tcp/ip as a higher priority protocol over named pipes as tcp/ip is the most common network protocol for sql severs these days. this msdn article has more details about the configuration options.

3. check your client side firewall rules.

sql servers communicate over tcp/ip through port 1433. the windows firewall software that shipped with xp sp2, vista and windows 7 is pretty good about about asking you when a new port is about to be used and letting you choose if you want it opened. if you're using another client side firewall solution, be sure to enable port 1433 for outbound connections. if your firewall software is set on an application by application basis, set up a rule for sql server management studio or visual studio appropriately.

4. check the sql azure server firewall rules

when you create your sql azure database, you were asked to set up firewall rules to allow outside connections to the server. when you add a rule the dialog box lets you to set a range of ip addresses. it also shows your current ip address. in most cases your current ip address is chosen from a bank of addresses on the network you're connected to.

to check these settings, log into your windows azure account, navigate to the databases area, and choose the database you're trying to connect to from the tree on the left side of the screen. you should see the dropdown option to view and edit the firewall rules for your database server. add or edit a rule to enable access for the development machine you're trying to connect with.

image

as a minimum, you should add your current ip address as it is shown at the bottom. the hands on labs recommend adding a large enough address range so that if you have to reboot and end up acquiring a slightly different address you'll still be able to connect with having to add another rule. you cans that i did this here.

note: the address shown for your current ip address is the public address that the server sees your internet traffic coming from. in the big chain of firewalls between you and your sql azure database, this is the address as it will be recognized from the network you currently reside in. it may or may not match the actual ip address your individual machine says it's using. that's ok. what it's seeing is the most public internet facing firewall that you're going through to get to the database. that's all the server needs to know to allow you in.

5. check your corporate firewall rules

if you still can't connect and all of the above items check out and you're currently connected to corporate network, chances are your corporate it folks have another firewall in place to keep the baddies out and to keep you from accidentally letting them in.

if you've got an alternative method to connect to the internet such as a wireless hotspot or a guest network, try connecting to it and see if your attempt to reach your sql azure server succeeds. if so, then you know there's a corporate firewall blocking you.

you'll have to check with your network admins to see if they allow outbound tcp/ip connections on port 1433. chances are you'll have to do some paperwork to get that set up.

these are the troubleshooting steps we've found fruitful during labs. if you're still stuck beyond this point, get a colleague to try connecting to your server from their machine. if they succeed, then you know there's a configuration difference. it's just a matter of finding the difference.

Cannot Connect to Azure Sql Database

Source: https://dzone.com/articles/why-cant-i-connect-my-sql