Justine Mackay
Justine Mackay

Reputation: 129

How to recover deleted Cloud Function

I accidentally, deleted all my cloud function on the CLI, is there anyway to recover it? I tried searching Google Cloud Platform features to restore it but with no avail.

Upvotes: 0

Views: 3537

Answers (2)

CristianDTツ
CristianDTツ

Reputation: 31

I had this problem today. Here is the solution I found.

Explanation of the solution

apparently, when one creates a function onRequest

function, all the code is uploaded, no matter if it is used or not.

For example:

we have 2 enpoints

GET products

GET history

when creating the cloud function for products, not only the products code is uploaded, but also the history code.

Step by step

then, what you need, is to download the source code, of one of the functions that you currently have active here:

https://console.cloud.google.com/functions

(clearly the function, for which you downloaded the source code, had to be uploaded when you had in your source code, the code you are looking for now)

  1. select the function that meets this requirement
  2. go to the "source" tab
  3. download the zip file of the source code

now you only have to search in that file, the code of the function you are looking for.

Upvotes: 1

ked
ked

Reputation: 2456

I think you can't recover the deleted cloud function. Created a temporary cloud function and deleted the function to check if deleted is showed in the list https://console.cloud.google.com/functions, but the function was removed from the list.

Upvotes: 5

Related Questions