How to deploy some functions to Cloud Functions for Firebase without affecting some other functions?

47,172

Solution 1

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)"

Solution 2

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:

Solution 3

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.

Solution 4

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"
Share:
47,172
Russell Ladd
Author by

Russell Ladd

Android Developer since 2009.

Updated on February 17, 2022

Comments

  • Russell Ladd
    Russell Ladd about 2 years

    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?

  • Dam
    Dam almost 7 years
    Hey ! It's available now :D
  • Frank van Puffelen
    Frank van Puffelen almost 7 years
    It indeed is Dam. That's why yuku's answer is the more upvoted and accepted one. :-)
  • Dam
    Dam almost 7 years
    That world is so awesome this way 😊
  • Marcos Pereira
    Marcos Pereira over 4 years
    Is this still working? I get an error when I try this now, but it used to work
  • The Black Horse
    The Black Horse almost 4 years
    Please Note: do not put a Space after a comma firebase deploy --only functions:func1,functions:func2
  • Sergey Mell
    Sergey Mell over 3 years
    For now it seems it should be firebase deploy --only "functions:func1,functions:func2"
  • shaimo
    shaimo over 3 years
    What about updating an internal helper function or variable? Impossible I guess...
  • Oleg Bondarenko
    Oleg Bondarenko over 3 years
    I have killed 1 hour to recognize why multiple deployment stops working. thank you @SergeyMell for mentioned quote escape.
  • Jousi
    Jousi over 2 years
    Currently not working for node ^14, for some reason running firebase deploy --only functions works fine, but firebase deploy --only functions:fetch_financials throws: package.json in functions directory has an engines field which is unsupported. Valid choices are: {"node": "8"}, {"node": "10"}, and {"node":"12"}. @FrankvanPuffelen