Windows Azure: how do I expose a configuration setting as an environment variable?
azure, configuration, environment-variables
Solution
Are you missing the declaration of that setting? I don't see the appropriate element in your `.csdef`, something like `<ConfigurationSettings><Setting name="AZURE_STORAGE_ACCOUNT"/></ConfigurationSettings>`. You need one of those in your `.csdef`, and then you still want the one in your `.cscfg` that includes the value.
If you're using Visual Studio, it should edit both files for you if you use its property view. (Just double click the role and then click around to get to config settings and add a new one.)
Problem
I tried adding this to my ServiceDefinition.csdef file: ``` <WorkerRole ...><Runtime><Environment> <Variable name="AZURE_STORAGE_ACCOUNT"> <RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/ConfigurationSettings/ConfigurationSetting[@name='AZURE_STORAGE_ACCOUNT']/@value" /> </Variable> </Environment></Runtime></WorkerRole> ``` And I set the configuration setting in my ServiceConfiguration.Cloud.cscfg file: ``` <Role name="WorkerRole"> <ConfigurationSettings> <Setting name="AZURE_STORAGE_ACCOUNT" value="<secret stuff>" /> </ConfigurationSettings> </Role> ``` But I got the following error when I run `cspack`: ``` CloudServices091 : The '/RoleEnvironment/CurrentInstance/Configur ationSettings/ConfigurationSetting[@name='AZURE_STORAGE_ACCOUNT']/@value' is an invalid xpath expression. ```