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.
To set environment variables when you start a container in the Azure portal, specify them in the Advanced page when you create the container. Under Environment variables, enter NumWords with a value of 5 for the first variable, and enter MinLength with a value of 8 for the second variable.
You can use the Azure portal or the Azure CLI to retrieve past key-values. Sign in to the Azure portal. Select All resources, and select the App Configuration store instance where your key-value are stored. In the Operations menu, select Restore.
Recommended way — use environment variable to read settings. var value = Environment. GetEnvironmentVariable("your_key_here"); The System.
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.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With