during development starting/restarting ALL the funcs in my app is slow, is there a way to limit the scope of functions? similar to how you can just deploy a subset with:
firebase deploy --only functions:token-tokenMetadata
I tried to do:
npm run build:watch | firebase emulators:start --only functions:peopleai-createTune
but it will start everything
docs don't seem to mention:
https://firebase.google.com/docs/functions/local-emulator
That's currently not a feature. It sounds like an interesting idea though, so I recommend filing a request for it on the GitHub repo of the project.
Related
I have an application that uses cloud functions to respond to Firestore triggers (onCreate, onDelete). I am trying to use the emulator to test these functions prior to deployment, however that does not work for me.
The emulator is properly setup, I can test and debug cloud functions, BUT I have to deploy them first. Am I missing something?
Basically, I have to do
> firebase emulator:start --inspect-functions
then
> firebase deploy --only functions
Any help or pointers would be greatly appreciated
If you are using TypeScript, you have to build the functions first. Read more.
I experimented with firebase functions for the init part and it has created a folder for me. Now when I deploy each time it also picks up the functions folder. When I remove the functions folder I get an error, when deploying. How do I deploy everything but functions?
firebase deploy has a parameter --except . So to deploy everything except functions you can run:
firebase deploy --except functions
You can use the only option/flag, for example firebase deploy --only hosting,storage, see the CLI doc.
You can also use deploy targets which "are short-name identifiers (that you define yourself) for Firebase resources in your Firebase project".
Check to make sure that you have removed the implicit reference to the function in your index.js and then running firebase deploy should do the trick. If you want to explicitly delete the function completely, you can use the firebase functions:delete <myFunction> and then delete the functions folder. You can find more details in the doc here
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
When I run
firebase deploy --only functions
it reads the index.js file and updates all functions exported from that file. If on the previous deploy there was a function named a, and in the current deploy there is no such function, a will be deleted.
In other words, the effect is the same as if all existing functions were deleted and then the all functions from the current index.js file were added.
Is it possible to add/update/delete individual functions?
Firebase CLI tools 3.8.0 has added the ability to deploy specific functions.
firebase deploy --only functions:func1,functions:func2
--only <targets>
only deploy to specified, comma-separated targets (e.g. "hosting,storage"). For functions,
can specify filters with colons to scope function deploys to only those functions (e.g. "--only functions:func1,functions:func2").
When filtering based on export groups (the exported module object keys), use dots to specify group names
(e.g. "--only functions:group1.subgroup1,functions:group2)"
The following way worked for me to deploy a particular function without affecting my other functions, where specificFunctionName is the function I wanted to deploy
firebase deploy --only functions:specificFunctionName
To copy the command quickly in terminal:
firebase deploy --only functions:
firebaser here
There is currently no way to deploy a single function with the Firebase CLI. Running `firebase deploy` will deploy all functions.
We've recently discussed deploying subsets of the functions, but it's not available at the moment - nor can we give a ballpark of if/when it might be.
Update Since Firebase CLI release the ability to deploy single functions is available. See yuku's answer.
firebase deploy --only "functions:<fileName>.<functionName>"
example folder structure:
functions
node_modules
index.js
smsNotification.js
...
You can redeploy just a function in a file with
firebase deploy --only "functions:smsNotification.sendChatNotif"
You can redploy all functions in a file with
firebase deploy --only "functions:smsNotification"
I never managed to get it working (and have no codebase property in my firebase.json) until I tried what #Sergey Mell mentioned in his comment :
firebase deploy --only "functions:func1,functions:func2"
The surrounding double quotes was what solved the issue.
In case anyone still can't make it work using firebase deploy --only functions:func1,functions:func2, it's probably because you're probably using codebases, "codebase": "my-codebase", in your firebase.json. Took me a while to diagnose but after removing that codebase property, deploying only some functions using the --only flag worked for me
This one gave me the missing package. Although package was included but I had to reinstall the mentioned package.
firebase --debug deploy --only functions:[functionName]
I am following this doc to try to debug my firebase cloud function: https://cloud.google.com/functions/docs/monitoring/debugging
First of all the
The require line given in the doc was wrong so I changed it to this to make it compile:
require('#google-cloud/debug-agent').start();
Also after implementing this and deploying the functions using firebase deploy --only functions there is no code in stack drive debug view. Any idea how to make this work?
Thanks :)
Currently, Cloud Functions for Firebase do not share their code with Stackdriver automatically. You'll need to source your code via Github, Bitbucket, or a Google Cloud Source Repository.
While debugging Cloud Functions for Firebase please refer to our documentation. We'll make sure to note any differences between the environments.