- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在 Azure 应用程序配置中,我将我的设置命名为:“Section1__SubSection1__MySetting”。当尝试将配置绑定(bind)到 .NET 6 应用程序中相应的 Options 类时,它无法正确映射(null)。如果我将“__”更改为“:”,它就可以正常工作。
我试图弄清楚为什么/如何使用双下划线来表示嵌套,因为通常建议使用“__”以获得更通用的支持。如果我在 Azure 应用程序配置 key 中使用“:”,如果我在 Linux 计算机上运行我的应用程序,它仍然可以工作吗?
有人可以解释一下这一切吗?
最佳答案
Written with [StackEdit](>Double underscore not equivalent to colon when trying to denote nesting
是的,表示嵌套配置因托管环境 (Windows/Linux) 而异。
如果您想在 Windows 应用程序中设置嵌套配置,则需要在嵌套键名称后面提及 :
符号(您已经尝试过)。
您可以看到MSDoc中提到了同样的内容。
In a default Linux app service or a custom Linux container, any nested JSON key structure in the app setting name like
ApplicationInsights:InstrumentationKey
needs to be configured in App Service asApplicationInsights__InstrumentationKey
for the key name. In other words, any:
should be replaced by__
(double underscore).
__
双下划线。检查以下解决方法:
我已关注Azure App Configuration with ASP.NET Core 添加嵌套配置。
我已创建一个 Web 应用并部署到 Linux 应用服务
。
最初我使用 :
和 __
设置配置
并尝试检索值。
在 Program.cs
中:
string myconn = builder.Configuration.GetConnectionString("AppConfig");
//string myconn = builder.Configuration.GetSection("AppConfig").Value;
builder.Configuration.AddAzureAppConfiguration(myconn);
在 Index.cshtml
中:
<h4>With Semicolon - @myconfig["Test:Settings:SemiColon"]</h4>
<h4>With UnderScore - @myconfig["Test__Settings__UnderScore"]</h4>
本地输出:
我已将应用部署到 Azure Linux 应用服务
。
部署的应用输出:
:
和 __
都为我在 Linux 应用程序环境
中使用 Azure 应用程序配置
部署了应用程序.
当我尝试使用 Azure 应用程序设置
时,
本地 appsettings.json
文件:
"Section1": {
"SubSection1": {
"MySetting": "Value from Local"
}
}
:
设置配置并尝试检索该值。本地输出:
:
在这里工作。
我已将应用部署到 Azure Linux 应用服务
。
要使用 Azure 应用程序设置覆盖该值,我已将值设置如下(使用 :
)。
__
,它允许我添加。
部署的应用输出:
If I use ":" in my Azure App Configuration keys, would it still work if I run my app on a Linux machine?
是的,:
适用于 Azure 应用配置
中的 Azure Linux 应用服务
。
而只有 __
在使用 Azure 应用设置
的 Azure Linux
上工作。
关于Azure应用程序配置: Double underscore not equivalent to colon when trying to denote nesting,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/77234673/
如何检查underscore.js中数组中的元素是否存在?例如,我有['aaa', 'bbb', 'cfp', 'ddd'],并想检查'cfp'是否存在。如果可以,我想显示一些文本。我的以下代码无法正
我有一个 array = [1,2,3,4,5]并想使用 underscore.js 获得累积和数组. 我想要的结果是: [1,3,6,10,15] 我想要数组而不是累积总和 15 作为值。任何帮助,
我正在使用 underscore.js的模板库,我不确定如何在模板中使用逻辑。例如,我想在模板中打印一组标签。最好的方法是什么? Javascript: bunny_data = { name:
我正在尝试将我的对象数组格式化为一个数组以供组件使用。我需要将对象的确切值映射到正确的位置。 例如 我的原始数据: var rawData = [ { name: 'j
我有一个带有键的对象 var obj = { a: { fruit: 'Apple' }, b: { fruit: 'Banana' } } 我想快速将键 (a/b) 移动到作为属性 name 的值
我有一个像这样的 json 数组: myArray=[{ a:1, b:[{c:"x",d:"y"}, {c:"r", d:"s"}...] },
可以说我有这个对象数组。 var initialData = [{Title:"Hat",Price:49.95}, {Title:"Pants",Price:7
在使用 _.findWhere 函数时,我无法弄清楚如何在 underscore.js 中动态设置属性。 这是该函数的文档: findWhere_.findWhere(list, properties
我正在将一个相当大的 php 模板(其中包含基本逻辑的页面)转换为一个 underscore.js 模板。 问题是我一直有错误,并且它是缩小的“编译”版本在抛出错误时没有提供有用的信息或行号。 有没有
在 PHP 中,特别是在 Wordpress 中,__('string') 和 _x('string') 有什么区别? 我正在阅读 Wordpress 文档并感到困惑。以下混淆的好例子来自 Wordp
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题吗? 更新问题,以便 editing this post 提供事实和引用来回答它. 关闭3年前。 社区在上个月审核了是
如何在 underscore.js 中查询日期?我知道我不能做“之间”子句,但请参阅下面的代码作为示例。我的目标是根据用户指定的日期范围将 JSON 数据加载到图表中。 var testdata=[{
$.each(asList(1, 2, 3), new Block() { public void apply(Integer item) { System.out.print
我遇到了在线文档与我在程序中看到的在 GO 代码中访问 C 结构的行为之间的脱节。 go version 说我正在使用: go version go1.4.2 linux/amd64 根据GO CGO
我正在浏览Underscore.js api我注意到 _.escape逃脱& , , " , ' , 和 /字符。让我吃惊的是逃跑/ . 有没有逃避的理由/我不知道的字符? 最佳答案 编辑 : 好吧
我想发送带有几个下划线的字符串 "__hello__its_me_"但 Discord 将其解释为 Markdown 并在我的字符串下划线或斜体。 我知道我必须用反斜杠转义下划线,但在 Visual
我有一个连接到 Visual Studio Online 的 Azure 网站。连接两者时,Visual Studio Online 会在托管构建 Controller 上创建一个持续交付构建运行。此
当我尝试呈现以下模板时,在运行时出现编译错误: Title: Author:
我发现自己经常使用以下模式 var line = "12|John Doe" var pieces = line.split("|") var user = { id : pieces[0],
我正在尝试在主干中使用带下划线的 Handlebars 样式模板(与require.js一起使用)。 我有以下几点: _.templateSettings.interpolate = /\{\{(.+
我是一名优秀的程序员,十分优秀!