From 0c5d5f1dd5af26a443e9b063444c85280c518bd3 Mon Sep 17 00:00:00 2001 From: Alan Ren Date: Thu, 18 Jul 2019 10:40:07 -0700 Subject: [PATCH] pass environment variables to Notebooks from ADS (#6389) * get the new environment variables for notebook * comments * Update serverInstance.ts address comments * be more specific when taking env variables --- extensions/notebook/src/jupyter/serverInstance.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/extensions/notebook/src/jupyter/serverInstance.ts b/extensions/notebook/src/jupyter/serverInstance.ts index 00309257ee..b58db7fef1 100644 --- a/extensions/notebook/src/jupyter/serverInstance.ts +++ b/extensions/notebook/src/jupyter/serverInstance.ts @@ -377,8 +377,13 @@ export class PerNotebookServerInstance implements IServerInstance { return childProcess; } - private getEnvWithConfigPaths(env: {}): any { + private getEnvWithConfigPaths(env: { [key: string]: string }): any { + // Take the variables that starts with 'AZDATA_NB_VAR_' from process.env object so that we can pass information to notebooks let newEnv: { [key: string]: string } = Object.assign({}, env); + Object.keys(process.env).filter(key => key.startsWith('AZDATA_NB_VAR_')).forEach(key => { + newEnv[key] = process.env[key]; + }); + newEnv['JUPYTER_CONFIG_DIR'] = this.instanceConfigRoot; newEnv['JUPYTER_PATH'] = this.instanceDataRoot; return newEnv;