I have a simple Cloud Run application written in Java that accesses a Cloud SQL MySQL database. I am using the Spring Google Cloud Platform utilities (spring-cloud-gcp-starter-sql-mysql) to interact with the database. When I deploy the app to Cloud Run, it runs great, having no problems when it queries the MySQL database.
I am using Visual Studio (VS) Code as my integrated development environment (IDE). VS Code includes a utility called Cloud Run Emulator that allows you to run your Cloud Run application locally in VS Code. When I run the application, I get this error: "The Google Cloud SQL Admin API is not enabled for the project "card-builder". Please use the Google Developers Console to enable it: <URL to the Cloud SQL Admin API>” Seems simple enough, only the API is already enabled, and has been for days now.
Further down the list of errors I see, “Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.” I tried to provide a credential for the Compute Engine default service account. I generated a key for the account in JSON format and then set the “spring.cloud.gcp.credentials.location” parameter. When I do that, the service does not even deploy, failing with the error, “Deploy Failed. Could not connect to cluster due to "https://127.0.0.1:51949/version?timeout=32s": net/http: TLS handshake timeout. Check if minikube is running using "minikube status -p cloud-run-dev-internal" command and try again.”
At any rate, I am not sure where to go next. Any insights are appreciated. Thanks.
Hi @WashDCGlenn,
Welcome to Google Cloud Community!
It sounds like you're running into a couple of different issues when trying to run your Cloud Run application locally in VS Code using the Cloud Run Emulator.
Regarding the first error, "The Google Cloud SQL Admin API is not enabled for the project," it sounds like you've already confirmed that the API is enabled in the Google Developers Console. One possible solution could be to ensure that the correct project is selected in the Cloud Run Emulator settings in VS Code.
Regarding the second error, "Request is missing required authentication credential," it sounds like you're trying to provide credentials for the Compute Engine default service account. One possible solution could be to ensure that the JSON key file is placed in the correct location and that the path to the file is correctly specified in the "spring.cloud.gcp.credentials.
Regarding the third error, "Deploy Failed. Could not connect to cluster due to "https://127.0.0.1:51949/
It's difficult to know exactly what's causing the issues you're experiencing without more context, but the above suggestions might help you troubleshoot the problem.
Thanks