13

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?

Ryan
  • 23,871
  • 24
  • 86
  • 132
  • From the msdn link you provided : "Only configuration settings within the appSettings tag can be read by CloudConfigurationManager. If your configuration settings are within a different tag, calling GetSetting will return Null." – Ognyan Dimitrov Jun 25 '15 at 10:07

2 Answers2

13

It will just be an appSettings key/value.

<configuration>
  <appSettings>
    <add key="Foo" value="AzureSetting"/>
  </appSettings>
</configuration>
SliverNinja - MSFT
  • 31,051
  • 11
  • 110
  • 173
  • Thats what I thought but it didn't work for me. Are you sure with AZURE CloudConfigManager? (just checking before I start digging up) – Ryan Jul 18 '12 at 19:08
  • 1
    Hmmm - ConfigurationManager.AppSettings doesn't work either so obviously something else wrong - Thanks! – Ryan Jul 18 '12 at 19:17
  • One question, if the webrole or worker role refers an assembly ,will CloudconfigurationManager read the appsettings in the app.config of that assembly? – Aravind Oct 03 '12 at 14:17
1

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>
kosmos.ebi
  • 442
  • 2
  • 11
  • No need to do this. From msdn [link](https://msdn.microsoft.com/en-us/LIBRARY/microsoft.windowsazure.cloudconfigurationmanager) in the question : "A .NET application running in an environment outside of Windows Azure usually stores configuration settings in a web.config or app.config file. The CloudConfigurationManager class enables you to read from the appropriate configuration file regardless of the environment in which your code is running. " – Ognyan Dimitrov Jun 25 '15 at 10:08