I've been using FireStore together with Cloud functions extensively and so far everything has been great.
As my Swift app nears production launch, I would like to build a separate dev environment. Based on the documentation I was able to:
- Create two separate projects
- Link these two projects to my 2 targets using the various GoogleService p-list
- I was also able to declare 2 service accounts for my Firebase Function environments and create two separate aliases.
It all seemed to work, except that my new Dev Cloud Function environment is not fully linked with my Dev FireStore DB but appears instead still linked to my initial FireStore DB instance - the cloud function is correctly triggered when I write something on it, but all the data retrieval function return empty (as if the .get() commands where targeting my "old" prod DB).
Could you let me know how I can "force" my Dev Cloud Functions environment to link with my Dev FireStore DB instance? I must have missed a step - for ex., I didn't re-initialize the CLI/ re-logged-in, etc. but only created a 2nd alias.
I am also getting this message: "Billing account not configured. External network is not accessible and quotas are severely limited. Configure billing account to remove these restrictions". It's weird as I am not using an external account (it's Firestore/ Cloud Functions/ FCM only).
Any documentation/ step-by-step guide you can point to would be super helpful!
Here is how I initialize my 2 apps:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
var serviceAccount = require("./adminKey.json");
var serviceAccountDev = require("./adminKey-dev.json");
var secondEnvironment = admin.initializeApp({
credential: admin.credential.cert(serviceAccountDev),
databaseURL: "https://<app name>-dev.firebaseio.com"
}, 'dev instance');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://<app name>.firebaseio.com"
});
var db = admin.firestore();
Thanks again, Francois