Easily switching ConnectionStrings on publish to Azure

痴心易碎 提交于 2019-12-12 01:32:59

问题


I'm currently building an Azure Web Role. I am testing this project against a local database server on localhost. Then, when confident that the project is working, I publish it to Staging on Windows Azure.

However, I also have to remember to change the connection string to point to the live SQL server on SQL Azure before deploying, and then change it back to localhost afterwards.

Is there any nice way to automate this, or perhaps a different process to take to avoid the issue altogether? For example is there a way to have a configuration file for Azure that isn't updated with every deploy?


回答1:


I ended up just referencing the machine name and whether or not I was using Azure, dynamically switching the ConnectionString I referenced accordingly.



来源:https://stackoverflow.com/questions/2997903/easily-switching-connectionstrings-on-publish-to-azure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!