This post explains how to create 2nd gen HTTPS triggered
Cloud Function in GCP.
GCP 2nd gen Cloud Functions
In August, 2022 Google Cloud announced the general availability of the
2nd generation of Cloud Functions. With this announcement
now Cloud Functions offers two product versions
Cloud Functions (1st gen), the original version, and
Cloud Functions (2nd gen), a new version built on Cloud Run
and Eventarc to provide an enhanced feature set. With the general
availability of the 2nd generation of Cloud Functions you can start using
2nd gen Cloud Functions for new workloads, while continuing to use your
existing 1st gen Cloud Functions.
1st vs 2nd gen Cloud Functions
How to create 1st gen Cloud functions
Steps to create 2nd gen HTTPS Cloud Function
1. Navigate to Google Cloud Console
2. In the search bar type Cloud Functions and select
Cloud Functions from the results.
3. Click on CREATE FUNCTION.
4. Enabled the required APIs.
5. Select the 2nd gen from the
Environment dropdown, provide
Function Name, select Region.
6. In the HTTPS trigger select
Allow unauthenticated invocations.
7. Keep the default settings in
Runtime, build, connection and security settings and click
8. Enable the required Artifact Registry API.
9. In the Runtime select Python 3.9, write
below code in hello_http entry point and click on
request_json = request.get_json(silent=True)
request_args = request.args
if request_json and 'name' in request_json:
name = request_json['name']
elif request_args and 'name' in request_args:
name = request_args['name']
name = '2nd gen Cloud Function Test'
10. Once the function deployment is complete, you should see function URL on
11. Click on the function URL and you should see below response in the