您需要將設置添加到ServiceDefinition.csdef中和ServiceConfiguration.cscfg
例如: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>
從你提供的msdn鏈接:「只有appSettings標籤內的配置設置可以是r由CloudConfigurationManager發送。如果你的配置設置在不同的標籤中,調用GetSetting將返回Null。「 – 2015-06-25 10:07:28