This sample application demonstrates how to store data in Google Cloud SQL with a SQL Server database when running in Google App Engine Flexible Environment.
-
Follow the set-up instructions in the documentation.
-
Enable APIs for your project. Click here to visit Cloud Platform Console and enable the Google Cloud SQL API.
-
Install the Google Cloud SDK. The Google Cloud SDK is required to deploy .NET applications to App Engine.
-
Install the .NET Core SDK, version 2.0 or newer.
-
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.
-
-
Edit appsettings.json. Update the connection string with the "User name" and "Password" you previously created on the Cloud SQL instance.
-
Download the Google Cloud SQL Proxy by following the instructions in the Installing the Cloud SQL Proxy section of the page for installing the Cloud SQL Proxy for MySQL, which are the same for SQL Server.
-
Run the Google Cloud SQL Proxy in Powershell using TCP (replace "myProject" and "myInstance" with the values for your project and instance):
./cloud_sql_proxy -instances=myProject:us-central1:myInstance=tcp:1433 sqlserver -u sqlserver --host 127.0.0.1
-
Edit appsettings.json. Replace
cloudsqlwith127.0.0.1in the connection string. -
With the Cloud SQL Proxy running, open another Powershell window and run the sample app:
PS > dotnet restore PS > dotnet run
-
Edit app.yaml. Replace
your-project-id:us-central1:instance-namewith your instance connection name, and leave the tcp port number set to1433for a SQL Server instance. -
Run in powershell:
PS > dotnet restore PS > dotnet publish PS > gcloud beta app deploy .\bin\Debug\netcoreapp2.1\publish\app.yaml
Google Cloud Tools for Visual Studio make it easy to deploy to App Engine. Install them if you are running Visual Studio.
-
Download and run the Google Cloud SQL Proxy.
-
Edit appsettings.json. Replace
cloudsqlwith127.0.0.1in the connection string. -
Open CloudSql.csproj, and Press F5.
-
Edit app.yaml. Replace
your-project-id:us-central1:instance-namewith your instance connection name. -
In Solution Explorer, right-click the CloudSql project and choose Publish CloudSql to Google Cloud.
-
Click App Engine Flex.
-
Click Publish.

