Obtaining a Spanner Instance ID
-
In a web browser, log into the Google Cloud console at https://console.cloud.google.com.
-
In the dashboard navigation menu, click Spanner.
-
Once the Spanner page is displayed, click the Spanner instance and take note of the Instance ID (you will use this to configure the Spanner plugin in Server Workbench).
Obtaining a Google Project ID
-
While in the Google Cloud console, click the project selector at the right side of the Google Cloud Platform interface.
-
Once the project selector is displayed, take note of the currently-selected project ID (you will use this to configure the Spanner plugin in Server Workbench).
Download and Install the Google Cloud SDK
-
In a browser, navigate to the Google Cloud SDK download page at https://cloud.google.com/sdk/downloads .
-
Locate the download link for Windows 64-bit (x86_64). The Spanner plugin was developed and tested using the SDK that can be download here: https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk182.0.0-windows-x86_64.zip.
-
Once downloaded, install the Google Cloud SDK. Follow the steps provided as the installation progresses.
Configure the Google Application Default Credentials
-
Log in to https://console.cloud.google.com.
-
Go to the API Console Credentials page by navigating to APIs & services > Credentials.
-
From the project drop-down, select your project.
-
On the Credentials page, select the Create credentials drop-down, then select Service account key.
-
From the Service account drop-down, select App engine app default service account.
-
At Key type, select the JSON key option, then select Create. The file will automatically be downloaded to your computer.
-
Place the *.json file you have just downloaded within your preferred directory location. The directory must be secured, but accessible to your web server code.
-
Set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the path of the downloaded JSON file.
Creating the Environment variable for your Google Credentials
-
Navigate to Windows Control Panel > System > Advanced System Settings > Advanced Tab > Environment Variables.
-
In System Variables, add a new variable using the following details:
-
Name:
GOOGLE_APPLICATION_CREDENTIALS -
Variable value:
C:\[PATH TO PRIVATE KEY FILE]\gcp-xxxxxxx-privatekey.json
Note: the variable value must be set according to the actual directory location of the private key file.
-
-
Having completed the above, use the following connection string format when provisioning a new client utilizing Spanner in Server Workbench:
-
Instance ID:
<GOOGLE_PROJECT_ID>/<GOOGLE_SPANNER_INSTANCEID> -
Database ID: The Spanner Database to be accessed
-
Schema: The schema of the Spanner database
-