15
votes

I have a Web site running on Azure App Services. It has a WebJob that deploys with it, and thus gets put in it's App_data folder once deployed.

If I FTP to the wwwroot/app_data folder of my site once deployed, the app.config file has none of the configured settings that I set up in the "Application Settings Blade" in the Azure portal. The settings are changed in my web.config for the Website though.

The most curious thing is that when I run the WebJob, the log output indicates that the correct settings are being used!!

So as per my title, does the WebJob use the App.Settings file once deployed or does it use some kind of in-memory copy of the app-settings from the azure portal, or does it use what is in the web.config of the website?

Just to pre-emt a possible question, I know that the app.settings gets renamed to myappname.exe.config

3

3 Answers

18
votes

Here is how it works:

  • Azure doesn't run your WebJob in-place, but instead copies it to a temp folder (to avoid locking it in-place when it runs).
  • As part of this copying process, the App Settings are transformed in the temp files. That's why you don't see the changes in the config file.
  • Azure listens to file changes in your WebJob files, so if you modify your config file, Azure copies/transforms the files again and restarts the WebJob.
2
votes

Mark Seeman elaborates on this:

As far as I can tell, it attempts to read configuration settings in this prioritized order:

1.Try to find the configuration value in the Web Site's >online configuration (see below).

2.Try to find the configuration value in the .cscfg file.

3.Try to find the configuration value in the app.config file or web.config file.

(Read the whole investigation here: http://blog.ploeh.dk/2014/05/16/configuring-azure-web-jobs/)

1
votes

David Ebbo answer is perfectly right.

Just wanted to state that you can also run web jobs in place by a using a parameter in settings.job:

{ 
    "is_in_place": true
}

Details can be found in Kudu docs:
https://github.com/projectkudu/kudu/wiki/WebJobs#webjob-working-directory