Wednesday, August 08, 2012

Enabling Remote Access to SQL Server on an Azure VM

The basic requirements for enabling remote access to SQL Server are pretty straightforward:

1. Ensure that “Allow Remote Connections” is enabled in SQL Server Management Studio.

2. Open your firewall to allow communication (by default TCP port 1433).

To get access to your SQL Server running on a Windows Azure Virtual Machine (VM), you need to take some additional steps—just as you would using an Amazon Web Services virtual machine. The same is true for opening HTTP access (e.g., over port 80), or any other port for that matter.

Note: This post is not about SQL Azure. This applies to an install of SQL Server on a Windows Azure Virtual Machine.

  1. First login to the new Azure Management Portal (currently in “Preview).

image

2. Click on the Virtual Machine you want to configure and then click “Endpoints.”

image

3. By default, SQL Server will use TCP port 1433, so add an endpoint with any name (using the allowed characters and character limit).

(I haven’t read up on it yet, but I’m assuming the public port is what you’ll be using from the outside and the private port is the one that will actually be forwarded to the VM. To keep it simple, I left them the same in my test.)

That’s it, you’re done! Now you can connect from a client machine to your remote SQL Server machine.

3 comments:

Anonymous said...

You should also mention that you need to turn on "Windows and SQL Server Authentication" within Management Studio in the server properties screen, otherwise you can't authenticate remotely if you set up SQL accounts.

By default in the Azure image it is set to Windows authentication only.

Anonymous said...

wrong azure does not autorize connection on 1433 port from outside.

Stephen Cawood said...

Anonymous, as I wrote in the post, you have to create an endpoint to allow port communication through the firewall.

I think the post is clear on that point.