13

显然, Microsoft.WindowsAzure.CloudConfigurationManager.GetSettings将从查看 ServiceConfiguration.*.cscfg 开始,然后返回到 web.config 和 app.config。

但是 - web/app .config 中应该采用什么格式?

例如,Microsoft.WindowsAzure.CloudConfigurationManager.GetSettings("Foo")从 app.config 中获取 XML 会是什么样子?

4

2 回答 2

13

它只是一个appSettings 键/值

<configuration>
  <appSettings>
    <add key="Foo" value="AzureSetting"/>
  </appSettings>
</configuration>
于 2012-07-18T18:54:36.893 回答
1

您需要将设置添加到 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>
于 2012-07-18T19:51:11.707 回答