Deploy a Cloud Run service with Cloud Code for VS Code
This page shows you how to get started quickly with Cloud Code.
You'll set up a Hello World service that runs on Cloud Run using a sample application, deploy your service to Cloud Run, and view the status of your live service's resources.
Before you begin
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the Cloud Run API.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the Cloud Run API.
- Install Git. Git is required for copying samples to your machine.
- Install the Cloud Code plugin if you haven't already.
Creating a service
In the Cloud Code status bar, click the active project name.
In the Quick Pick menu that appears, select New Application.
Choose Cloud Run application as your preferred application type.
From the list of sample applications (Node.js, Python with Flask and Django frameworks, Java, Go), choose a Hello World service.
For example, choosing
Node.js: Hello World
creates a starter Node.js Hello World service.Confirm your service location on disk (or modify it, if necessary) and click Create New Application.
A preview of the README file for your selected service will open in VS Code.
Deploy to Cloud Run
To deploy your service to Cloud Run, follow these steps:
Open the Command Palette (press
Ctrl
/Cmd
+Shift
+P
or click View > Command Palette) and then run the Deploy to Cloud Run command.In the Deploy to Cloud Run pane, set your Google Cloud project.
Accept the remaining default settings and then click Deploy.
Cloud Code builds your image, pushes it to the registry, and deploys your service to Cloud Run.
To view your running service, open the URL displayed at the top of the Deploy to Cloud Run dialog.
Viewing logs
You can also view logs from your deployed service with the Log Viewer that comes with Cloud Code.
To view logs, follow these steps:
- Click Cloud Code in the VS Code Activity bar on the left.
- Expand the Cloud Run section to view your Cloud Run service.
- Right-click your Cloud Run service and then click View logs.
Viewing resource status
You can view the status of your Cloud Run services using the Cloud Run service browser:
- Click Cloud Code in the VS Code Activity bar on the left.
- Expand the Cloud Run section to view your Cloud Run service.
- Click the Cloud Run service you'd like to know more about. The service's properties are displayed in the window below.
Cleaning up
To delete your project:
Go to the Projects page in the Google Cloud console:
Select the project you created for this quickstart and then click Delete.
Type the project ID to confirm and then click Shut down.
This shuts down the project and schedules it for deletion.
If you're using a pre-existing project and would like to delete resources you created for this quickstart:
Container image: While Cloud Run doesn't charge when the service isn't in use, you might be charged for storing the container image in Container Registry. For steps to delete your image, see Deleting images.
Cloud Run service: To delete a Cloud Run service, navigate to Cloud Run in the Google Cloud console using the navigation menu. Select the service you want to delete and then click Delete.
What's next
- Discover the language-specific debugging support that Cloud Code provides.
- Customize your Cloud Code experience by configuring relevant settings.
- Try creating and running a Kubernetes application with Cloud Code.