Creating instances

This page describes how to create a Cloud SQL for SQL Server instance.

For detailed information about all of the instance settings, see Instance settings.

After creating a Cloud SQL instance, you add databases to it by creating or importing them.

Choosing values for vCPUs and memory size

When you customize your instance, note the available values, below, for vCPUs and memory.

Standard options are available. Lightweight and high memory options also are available.

Version CPU / Memory
SQL Server 2017 Express Select from preset options:
  • 1vCPU, 3.75 GB
  • 2vCPU, 3.75 GB
  • 4vCPU, 3.75 GB
SQL Server 2017 Web Select from preset or custom options:
  • 1vCPU, 4 GB
  • 2vCPUs, 8 GB
  • 4vCPUs, 16 GB
  • 1-16 vCPUs, 4 to 64 GB
SQL Server 2017 Standard Select from preset or custom options:
  • 1vCPU, 4 GB
  • 2vCPUs, 8 GB
  • 4vCPUs, 16 GB
  • 1-24 vCPUs, 4 to 104 GB
SQL Server 2017 Enterprise Select from preset or custom options:
  • 2vCPU, 8 GB
  • 4vCPU, 16 GB
  • 2-96 vCPUs, 8 to 104 GB

Creating an instance

Console

  1. Go to the Cloud SQL Instances page in the Google Cloud Console.

    Go to the Cloud SQL Instances page

  2. Click Create instance.
  3. Select SQL Server and click Next.
  4. Enter a name.

    Do not include sensitive or personally identifiable information in your instance name; it is externally visible.
    You do not need to include the project ID in the instance name. This is done automatically where appropriate (for example, in the log files).

  5. Enter a password for the user.
  6. Under Location, select the region and zone for your instance.

    Place your instance in the same region as the resources that access it. The region you select can't be modified in the future. In most cases, you don't need to specify a zone.

  7. Under Configuration options, update any other settings you need for your instance:

    Setting Notes
    Database version
    Database version SQL Server 2017 Standard (default)
    SQL Server 2017 Enterprise
    SQL Server 2017 Express
    SQL Server 2017 Web
    Authentication
    Active Directory domain The Join an Active Directory domain dropdown menu lists any Managed Microsoft AD domains that previously were created in your project. From the dropdown menu, select a domain. For more information, see Overview of Managed Microsoft AD in Cloud SQL.
    Connectivity
    Private IP Adds a private IP address for your instance. To enable connecting to the instance, additional configuration is required.
    Public IP Adds a public IP address for your instance. To enable connecting to the instance, additional configuration is required.
    Machine type and storage
    Cores The number of vCPUs for your instance. Learn more.
    Memory The amount of memory for your instance, in GBs. Learn more.
    Storage type Indicates that your instance uses SSD storage. All SQL Server instances use SSD storage. Learn more.
    Storage capacity The amount of storage provisioned for the instance. Learn more.
    Automatic storage increase Determines whether Cloud SQL automatically provides more storage for your instance when free space runs low. Learn more.
    Automatic backups and high availability
    High availability If you need your instance to be configured for high availability, you must select the High availability (regional) option. Learn more.
    Automatic backups The window of time when you would like backups to start.
    Retention settings for automatic backups The number of automated backups you would like to retain (from 1 to 365 days). Learn more.
    Authorized networks
    Database flags
    Flags and parameters You can use database flags to control settings and parameters for your instance. Learn more.

    Additionally, you can set a default value for the type of collation used for the databases in your instance. Under Default collation, in the dropdown menu, you can specify a default value for sorting data and related operations. This value determines the default sorting rules, case, and accent sensitivity for databases of this instance, which can save effort later. This collation default is permanent at the instance level but not at the database level. You can change this default with a database administration tool, but only for a specific database that you are creating or updating. You cannot change the collation default for an instance after creating the instance (unless you recreate the instance). For information about collations in SQL Server, see Collation and Unicode support.
    Maintenance schedule
    Maintenance window Determines a one-hour window when Cloud SQL can perform disruptive maintenance on your instance. If you do not set the window, then disruptive maintenance can be done at any time. Learn more.
    Maintenance timing Your preferred timing for instance updates, relative to other instances in the same project. Learn more.
  8. Click Create.
  9. After the instance finishes initializing, click the instance name to open it.

gcloud

For information about installing and getting started with the gcloud command-line tool, see Installing Cloud SDK. For information about starting Cloud Shell, see the Cloud Shell documentation.

You must use gcloud version 243.0.0 or later.

  1. Create the instance:
    gcloud beta sql instances create [INSTANCE_NAME] \
    --database-version=SQLSERVER_2017_STANDARD \
    --cpu=[NUMBER_CPUS] \
    --memory=[MEMORY_SIZE] \
    --root-password=[INSERT-PASSWORD-HERE]
    

    Do not include sensitive or personally identifiable information in your instance name; it is externally visible.
    You do not need to include the project ID in the instance name. This is done automatically where appropriate (for example, in the log files).

    As noted earlier on this page, the values for vCPUs and memory size are limited. See Choosing values for vCPUs and memory size.

    For example, the following string creates an instance with two vCPUs and 7,680 MB of memory:

    gcloud sql instances create myinstance \
    --database-version=SQLSERVER_2017_STANDARD \
    --cpu=2 \
    --memory=7680MB \
    --root-password=[INSERT-PASSWORD-HERE]
    

    For some sample values, see Sample machine types.

    You can add more parameters for other instance settings:

    Setting Parameter Notes
    Required parameters
    Database version --database-version SQLSERVER_2017_STANDARD, SQLSERVER_2017_ENTERPRISE, SQLSERVER_2017_EXPRESS, or SQLSERVER_2017_WEB
    Region --region See valid values.
    Authentication
    Active Directory domain --active-directory-domain Specifies a Managed Microsoft AD domain that previously was added in your project. For more information, see Overview of Managed Microsoft AD in Cloud SQL.
    Connectivity
    Private IP --network Specifies the name of the VPC network you want to use for this instance. Private services access must already be configured for the network. Available only for the beta command (gcloud beta sql instances create). Learn more.
    Public IP --authorized-networks For public IP connections, only connections from authorized networks can connect to your instance. Learn more.
    Machine type and storage
    Storage type --storage-type Indicates that your instance uses SSD storage (all SQL Server instances use SSD storage). Learn more.
    Storage capacity --storage-size The amount of storage provisioned for the instance, in GB. Learn more.
    Automatic storage increase --storage-auto-increase Determines whether Cloud SQL automatically provides more storage for your instance when free space runs low. Learn more.
    Automatic storage increase limit --storage-auto-increase-limit Determines how large Cloud SQL can automatically grow storage. Available only for the beta command (gcloud beta sql instances create). Learn more.
    Automatic backups and high availability
    High availability --availability-type For a highly-available instance, set to REGIONAL. Learn more.
    Automatic backups --backup-start-time The window of time when you would like backups to start. Learn more.
    Retention settings for automated backups --retained-backups-count The number of automated backups to retain. Learn more.
    Add database flags
    Database flags --database-flags You can use database flags to control settings and parameters for your instance. Learn more about database flags. Learn more about how to format this parameter.
    Add a default collation
    Default collation --collation You can set a default value for the type of collation used for the databases in your instance. For example, you could specify the following value for this parameter:
    SQL_Latin1_General_CP1_CI_AS

    This collation default is permanent at the instance level but not at the database level. You can change this default with a database administration tool, but only for a specific database that you are creating or updating. You cannot change the collation default for an instance after creating the instance (unless you recreate the instance). For information about collations in SQL Server, see Collation and Unicode support.
    Set maintenance schedule
    Maintenance window --maintenance-window-day,
    --maintenance-window-hour
    Determines a one-hour window when Cloud SQL can perform disruptive maintenance on your instance. If you do not set the window, then disruptive maintenance can be done at any time. Learn more.
    Maintenance timing --maintenance-release-channel Your preferred timing for instance updates, relative to other instances in the same project. Use preview for earlier updates, and production for later updates. Learn more.
  2. Note the automatically-assigned IP address.

    If you are not using the Cloud SQL Auth proxy, you will use this address as the host address that your applications or tools use to connect to the instance.

  3. Set the password for the user:
    gcloud sql users set-password sqlserver no-host --instance=[INSTANCE_NAME] \
           --password=[PASSWORD]
    

REST v1beta4

1. Create the instance

For a complete list of parameters for this call, see the Instances:insert page. For information about instance settings, including valid values for region and machine type, see Instance settings.

Do not include sensitive or personally identifiable information in instance-id; the value is externally visible.
You do not need to include the project ID in the instance name. This is done automatically where appropriate (for example, in the log files).

The collation parameter (not shown in the basic API call below) enables you to set a default value for the type of collation used for the databases in your instance. This collation default is permanent at the instance level but not at the database level. You can change this default with a database administration tool, but only for a specific database that you are creating or updating. You cannot change the collation default for an instance after creating the instance (unless you recreate the instance). For information about collations in SQL Server, see Collation and Unicode support. For a prototype of a JSON body, see Settings. Here is an example string you could specify for the collation parameter: SQL_Latin1_General_CP1_CI_AS.

To create an instance that is integrated with Managed Microsoft AD, specify a domain, such as subdomain.mydomain.com, for the domain field. For more information, see Creating an instance with Windows Authentication.

Before using any of the request data below, make the following replacements:

  • project-id: Your project ID
  • instance-id: The desired instance ID
  • region: The desired region
  • database-version: Enum string of the database version. For example: SQLSERVER_2017_STANDARD
  • password: The password for the root user
  • machine-type: Enum string of the machine (tier) type, as: db-custom-[CPUS]-[MEMORY_MBS]

HTTP method and URL:

POST https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances

Request JSON body:

{
  "name": "instance-id",
  "region": "region",
  "databaseVersion": "database-version",
  "rootPassword": "password",
  "settings": {
    "tier": "machine-type",
    "backupConfiguration": {
      "enabled": true
    }
  }
}

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "kind": "sql#operation",
  "targetLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id",
  "status": "PENDING",
  "user": "user@example.com",
  "insertTime": "2020-01-01T19:13:21.834Z",
  "operationType": "CREATE",
  "name": "operation-id",
  "targetId": "instance-id",
  "selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/operations/operation-id",
  "targetProject": "project-id"
}

After the instance is created, you can further configure the default user account.

2. Retrieve the IPv4 address of the instance

Optionally, you can retrieve the automatically-assigned IPv4 address. In the response, that address is in the ipAddress field.

Before using any of the request data below, make the following replacements:

  • project-id: Your project ID
  • instance-id: You instance ID, created in the previous step

HTTP method and URL:

GET https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "kind": "sql#instance",
  "state": "RUNNABLE",
  "databaseVersion": "database-version",
  "settings": {
    "authorizedGaeApplications": [],
    "tier": "machine-type",
    "kind": "sql#settings",
    "pricingPlan": "PER_USE",
    "replicationType": "SYNCHRONOUS",
    "activationPolicy": "ALWAYS",
    "ipConfiguration": {
      "authorizedNetworks": [],
      "ipv4Enabled": true
    },
    "locationPreference": {
      "zone": "zone",
      "kind": "sql#locationPreference"
    },
    "dataDiskType": "PD_SSD",
    "backupConfiguration": {
      "startTime": "19:00",
      "kind": "sql#backupConfiguration",
      "enabled": true
    },
    "settingsVersion": "1",
    "dataDiskSizeGb": "10"
  },
  "etag": "--redacted--",
  "ipAddresses": [
    {
      "type": "PRIMARY",
      "ipAddress": "10.0.0.1"
    }
  ],
  "serverCaCert": {
    ...
  },
  "instanceType": "CLOUD_SQL_INSTANCE",
  "project": "project-id",
  "serviceAccountEmailAddress": "redacted@gcp-sa-cloud-sql.iam.gserviceaccount.com",
  "backendType": "backend-type",
  "selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id",
  "connectionName": "project-id:region:instance-id",
  "name": "instance-id",
  "region": "region",
  "gceZone": "zone"
}

Sample machine types

Flexible instance configurations let you select the amount of memory and CPUs that your instance needs. This flexibility lets you choose the appropriate VM shape for your workload. Machine type names use the format db-custom-CPU-RAM, where CPU is the number of CPUs in the machine, and RAM is the amount of memory in the machine.

When selecting the number of CPUs and amount of memory, there are some restrictions on the configuration you choose:

  • vCPUs must be either 1 or an even number between 2 and 96.
  • Memory must be:
    • 0.9 to 6.5 GB per vCPU
    • A multiple of 256 MB
    • At least 3.75 GB (3840 MB)

What's next