Cloud Functions

Functions as a Service

Cloud Run functions (formerly Cloud Functions) run a single function in response to an HTTP request or an event, with no container to write.

# main.py
import functions_framework

@functions_framework.http
def hello(request):
    name = request.args.get("name", "world")
    return {"message": f"Hello, {name}!"}

Example (deploy)

gcloud functions deploy hello --gen2 --runtime=python312 \
  --region=asia-south1 --trigger-http --allow-unauthenticated --entry-point=hello

Example output

state: ACTIVE
url: https://asia-south1-shop-dev-1234.cloudfunctions.net/hello