Deploy a service in Cloud Code for VS Code

This page shows you how to deploy a service to Cloud Run using Cloud Code for VS Code.

Deploying a service to Cloud Run

To deploy your service to Cloud Run:

  1. Open the Command Palette (press Ctrl/Cmd+Shift+P) and then run the Deploy to Cloud Run command.

  2. In the Deploy to Cloud Run pane, set your Google Cloud project.

  3. Select a preexisting service or create a new one.

  4. If you're creating a new service, choose your platform preferences under Deployment Platform, either Cloud Run (fully managed) or Cloud Run for Anthos. For help choosing the best option for your development needs, see the Choosing your platform guide.

  5. If you selected Cloud Run (fully managed), choose a region to deploy to. If you selected Cloud Run for Anthos, configure the Kubernetes cluster information.

  6. (Optional) To specify additional settings like service account, environment variables, and SQL connections, expand the Advanced revision settings section.

    The following environment variables are automatically added to the running containers:

    Name Description Example
    PORT The port your HTTP server should listen on. 8080
    K_SERVICE The name of the Cloud Run service being run. hello-world
    K_REVISION The name of the Cloud Run revision being run. hello-world.1
    K_CONFIGURATION The name of the Cloud Run configuration that created the revision. hello-world

  7. Under Build environment, specify whether to build locally or using Cloud Build.

    If you're using an Apple machine that uses M-Series silicon, you must use Cloud Build to deploy to Cloud Run which only supports x86 images (this can incur charges). Cloud Code helps you build x86 images using Cloud Build. For more information, see Cloud Code support for Apple M series silicon.

  8. Specify your builder (Docker or Buildpack) and its settings.

  9. After you define your preferred settings, click Deploy.

    Cloud Code for VS Code builds your image, pushes it to the registry, and deploys your service to Cloud Run. Your service is now live!

  10. View your running service by following the URL displayed in the webview.

    You can also view details of your running service by clicking the Show Detailed Logs button and looking through your verbose logs in the output window.

    URL of the running service displayed in Deploy to Cloud Run UI and Show detailed logs button underneath

  11. After your session completes, you can use the following contextual menu commands:

    • Open Deployment Logs: Open the application logs of a specific deployment with the Cloud Code Logs Explorer
    • Open Service URL: Open the application service URL of a specific service in a web browser
  12. If you've turned off watch mode in your launch configuration and you want to make changes to your application and rebuild and redeploy the application, in the Development sessions pane, pause on the run action and then click Rebuild and redeploy icon Rebuild and redeploy the application.

Getting Support

To send feedback, report issues on GitHub, or ask a question on Stack Overflow.