node.js - Environment variables not being set when deploying to Azure Cloud Service via Visual Studio -
having few issues environment variables in azure cloud services. i'm trying set "node_env" environment variable during deployment via servicedefentition.csdef file.
the variable read in node.js app via process.env.node_env.
the documentation isn't extensive (as appears simple thing do) have been following: link1 link2
the section of servicedefinition file have following:
<?xml version="1.0" encoding="utf-8"?> <servicedefinition name="userapiserver" xmlns="http://schemas.microsoft.com/servicehosting/2008/10/servicedefinition" schemaversion="2015-04.2.6"> <webrole name="userapiwebrole" vmsize="large"> ... <runtime> <environment> <variable name="node_env" value="dev" /> </environment> </runtime> ... </webrole> </servicedefinition>
i've tried numerous variations; setting env variable under startup task instead on runtime, using xpaths configuration settings don't seem creating env variables me.
when messing around xpaths approach did find configuration settings being created on instance, definition file being read.
are there common (or uncommon) gotcha's or hidden details i'm missing because apparently simple i'm having lot of trouble it.
it correct set node_env
variable in web.config
, iisnode.yml
@aidan casey said.
additionally, can leverage pure node.js 3rd part module dotenv. need create file named .env
content:
node_env=production
include , initialize module in nodejs script:
require('dotenv').load();
Comments
Post a Comment