This sample shows a Google Cloud Function that uses a dependency from NPM, and is a handy way to generate a v4 UUID from the command-line.
View the documentation or the source code.
-
Follow the Cloud Functions quickstart guide to setup Cloud Functions for your project.
-
Clone this repository:
git clone https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git cd nodejs-docs-samples/functions/uuid
-
Create a Cloud Storage Bucket to stage our deployment:
gsutil mb gs://[YOUR_BUCKET_NAME]
- Replace
[YOUR_BUCKET_NAME]
with the name of your Cloud Storage Bucket.
- Replace
-
Deploy the
uuid
function with an HTTP trigger:gcloud alpha functions deploy uuid --bucket [YOUR_BUCKET_NAME] --trigger-http
- Replace
[YOUR_BUCKET_NAME]
with the name of your Cloud Storage Bucket.
- Replace
-
Call the
uuid
function:gcloud alpha functions call uuid
You should see something like this in your console:
executionId: abcd1234-0 result: 0ef22088-07f2-44ca-9cef-cea8ff666d69