I have a class library shared between an Azure Worker Role and a ASP.NET Website. A method in the library needs to pull a value from the config to determine if it should send an email or not.
In the ASP.NET site, the setting is in web.config:
<add key="SendEmails" value="true"/>
And in the Azure worker role it is in ServiceConfiguration.Cloud.cscfg:
<Setting name="SendEmails" value="true"/>
What I am trying to do is have my class library be able to access either config setting, depending on what environment it is running under.
Create your own class to retrieve configuration values and in it you’ll have items like this:
RoleEnvironment.IsAvailable will detect is supposed to detect if you’re in the Windows Azure fabric and return true. It will require that you include the Microsoft.WindowsAzure.ServiceRuntime assembly/referrence in your ASP.NET project.
I did a blog post on this topic if you want more information.