HowlingFantods
HowlingFantods

Reputation: 832

How do you un-deploy Cloud Functions for Firebase?

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.

Upvotes: 54

Views: 38987

Answers (6)

Apisak Srihamat
Apisak Srihamat

Reputation: 1

I found the way to make it happen.

The method is to go into https://console.cloud.google.com/storage/ => TRANSFER DATA => Transfer data in

Then you Create a transfer job

  1. Source/Destination type = Google Cloud Storage
  2. Select Source as gcf-source-[project number]-[region]
  3. Select Destination as [project name].appspot.com => Create new folder as FunctionCode
  4. Run job immediate
  5. Wait until complete

Then visit your firebase storage in folder FunctionCode

Bingo!! You get your source code of your previous released. Use it to redeploy again as you wish.

Note: In my understanding, google will help to keep latest 2 versions for us in gcf-source-[project number]-[region].

Upvotes: 0

isuru
isuru

Reputation: 3565

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

Upvotes: 4

Neeraj Sewani
Neeraj Sewani

Reputation: 4297

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

Upvotes: 56

Sumer Singh
Sumer Singh

Reputation: 523

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.

Upvotes: 45

Rbar
Rbar

Reputation: 3948

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

Upvotes: 5

Robert-Jan Huijsman
Robert-Jan Huijsman

Reputation: 1934

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.

Upvotes: 64

Related Questions