I have a firebase project with multiple functions deployed. Is it possible to remove all the functions in a single go through the CLI?
I tried the command firebase functions:delete --region us-central1
and the error output was Error: Must supply at least function or group name.
As of right now, I deleted all of them specifying each of their names as such:
firebase functions:delete function1 function2 ...functionN but this is very cumbersome.
The version of firebase-tools installed is v4.0.0
Sign in to your Google Cloud Console at https://console.cloud.google.com, select your project, then from the list on the left pick Cloud Functions. When you get the list of functions, click the check box on the header line to select all, then the Delete button in the tool bar.
Update for comment:
I don't know what the product strategy for Firebase Console is with regard to Cloud Functions. My guess is that it is intended to provide a simplified, more convenient interface for managing Firebase related cloud functions. The Google Cloud Console provides a richer set of capabilities for managing functions and viewing logs. You could submit a feature request to Firebase to get those capabilities added to the Firebase console. Some details on the Firebase/Google Cloud relationship are provided at these links:
https://stackoverflow.com/a/42859932/4815718
https://cloud.google.com/functions/docs/concepts/functions-and-firebase
Just comment (or delete) all the functions in your index.js file and redeploy it through the CLI.
Adding other deletion options. For more information, checkout Firebase official documentation.
Now you can simply delete a function from the function dashboard as follows. Click on the three dots mark of relevant function in the right side corner.
Related
I use following firebase cli command to deploy my firebase functions
firebase deploy --only functions
How can I limit the number of instances for functions, when deployed like this? It looks like gcloud command has --max-instances option to limit instances, but couldn't find anything like this for firebase cli.
You can set the maxInstances when you write the function, using runWith and passing in RuntimeOptions
Something like this:
functions
.runWith({maxInstances: 3})
.https.onCall(() => {});
There is currently no option on the Firebase CLI for this. Feel free to file a feature request with Firebase support. If such an option is added, it likely won't end up in the CLI, but rather the function builder interface, similar to how region and memory are set.
For now, you can use the Google Cloud console by finding your deployed function there and editing to to use the value you want.
I'm using simply console.log('some flag', someObject) on Google Cloud and functions.logger.log('some flag', someObject) on firebase functions.
The problem is that both Firebase's admin panel logs page and Google Cloud's logs page makes this hard to read. Logs are getting split into lines. If my log had line breaks, then each line will be displayed as a separate log. Moreover, Google Clodu clearly has some kind of racing conditions when it comes to recording logs, as my logs are often displayed in the wrong order.
An obvious solution would be console.log('some flag', JSON.stringify(someObject)), but this makes logs hard to read in a different way. Now I have to copy the stringified object and JSON.parse it somewhere in browser console to make it readable.
What is the right way of writing logs in Firebase and Google Cloud?
The Cloud Functions logger SDK provides a standard interface that has a similar api to console.log statements and supports other log levels. You can use this SDK to log events with structured data, enabling easier analysis and monitoring.
The logger SDK supports log entries as part of a wildcard import. For example:
const functions = require("firebase-functions");
functions.logger.log("Hello from info. Here's an object:", someObj);
For Firebase Cloud Functions is better to use functions:logger to write logs and for reading logs use the command
firebase functions:log from CLI
I've got 2 different firestore interfaces: both using the same firestore project.
I'm finding this abit confusing - which one am I meant to operate in?
How come the 2nd doesn't have access to other settings such as Rules?
They are both meant for you to operate in. Which one you use depends on whatever your preference is. If you prefer to stay in the Firebase ecosystem, then use the Firebase console. If you prefer to stay in the Google Cloud ecosystem, then use the Cloud console.
Read more about the differences with Cloud Firestore between Firebase and Google Cloud.
Cloud Firestore is available with, or without Firebase SDKs.
For Firebase users, the Firebase interface allows you to configure Firebase specific functionality (Rules).
For GCP users, the Google Cloud interface keeps you closer to other services and admin settings you'll likely be using, such as IAM, BigQuery, etc. It also gives you quick access to a shell (Just click the Cloud Shell icon) so you can quickly run commands like gcloud firestore export.
Both interfaces will show you the same data.
Work in the first one. The second one is a simplified screen I think, because it is also for other services
We are using a firebase platform for our recent projects. We recently launched and have been monitoring the usage.
I can see total number of firebase invocation in the firebase console but could not find the way of seeing the number of invocation for each function..
Could you please advice if there is any way of seeing these number?
We wanted to find the most used firebase functions.
We can expect which firebase functions would be mostly used, but wanted to know the exact number called.
The Firebase console doesn't offer a breakdown of invocations per function, but the Cloud console does. And since each Firebase project is also a project on the Cloud platform, you can just switch over to console.cloud.google.com to get the more detailed information.
Since the Cloud console is a bit trickier to navigate, here are the steps:
Go to console.cloud.google.com.
Sign in if needed.
Select your project from the dropdown at the top.
In the search box (🔍) next to the project name, type and select Cloud Functions.
You'll now see a list of the functions in your project.
Click on the name of the function you want to see the invocations of.
You'll now see a chart of the invocations.
From one of my projects:
In times when Parse.com was on they had a function that called a cloud function directly and returned whatever I wanted. So I could have all the server logic on the server, not in client code. Doe's Firebase has it as well? I can't find it - all I found are HTTP triggers, but it implies that it's not available through Javascript SDK. Am I missing something or do I have to use REST interface for that?
To run server-side code that is triggered by events in Firebase, you'd use Cloud Functions for Firebase. Currently these can trigger code through the Firebase Database updates, Authentication, Analytics, Cloud Storage and HTTP. The documentation I linked has all the details.
As Frank van Puffelen has explained you could use Functions, I'll like to add a couple of things.
You could also use the Firebase Database Admin SDK for the Database, this requires you have a server
Firebase Functions is a sort of big brother, constantly listening for whatever you want. Currently starting and deploying functions is fairly easy and fast, I love this how to video. Basically, you have to install the CLI and then using commands, create a project, write your js for Functions and for deploying those changes to Firebase Functions use the CLI again
Functions can listen more than what the Admin SDK can, the Admin SDK is for the Database while Functions is for, authentification, database, and cloud messaging. This means any user registration or deletion or any change in a node, can trigger further logic. This logic could include sending push notifications. There is a github repo where you can see a lot of examples, I made myself a small repo for the same purpose