David B.
David B.

Reputation: 314

Connection string Azure Sql database

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?

Upvotes: 2

Views: 8469

Answers (1)

Dara Oladapo
Dara Oladapo

Reputation: 596

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.

Upvotes: 0

Related Questions