Azure WebJob 是否在部署后查看 app.config

Does Azure WebJob look at the app.config once deployed

我在 Azure 应用服务上有一个网站 运行ning。它有一个与它一起部署的 WebJob,因此一旦部署就被放入它的 App_data 文件夹中。

如果我 FTP 部署到我站点的 wwwroot/app_data 文件夹,app.config 文件有 none 我在 "Application Settings Blade" 在 Azure 门户中。不过,我的 web.config 网站设置已更改。

最奇怪的是,当我 运行 WebJob 时,日志输出表明正在使用正确的设置!!

因此,根据我的标题,WebJob 是在部署后使用 App.Settings 文件,还是使用来自 Azure 门户的 app-settings 的某种 in-memory 副本,或者它使用网站 web.config 中的内容吗?

只是为了 pre-emt 一个可能的问题,我知道 app.settings 被重命名为 myappname.exe.config

Mark Seeman 对此进行了详细说明:

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.

(在此处阅读整个调查:http://blog.ploeh.dk/2014/05/16/configuring-azure-web-jobs/

工作原理如下:

  • Azure 不会 运行 您的 WebJob 就地,而是将其复制到临时文件夹(以避免在 运行 时将其锁定就地)。
  • 作为此复制过程的一部分,应用程序设置会在临时文件中进行转换。这就是为什么您看不到配置文件中的更改。
  • Azure 侦听您的 WebJob 文件中的文件更改,因此如果您修改配置文件,Azure copies/transforms 文件会再次启动并重新启动 WebJob。

David Ebbo 的回答完全正确。

只是想说明您还可以通过使用 settings.job 中的参数 运行 网络作业:

{ 
    "is_in_place": true
}

可以在 Kudu 文档中找到详细信息:
https://github.com/projectkudu/kudu/wiki/WebJobs#webjob-working-directory