Deploy a Cloud Run service by using Cloud Code for Cloud Shell Stay organized with collections Save and categorize content based on your preferences.
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.
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.
Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
- Create a project: To create a project, you need the Project Creator role (
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission.Learn how to grant roles.
Verify 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.
Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
- Create a project: To create a project, you need the Project Creator role (
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission.Learn how to grant roles.
Verify that billing is enabled for your Google Cloud project.
Create an application
- Launch the Cloud Shell Editor.
- From the Cloud Code status bar, selectNew Application.
- ChooseCloud Run application as your preferred application type.
- From the list of sample applications, choose a Hello World app. For example, choosing
Python (Flask): Hello Worldcreates a starterPython (Flask) Hello World app. - Select a folder as your application location and then clickCreate New Application. Cloud Shell Editor loads the application in a newworkspace. After the workspace loads, your app is accessible in the explorer view.
Deploy to Cloud Run
To deploy your application to Cloud Run:
- Choose theDeploy 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 clickingEnable APIs.
- In the Deploy to Cloud Run dialog, select a pre-existing service or createa new one.
- If you're creating a new service, chooseCloud Run (fully managed)under Deployment Platform.
- Choose a region to deploy to.
- For Authentication, selectAllow unauthenticated invocations to make this a public service.
- After you define your preferred settings, clickDeploy. Cloud Code builds your image, pushes it to the registry, anddeploys your app to Cloud Run. Your service is now live.
- View your running service by following the URL displayed inyour Cloud Run: Deploy dialog.
Edit your service
To edit your application:
- With the Explorer view, find the
app.pyfile that implements the servicebehavior. - Change the message "It's running!" to a message of your choosing.
- After you make this change, choose theDeploy to Cloud Run commandusing the command palette.
- Check that the service you created is selected in Service Settings.
- ClickDeploy.
- After your application finishes building and deploying, you can refresh yourservice to see your updated message.
View logs
You can also view logs from your deployed application with the Log Viewerthat comes with Cloud Code.
To view logs:
- To open the Cloud Run Explorer, click
Cloud Code and then expand theCloud Run section. - Right-click your Cloud Run service and then clickView logs.
- Refresh your app in the browser, and see the new logs generated byclicking the Logs refresh button.
Clean up
To avoid incurring charges to your Google Cloud account forthe resources used on this page, follow these steps:
If you're using a pre-existing project and want to delete the resources you created for thisquickstart:
- Container image: While Cloud Run doesn't charge when aservice isn't in use, you might still becharged for storing the container image in Artifact Registry.To delete your image, open the Artifact Registry page, select the repository that contains yourimage, select your image, clickDelete, and then clickDelete.
- Cloud Run service: To delete a Cloud Runservice, from the Cloud Run page in theGoogle Cloud console, select the service you'd like to delete, clickDelete, and then clickDelete.Open the Cloud Run page
What's next
- Discover the features that theCloud Shell Editor interface offers.
- Learn how toconfigure Cloud Shell to customize your experience.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.