Issues while setting up objectify with The Datastore - google-compute-engine

I have an application which uses objectify which i want to deploy in a Google Compute engine to access google datastore. I have been able to test this application in local development server using Objectify. I am also able to access the cloud datastore from the compute engine by following the documentation in https://cloud.google.com/datastore/docs/getstarted/start_java/.
But when I deploy my application in the google compute engine I am not able to communicate with the google cloud datastore and am getting the following exception:
No API environment is registered for this thread.
I should be missing something. Kindly help me out.

As far as I can tell, Objectify currently only works with Datastore if you are running in Google App Engine (GAE), not for Datastore Access via Google Compute Engine (GCE). There is an open issue https://github.com/objectify/objectify/issues/203
The reason it does not work on Google Compute Engine is apparently because the API for Datastore access in GCE is apparently different from the one used for GAE.

Related

Google App Script (not) using GCP Classic VPN route?

This reads like a duplicate of other GAS+VPN/SDC questions but none of the existing questions refer explicitly to using a GCP Hybrid (Classic) VPN to provide App Script access to on-premise resources.
I have the GCP VPN setup and working (verified pinging both ways via VM) and I have associated the App Script project with the GCP resource but the App Script cannot URLFetch from anywhere over the VPN. Is this a known limitation of App Script or can someone point me in the right direction please?
edit 1: I have also tried to setup a Serverless VPC Connector but as App Script has no VM instance, I couldn't complete the Connector setup. Giving network.user access to the App Script's GCP service accounts didn't achieve anything.
edit 2:
#eric-wong wrote the following in an answer to a smiliar question 2 years ago:
The documentation made it quite clear, that since App Scripts are ran on shared App Engine instances, it is impossible to restrict with IP, and that also implies the networking capability would be very limited (i.e. no VPC peering or alike)
I cannot understand why Google would provide the ability to link an App Script to a GCP project but then not provide a mechanism to utilise the GCP's network.
I originally asked this question on ServerFault as I thought I had a GCP config issue but now I'm feeling like it's more like a GAS issue.
Thanks for all help!

Cannot access Google Cloud SQL database from my App Engine

Last week I tried to setup Google Cloud for a NodeJS API and Cloud SQL database. Overall it works fine, but I can't access my Cloud SQL database. The authorization of the SQL database shows that all apps within the current project are granted to access the database. Unfortunality, this is not true. I need to granted the IP addresses of the instances from the App Engine. The IP adressess of the instances constantly changes after I deploy a newer version of the the API.
Does anybody have a solution to get access from the App Engine to the Cloud SQL database. It's very annoying to add constant the instance ip address to grant the database.
Sample here
Thank you in advance!
Jelle
I was going to suggest to assign a static IP to the app engine, but seems like it's not possible in App engine (it's possible in compute engine though). So lets tackle the root of the problem, you being unable to access cloud sql from App engine, are you sure you followed the instructions of the following link to the letter?
https://cloud.google.com/nodejs/getting-started/using-cloud-sql
This might solve your connection issue if you haven't.

Google App Engine API - Failed to Load Databases - Cloud SQL

I have a Google App Engine PHP website with MySQL database.
The website works and the database works correctly. I have connected the database instance to the application and I can access MySQL Client (and can perform queries).
But when I access the Google Cloud SQL API via the Google App Engine Developers Console (on the google developer console website) the database fails to load.
For example:
I select the correct application/database instance. I go on 'Google Cloud SQL' API and then 'SQL Prompts' but get:
Failed to load databases.
Any reasons as to why this is happening? and how to load the database? or why won't the database load in the first place?
Are you trying to access the link [1] to load your database in your browser.If yes then might be its a browser issue or multiple login problem.
[1] https://console.developers.google.com/project/app-id/sql/instances

How to connect to google cloud sql instance from eclipse using App Engine?

I am trying to connect to google cloud sql instance from eclipse in my app engine connected android project.
So far i am able to connect to cloud sql instance using Class.forname("com.mysql.jdbc.Driver"). But it requires authorising my ip address in google cloud sql every time i want to use the instance hence making it unfeasible.
I know that while connecting from app engine i dont need to authorize my ip address. Bur for that i have to use GoogleDriver ie. Class.forname("com.mysql.jdbc.GoogleDriver").
But when i run my code it gives me ClassNotFoundException.
I am stuck at this situation for a long time. Please give me a proper solution to the problem
The GoogleDriver is only intended to be used when actually running on App Engine. When running from eclipse or the dev_appserver you will have to use the stock com.mysql.jdbc.Driver class, and you will have to authorize your IP address. A good example of this is shown in the documentation, which demonstrates how to choose in code which driver to use. Note the commented out line for connecting from your dev environment to Cloud SQL.
As an FYI don't forget to enable the connector for running on App Engine.
I have authorised 0.0.0.0/0 in access control in my cloud instance and now all the devices are able to connect to the cloud instance with stock mysql driver ie. com.mysql.jdbc.Driver without need to changing authorised network again and again in access control.
Still can't figure out to implement GoogleDriver but for now this solution will work.
If anyone find a more better and general way to connect to cloud instance please post your answer.

App Engine and MySQL

I just wanted to ask if we can access an external MySQL server from Google App Engine...
The only way to communicate with other hosts is by using UrlFetch that only provides HTTP and HTTPS requests.
So, you can't do it out of the box.
Anyway, if you really need to access an external MySQL server database, you should consider to expose it through a Web API (RESTful, Soap web-services for example).
In this way your data would be available also via UrlFetch.
I am still in the learning phase of all this, but I am fairly certain you can do this now a few ways:
Link Apps Scripts to App Engine and use the JDBC
Link it to Google
Cloud SQL Store your SQL database on Google Cloud Store
Connect Apps Scripts via spreadsheet scripting
"Google Apps Script has the ability to make connections to databases via JDBC with the Jdbc Service. The current support extends to MySQL, Microsoft SQL Server and Oracle. Apps Script makes it easy to connect to databases hosted on Google Cloud SQL, but also works with other cloud hosting platforms and even local databases." https://developers.google.com/apps-script/jdbc
(edited for structure)
It is still not possible to native connect GAE to an external MySQL server the only exception is Googles Cloud SQL. We are using it in our production environment and like the experience. Stable and the performance is good.
GAEs own database scales well and we are using it in most situations, but in cases where we need to ask more complex questions or need aggregate functions, we use Googles Cloud SQl.
These answers are a bit outdated. Google App Engine instances can connect to external database servers.
The ability to connect externally requires that the account the App Engine is running under be a "paid account" a/k/a "billing enabled".
References:
-https://cloud.google.com/appengine/docs/php/using-third-party-databases
-https://cloud.google.com/appengine/docs/php/runtime#PHP_Functions_that_requires_billing_enabled