If you are planning to or even considering jumping in to Google Cloud Platform and you work with .NET technologies, you’ll almost certainly want to know how to run SQL Server in the Google Cloud. Google Cloud has made a big effort lately to more fully support the .NET stack, including SQL Server. This is good news for everyone, because more options means more chances to find the right fit for your development project!

Why Run SQL Server in the Google Cloud?

There could be multiple answers to this question, but here are a couple to consider: If you are maintaining or migrating a production solution, you might be looking to take advantage of other services in the Google Cloud Platform. And you may already have a SQL server instance or instances as a part of your stack.

In that case, you’ll have to consider your current deployment strategy against the GCP offerings. Knowing that you CAN run SQL Server on Google Cloud is a good start! You will also want to consider licensing – if you are already running on another cloud platform you are probably already familiar with how that works, particularly if you already use Microsoft License Mobility.

Note that there are different pricing levels for SQL Server Express, Standard, and Web, and that currently Enterprise is “Coming Soon”. What’s interesting and might be a game changer for some customers, is that using SQL Server on Google Cloud lets you pay-as-you-go for SQL Server licensing, just as you do for other cloud resources. So take a look at regular licensing fees for SQL server and you’ll see why that might be a good choice!

But the case I want to consider first is a little more developer-centered. How would a .NET developer who is just getting started with Google Cloud Platform go about setting up a simple SQL Server instance on a VM and connect to it? This is a great exercise in taking something you probably already know – how to set up and connect to a SQL Server instance for development, except do it on GCP.

Before You Start

Before you get started, there are a couple of pieces you need to have ready:

Creating the SQL Server Instance

From the Console, choose VM Instances and Create Instance.

Now we must choose options for our VM. If you’re familiar with this process in Azure, you may want a reference to the recommended machine configurations for SQL Server.

To get something comparable to the most economical option from the Azure recommendations (DS12_V2), let’s choose the n1-highmem-4 configuration for Google Cloud.

Next, set the boot disk to an image with SQL Server pre-installed. Choose Change on the Boot Disk section, and then select the Application images tab in the Boot disk menu.

Now you can select the SQL Server image of your choice. We can leave the other options as-is and click Create. Once the instance is created (which you’ll notice is lightning fast!), you can select the new VM in your instances list.

Then choose Create or reset Windows password. Make SURE to note the account name and password somewhere safe, you will need them to access this VM. But if you misplace them, this is also how you can reset the Windows password.

Connect to the VM

Now we can remotely connect to the VM. Click the RDP button on the instance page. If you haven’t already, this is a good time to install the Chrome RDP Extension! You can also download the RDP file to connect using the Windows client.

Now you can enter the credentials you created for the Windows account. Then you should be able to see the server manager for your new Windows Server VM, and verify that SQL Server is running.

Configuring for a Development Connection

At this point, if you want to alter any of the SQL Server features, you can access the SQL Server installer directly on the VM. You can also open SSMS. Here I just typed SQL into the windows search to bring up these two options. They are both available by default, just because we chose the SQL Server image for our VM.

Open SSMS and use the preset windows authentication login. Now we can change settings directly on our SQL Server instance, just as we would using SSMS locally. For the rest of our example, we are going to set up this SQL server instance as if we wanted to connect from our local machine for development. This isn’t necessarily something you would need for production, but instead lets us see how to make familiar changes to SQL Server even when running on Google Cloud. If we want to enable the sa account for development purposes, we will need to enable SQL Server authentication by selecting properties and then the security tab.

Then turn on SQL Server and Windows Authentication mode.

We also have to expand the Logins folder and select sa >properties to set a password. Under Status, select Enabled to turn the account on. It is a good idea to restart after this step and test the login.

Enable External Access to SQL Server

If we want to access this SQL server instance from outside the VM, we have to add a firewall rule.  The default SQL Server installation included in the image is already set up from the VM side, so we just need to allow connections via the networking configuration. Under Compute > Networking from the Console menu, we can see the current firewall rules and also add a new one to allow connections to port 1433 for SQL Server.

You can set the firewall rule to be as open or restrictive as you like – “allow from any source” will work for any IP, you can add a range, or simply your development machine’s IP. To add a single IP choose the option for IP ranges – single values are also allowed, and no subnet mask is required.

We’re almost there! To connect from a local SSMS, you’ll need the external IP of the VM. Go to External IP Addresses in the console and copy that address.

Finally, use that IP and your SQL Server Authentication credentials to connect from your local machine. Now you can use that connection to set up connection strings in your web.config files or anywhere you would normally use SQL credentials in your development process.

More Resources

Google has some great related tutorials that you may also want to check out:
Creating a High-Performance SQL Server Instance 
Best Practices for SQL Server Instances
SQL Server images on Google Computer Engine

The following two tabs change content below.
  • Tushar Kshirsagar

    No luck tried same steps