Is an App Engine instance required for accessing Datastore? - google-app-engine

Do I need to deploy an App (even a dummy one) on the App Engine in order to use the Datastore service using the google-cloud-datastore Java API from a client such as a Compute Engine running in the google cloud?

No, you don't need to deploy an AppEngine app to access the Google Cloud Datastore. You just need to create a project from the Console and you can connect to the Datastore in the project from anywhere using the google-cloud-datasource API.

Related

Is it possible to implement create a web project in Spring Boot + Datastore?

I'm currently new to web developing and right now I started with a Spring Boot application which I converted to standard App Engine project. I'm wondering if it is possible to not convert my Spring Boot application to my App Engine project and still use Datastore as database?
Yes, it's possible to use the Cloud Datastore from an app in the GAE flexible environment, from outside GAE or even from outside the Google Cloud. From Cloud Datastore (emphasis mine):
You can access Cloud Datastore from anywhere using the Cloud
Datastore API. Use the Google Cloud client libraries to store and
retrieve data from Cloud Datastore.
The same Cloud Datastore data is available regardless of if you use
the App Engine libraries, the Google Cloud client libraries, or call
the API directly.
But you can't use the GAE Standard Environment Client Libraries, you have to use either the Cloud Datastore Client Libraries or the Cloud Datastore API v1.
Potentially of interest: the Deploying to the App Engine Flexible Environment guide happens to use a spring boot app as example.

I want to choose my own Server and own database in google app engine

I am very newly in google app engine.. There are three Questoins on google app engine and in google app engine i want to choose JAVA language.
Does google app engine provide private cloude ?
I want to deploy my application with my own server( E.x.glassfish or JBoss) on google app engine ?
I want to use my own database instead of cloud SQL in google app engine?
Is it possible or not?
With Google Cloud Appengine - no, it's impossible.
With Google Cloud Instances or Google Cloud Containers - all of this is possible.
Appengine is just one piece of Google Cloud, designed for very specific job, with infrastructure managed by Google. You can only write some code (with lot of restrictions too) that runs inside it. You can read some details about code restritions there: https://cloud.google.com/appengine/docs/java/#Java_The_sandbox
What you're looking for is Google Cloud Instances, that are more standard virtual machines, where you can run anything you want. See https://cloud.google.com/compute/
There is still tools for Load Balancing, Health Check, Centralized Logging for Cloud Instances, and other stuff similar to features provided by Appengine.

How do I access my AppEngine DataStore entities from my Compute Engine VM?

My app is running on App Engine, but I would like to access its NDB DataStore entities from my Compute Engine VM to do some processing and write the results back to the App Engine DataStore. How can I do that?
Also, are the Google Cloud DataStore and App Engine DataStore the same thing?
https://developers.google.com/datastore/
https://developers.google.com/appengine/docs/python/ndb/
David's solution requires you to use App Engine instance time to make requests, but you can bypass it and make requests directly to Datastore from Compute Engine instance. There is a pretty good tutorial about how to do this. But its not so pretty like ndb.
>>> import googledatastore as datastore
>>> datastore.set_options(dataset='project-id')
>>> req = datastore.BeginTransactionRequest()
>>> datastore.begin_transaction(req)
<datastore.datastore_v1_pb2.BeginTransactionResponse object at ...>
Google Cloud Datastore is kind of a standalone version of App Engine's datastore.
Back to your problem, you have two options :
Write a web-service to expose your entities from the App Engine app to the Compute Engine VMs. One option is Cloud Endpoints. Cloud Endpoints uses OAuth2 authentication and the Compute Engine VMs are shipped with OAuth2 service accounts that you can use to authenticate to the service.
Use the App Engine remote API to access the Datastore. The remote API provides access to the Datastore as if you were in an App Engine instance. But by default the API requires you to provide the password of an App Engine amdin, so you might have to store your password in the Compute Engine VMs, which is not safe.
Aside from options that #David explained, you can also look into Managed VMs: they are a cross between Compute Engine and App Engine - basically a managed Compute Engine instance that has access to App Engine services.
The officially recommended way is to use the datastore client libraries; see https://cloud.google.com/datastore/docs/reference/libraries
You need to create a service account, or use the standard compute engine service account, give permission to either all APIs, or to datastore to that service account, and create the compute engine instance to be part of that service account. See here for more information.
Then you can do something like:
from google.auth import compute_engine
from google.cloud import datastore
datastore_client = datastore.Client(project='yourproject',
credentials=compute_engine.Credentials())
q = datastore_client.query(kind='YourEntity')
q.add_filter('field_name', '=', 'HelloThere')
print list(q.fetch(1))

Using Google App Engine services outside of uploaded application

I am looking to use Google Cloud Storage services outside of launching a google app engine application. My application is designed for running on a hosted server of our own, and I would like to still use the cloud storage service.
I've written a dev app that did this, and ran it with dev_appserver.py in the python GAE framework. It seems the dev_appserver.py is necessary as it fills in how to perform the RPC functions the cloud storage provides.
Is there a way to easily use google cloud storage service without the rest of it?
There is gsutil command line tool:
https://developers.google.com/storage/docs/gsutil
There is an xml/json restful service all at:
https://developers.google.com/storage/index
You'll need to enable the google cloud storage on the google console at:
https://code.google.com/apis/console/ and get the necessary api keys.

How to integrate Google App Engine to an existing web application?

I am new to Google App Engine, I have an existing web application and now I need to integrate that with Google App Engine for https://developers.google.com/appengine/docs/java/mail/receiving purpose, how to do that?
One way would be to write your appengine application with a RPC service
http://googleappengine.blogspot.com/2011/04/introducing-protorpc-for-writing-app.html

Resources