In this article, I'm going to walk you through quickly generating either a basic starter Express API app or a simple example Express API app and deploying it to Cloud Run.
See the prerequisites for using
run, a lightweight CLI for creating and deploying Cloud Run apps here.
example-express-api when asked to choose a project template. The example version demonstrates using various Express methods for a mock database.
You can run the app locally, if you want.
To deploy to Cloud Run, enter:
Since this is the first deployment, you'll be presented with a series of prompts. Your settings will be saved to a a local configuration file (
Note: In the current version of
run, only the new project option works.
When the deployment is finished, the
run will print the URL for accessing the app.
If you chose
example-express-api, the README includes instructions about testing the API using
curl commands in a test script.
To get the link to view the logs web page, enter:
run command to delete the project when finished is not yet implemented. For now, use
gcloud to delete the project using its ID (if you forget the project ID, it's stored in
gcloud projects delete PROJECT
If you run into any problems, check to see if there is an issue here and, if not, please create one.
I provide background on
run in my last article.
If you prefer to use
gcloud, see this article if you need help getting started. You'll still use
run to create the app from a template.