首页 > 解决方案 > 天蓝色应用程序设置 - 如何添加嵌套项

问题描述

我在 azure 上有一个运行 .net core api 的 appservice。

在我的 appsettings.json 文件中,我有一个类似于以下内容的部分:

"Serilog": {    
"LevelSwitches": { "$controlSwitch": "Information" },
"MinimumLevel": {
  "ControlledBy": "$controlSwitch",
  "Override": {
    "Microsoft": "Warning",
    "System": "Warning"
  }
},
"WriteTo": [
  {
    "Name": "File",
    "Args": {
      "path": "LOGS\\log.json",
      "rollingInterval": "Day",
      "formatter": "Serilog.Formatting.Json.JsonFormatter, Serilog"
    }
  },      
  {
    "Name": "Seq",
    "Args": {
      "serverUrl": "https://MyLoggingServer",
      "apiKey": "AAAAAAAAAAAAAAAAA",
      "controlLevelSwitch": "$controlSwitch"          
    }
  }
]}

在 azure 门户的 azure appsetting 部分中,我不确定如何设置 apiKey,在其他更简单的设置中,我在 appsettings.json 中有另一个部分

 "CustomSettings": {    
    "MySpecificSetting": "ABCDEFG",    
  }

然后在 azure 门户中,我可以通过执行以下操作来设置设置

CustomSettings:MySpecificSetting 

但我不确定这种语法如何允许我访问 writeTo 数组中的特定项目

谢谢你的帮助

标签: azureazureportal

解决方案


你使用 : 嵌套:keys:down

您使用 __ 来嵌套 __keys__down 的跨平台(因为 : 对 *nix 中的 envar 不利)

关键是它不是天蓝色做任何特别的事情......天蓝色只是从那里为应用程序设置环境变量。它是 .net 核心配置,它实际上是在查看环境变量并做一些特殊的事情,请参阅https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/index?tabs=basicconfiguration&view=aspnetcore-3.1#hierarchical -配置数据https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/index?tabs=basicconfiguration&view=aspnetcore-3.1#environment-variables-configuration-provider


推荐阅读