【问题标题】:applying appsettings.json on azure webapp在 azure webapp 上应用 appsettings.json
【发布时间】:2017-03-10 01:02:16
【问题描述】:

我想在我的 Azure Web 应用的应用设置下设置一个键值对。

我已经尝试了许多不同的方法来在我的 appsettings.json 上设置它,但是它们都不起作用。

这是我尝试过的:

测试 1

{
  "APPSETTING_WEBSITE_TIME_ZONE": "E. South America Standard Time",
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Warning"
    }
  }
}

还有

{
  "AppSettings:WEBSITE_TIME_ZONE": "E. South America Standard Time",
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Warning"
    }
  }
}

另一个测试

{
  "AppSettings": {
    "WEBSITE_TIME_ZONE": "E. South America Standard Time"
  },
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Warning"
    }
  }
}

【问题讨论】:

  • 不确定我是否关注。 Web App 的应用设置会覆盖 appsettings.json 中的设置,而不是相反。这些不会在那里显示。
  • 其实用Kudu检查,我在azure上的App Settings变量其实是环境变量。但无论如何,我想直接从 appsettings 设置它们,而不是通过门户。

标签: azure asp.net-core azure-web-app-service


【解决方案1】:

一般情况下,您可以在appsettings.json 中设置应用设置。详情请见doc

这里的问题是您尝试设置 WEBSITE_TIME_ZONE,这是 Azure Web Apps 识别的特殊设置。要使其生效,必须将其设置为 Azure 应用设置。其他各种特殊的WEBSITE_ 设置也是如此(例如,参见列表here)。

【讨论】:

  • 所以,我需要创建一个 .deployment 文件并设置为 WEBSITE_TIME_ZONE=Eastern Standard Time ?
  • 不,根据我的回答,您需要为此使用 Azure 应用程序设置。其他都行不通。
  • 如果我只是在 appsettings.json 中包含 AzureAppSetting(如我的第三个 json 示例)并定义 WEBSITE_TIME_ZONE 它会起作用吗?我一直在寻找样品,但找不到。
  • 不,这行不通。你需要一个真正的 Azure 应用设置
  • 门户或 Azure ARM API。不是通过文件。
猜你喜欢
  • 1970-01-01
  • 2016-08-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-31
  • 1970-01-01
  • 2021-10-08
  • 1970-01-01
相关资源
最近更新 更多