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.
Related
I am getting this error :
Error: Your project myproject must be on the Blaze (pay-as-you-go) plan to complete this command. Required API cloudbuild.googleapis.com
can't be enabled until the upgrade is complete. To upgrade, visit the following URL:
https://console.firebase.google.com/project/fluttershare-d057e/usage/details
while using this command : firebase deploy --only functions
which means I have to purchase flutter functions to proceed. Now I want to know is there any alternative way to deploy function like onCreate() free or can we build these functions manually for firebase ? I am using flutter technology.
Based on #Brugui and #FrankvanPruffelen answers, you need the Blaze plan in order to use Cloud Functions, however, it doesn't necessarily mean you'll have to pay for Cloud Functions usage as there's a significant free tier.
Can I use firestore triggers without first deploying my functions? I am getting an error that looks like it but I want to be sure.
If you want a Firestore trigger to respond to a change in a document that's actually in Firestore (and not running in a local emulator), then yes, you will have to deploy the trigger. Cloud Functions only works when deployed to Google's cloud.
I'd like to implement a full text search an app that is using Cloud Firestore.
Integrating with Algolia sounds great, but it can't work on the free Spark plan since outbound networking is limited to Google services only.
Therefore, the obvious question:
(1) Is it possible to use firebase-functions to create a function that monitors Firestore changes and deploy it to something like Zeit's Lambda or AWS Lambda?
Somewhat related question:
(2) Is it possible to use onSnapshot instead of onCreate/onUpdate/etc. to monitor Firestore changes?
You can't deploy Cloud Functions code to other serverless function providers. You can certainly try to reuse your core logic, but each provider has its own APIs and infrastructure, and firebase-functions only knows how to work with Cloud Functions.
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.
When emulating firebase functions locally is there a way to change the function timeout from the default 60s?
--idlePruneInterval has been added as an option to the google cloud emulator CLI: https://github.com/GoogleCloudPlatform/cloud-functions-emulator/issues/66
This option doesn't appear to work is not officially supported in either the firebase serve mode:
firebase serve --only functions --idlePruneInterval=5000
or the experimental shell emulation:
firebase experimental:functions:shell --idlePruneInterval=5000
Is there another way around this problem? Perhaps editing a config file?
The Cloud Functions emulator from Firebase is separate from the one provided by the Google Cloud Platform org. The command line parameters from one won't necessarily work on the other.