Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

cloud functions gen2 deploy from source code repository

michaelgrant_0-1670836067830.png

I just tried creating a new 2nd generation (gen2) cloud function.  I don't see the option to get the source code from a source code repository.  How do I deploy this from a repository like a gen1 function?

 

0 1 685
1 REPLY 1

Hi @michaelgrant,

Welcome to Google Cloud Community!

 

To deploy a Cloud Function from a source code repository, you need to use the Cloud Functions API or the gcloud command-line tool.
 
Here's an example of how you can deploy a Cloud Function using the gcloud command-line tool:
  1. Clone the repository containing your Cloud Function's source code to your local machine.
  2. Navigate to the directory containing your Cloud Function's source code.
  3. Run the following command to deploy your Cloud Function:
gcloud functions deploy FUNCTION_NAME --runtime RUNTIME --trigger-http
 
Replace `FUNCTION_NAME` with the name you want to give your Cloud Function and `RUNTIME` with the runtime you want to use (e.g. `nodejs12`, `python37`, etc.).
 
This will deploy your Cloud Function and create an HTTP trigger that you can use to invoke it.
 
Alternatively, you can use the Cloud Functions API to deploy a Cloud Function from a source code repository. This involves making an HTTP request to the API with the necessary parameters, including the repository URL and the name of your Cloud Function.
 
Thank you