Azure Appconfiguration 和 IOption|snappshot|monitor 模式 [英] Azure Appconfiguration and IOption|snappshot|monitor pattern
问题描述
如果您使用 IOptions-pattern 即类型化设置方法,那么您应该如何在应用程序配置 (AC) 中为参数制定动态命名约定?.. 假设我们有 3 个环境 test、stage 和 prod 以及在 AC 中我们希望参数的命名约定为:
If you use IOptions-pattern i.e typed settings approach how should you then be able to have a dynamic name convention for parameters in App Configuration (AC) ?.. Lets say we have 3 environments test, stage and prod and in AC we would like to have a name convention for parameters as:
<environment>:<application name>:<param name>
这是否可能实现,因为我测试时似乎有一些幕后"?基于 IOptions-entity-name 和 appsettings-json-structure 的映射,或者我可以覆盖此行为以实现基于环境参数的更动态的参数名称约定为 (test|stage|prod),环境参数用于服务名称和IOptions-entity/appsettings-files 中更通用的命名约定,用于所有应该集中/动态存储的参数
Is that possible to achieve due to when I have tested there seems to be some "behind the scene" mapping based IOptions-entity-name and appsettings-json-structure or can I override this this behavior to achieve a more dynamic param name convention based on Env-parameters as (test|stage|prod), Env-parammeter for service name and a more generic name convention in IOptions-entity/appsettings-files for all parameters that should be centrally/dynamically stored
谢谢!
推荐答案
您计划使用的命名约定将起作用,但是,我建议像下面这样命名配置键,并在 AC 中使用 labels环境.
The naming convention you plan to use will work, however, I would recommend naming config keys like below and use labels in AC for environments.
<application name>:<param name>
例如
键 | 值 | 标签 |
---|---|---|
app1:settings:debug | true | dev |
app1:settings:debug | true | 舞台 |
app2:settings:color | 黄色 | 测试 |
然后,您的应用程序可以通过使用关键过滤器和标签过滤器,仅加载与其相关的配置(app1 与 app2)以及它运行的环境(开发/状态/测试等).您可以在 https 中找到有关此讨论的更多详细信息://docs.microsoft.com/en-us/azure/azure-app-configuration/concept-key-value.
Your application then can load only the configuration that is relevant to it (app1 vs. app2) and for the environment where it runs (dev/state/test etc.) by using key filters and label filters. You can find more details of this discussion in https://docs.microsoft.com/en-us/azure/azure-app-configuration/concept-key-value.
这是一个教程,展示了如何在 ASP.NET Core 应用程序中使用 IOptions
和应用程序配置:https://docs.microsoft.com/en-us/azure/azure-app-configuration/enable-dynamic-configuration-aspnet-core
Here is a tutorial that shows how to use IOptions
with App Configuration in an ASP.NET Core app:
https://docs.microsoft.com/en-us/azure/azure-app-configuration/enable-dynamic-configuration-aspnet-core
这篇关于Azure Appconfiguration 和 IOption|snappshot|monitor 模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!