clean up the setting of env vars and  better support azure weirdness