Configuring your service for development
To run your service locally, you'll need to specify your configuration first:
- Select Run on Cloud Run Emulator using the Command Palette (accessible with Ctrl/Cmd+Shift+P).
This launches the Run/Debug on Cloud Run Emulator dialog where you can set the specifications for your configuration.
Optional: Customizing your configuration
In addition to the settings above, you can specify advanced settings like a service account and environment variables, using the Advanced settings section.
The following environment variables are automatically added to the running containers:
|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|
Running your service locally
- After you define your preferred settings, you can click Run.
Monitor the status of your deployment in the output window.
Once completed, you can view your running service by following the URL displayed in the output window.
Switch to the detailed Cloud Run view within the output window to view verbose logs.
After your session completes, additional contextual menu options are available to monitor your application and its resources via the Cloud Code status bar, including:
- Open Deployment Logs: Open the application logs of a specific deployment with the Cloud Code Logs Viewer
- Open Service URL: Open the application service URL of a specific service in a web browser
Turn on/off watch mode: Toggle watch mode for the current session (not available for debug sessions)
To stop your deployment, you can click the Stop button in the action bar for your current deployment.
If your code includes potentially sensitive data like API keys, passwords, and certificates, it is recommended you store them as secrets. With Cloud Code, you can securely store these secrets in Secret Manager and programmatically fetch them when you need them. For a detailed look at how you can create and manage secrets with Cloud Code, refer to the Secret Manager guide.
Customizing an existing launch.json configuration
To configure how your service is run, you can customize your skaffold.yaml
as well as specify the following fields in your
- watch: Watches for changes in the workspace when in Run mode and reruns the service. Unless explicitly set to false, true by default.
- build: Specify the builder (Docker, buildpacks) to build your images with.
- image: Specify the name of the image you'd like to use.
- service: Specify the Cloud Run service you'd like to use.
- debug: Specify preferred debug settings such as remote path mapping to map a local path to a path on the remote container.