Nelu
Nelu

Reputation: 18790

How to set environment variables when using the VSCode Cloud Code extension?

I know how to set environment variables in Cloud Run using the web console (https://cloud.google.com/run/docs/configuring/environment-variables#setting), but how can I do this locally in the emulator when using VSCode with the Cloud Code extension?

I've only seen how to do it on the initial run (https://youtu.be/EtMIEtLQNa0?t=307) but not on subsequent runs. The advanced settings window no longer shows up when I rerun the command. enter image description here

UPDATE: There's also this explanation (of the same thing) here https://cloud.google.com/code/docs/vscode/develop-service, but I think this adds the settings to launch.json(?) which gets committed to git.

I tried adding a .env file but process.env.MY_VARIABLE is undefined.

Upvotes: 0

Views: 987

Answers (1)

ChaseMor
ChaseMor

Reputation: 21

Unfortunately, even when you use the advanced settings form on the initial run, it will save the environment variables to the launch.json. Pulling in variables from a specified file other than launch.json at runtime is not currently a supported feature in Cloud Code for VS Code.

Upvotes: 2

Related Questions