简体   繁体   中英

Machine.config alternative in Azure

I have a webservice which connects to a database on DEV / Production environments.

I'm managing both environments connection strings in the machine.config file of the servers.

For example, the machine.config in the production server will contain something like this:

<add key="MyDatabase" value="productsConnString..." />

and the dev server machine.config will have this settings:

<add key="MyDatabase" value="devConnString..." />

Naturally, when i connection to the database in code, i'm calling ConfigurationManager.AppSettings["MyDatabase"] and the correct connection string is loaded.

Is there i way i can achieve same abstraction level in Azure environment?

I read some articles which explain about Config transformations but if i use this i would need to Copy&Paste the connection strings to each Application (incase i have more than just that WebService).

Is there any alternative to machine.config in Azure? Maybe a subscription level Configuration file of some sort?

Thanks!!

I would seriously consider using the cloud service configuration file (assuming this is a PaaS solution). It not only allows you to separate the application deployment package from the configuration settings (like you're doing), but also gives you the ability to adjust those changes "on the fly" to accommodate things like failover. If you take the extra step of creating your own configuration provider, it also gives you some simple ways to support both models.

与Brent同意-使用Cloud Service配置文件并通过CloudConfigurationManager.GetSetting("settingsKey")获取设置-如果您首先在Azure或仿真器中,则使用Cloud Service配置,如果在此密钥中也找不到它在appSettings的web.config文件中查找。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM