Creating SQL Server VM instances


Microsoft SQL Server is a database system that runs on Windows Server and someLinux distributions. You can use SQL Server on Compute Engine as partof the backend for your applications, as a flexible development and testenvironment, or in addition to your on-premises systems for backup and disasterrecovery.

Compute Engine provides images with Microsoft SQL Server preinstalledon Windows Server. For these SQL Server images, Compute Enginemanages the license for both Windows Server and SQL Server, and includes thecost in your monthly bill. Create VMs with SQL Server and scale out tolarge multi-node configurations when you need them.

Compute Engine stores your data on durablepersistent disks with automatic redundancy andautomatic encryption at rest. Use these persistent disks to store yourSQL Server data without having to worry about the durability or security ofyour data. For additional performance, create your VMs with alocal SSD as a cache that providesadditional IOPS and performance for SQL Server queries.

You can create Compute Engine virtual machine (VM) instances that runSQL Server in the following ways:

For a full list of the available images that include SQL Serverpreinstalled, seeOperating system details.

Machine type requirements for SQL Server images

The best machine type for SQL Server depends on the edition of SQL Server thatyou're running.

SQL Server Standard

You can run SQL Server Standard on VMs with any machine type, butshared-core machine typeswon't run optimally. Google recommends that you use VMs with at least one vCPUto run SQL Server Standard.

SQL Server Enterprise

VMs that run SQL Server Enterprise must have at least 4 vCPUs. For optimalperformance, Google recommends that you run SQL Server Enterprise on VMs withlarger memory capacities. Depending on your workload, you should usehighmempredefined machine types with 8 vCPUs or more, such as forN2. Thehighmempredefined machine types maximize the ratio of memory to each vCPU that isavailable on Compute Engine, which is optimal for SQL ServerEnterprise VMs.

Additionally, you can use SQL Server Enterprise on Compute Engine tocreate SQL Server Availability Groups.

Default components

SQL Server images include several components by default. The default componentsdepend on the edition of SQL Server that you selected.

For information about the default components included with your version of SQLServer, seeEditions and supported features of SQL Server 2019.

For information about modifying the SQL Server components, seeAdd Features to an Instance of SQL Server.

Before you begin

Creating a SQL Server instance

To create a SQL Server instance, specify the image family for the specificversion of SQL Server that you need. For a list of the SQL Server imagefamilies, seeOperating system details.

For optimal performance, database server platforms require machine types withmore virtual CPUs and larger amounts of memory. Google recommends that you usemachine types with at least 2 vCPUs and at least 4 GB of memory when you run SQLServer instances. You can usecustom machine typesto configure SQL Server instances to match the performance requirements for yourworkload. Additionally, you can use larger persistent disks and faster SSDpersistent disks to improve the performance of your applications.

Additionally, you must set specific firewall rules to allow SQL Server trafficon the VPC network or subnet that your VM is a part of. For moreinformation seeBest practices for SQL Server.

Console

To create a SQL Server instance, follow these steps:

  1. In the Google Cloud console, go to theCreate an instance page.

    Go to Create an instance

  2. Specify the VM details.

  3. In theBoot disk section, clickChange, and then do thefollowing:

    1. On thePublic images tab, click theOperating system list, andthen selectSQL Server on Windows Server.
    2. In theVersion list, select a version.
    3. In theBoot disk type list, select a boot disk type.
    4. In theSize (GB) field, set the boot disk size.
    5. Optional: To modify the advanced configuration for the boot disk,clickShow advanced configuration, and then specify yoursettings.
    6. To save the boot disk configuration, clickSelect.
  4. ClickCreate.

After you create the VM, create a firewall rule to allow access toSQL Server on your VM. The default SQL Server port is 1433.

  1. In the Google Cloud console, go to theFirewall Rules page.

    Go to Firewall Rules

  2. At the top of the page, clickCreate firewall rule to start creatinga firewall rule.

  3. Specify the details for this firewall rule.

    • In theName field, specify a name for the firewall rule.
    • In theNetwork field, select the VPC network where your SQLServer instance is located.
    • For theDirection of traffic, select Ingress.
    • In theTargets field, choose the targets for the firewall rule,which can be all instances, or specified target tags orservice accounts. For example, you can select the optionAll instances in the network. If you configured a tag or serviceaccount for your SQL Server instance, then you can limit thefirewall rule to the specific tag or service account.
    • InSource filter field, select the range of IPs that you want toallow access on this port. For an ingress rule, you can selectSource IPv4 ranges, source IPv6 ranges, source tags, or serviceaccounts. Use the fields afterSource filter to supplyadditional information about your choice.
    • In theProtocols and ports section, chooseSpecified protocolsand ports and enter the port that SQL Server uses. For thisexample, chooseTCP and enter1433, which is the default port.
  4. ClickCreate to create this firewall rule and allow access to yourSQL Server instance over port 1433.

If you need to add additional firewall rules to your VM, see thefirewall rules documentation.

gcloud

Use thecompute images listcommand to see a list of available SQL Server images:

gcloud compute images list --project windows-sql-cloud --no-standard-images

Use thecompute instances createcommand to create a new VM and specify the image family for one ofthe Windows Server or SQL Serverpublic images.

gcloud compute instances createVM_NAME \    --image-project windows-sql-cloud \    --image-familyIMAGE_FAMILY \    --machine-typeMACHINE_TYPE \    --boot-disk-sizeBOOT_DISK_SIZE \    --boot-disk-typeBOOT_DISK_TYPE

Replace the following:

  • VM_NAME: thename for the new instance.
  • IMAGE_FAMILY: one of thepublic image families for Windows Server or SQL Server images.
  • MACHINE_TYPE: one of the availablemachine types.
  • BOOT_DISK_SIZE: the size of the boot disk in GB. Larger persistent disks havehigher throughput.
  • BOOT_DISK_TYPE: thetype of the boot disk for your instance. For example,pd-balanced.

After you create the VM, create a firewall rule to allow access toSQL Server on your VM. The default SQL Server port is 1433.

gcloud compute firewall-rules create sql-server-1433 \    --description "Allow SQL Server access from all sources on port 1433." \    --allow tcp:1433 --networkNETWORK

whereNETWORK is the name of the VPC network where your VM is located.

If you need to add additional firewall rules to your VM, see thefirewall rules documentation.

Terraform

To create the SQL Server VM instances, use thegoogle_compute_instance resource.

resource "google_compute_instance" "sqlserver_vm" {  provider = google-beta  name     = "sqlserver-vm"  boot_disk {    auto_delete = true    device_name = "persistent-disk-0"    initialize_params {      image = "windows-sql-cloud/sql-std-2019-win-2022"      size  = 50      type  = "pd-balanced"    }    mode = "READ_WRITE"  }  machine_type = "n1-standard-4"  zone         = "europe-west1-b"  network_interface {    access_config {      network_tier = "PREMIUM"    }    network    = google_compute_network.default.id    stack_type = "IPV4_ONLY"    subnetwork = google_compute_subnetwork.default.id  }}

To learn how to apply or remove a Terraform configuration, seeBasic Terraform commands.

REST

To create a VM with the API, include theinitializeParams propertyin your VM creation request and specify a Windows image.

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instancesinstance = {  "name": "VM_NAME",  "machineType": "zones/ZONE/machineTypes/MACHINE_TYPE",  "disks": [{      "boot": "true",      "type": "PERSISTENT",      "initializeParams": {         "diskName": "DISK_NAME",         "sourceImage": "projects/IMAGE_PROJECT/global/images/family/IMAGE_FAMILY",         "diskSizeGb": "BOOT_DISK_SIZE",         "diskType": "BOOT_DISK_TYPE",       }    }],  "networkInterfaces": [{    "accessConfigs": [{      "type": "ONE_TO_ONE_NAT",      "name": "External NAT"     }],    "network": "global/networks/default"  }],  "serviceAccounts": [{       "email": DEFAULT_SERVICE_EMAIL,       "scopes": DEFAULT_SCOPES  }]}

Replace the following:

  • PROJECT_ID: the ID for your project.
  • ZONE: thezone for this instance.
  • VM_NAME: thename for the newVM.
  • MACHINE_TYPE: the availablemachine types.
  • IMAGE_PROJECT: eitherwindows-cloud for Windows Server imagesorwindows-sql-cloud for Windows Server images with SQL Serverpreinstalled.
  • IMAGE_FAMILY: thepublic image familiesfor Windows Server or SQL Server images.
  • BOOT_DISK_SIZE: the size of the boot disk in GB.Larger persistent disks havehigher throughput.
  • BOOT_DISK_TYPE: thetypeof the boot disk for your VM. For example,pd-ssd.

After you create the VM, use thefirewalls.insert methodto create a firewall rule that allows access to SQL Server on your VM. Thedefault SQL Server port is1433.

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/firewalls{ "name": "sql-server-1433", "network": "global/networks/NETWORK", "allowed": [  {   "IPProtocol": "tcp",   "ports": [    "1433"   ]  } ]}

Replace the following:

  • PROJECT_ID: the ID for your project.
  • NETWORK: the name of the VPC network where your VM is located.

After you create your SQL Server instance,set the initial password for the VMso that you canconnect to the VMthrough RDP. Then, run the SQL Server Management Studio as an administrator tomanage databases on your SQL Server instance.

Additionally, you can enhance the SQL Server installation with one or more ofthe following items:

Managing SQL Server databases

Run the SQL Server Management Studio as an administrator to configure SQL Serverdatabases. You candownload and installthe SQL Server Management Studio on your local workstation, and use it toremotelyconnect to the database engineon your VM.

If you can't install the Management Studio on your local workstation,connect to the VM through RDPand run the Management Studio on the VM itself. SQL Server 2012 and SQLServer 2014 both include the SQL Server Management Studio by default. For SQLServer 2016, you must download the SQL Server Management Studiofrom the Microsoft website and install it on the VM.

By default, SQL Server uses Windows Authentication mode to control remoteaccess to SQL Server itself. If you need to use SQL Server Authentication mode,change the authentication mode.

Manually updating SQL Server instance names

If yourename a VM that hostsSQL Server, you must update the SQL Server instance name. For more information,seeRename a computer that hosts a stand-alone instance of SQL Server.

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-16 UTC.