Deploy a Cloud Run service by using 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.


For step-by-step guidance for this task directly in the Cloud Shell Editor, click Guide me:

Guide me


The following sections take you through the same steps as clicking Guide me.

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.

    Go to project selector

  3. Make sure that billing is enabled for your Cloud project. Learn how to check if billing is enabled on a project.

  4. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  5. Make sure that billing is enabled for your Cloud project. Learn how to check if billing is enabled on a project.

Create an application

  1. Launch the Cloud Shell Editor.
  2. From the Cloud Code status bar, select New Application.
  3. Choose Cloud Run application as your preferred application type.
  4. 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.
  5. 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:

  1. 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.
  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 clicking Enable APIs.
  5. In the Deploy to Cloud Run dialog, select a pre-existing service or create a new one.
  6. If you're creating a new service, choose Cloud Run (fully managed) under Deployment Platform.
  7. Choose a region to deploy to.
  8. For Authentication, select Allow unauthenticated invocations to make this a public service.
  9. 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.
  10. View your running service by following the URL displayed in your Cloud Run: Deploy dialog.

Edit your service

To edit your application:

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

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

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

    Go to Manage resources

  2. In the project list, select the project that you want to delete, and then click Delete.
  3. 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:

What's next