How to deploy some functions to Cloud Functions for Firebase without affecting some other functions?
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
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"
Comments
-
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 nameda
, 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 almost 7 yearsHey ! It's available now :D
-
Frank van Puffelen almost 7 yearsIt indeed is Dam. That's why yuku's answer is the more upvoted and accepted one. :-)
-
Dam almost 7 yearsThat world is so awesome this way 😊
-
Marcos Pereira over 4 yearsIs this still working? I get an error when I try this now, but it used to work
-
The Black Horse almost 4 yearsPlease Note: do not put a Space after a comma firebase deploy --only functions:func1,functions:func2
-
Sergey Mell over 3 yearsFor now it seems it should be firebase deploy --only "functions:func1,functions:func2"
-
shaimo over 3 yearsWhat about updating an internal helper function or variable? Impossible I guess...
-
Oleg Bondarenko over 3 yearsI have killed 1 hour to recognize why multiple deployment stops working. thank you @SergeyMell for mentioned quote escape.
-
Jousi over 2 yearsCurrently not working for node ^14, for some reason running
firebase deploy --only functions
works fine, butfirebase 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