A joint project of the Azure Web Role role and a movie clip without seeing app.config when deployed

I am implementing a combined web / workplace role script as described here , where you simply add the following to your work role:

public override void Run() { // This is a sample worker implementation. Replace with your logic. Trace.WriteLine("WorkerRole1 entry point called", "Information"); while (true) { Thread.Sleep(10000); Trace.WriteLine("Working", "Information"); } } 

The problem, as noted in the comments on the post, is that this workflow cannot read web.config, so you need to add app.config. It is also noted that app.config is not automatically deployed.

So my question is: how do I set up my project so that the app.config application is deployed?

I added app.config to my project, set the build action to “Content” and “Always Copy”

THIS WORK IN THE EMULATOR, but not when deployed to Azure.

Note. I noticed that the projectname.dll.config file was created in the emulator, but not when deployed to Azure. I am using VS2010, Windows Azure Tools 2011

I know that some will suggest using a .cscfg file, but many of my components get their settings from web.config / app.config: Elmah, a client for handling transient errors, diagnostics, email, etc.

+6
source share
3 answers

Please read this blog post carefully. This explains in detail what happens on Windows Azure Web Role with full IIS.

What you need to do is add the WaIISHost.exe.config file (with copy to output = copy always). And put all the configurations you need in this file. This is because your code (RoleEntryPoint) lives in the WaIISHost.exe process, and not in the pdojectName.dll process.

+3
source

To use the Azure SDK 1.8 and deploy the web worker role from Visual Studio using publishing, I had to include a configuration file called. ProjectName.Dll.config with my settings. The app.config configuration is not picked up by the web role when working in azure windows. The app.config file is not converted to the ProjectName.Dll.config file and is automatically added to the bin folder of the deployment package, so you need to create it manually and configure it to always be copied.

+3
source

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.

+2
source

Source: https://habr.com/ru/post/924202/


All Articles