在 Azure 中,可以将连接字符串存储在在线门户的“应用程序设置”部分中。这会覆盖 web.config 中的值,这非常有用。
问题是,我在 Azure 中有多个 Web 应用程序,它们都使用相同的连接字符串,因此我希望在门户中拥有一个通用条目,我可以在其中进行设置,并且所有应用程序都应该使用它。这是故意不可能的,因为这是不好的做法,我错过了它还是根本不可能?
最佳答案
应用程序设置始终是为应用程序在后台运行的 IIS 实例定义的。如果您有多个网络应用程序,那么它们需要重复相同的设置。
但是,您正在寻找的内容被称为 External Configuration Store pattern .
外部配置存储模式
此模式描述了您有多个应用程序的情况,其中每个应用程序都需要访问相同的配置。在此模式中,这是通过在外部保存设置来完成的,例如Azure 存储 blob。
从上面的链接中,突出显示您所描述的用例:
When to use this pattern
This pattern is useful for:
- Configuration settings that are shared between multiple applications and application instances, or where a standard configuration must be enforced across multiple applications and application instances.
- A standard configuration system that doesn't support all of the required configuration settings, such as storing images or complex data types.
- As a complementary store for some of the settings for applications, perhaps allowing applications to override some or all of the centrally-stored settings.
- As a way to simplify administration of multiple applications, and optionally for monitoring use of configuration settings by logging some or all types of access to the configuration store.
关于azure - 在 Azure 中的 Web 应用程序之间共享连接字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49316016/