vscode-extensionsgoogle-cloud-runcloud-run-emulator

Google Cloud code in VS Code : How to set environment variables after launch.json is created?


While using Google Cloud Code extension in VS Code, how to setup environment variables after launch.json is created by "Run on Cloud Run Emulator" command?

Reference: https://cloud.google.com/code/docs/vscode/develop-service

#cloud-code-vscode


Solution

  • I ended up clearing launch.json file and redoing "Run on Cloud Run Emulator" command in vscode.

    I entered the key:value pairs in Environment Variables section in "Advanced Service Settings"

    Screenshot shows a text box for environment variables to store them as key:value pairs, one per line.

    This added an env section in launch.json with the values.

                "service": {
                    "name": "abc-cloud-run",
                    "containerPort": 8080,
                    "env": [
                        {
                            "name": "PORT",
                            "value": "8080"
                        },
                        {...}