Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ConnectionString configSource not found when deployed to Azure

I am securing my MVC5 project, by moving the connection strings out of web.config into an external file, and not checking this into source control, nor adding it to the project.

My web.config looks like

<configuration>
  <connectionStrings configSource="ConnectionStrings.config" />

This works perfectly in development.

I have the website hosted in Azure WebSites, and I have manually defined the connectionstrings in the configuration portal.

The problem is that when I publish to Azure, I get the error "Unable to open configSource file 'ConnectionStrings.config'."

Is there a way to override the Connection Strings element in the web.config so it will not try and find the external file? Is Web Transforms able to do this?

Thanks in advance, all help appreciated

like image 836
Joel Gallagher Avatar asked Dec 31 '14 01:12

Joel Gallagher


People also ask

Where do I put ConnectionString in web config?

config file in the Views folder.) Find the <connectionStrings> element: Add the following connection string to the <connectionStrings> element in the Web. config file.

How to store connection string?

The best way to secure the database connection string is to encrypt the value within the configuration file. The application would then load the encrypted value from the config file, decrypt the value, and then use the decrypted value as the connection string to connect to the database.

How to get connection string in console application c#?

In this window, click Console Application under Visual C#. Give the name of your application as "Database_Connection_Application" and then click OK. Now, specify a name, then click in the Type cell. In the drop-down box choose "Connection String".


1 Answers

Use a RemoveAttributes transform on the web.config and remove the configSource attribute on deploy to Azure.

like image 162
MeyC Avatar answered Nov 19 '22 12:11

MeyC