I'm currently using json-server repo to emulate my back-end db and server for a prototype. To use/start json-server, I need to execute npm run json:server.
I've deployed my project to firebase but can't find a way to access a cmd or run that command from my own git-bash.
Is there any way of doing so or firebase doesn't allow to run commands on their end?
If you want to run small Node.js snippets on Firebase, have a look at the integration between Firebase Hosting and Cloud Functions.
Also see the Firebase documentation on what can you host on Firebase? and the overview documentation for running micro-services on Firebase Hosting and Cloud Functions.
Related
Following the Firebase examples to create and deploy a function, I keep failing at the deploy phase.
The error, with --debug enabled, shows:
<<< [apiv2][body] POST
https://cloudfunctions.googleapis.com/v1/projects/actus-poc2/locations/us-central1/functions
{"error":{"code":403,"message":"Cloud Functions uses Artifact Registry
to store function docker images. Artifact Registry API is not enabled
in your project. To enable the API, visit
https://console.developers.google.com/apis/api/artifactregistry.googleapis.com/overview?project=...
Now I was expecting to be able to stay within the confines of the firebase console but this message seems to imply I need to open the Google Cloud Console to enable additional permissions.
Should the code samples better document this?
Or is this a recent change in firebase functions that breaks many of the existing examples?
I need to open the Google Cloud Console to enable additional permissions.
The reason why you need to use the Google Cloud Console is because Cloud Functions for Firebase relies on some Google Cloud services. See.
Function deployments with Firebase CLI 11.2.0 and higher rely on Cloud Build and Artifact Registry.
is this a recent change in firebase functions that breaks many of the existing examples?
Deployments to older versions also do rely on some Google Cloud services. Deployments to older versions use Cloud Build in the same way, but rely on Container Registry and Cloud Storage for storage instead of Artifact Registry.
Should the code samples better document this?
If you do think an update to said documentation could be helpful, here is more about opening Feature requests.
I am using gcloud + firebase cli to explore a reproducible way to create and configure a GCP + Firebase project.
I have created the GCP project using gcloud cli tool. I have then used firebase cli to run the command firebase init firestore.
Ulimately it ended up outputting...
Error: It looks like you haven't used Cloud Firestore in this project before. Go to https://console.firebase.google.com/project/my-project/firestore to create your Cloud Firestore database.
Is there a way I can "create my firestore database" using a cli tool or scripting api, instead of having to navigate to a web GUI tool and manually execute steps?
Unless Firebase do more behind the scenes, creating a Firestore instance could be as simple as this command from the GCloud CLI reference:
gcloud firestore databases create --region=us-central --project=my-project
The documentation for the entire create-provision cycle (from GCP's perspective) is here - including Terraform details (some commands may have been released since the docs were written).
I'm migrating a Firebase Function to Cloud Run. Everything is working as expected so far, including the Firebase Hosting link (which is great!). I'm just not sure how I should read the environment variables I've configured for this project (via https://firebase.google.com/docs/functions/config-env).
You'll have to find a different way to configure Cloud Run. You won't be able to access your environment variables set for Cloud Functions when deployed with the Firebase CLI. Those variables are only accessible for code running in Cloud Functions that uses the "firebase-functions" module.
Instead, you should set your Cloud Run environment with gcloud as documented here.
I'm trying to create a function to delete all users from the Database and write it on index.ts file and deploy it. Now, how can I run it?? I don't want my clients to run it from their mobile app, I need some admin tool to run the management functions. When I see cloud functions on Firebase console there's no option to run the functions, just to view their logs.
Cloud Functions isn't for running one-time scripts. You should do that on your local machine. Cloud Functions is for running code that responds to HTTP requests, or events that occur within other products in your project.
You may want to read this article: https://firebase.googleblog.com/2017/03/how-to-schedule-cron-jobs-with-cloud.html - it suggests using App Engine cron job for that purpose. Relevant project on github: https://github.com/FirebaseExtended/functions-cron
Also there's an example on similar topic in Firebase docs: https://github.com/firebase/functions-samples/tree/master/delete-unused-accounts-cron
I have 100ds of functions deployed to firebase and I would like to know if I can list the remote functions on my machine using the firebase command line tools.
I want to see the list of functions deployed.
What I am trying to solve is:
Batch deploy functions to avoid deployment limit.
Deployment error when function deleted/renamed locally and then deploying whole functions.
Thanks!
I got the exact answer from Google support.
Currently, Firebase CLI doesn’t have any command to list deployed functions, whereas “gcloud functions list” CLI from Cloud SDK shows the list instead.
More details found here
While it doesn't seem to be documented here, you can list all deployed Cloud Functions when you have firebase-tools installed with firebase functions:list. The command is also mentioned in firebase --help.
Verified with firebase-tools version 10.5.0
At the time of writing this answer, there is no CLI command that allows listing all the deployed functions for your project. The available commands can be found here: https://firebase.google.com/docs/cli/#commands
However, note that you can list the deployed functions in the Google Cloud console (not the Firebase one) by opening: https://console.cloud.google.com/functions/list?project=your_project_name