Can't deploy or delete a google cloud function

Viewed 92

I had initially a 1st gen cloud function deployed but i wanted to upgrade it to 2nd gen. I tried to deploy a 2nd gen cloud function but then i wanted to go back to 1st gen again, and then i tried to deploy a 1st gen cloud function, which gave me this error

ERROR: (gcloud.functions.deploy) ResponseError: status=[400], code=[Ok], message=[Failed to create function, function function_name already exists under 2nd gen environment. Please delete conflicting function first or deploy the function with a different name.]

However, the 2nd gen cloud function does not appear on the list with all the other cloud functions.

Additionally, i tried to delete the cloud function using the command

gcloud functions delete function_name --gen2 --region=region , but it says that the cloud function does not exist.

1 Answers

Since gen2 Cloud Functions deploy as a Cloud Run container, they are considered a deployment type altogether. Thus, we can't upgrade a gen1 GCF to a gen2 GCF (or vice versa) if we use the same function name.

The error code says this can be fixed by deleting the old function. If you want to delete the function, I recommend using gcloud functions delete function_name. The flags are only necessary to delete an instance of the deployment, but in your case, you want to delete the entire deployment. Without the flags, these will resolve to the default function/region and function/gen2 config properties. Once deleted, you can use that GCloud function_name again.

Related