45
votes

I was experimenting with Cloud Functions for Firebase and deployed one of the samples in the functions-samples repo and linked it to an existing project using firebase use --add.

Since I was just playing around, these files were not added to my version control, and I no longer have access to the machine this was done on. I would like to build on this function or create new ones, but I am unsure how to either 1) modify and re-deploy over the original function or 2) un-use --add and start fresh. I see the function in my firebase console but no 'delete' or 'remove' button and have read through the CLI docs looking for clues to no avail.

Thanks for adding functions to the firebase 'stack.' Any guidance is much appreciated.

5

5 Answers

61
votes

Functions get deleted when they aren't present during a firebase deploy. Most commonly that'd be because because you removed the function from your index.js, but if you've removed the whole functions directory that'll work too.

To continue work on a function for which you don't have the source anymore, the easiest is to start fresh. The function(s) you deploy will replace the ones you deployed previously.

Alternatively, if you're partial to using the Google Cloud Console instead of the Firebase Console, the Cloud Console will show you the code for the currently-deployed function, so you can copy-paste it onto your local machine.

The Cloud Console also has a 'delete' button for every function, and even a web editor. Be aware when editing functions from the Cloud Console though: your next firebase deploy will overwrite any changes.

38
votes

Go to Google Cloud Console Cloud Functions and select project, then select the function you want to undeploy or delete. Select it and click delete.

36
votes

To delete a function explicitly use the following command:

$ firebase functions:delete myFunction

Replace myFunction with your function name. For detailed info. follow this link: https://firebase.google.com/docs/functions/manage-functions

4
votes

To delete/undeploy a single function, you can delete the code for your function and then run the following in command line:

firebase deploy --only functions:YourFunctionName

Replace YourFunctionName with the name of your function

In the case that you are working on other functions that you are not ready to deploy or do not want to deploy all of your functions for any reason, then the code above can be handy. This also feels a bit safer since you're not redeploying everything :)

3
votes

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.

enter image description here