firebase deploy --only functions overrides existing functions

46,601

Solution 1

You can use firebase partial deploys

$ firebase deploy --only functions:makeUppercase

Will only deploy makeUppercase function.

Hope it helps.

Note: To deploy more than one function at once (but not all) use:

$ firebase deploy --only functions:function1,functions:function2

Solution 2

firebaser here

Running firebase deploy will deploy all functions in the project. There is currently no option to deploy just new or modified functions.

It does sound like a useful addition though, so you might want to file a feature request.

Update: since version 3.8 of the Firebase tools CLI this is possible. See Pablo's answer or the release notes.

Solution 3

Make sure you are editing the functions in your "functions/src" directory and not the functions in your 'lib' directory. I made this mistake and watched them get replaced...

Share:
46,601
Quan Vuong
Author by

Quan Vuong

https://quanvuong.github.io/

Updated on July 05, 2022

Comments

  • Quan Vuong
    Quan Vuong almost 2 years

    Running firebase deploy --only functions deletes the existing functions before creating new ones. Is it possible to modify this behavior to create if not exist, update if exists, no actions if functions not being deployed?

  • Quan Vuong
    Quan Vuong about 7 years
    Thanks Frank. You have helped me out more than once :)
  • Quan Vuong
    Quan Vuong about 7 years
    feature request filed. Thanks for the link!
  • Quinn Turner
    Quinn Turner about 7 years
    I could use some help with this! I would like to deploy multiple functions as well. I have set up my project structure exactly like github.com/firebase/functions-samples has. In fact, I used it as a base, stripped all but two functions, modified, and want to deploy. I have tried firebase deploy, firebase deploy --only ..., and comma separated attempts.
  • Quinn Turner
    Quinn Turner about 7 years
    If I run "firebase deploy" from root I get that it couldn't locate firebase.json. My guess is I have to restructure the applications, but I haven't had any luck after trying a few alternatives.
  • Scott
    Scott about 7 years
    @QuinnTurner Try running firebase init, which will add all necessary files.
  • Frank van Puffelen
    Frank van Puffelen about 7 years
    @QuinnTurner please don't post new questions in a comment. If you have a new problem, post a new question. Be sure to include the minimal code that reproduces the problem in that question (and read the link, it's quite useful).
  • Thorbjørn Kappel Hansen
    Thorbjørn Kappel Hansen over 6 years
    It's also possible to deploy multiple functions in a partial deploy: firebase deploy --only functions:function1,functions:function2
  • Simon Moshenko
    Simon Moshenko over 5 years
    I believe the best solution would be using groups, also seen in the documentation link.
  • Ramesh Vishnoi
    Ramesh Vishnoi over 3 years
    Thanks. This saved lot of time
  • Mars2024
    Mars2024 almost 2 years
    But how should you actually NAME your firebase functions? What does it Actually look like?