How to override an ASP.NET Core configuration array setting using environment variables

假如一个appsettings.json文件, 需要在环境变量中添加配置覆盖AppSettings/EnabledWorkspace节:

{
  "Logging": {
    "LogLevel": {
      "Default": "Warning",
      "System": "Information",
      "Microsoft": "Information"
    }
  },
  //Basic Auth for Tapd api
  "AppSettings": {
    "EnabledWorkspace": [ "58645295", "44506107", "84506239" ]
  }
}

这样配置:

AppSettings__EnabledWorkspace__0 = 58645295
AppSettings__EnabledWorkspace__1 = 44506107
AppSettings__EnabledWorkspace__2 = 84506239

 

Refer to:

How to override an ASP.NET Core configuration array setting using environment variables

Configuration in ASP.NET Core