显然Microsoft.WindowsAzure.CloudConfigurationManager.GetSettings将首先查看ServiceConfiguration。*。cscfg然后再回到web.config和app.config。
但是 - 这应该是在web / app .config中的格式吗?
E.g。让Microsoft.WindowsAzure.CloudConfigurationManager.GetSettings("Foo")
从app.config中获取XML是什么样的?
答案 0 :(得分:13)
<configuration>
<appSettings>
<add key="Foo" value="AzureSetting"/>
</appSettings>
</configuration>
答案 1 :(得分:1)
您需要将设置添加到ServiceDefinition.csdef和ServiceConfiguration.cscfg
ex:ServiceDefinition.csdef
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="WindowsAzure1" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2012-05.1.7">
<WebRole name="WebRole1" vmsize="Small">
<ConfigurationSettings>
<Setting name="Foo"/>
</ConfigurationSettings>
:
</WebRole>
</ServiceDefinition>
例如:ServiceConfiguration.cscfg
<?xml version="1.0" encoding="utf-8"?>
<ServiceConfiguration serviceName="WindowsAzure1" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="1" osVersion="*" schemaVersion="2012-05.1.7">
<Role name="WebRole1">
<Instances count="1" />
<ConfigurationSettings>
<Setting name="Foo" value="val"/>
</ConfigurationSettings>
</Role>
</ServiceConfiguration>