1
votes

I have an ASP.NET web project, and I've placed a dummy connection string in my web.config file pointing to an Azure Sql database.

<add name="YurClanConnection" connectionString="Placeholder connection string" providerName="System.Data.SqlClient" />

See this article for the reasoning behind this: http://www.hanselman.com/blog/HowToKeepYourASPNETDatabaseConnectionStringsSecureWhenDeployingToAzureFromSource.aspx

This works in production--the real connection string stored on Azure servers replaces the placeholder connection string in my project. From what I've read, putting your connection in Azure under Websites-Config in the app settings, stored as key/value pairs, is the right way to secure your connection string when using an Azure Sql database. However, this does not work in development.

What is the right way to store a connection string securely so that it works properly in both development and production, specifically when using an Azure Sql database?

1
Why doesn't that work in Dev? Haven't you got two websites, Dev and Prod? Why can't you change the connection string in both?Maria Ines Parnisari
@l19 I'm not able to connect to my Azure Sql database when developing on my local machine, since my connection string is stored in Azure. However, my deployed website can connect to the database. I don't want to have to put my connection string in web.config during development, then remove/replace it with the placeholder connection string every time I deploy.David B.
@l19 I want access to the database in development AND obviously on the deployed site.David B.
When i work with azure web sites i do the following: create a database for development and create another database for production. In Web.Config, enter the connection string for the development database. In the azure portal, override the connection string with the production variant.dannl
@dannl After further research, I've done just what you said, I think that's the best option unless someone has a better way. However, I've not only created a separate development database, I've also created a separate server for that database, since the credentials are visible in the connection string. The production database connection string is tucked away in Azure for security purposes. Thanks so much!David B.

1 Answers

0
votes

Here is how I have worked with databases locally and in Azure.

  • On the dev machine, have a database and your connections string
  • In Azure, create an Azure SQL database (or any other kind of database)
  • Go to the Web App Settings in Azure and scroll down to the section where you have connection strings and input the connection string for your db in Azure Picture here
  • Save and you should be fine.