Default
Usually we use this command
gcloud functions deploy test_hello_world --runtime python37 --trigger-http --project PROJECT_ID
To deploy a function named test_hello_world
in the file main.py
def test_hello_world(request): return 'Hello World'
Where you url for the function is
https://us-central1-PROJECT_ID.cloudfunctions.net/test_hello_world
Change Cloud Function Name
To change the cloud function name (different from source code function name)
gcloud functions deploy test --entry-point test_hello_world --runtime python37 --trigger-http --project travelopyz
Function name must contain only lower case Latin letters, digits and a hyphen (-). It must start with letter, must not end with a hyphen, and must be at most 63 characters long.
NOTE: It is not possible to group function name under subdirectory, such as /intents/test
. An alternative would be via cloud functions url redirect via Cloud Functions Custom Domain With Firebase Hosting.
The generated url shall be
https://us-central1-PROJECT_ID.cloudfunctions.net/test
Change Source File
Sadly, the function must reside within the file named main.py
, but you can change the directory name.
gcloud functions deploy test --entry-point test_hello_world --source production --runtime python37 --trigger-http --project travelopyz
--source=SOURCE Location of source code to deploy. Location of the source can be one of the following three options:
Source code in Google Cloud Storage (must be a .zip archive), Reference to source repository or, Local filesystem path (root directory of function source).
Create the file production/main.py
.
References: