[QuickStart] Python CloudFunction deploy with gcloud sdk

1. Download & Install Cloud SDK

Step 1 – download gcloud to your desktop

  1. Windows User can check here.
  2. Mac User can check here.

Q: How to check for your Mac is 32-bit or 64-bit?
A: Normally, if you have anything newer than 2008 Macbook, you will have  64 bit processor. You can run this on command line:

Step 2 – run google-cloud-sdk/install.sh

Step 3 – run gcloud init

If you see this on your terminal, it means you install it successfully!

If you see the gcloud not found error msg:

then try to restart your config:

run below command to set your account config:

Other gcloud commands

1. gcloud displays a list of your accounts.

2. gcloud displays the list of your properties.

3. gcloud displays the projects of your properties.

4. switch to other project.

2. Prepare CloudFuncion folder

Folder structure

  1. main.py
  1. deploy.sh

Deploy CloudFunction with gcloud SDK

Enable the Cloud function api in Google cloud platform:

https://console.developers.google.com/apis/api/cloudbuild.googleapis.com/overview?project=151775453437

Run below command in your terminal:

After deployment, you can check the GCP, enter the URL, can see the “Hello World!” response.

References:

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *