Learn how to set up and deploy a sample Hello World application to Cloud Run and view the status of your live service's resources.
To follow step-by-step guidance for this task directly in the Cloud Shell Editor, click Guide me:
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.
-
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.
Create an application
- 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 sample applications, choose a Hello World app. For example, choosing
Python (Flask): Hello World
creates a starter Python (Flask) Hello World app. - Select a folder as your application location and then click Create New Application. Cloud Shell Editor loads the application in a new workspace. After the workspace loads, your app is accessible in the explorer view.
Deploy to Cloud Run
To deploy your application to Cloud Run:
- Choose the Deploy to Cloud Run command using
the command palette (accessible with
Ctrl
/Cmd
+Shift
+P
). This brings up the Cloud Run Deploy UI. - If prompted, authorize Cloud Code to make Google Cloud API calls.
- Set your Google Cloud project.
- If prompted, enable the Cloud Run API by clicking Enable APIs.
- In 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, click Deploy. Cloud Code 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.
Edit your service
To edit your application:
- With the Explorer view, find the
app.py
file that implements the service behavior. - Change the message "It's running!" to a message of your choosing.
- After you make this change, choose the Deploy to Cloud Run command using the command palette.
- Check that the service you created is selected in Service Settings.
- Click Deploy.
- After your application finishes building and deploying, you can refresh your service to see your updated message.
View logs
You can also view logs from your deployed application with the Log Viewer that comes with Cloud Code.
To view logs:
- To open the Cloud Run Explorer, click Cloud Code and then expand the Cloud Run section.
- Right-click your Cloud Run service and then click View logs.
- Refresh your app in the browser, and see the new logs generated by clicking the Logs refresh button.
Clean up
To avoid incurring charges to your Google Cloud account for the resources used on this page, follow these steps:
- In the Google Cloud console, go to the Manage resources page.
- In the project list, select the project that you want to delete, and then click Delete.
- In the dialog, type the project ID, and then click Shut down to delete the project.
If you're using a pre-existing project and want to delete the resources you created for this quickstart:
- Container image: While Cloud Run doesn't charge when a
service isn't in use, you might still be
charged for storing the container image in Container Registry.
To delete your image, open the Container Registry page, expand the
repository that contain s your image, select your image, click Delete,
and then click Delete.
Open the Container Registry page - Cloud Run service: To delete a Cloud Run service, from the Cloud Run page in the Google Cloud console, select the service you'd like to delete, click Delete, and then click Delete. Open the Cloud Run page
What's next
- Discover the features that the Cloud Shell Editor interface offers.
- Learn how to configure Cloud Shell to customize your experience.