-
If you haven't already, set up a Node.js Development Environment by following the Node.js setup guide and create a project.
-
Under the instance's "USERS" tab, create a new user. Note the "User name" and "Password".
-
Create a new database in your Google Cloud SQL instance.
-
List your database instances in Cloud Cloud Console.
-
Click your Instance Id to see Instance details.
-
Click DATABASES.
-
Click Create database.
-
For Database name, enter
votes. -
Click CREATE.
-
-
Create a service account with the 'Cloud SQL Client' permissions by following these instructions. Download a JSON key to use to authenticate your connection.
Use the information noted in the previous steps to set the following environment variables:
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account/key.json
export DB_USER='my-db-user'
export DB_PASS='my-db-pass'
export DB_NAME='my_db'Note: Saving credentials in environment variables is convenient, but not secure - consider a more secure solution such as Secret Manager to help keep secrets safe.
Download and install the cloud_sql_proxy by
following the instructions here.
Then, use the following command to start the proxy in the background using TCP:
./cloud_sql_proxy -instances=${CLOUD_SQL_CONNECTION_NAME}=tcp:1433 sqlserver -u ${DB_USER} --host 127.0.0.1Next, setup install the requirements with npm:
npm installFinally, start the application:
npm startNavigate towards http://127.0.0.1:8080 to verify your application is running correctly.
App Engine Flexible supports connecting to your SQL Server instance through TCP
First, update app.yaml with the correct values to pass the environment
variables and instance name into the runtime.
Then, make sure that the service account service-{PROJECT_NUMBER}>@gae-api-prod.google.com.iam.gserviceaccount.com has the IAM role Cloud SQL Client.
The following command will deploy the application to your Google Cloud project:
gcloud beta app deploy