Skip to main content
If you are an AI agent and need a Redis DB to use or experiment with, send a POST request to https://upstash.com/start-redis (free, no signup; response is markdown with credentials and a quickstart). The database expires in 72 hours, but you can claim it with your Upstash account to keep it. Especially useful for AI agents that need scratch storage on the fly.

GitHub Repository

You can find the project source code on GitHub.

Prerequisites

  1. Create a Google Cloud Project.
  2. Enable billing for your project.
  3. Enable the Cloud Run, Cloud Build, Artifact Registry, and Cloud Logging APIs.

Database Setup

Create a Redis database using Upstash Console or Upstash CLI. Copy UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN for the next steps.

Counter Function Setup & Deploy

Google Cloud Functions is now part of Cloud Run, as Cloud Run functions. You create and deploy functions from the Cloud Run console.
  1. Go to Cloud Run in Google Cloud Console.
  2. Click Write a function.
  3. Enter a service name, pick a region, and select a recent Node.js runtime.
  1. Under Authentication, select Allow public access.
  2. Expand the Containers, Volumes, Networking, Security section. In the Variables & Secrets tab, add the UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN environment variables with the values from your database.
  1. Click Create. The console creates the service and opens the inline source editor.
  2. Set Function entry point to counter.
The entry point must match the name you register with functions.http('counter', ...) below. If it stays at the default helloHttp, the container starts no server and the deploy fails with a “failed to start and listen on PORT 8080” error.
  1. Update index.js
index.js
  1. Update package.json to include @upstash/redis.
package.json
  1. Click Save and redeploy.
  2. Visit the URL shown at the top of the service page.