Azure应用程序设置-如何添加嵌套项目 [英] azure application settings - how to add nested item

查看:114
本文介绍了Azure应用程序设置-如何添加嵌套项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在运行.net核心api的azure上有一个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数组中的特定项目

感谢您的帮助

解决方案

您使用:嵌套:keys:down

关键是它不是azure做任何特殊的事情... azure只是从那里设置应用程序的env vars. .net核心配置实际上是在查看环境变量并做一些特殊的事情,请参见

In azure appsetting section on the azure portal i'm not sure how i would go about setting the apiKey, in other more simple settings i have another section in appsettings.json

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

Then in azure portal i have been able to set the setting by doing the following

CustomSettings:MySpecificSetting 

but i'm not sure how this syntax would allow me to access the specific item in the writeTo array

Thanks for any help

解决方案

you use : to nest:keys:down

the key thing is it's not azure doing anything special... azure just sets env vars for the app from there. it's .net core config that's actually looking at the env vars and doing special things see https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/index?tabs=basicconfiguration&view=aspnetcore-3.1#hierarchical-configuration-data & https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/index?tabs=basicconfiguration&view=aspnetcore-3.1#environment-variables-configuration-provider

这篇关于Azure应用程序设置-如何添加嵌套项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆