【发布时间】:2013-01-11 09:22:27
【问题描述】:
我们将在未来使用 Windows Azure 网站来满足我们的基本托管需求。由于云与本地有非常具体的配置设置,您如何管理这些设置?举个例子:
本地开发服务器:
string path = AppSettings["StoragePath"];
<add key="StoragePath" value="c:\temp" />
Windows Azure:
string path = AppSettings["StoragePath"];
<add key="StoragePath" value="xyz" />
您是否在每次发布之前手动更改配置文件中的 StoragePathOR 代码中是否有一些可以完成的操作,例如:
<add key="LocalStoragePath" value="c:\temp" />
<add key="BlobStoragePath" value="xyz" />
string path;
if (Azure)
{
path = AppSettings["BlobStoragePath"];
}
else
{
path = AppSettings["LocalStoragePath"];
}
如果后者可以,如何判断环境是否为Windows Azure?
【问题讨论】:
-
为什么不能使用serviceconfiguration.local和serviceconfiguration.cloud的configurationsettings?
-
@allen 我对此持开放态度,只是我没有意识到这一点。 serviceconfiguration 会完全取代 AppSettings 吗?我还应该补充一点,我们正在部署简单的网站,而不是虚拟机,如果这有影响的话。
标签: c# .net azure configuration