If you don't have a.vscode/launch.jsonfile defined, theRun/Debug on Cloud Run Emulatordialog lets you configure your launch and
then saves your settings to.vscode/launch.json. If you have a.vscode/launch.jsonfile configured, you can edit the file directly.
To run your service locally, specify your configuration:
Open the command palette (pressCtrl/Cmd+Shift+Por clickView>Command Palette) and then run theRun on Cloud Run Emulatorcommand.
In the Run/Debug on Cloud Run Emulator dialog, set the
specifications for your configuration:
Only locally-installed build tools are available for Cloud Run
Emulator
ChooseDockerorBuildpacksas your builder and then specify the
source
(Optional) To specify any environment variables to pass to the running
containers, expandAdvanced Build Settingsand then click to specify
key-value pairs.
Name
Description
Example
PORT
The port for the HTTP server to 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
(Optional) To specify Cloud SQL connections, expandAdvanced Service Settings, clickConnections, and then specify one
Cloud SQL connection per line.
(Optional) Check theMake the service accessible from other devices on the local networkoption.
(Optional) If you only want to rebuild and run your service manually,
instead of automatically when you make a change, clear theAutomatically re-build and re-run on changesoption.
Running your service locally
After you define your preferred settings, run your service by clickingRun.
Monitor the status of your deployment in theoutput window.
After deployment is complete, you can view your running service by opening
the URL displayed in the output window.
To view verbose logs, switch to the detailed Cloud Run view
in the output window.
After your session completes, right-click to use the following commands:
View Logs:Open the application logs of a specific deployment with the
Cloud Code logs explorer.
Open URL:Open the application service URL of a specific
service in a web browser.
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,
click the Cloud Code status bar and then clickTurn on watch mode.
To stop your deployment, you can click theStopbutton in the action bar
for your current deployment.
Storing secrets
If your code includes potentially sensitive data like API keys, passwords, and
certificates, storing them as secrets can help secure them. The
Cloud Code Secret Manager integration lets you securely
store these secrets and fetch them programmatically. For a detailed look at how
you can create and manage secrets with Cloud Code, see
theSecret Manager guide.
Customizing an existing launch.json configuration
The Cloud Code plugin updates thelaunch.jsonconfiguration file
automatically when you choose a run action. To further customize how your
service is run, you can specify the following fields in your.vscode/launch.jsonfile:
watch: Watches for changes in the workspace and reruns
the service. True by default.
The following sample shows watch set totrue:
"watch":true,
build: Specify the builder
(Docker,
jibMaven, jibGradle, orbuildpacks)
to build your images with.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eYou can develop services locally using a Cloud Run emulator before deploying them to Cloud Run, with configuration options accessible via the command palette or by editing the \u003ccode\u003e.vscode/launch.json\u003c/code\u003e file directly.\u003c/p\u003e\n"],["\u003cp\u003eThe Run/Debug on Cloud Run Emulator dialog allows you to configure build settings like selecting Docker or Buildpacks, setting environment variables, specifying Cloud SQL connections, and enabling network accessibility.\u003c/p\u003e\n"],["\u003cp\u003eAfter deploying, you can monitor the service status in the output window, access detailed logs, and open the service URL, with the ability to turn watch mode on or off to control automatic rebuilding and redeployment.\u003c/p\u003e\n"],["\u003cp\u003eSensitive data can be secured by storing them as secrets using Cloud Code Secret Manager integration.\u003c/p\u003e\n"],["\u003cp\u003eYou can further customize the service launch by modifying the \u003ccode\u003e.vscode/launch.json\u003c/code\u003e configuration file, allowing adjustments to build settings, image names, service parameters, and debug options like source file mapping.\u003c/p\u003e\n"]]],[],null,["# Develop a Cloud Run service locally in Cloud Code for Cloud Shell\n\nBefore you\n[deploy a service to Cloud Run](/code/docs/shell/deploy-service),\nyou can develop it locally using a Cloud Run emulator.\n\nConfiguring your service for development\n----------------------------------------\n\nIf you don't have a `.vscode/launch.json` file defined, the\n**Run/Debug on Cloud Run Emulator** dialog lets you configure your launch and\nthen saves your settings to `.vscode/launch.json`. If you have a\n`.vscode/launch.json` file configured, you can edit the file directly.\n\nTo run your service locally, specify your configuration:\n\n1. Open the command palette (press `Ctrl`/`Cmd`+`Shift`+`P` or click **View** \\\u003e **Command Palette** ) and then run the **Run on Cloud Run Emulator** command.\n2. In the Run/Debug on Cloud Run Emulator dialog, set the\n specifications for your configuration:\n\n - Only locally-installed build tools are available for Cloud Run Emulator\n - Choose **Docker** or **Buildpacks** as your builder and then specify the source\n - (Optional) To specify any environment variables to pass to the running containers, expand **Advanced Build Settings** and then click to specify key-value pairs.\n\n - (Optional) To specify Cloud SQL connections, expand **Advanced Service Settings** , click **Connections**, and then specify one Cloud SQL connection per line.\n - (Optional) Check the **Make the service accessible from other devices on the local network** option.\n - (Optional) If you only want to rebuild and run your service manually, instead of automatically when you make a change, clear the **Automatically re-build and re-run on changes** option.\n\nRunning your service locally\n----------------------------\n\n1. After you define your preferred settings, run your service by clicking\n **Run**.\n\n2. Monitor the status of your deployment in the **output window**.\n\n After deployment is complete, you can view your running service by opening\n the URL displayed in the output window.\n3. To view verbose logs, switch to the detailed Cloud Run view\n in the output window.\n\n4. After your session completes, right-click to use the following commands:\n\n - **View Logs:** Open the application logs of a specific deployment with the Cloud Code logs explorer.\n - **Open URL:** Open the application service URL of a specific service in a web browser.\n5. If you've turned off watch mode in your launch configuration and you want to\n make changes to your application and rebuild and redeploy the application,\n click the Cloud Code status bar and then click\n **Turn on watch mode**.\n\n6. To stop your deployment, you can click the **Stop** button in the action bar\n for your current deployment.\n\nStoring secrets\n---------------\n\nIf your code includes potentially sensitive data like API keys, passwords, and\ncertificates, storing them as secrets can help secure them. The\nCloud Code Secret Manager integration lets you securely\nstore these secrets and fetch them programmatically. For a detailed look at how\nyou can create and manage secrets with Cloud Code, see\n\n\nthe [Secret Manager guide](/code/docs/shell/secret-manager).\n\n\nCustomizing an existing launch.json configuration\n-------------------------------------------------\n\nThe Cloud Code plugin updates the `launch.json` configuration file\nautomatically when you choose a run action. To further customize how your\nservice is run, you can specify the following fields in your\n`.vscode/launch.json` file:\n\n- **watch**: Watches for changes in the workspace and reruns\n the service. True by default.\n\n The following sample shows watch set to `true`: \n\n \"watch\": true,\n\n- **build** : Specify the builder\n ([Docker](https://skaffold.dev/docs/pipeline-stages/builders/docker/),\n jibMaven, jibGradle, or\n [buildpacks](https://skaffold.dev/docs/pipeline-stages/builders/buildpacks/))\n to build your images with.\n\n The following sample shows a Docker builder: \n\n \"build\": {\n \"docker\": {\n \"path\": \"Dockerfile\"\n }\n },\n\n The following sample shows a buildpack builder: \n\n \"build\": {\n \"buildpacks\": {\n \"path\": \"src/requirements.txt\",\n \"builder\": \"gcr.io/buildpacks/builder:v1\"\n }\n },\n\n- **image**: Specify the name of the image to use.\n\n The following sample shows how to specify an image name: \n\n \"image\": \"hello-world\",\n\n- **service**: Specify the Cloud Run service to use.\n\n The following sample shows how to specify a service name, port, and resource\n limits: \n\n \"service\": {\n \"name\": \"hello-world\",\n \"containerPort\": 8080,\n \"resources\": {\n \"limits\": {\n \"memory\": \"256Mi\"\n }\n }\n },\n\n- **debug**: Specify debug settings such as remote path mapping to map a local\n path to a path on the remote container.\n\n The following sample shows a debug section that indicates the source files'\n location: \n\n \"debug\": {\n \"sourceFileMap\": {\n \"${workspaceFolder}\": \"/app\"\n }\n }"]]