cscfg 中连接字符串的可变大小列表

variable size list of connection strings in cscfg

我有一个 Azure 服务,我正在使用 .cscfg 文件进行配置。 当我的服务加载 .cscfg 时,它预计至少有 1 个连接字符串。

问题是,以后可能会向 cscfg 文件中添加更多连接字符串,我不想更改我的代码来处理它们。

我找不到以构建连接字符串列表的方式编写 cscfg 的方法。 你知道这是否可能吗?如果没有,你会建议我做什么?每次我向 cscfg 添加另一个连接字符串时,如何在不更改代码的情况下处理所有连接字符串?

非常感谢。

I couldn't find a way to write the cscfg in a way that it'll build a list of connection strings. Do you know if this is possible?

与具有专用 ConnectionStrings 元素的 app/web.config 文件不同,NOT 可以对服务配置文件执行相同的操作。就设置而言,很简单name/value

How would I process all the connection strings without changing the code every time that I add another connection string to the cscfg?

只是大声思考,您可以将所有连接字符串保存在一个序列化的 JSON 数组中,并且只使用一个名为 ConnectionStrings 的键,然后让您的代码解析这个 JSON 数组并根据此 JSON 数组中的键创建不同的连接字符串。