【问题标题】:Web job app.config not reflecting in azure portal configure tabWeb 作业 app.config 未反映在 Azure 门户配置选项卡中
【发布时间】:2015-10-30 03:18:27
【问题描述】:

我创建了一个 Web 作业并使用 VS2013 将其发布到现有的 Web 应用程序。但是我的网络作业 app.config 的配置值没有出现在 azure 门户配置选项卡中。我不想在 azure 门户中手动输入配置值,而且我不希望我的网站具有这些值。有什么想法吗?

我还尝试使用 powershell cmdlet New-AzureWebsiteJob 进行部署,但它不接受应用配置。我看到的唯一选项是使用 powershell 读取 app.config 并使用 Set-AzureWebSite cmdlet 推送配置值。

【问题讨论】:

  • 您是对的,在 Publish for WebJobs 期间设置应用程序的应用程序设置不是一个选项。我会将这些反馈反馈给团队。我认为您的 PowerShell 脚本听起来像是解决您的问题的合乎逻辑的解决方案。如果您编写 PS 脚本,则应将其发布为答案,以防有人与您处于相同的场景中。
  • 感谢您的快速回复!

标签: azure-webjobs azure-webjobssdk


【解决方案1】:

好的,这就是我解决它的方法。很高兴听到是否有更好的解决方案。

$path = "<web job app.config file path>"
$xml = [xml](Get-Content $path)
$appSettings = @{}
$connectionStrings = (Get-AzureWebsite -Name "MyWebApp").ConnectionStrings

$xml.configuration.connectionStrings.add | ForEach-Object { $connectionStrings.Add(@{Name=$_.name; ConnectionString=$_.connectionString; Type="custom"})}

$xml.configuration.appSettings.add | ForEach-Object { $appSettings.Add($_.key, $_.value) }

Set-AzureWebsite -Name "MyWebApp" -ConnectionStrings $connectionStrings -AppSettings $appSettings

【讨论】:

    【解决方案2】:

    App.Config 或 Web.Config 中的设置根本不会显示在门户中。但是门户中的任何设置都将覆盖这些文件中的任何设置。因此,如果您不想在门户中设置它们,则根本不需要。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-31
      • 2020-09-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多