# Deploy a Cloud Run service with Cloud Code for IntelliJ

This page shows you how to get started with Cloud Code.

You'll set up a Hello World service that runs on Cloud Run using
a sample application, deploy your service to Cloud Run, and
view the status of your live service's resources.

## Before you begin

1. Install [Git](https://git-scm.com/downloads) so that Cloud Code can perform Git operations, like cloning a sample.
2. Install the [Cloud Code plugin](https://docs.cloud.google.com/code/docs/intellij/install#installing) if you haven't already.

<br />

## Creating a service

Cloud Code comes with a collection of
[code sample](https://github.com/GoogleCloudPlatform/cloud-code-samples#readme)
templates to get you started quickly. To create a new service using an existing
sample:

1. In your IDE, open **File** \> **New Project** and then select **Cloud Code: Cloud Run**.
2. Select the programming language for your sample application and then click **Next** . ![Creating a service from a list of existing sample apps](https://docs.cloud.google.com/static/code/docs/intellij/images/cccr-new-app.png)
3. Name your project and then click **Finish**.

   Cloud Code clones the sample application, opens your newly
   created project for use, and creates the necessary Cloud Run
   run configurations.
4. If you chose a Java sample application, when prompted, click
   **Load Maven project**.

   ![Maven build scripts found notification - choose Load Maven Project, Skip, or Help](https://docs.cloud.google.com/static/code/docs/intellij/images/mavensync.png)

You can now run your Hello World service. Cloud Code watches your
file system for changes so that you can edit and rerun your service in near real
time.

## Deploying your service to Cloud Run

To deploy your service, follow these steps:

1. Choose the automatically created run configuration, **Cloud Run: Deploy**, from the Run/Debug configurations selector in the Navigation bar.
2. Click ![run action icon](https://docs.cloud.google.com/static/code/docs/intellij/images/run-action-icon.png) **Run**. This brings up the Edit configuration window.
3. Set your Google Cloud project ID.
4. Choose a region for your deployment platform.

   This quickstart uses the default platform option, **Cloud Run
   (fully managed)**, as the Deployment Platform.
5. Click **Run**.

6. View your running service by following the URL displayed in the
   **output window**.

7. You can also view the status of your service (metrics, revision details,
   and more) by following the logs URL displayed in the output window.

   ![Viewing the status of your service in the Google Cloud console](https://docs.cloud.google.com/static/code/docs/intellij/images/cccr-view-logs.png)

## Viewing resource status

To view the status of your running service's resources, follow these steps:

1. Navigate to the Cloud Run Explorer. It can be accessed from
   the sidebar panel on the right.

   ![Cloud Run explorer tab highlighted on the right hand-side panel](https://docs.cloud.google.com/static/code/docs/intellij/images/cloud-run-explorer.png)
2. To display a service or revision's properties, click the service or revision
   in the explorer.

   ![Cloud Run explorer open with a service selected and its properties displayed below](https://docs.cloud.google.com/static/code/docs/intellij/images/service-properties.png)
3. To view a revision's logs, right-click the revision and then click **View Cloud Logs**.

   ![Right-click a revision to view its logs](https://docs.cloud.google.com/static/code/docs/intellij/images/view-service-logs.png)

## Cleaning up

If you created a project for this quickstart, be sure to delete it to avoid
unnecessary charges:

1. Go to the Projects page in the Google Cloud console:

   [Go to the Projects page](https://console.cloud.google.com/project)
2. Select the project you created for this quickstart and then click
   **Delete**.

   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 doesn't charge when the service isn't in use, you might still be [charged for storing the container image in Artifact Registry](https://cloud.google.com/artifact-registry/pricing). To delete your image, follow the steps in [Deleting images](https://docs.cloud.google.com/artifact-registry/docs/docker/manage-images#deleting_images).
- **Cloud Run service:** To delete a Cloud Run service, navigate to Cloud Run in the Google Cloud console using the navigation menu. Select the service you'd like to delete and then click **Delete**.

## Clean up


To avoid incurring charges to your Google Cloud account for
the resources used on this page, follow these steps.

## What's next

- Add [Google Cloud APIs and client libraries](https://docs.cloud.google.com/code/docs/intellij/client-libraries) to your project.
- Customize your run configurations with [advanced settings](https://docs.cloud.google.com/code/docs/intellij/deploying-a-cloud-run-app).
- Try creating and [running a Kubernetes application with
  Cloud Code](https://docs.cloud.google.com/code/docs/intellij/deploy-kubernetes-app).