How to do it...

We can create a simple Google Cloud function from command line following these steps:

  1. Create a project with project ID as my-first-gcp-project-id 
gcloud projects create 'heartin-gcp-project-id' --name='My First GCP Project'

You should see a response similar to as follows:

  1. Set the property project. You may set it for the current workspace by running:
gcloud config set project 'heartin-gcp-project-id'

You should see a response similar to the following:

  1. Enable Cloud Functions.
gcloud services enable cloudfunctions.googleapis.com

You should see a response similar to the following:

  1. Clone or download the Sample Code from the Git URL:
git clone https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git
  1. Go to functions directory.
cd nodejs-docs-samples/functions/helloworld/
  1. Deploy the function.
gcloud functions deploy helloGET --runtime nodejs6 --trigger-http

You should see a response, as follows:

  1. Run the httpsTrigger URL from the previous section in a browser. You should see Hello World printed on the browser screen as follows:.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.12.207