This page provides an overview of Cloud Functions, a serverless compute service that allows you to run code in response to events without managing servers.
Overview
Cloud Functions is a fully managed service that enables you to execute code in response to events published by other Google Cloud services, such as Pub/Sub topics, HTTP requests, and many more. It allows you to build and run your code without provisioning or managing servers, so you can focus on writing code.
Getting Started
To get started with Cloud Functions, you can use the following steps:
- Create a Google Cloud project
- Enable the Cloud Functions API for your project
- Write your first Cloud Function
Write Your First Cloud Function
Here's an example of a simple Cloud Function that triggers on an HTTP request:
exports.helloHttp = (req, res) => {
res.send('Hello, world!');
};
To deploy this function, you would use the following command:
gcloud functions deploy helloHttp --runtime nodejs14 --trigger-http