Firestore (Native Mode)
Connecting to Firestore (Native Mode) from a DevZero workspace.
If you're more of a visual learner, check out the video tutorial!
Architecture Diagram

Prerequisites
- Follow the Connecting to GCP guide.
Existing Database
Step 1: Accessing GCP Firestore Instance from a DevBox
- Connect to your DevZero workspace.
- Store the Google Authentication Credentials on the workspace.
- Install Python and PIP:
sudo apt update
sudo apt install python3 python3-dev python3-venv
sudo apt-get install wget
wget https://bootstrap.pypa.io/get-pip.py- Install Firestore Admin API:
pip install --upgrade firebase-admin- Set the GOOGLE_APPLICATION_CREDENTIALS environment variable.
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/the/key.json- Write a Python scipt to test the Firestore Admin API Connection:
import firebase_admin
from firebase_admin import credentials, firestore
db = firestore.Client(project='content-gen-418510', database='devzero-test')
if db:
print('connected')
else:
pass- Run the Python Script:
python3 <file-name>.pyIf the connection is successful, you should see "Connected" printed in the terminal output.

New Database
Step 1: Creating an Firestore Instance
- Go to Firestore > Databases and click on Create database.
- Choose the Native Mode and click on Continue.
- Enter your Database ID and select the between Region and Multi-region mode.
- Choose your desired region and click on Create Database.

Step 2: Accessing Firestore Database from DevBox
- Connect to your DevZero workspace.
- Store the Google Authentication Credentials on the workspace.
- Install Python and PIP:
sudo apt update
sudo apt install python3 python3-dev python3-venv
sudo apt-get install wget
wget https://bootstrap.pypa.io/get-pip.py- Install Firestore Admin API:
pip install --upgrade firebase-admin- Set the GOOGLE_APPLICATION_CREDENTIALS environment variable.
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/the/key.json- Write a Python scipt to test the Firestore Admin API Connection:
import firebase_admin
from firebase_admin import credentials, firestore
db = firestore.Client(project='content-gen-418510', database='devzero-test')
if db:
print('connected')
else:
pass- Run the Python Script:
python3 <file-name>.pyIf the connection is successful, you should see "Connected" printed in the terminal output.
