I am using Azure SDK 2.0 and OS Family 3 and am very confused about this. So I created an MVC 4.0 website with all 4 configuration files offered in various answers. I.e:
- Web.config
- App.config
- WaIISHost.exe.config
- [AssemblyName] .dll.config
For all but Web.config, set to "Copy if new."
In the configs file, I wrote:
<appSettings> <add key="AppSettingFile" value="[NameOfConfigFile]"/> </appSettings>
In WebRole.cs, I have the following code:
public class WebRole : RoleEntryPoint { public override void Run() { string appSetting = ConfigurationManager.AppSettings["AppSettingFile"] ?? "No config file found"; Trace.TraceInformation("Config file: " + appSetting); while (true) { ... } } }
The result when deploying with 4 .config files is: "Configuration file: App.config . So App.config should be the answer, right?
Wrong! The result when deployed using Web.config and App.config only is: "Configuration file: configuration file not found . " Hmm spell.
Deployment result using Web.config, App.config and [AssemblyName] .dll.config: "Configuration file: [AssemblyName] .dll.config" . So [AssemblyName] .dll.config should be the answer, right?
Wrong! The result when deployed only with Web.config and [AssemblyName] .dll.config: "Configuration file: configuration file not found . " WTF!
The result when deploying only with Web.config and WaIISHost.exe.config is: "Configuration file: configuration file not found . "
The result when deployed using Web.config, App.config, and WaIISHost.exe.config: "Configuration file: configuration file not found . " WTF!
So, I came to the conclusion that you need to have 3 or 4 configuration files in order to configure the role of a working web project.
This is clearly a mistake. Personally, I think the intention of MS was to switch from WaIISHost.exe.config to App.config (to align with work roles and .NET in general). But App.config is only used when all 4 .config files exist.
So, at the moment I have Web.config and both App.config and [AssemblyName] .dll.config, and they contain exactly the same.
We hope that with Azure SDK 2.x we can only use App.config and Web.config.