2

I am writing my first python 3.10 application in Visual Studio Code and aim to deploy that application to Cloud Run soon. I have a Cloud SQL database that stores my data for the application.

Before deploying I want to debug my application with the Cloud Code plugin for VSCode. The Cloud Code plugin has a convenient "Debug on Cloud Emulator" command that I can use for that purpose, but I am struggling to figure out how to add SQL connections in my Build Settings before running the Cloud Emulator.

Can somebody help me figure out the syntax for adding a Cloud SQL connection under the Advanced Service Settings?

enter image description here

Any examples / resources would be incredibly useful.

Thanks so much for your help up front!

Martin Reindl
  • 989
  • 2
  • 15
  • 33
  • Have you tried this format, `PROJECT-ID:REGION:INSTANCE-ID`? Also, see this article on the [connection options for Cloud SQL](https://cloud.google.com/sql/docs/mysql/connect-overview). You may need to setup a Cloud SQL Auth proxy to provide secure access to your Cloud SQL instance. – Mabel A. Mar 07 '22 at 08:03
  • Hi Mabel - that looks super reasonable. Currently can't verify this works, since I'm running into another issue (https://stackoverflow.com/questions/71389200/build-arm64-image-for-cloud-codes-debug-on-cloud-run-emulator-from-m1-mac), but will let you know as soon as I have that resolved. Do you want to submit this as a proper answer, so I can accept it later if correct? – Martin Reindl Mar 08 '22 at 01:58

1 Answers1

1

In the Cloud SQL - Overview screen, you can find the connection name of your instance in this format:

PROJECT-ID:REGION:INSTANCE-ID

Additionally, see this article on the connection options for Cloud SQL. You may also need to setup a Cloud SQL Auth proxy to provide secure access to your Cloud SQL instance.

Mabel A.
  • 1,775
  • 4
  • 14