Windows Azure: how do I expose a configuration setting as an environment variable? Windows Azure: how do I expose a configuration setting as an environment variable? azure azure

Windows Azure: how do I expose a configuration setting as an environment variable?


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.)


The configuration seems to be correct. It would be better if you can make sure you’re using the latest SDK. The xPath feature is available in Windows Azure SDK 1.5 and later.

Best Regards,

Ming Xu.


I have tried out different options mentioned at blogs, like including the setting in both .cscfg and .csdef. But, it doesn't seem to work.Also, other Xpath queries like

      <RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/@id"/>

work correctly.

Finally, I figured out that the variable name used was different:

In cscfg I had :

<Setting name="WFFEPeriodicRestartTime" value="168:00:00" />

in csdef I had :

  <ConfigurationSettings>      <Setting name="PeriodicRestartTime" />   </ConfigurationSettings>

........

 <Variable name="PeriodicRestartTime">            <RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/ConfigurationSettings/ConfigurationSetting[@name='WFFEPeriodicRestartTime']/@value" />  </Variable>

Changed csdef to :

<ConfigurationSettings>      <Setting name="WFFEPeriodicRestartTime" />   </ConfigurationSettings>

........

 <Variable name="WFFEPeriodicRestartTime">            <RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/ConfigurationSettings/ConfigurationSetting[@name='WFFEPeriodicRestartTime']/@value" />          </Variable>

It seems to work correctly now