This page contains code samples for Cloud Functions. To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.
Cached library
HTTP Cloud Function that uses a cached client library instance to reduce the number of connections required per function invocation.
View in documentation
View in documentation
Cloud Storage Hello World
Shows a Storage Cloud Function sample.
Cloud Storage integration tests
Demonstrates how to integration test a function triggered by Cloud Storage.
View in documentation
Cloud Storage unit tests
Demonstrates how to unit test a function triggered by Cloud Storage.
View in documentation
Global versus function scope
Creates a heavy object only once per function instance, and shares it across all function invocations reaching the given instance.
View in documentation
View in documentation
View in documentation
- Create and deploy a HTTP Cloud Function by using Go
- Create and deploy a HTTP Cloud Function by using Node.js
- Create and deploy a HTTP Cloud Function by using PHP
- Create and deploy a HTTP Cloud Function by using Python
- Create and deploy a HTTP Cloud Function by using Ruby
- Specifying dependencies in Node.js
- Testing HTTP Functions
- Tips & Tricks
HTTP Hello World - Get
Function that prints "Hello world!" in response to a GET request.
View in documentation
- .NET Languages
- Create and deploy a Cloud Function (1st gen) by using the Google Cloud CLI
- Create and deploy a Cloud Function (2nd gen) by using the Google Cloud CLI
- Create and deploy a HTTP Cloud Function by using .NET
- Create and deploy a HTTP Cloud Function by using Java
- HTTP Tutorial
- HTTP Tutorial (2nd gen)
- JVM Languages
ImageMagick tutorial step 1 - Analyze image
Demonstrates how to use the Google Cloud Vision API and ImageMagick to detect and blur offensive images that get uploaded to a Cloud Storage bucket.
View in documentation
ImageMagick tutorial step 2 - Blur image
Demonstrates how to use the Google Cloud Vision API and ImageMagick to detect and blur offensive images that get uploaded to a Cloud Storage bucket.
View in documentation
Memorystore for Redis
Demonstrates a Cloud Function that connects to a managed Redis instance.
View in documentation
View in documentation
OCR tutorial step 1 - Process image
Demonstrates how to upload image files to Cloud Storage, and extract and translate text from the images by using the Vision API and Translation API.
View in documentation
OCR tutorial step 2 - Detect text
Demonstrates how to upload image files to Cloud Storage, and extract and translate text from the images by using the Vision API and Translation API.
View in documentation
OCR tutorial step 3 - Translate text
Demonstrates how to upload image files to Cloud Storage, and extract and translate text from the images by using the Vision API and Translation API.
View in documentation
OCR tutorial step 4 - Save result
Demonstrates how to upload image files to Cloud Storage, and extract and translate text from the images by using the Vision API and Translation API.
View in documentation
View in documentation
Pub/Sub Hello World
Shows a Pub/Sub Cloud Function sample.
Pub/Sub integration tests
Demonstrates how to integration test a function triggered by Pub/Sub.
View in documentation
Pub/Sub system tests
Demonstrates how to system test a function triggered by Pub/Sub.
View in documentation
Pub/Sub unit tests
Demonstrates how to unit test a function triggered by Pub/Sub.
View in documentation
Use HTTP connection pooling
Shows how to recycle HTTP connections using HTTP connection pools.
View in documentation