Whats difference between:
firebase functions:secrets:set
and:
firebase functions:config:set
?
Related
When I start the emulators, the Storage emulator starts and is available at localhost:9199.
Then I access storage with the admin SDK in node.js with:
serviceAccountKey = require('./serviceAccountKey.json');
const config = {
credential: admin.credential.cert(serviceAccountKey),
};
const adminApp = admin.initializeApp(config);
const storage = adminApp.storage();
Now storage points to the emulator, not the real service as before this emulator has been implemented.
How can I get access to the real service?
I have tried setting projectId and the env variable as described here, but it does not work.
OK, so the way is simply to start all services but storage from the command line, and not from firebase.json, this way:
firebase emulators:start --only hosting,functions,firestore,auth,ui
Running firebase emulators:start will start all services in an emulated state. If you want to talk to a production service, you can run firebase serve, or if you want some services emulated but not storage, you can run firebase serve --only {services,to,emulate} (eg, firebase serve --only functions,hosting. This would emulate functions and hosting, but any call to storage (or auth or other non-emulated services) would talk to the live Firebase environment.
Why can't anything be easy? I am trying to add push notifications from Firebase Cloud Messaging. When I run firebase init I get the following:
How do I get this to work? I have tried all the solutions I have read here but none of them have worked.
The CLI is recognizing your project, but the initialization is failing due to an error with Cloud Storage for Firebase.
Try going to the Storage section within your Firebase Console (here) and initialize Cloud Storage for Firebase first.
After you've chosen a location for your bucket try running your command again.
I am the owner of the firebase project from which I am trying to fetch the data, e.g., firebase database:get /orders. However, the request always returns null. I tried to set up different roles https://console.cloud.google.com/iam-admin/iam?project=[myproject] with no luck. I have only one firebase project and it is selected as I can see in firebase list. I can deploy functions and app from the Firebase CLI.
You should check that your /orders path exists in Realtime Database and not Firestore. The command firebase database:get is for interacting with Firebase Realtime Database only and not Firestore.
I'm trying deploy my firebase app. But when I try run 'firebase deploy', I got:
Is any way to deploy the app automatically ( without human login to dashboard) ? I care only to send on firebase security rules.
You can use firebase login:ci to work with continuous integration systems.
The command firebase login:ci will create a token, then you can use this token for deploying with:
firebase deploy --token
See the Github repo section on CI Systems for more information.
I'm having trouble deploying travis CI with firebase using these firebase commands:
firebase deploy --email ${FIREBASE_USERNAME} --password ${FIREBASE_PASSWORD}
firebase deploy --token ${FIREBASE_TOKEN}
It does not like --email option and it does seem that it takes --token but does not work with my firebase auth token I can get from my firebase app. What am I doing wrong?
The email option was removed in the 2.0 release of the CLI.
Use firebase login:ci to generate a token.
On a machine with a browser, install the Firebase CLI.
Run firebase
login:ci to log in and print out a new access token (the current CLI
session will not be affected).
Store the output token in a secure but accessible way in your CI system.
Another firebase deployment option in travis-ci is to use dpl (https://github.com/travis-ci/dpl) which is a deployment provider
OPTIONS
token: Your Firebase CI Access Token (generated from firebase login:ci)
project: Deloy to a different Firebase Project than specified in firebase.json
public: Specifies which directory to upload to Firebase Hosting.
ignore: Specifies the files to ignore on deploy. (similar to .gitignore)
EXAMPLE
dpl --provider=firebase --token=<token> --project=<project>
What is really cool about using this deployment provider utility is that you can deploy to one or more firebase hosted applications from a single project commit...
after_script:
- dpl --provider=firebase --token=${FIREBASE_TOKEN} --project=${PROJECT_ONE}
- dpl --provider=firebase --token=${FIREBASE_TOKEN} --project=${PROJECT_TWO}
References:
(firebase.json) https://www.firebase.com/docs/hosting/guide/full-config.html
(dpl --provider=firebase) https://github.com/travis-ci/dpl#firebase
Note: One thing you will need to consider is how you set FIREBASE_URL as a constant in each hosted application if they need to use the same code base but a separate Firebase for storing data.