Deploy a Cloud Run service by using Cloud Code for Cloud Shell

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

  1. 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.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud 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.create permission.Learn how to grant roles.
    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.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. In the Google Cloud console, on the project selector page, select or create a Google Cloud 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.create permission.Learn how to grant roles.
    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.

    Go to project selector

  5. Verify that billing is enabled for your Google Cloud project.

Create an application

  1. Launch the Cloud Shell Editor.
  2. From the Cloud Code status bar, selectNew Application.
  3. ChooseCloud Run application as your preferred application type.
  4. From the list of sample applications, choose a Hello World app. For example, choosingPython (Flask): Hello World creates a starterPython (Flask) Hello World app.
  5. 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:

  1. Choose theDeploy to Cloud Run command using the command palette (accessible withCtrl/Cmd+Shift+P).This brings up the Cloud Run Deploy UI.
  2. If prompted, authorize Cloud Code to make Google Cloud API calls.
  3. Set your Google Cloud project.
  4. If prompted, enable the Cloud Run API by clickingEnable APIs.
  5. In the Deploy to Cloud Run dialog, select a pre-existing service or createa new one.
  6. If you're creating a new service, chooseCloud Run (fully managed)under Deployment Platform.
  7. Choose a region to deploy to.
  8. For Authentication, selectAllow unauthenticated invocations to make this a public service.
  9. 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.
  10. View your running service by following the URL displayed inyour Cloud Run: Deploy dialog.

Edit your service

To edit your application:

  1. With the Explorer view, find theapp.py file that implements the servicebehavior.
  2. Change the message "It's running!" to a message of your choosing.
  3. After you make this change, choose theDeploy to Cloud Run commandusing the command palette.
  4. Check that the service you created is selected in Service Settings.
  5. ClickDeploy.
  6. 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:

  1. To open the Cloud Run Explorer, clickCloud Code and then expand theCloud Run section.
  2. Right-click your Cloud Run service and then clickView logs.
  3. 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:

    Caution: Deleting a project has the following effects:
    • Everything in the project is deleted. If you used an existing project for the tasks in this document, when you delete it, you also delete any other work you've done in the project.
    • Custom project IDs are lost. When you created this project, you might have created a custom project ID that you want to use in the future. To preserve the URLs that use the project ID, such as anappspot.com URL, delete selected resources inside the project instead of deleting the whole project.

    If you plan to explore multiple architectures, tutorials, or quickstarts, reusing projects can help you avoid exceeding project quota limits.

  1. In the Google Cloud console, go to theManage resources page.

    Go to Manage resources

  2. In the project list, select the project that you want to delete, and then clickDelete.
  3. In the dialog, type the project ID, and then clickShut down to delete the project.

If you're using a pre-existing project and want to delete the resources you created for thisquickstart:

What's next

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.