This page shows you how to get started quickly with Cloud Code.
You'll set up a Hello World application that runs on Cloud Run using a starter template, deploy your app to Cloud Run, and view the status of your live service's resources.
If you'd prefer to work through this quickstart interactively, launch the Cloud Shell walkthrough with the button below.
Before you begin
Sign in to your Google Account.
If you don't already have one, sign up for a new account.
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 Cloud project. Learn how to confirm that billing is enabled for your project.
Creating an application
- Directly launch the Cloud Shell Editor.
- From the Cloud Code status bar, select New Application.
- Choose 'Cloud Run application' as your preferred application type.
From the list of templates (Node.js, Python (Flask and Django frameworks), Java, Go), choose a Hello World app in a language of your choosing.
For example, choosing
Python (Flask): Hello Worldwill create a starter Python (Flask) Hello World app.
Select a folder as your application location to proceed and click 'Create New Application'.
Cloud Shell Editor loads the application in a new workspace. Once reloaded, your app is accessible in the explorer view.
Deploy to Cloud Run
To deploy your application to Cloud Run, follow these steps:
Choose the Cloud Run: Deploy command using the Cloud Code status bar.
This brings up the Cloud Run: Deploy UI.
If prompted, authorize Cloud Shell to make Google Cloud API calls.
Set your Google Cloud project.
If prompted, enable your Cloud Run API by clicking 'Enable APIs'.
Within the Deploy to Cloud Run dialog, select a pre-existing service or create a new one.
If you're creating a new service, choose 'Cloud Run (fully managed)' under 'Deployment Platform'.
Choose a region to deploy to.
For Authentication, select 'Allow unauthenticated invocations' to make this a public service.
After you define your preferred settings, you can click 'Deploy'.
Cloud Code then builds your image, pushes it to the registry, and deploys your app to Cloud Run. Your service is now live!
View your running service by following the URL displayed in your Cloud Run: Deploy dialog.
Editing your service
To edit your application, follow these steps:
- With the Explorer view, find the app.py file which implements the service behavior.
- Modify the message "It's running!" to a message of your choosing.
- Once you make this change, choose the Cloud Run: Deploy command using the Cloud Code status bar.
- Check that the service you just created is selected in Service Settings.
- Click 'Deploy'.
- Once your application finishes building and deploying, you can refresh your service to see your updated message.
You can also view logs from your deployed application with the Log Viewer that comes with Cloud Code.
To view logs, follow these steps:
- Navigate to the Cloud Run explorer by clicking on its icon in the VS Code Activity bar on the left .
Right-click on your Cloud Run service and choose 'View logs'.
Refresh your app in the browser, and see the new logs generated by clicking the Logs refresh button.
To delete your project:
Go to the Projects page in the Cloud Console:
Select the project you created for this Quickstart and click on the trash can icon next to delete it.
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 does not charge when the service is not in use, you might still be charged for storing the container image in Container Registry. To delete your image, follow this guide.
Cloud Run service: To delete a Cloud Run service, navigate to Cloud Run in the Console using the navigation menu. Select the service you'd like to delete and click on the 'Delete' trash can icon.
- Discover the variety of features the Cloud Shell Editor has to offer.
- Learn how to configure Cloud Shell to customize your experience.