Azure configuration settings and Microsoft.WindowsAzure.CloudConfigurationManager

北城以北 提交于 2019-12-17 20:03:50

问题


Apparently Microsoft.WindowsAzure.CloudConfigurationManager.GetSettings will start by looking in ServiceConfiguration.*.cscfg and then fall back to web.config and app.config.

But - what format should this be in web/app .config?

E.g. to get Microsoft.WindowsAzure.CloudConfigurationManager.GetSettings("Foo") to pick up from app.config what would the XML look like?


回答1:


It will just be an appSettings key/value.

<configuration>
  <appSettings>
    <add key="Foo" value="AzureSetting"/>
  </appSettings>
</configuration>



回答2:


You will need to add the settings to the ServiceDefinition.csdef and 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>

ex: 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>


来源:https://stackoverflow.com/questions/11548301/azure-configuration-settings-and-microsoft-windowsazure-cloudconfigurationmanage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!