dddeastanglia / DDDEastAnglia

DDD East Anglia website
https://www.dddeastanglia.com
7 stars 10 forks source link

Put the connection strings into a 'secret' file #272

Closed adrianbanks closed 10 years ago

adrianbanks commented 10 years ago

Similar to appSettingsSecret.config, there is now support for a connectionStringsSecret.config file to contain the database connection strings. This file should not be checked into git, and should contain machine-specific connection strings. The connection string on the live sites is configured in the Azure portal.

adrianbanks commented 10 years ago

Not sure why this isn't building - I've set the properties of the new file to match those of the existing "secret" file.

alastairs commented 10 years ago

The build is failing because the file doesn't exist:

web.config(18): error ASPCONFIG: Unable to open configSource file 'connectionStringsSecret.config'. [DDDEastAnglia\DDDEastAnglia.csproj]

A related issue is that Azure requires the connection string to be defined somewhere before it can be overridden with the settings from the portal. What we can do to sort all of this is to check in the new connectionStringsSecret.config file, perhaps with an empty value, and then explicitly ignore this file so git does not track any further changes to the file. This will allow the deployments to succeed (and should fix the build too), while still buying us the benefit of removing the churn on this part of the web.config file (and potential security hazards of people checking in credentials to their development databases).

adrianbanks commented 10 years ago

What we can do to sort all of this is to check in the new connectionStringsSecret.config file, perhaps with an empty value, and then explicitly ignore this file so git does not track any further changes to the file. This will allow the deployments to succeed (and should fix the build too), while still buying us the benefit of removing the churn on this part of the web.config file (and potential security hazards of people checking in credentials to their development databases).

Sounds like a plan. I'll make that change (will have to be two separate pull requests I believe). I was confused however how the other secret file is in the project but doesn't exist in git, yet the deployment still works.

alastairs commented 10 years ago

I was confused however how the other secret file is in the project but doesn't exist in git, yet the deployment still works.

Simplez: the implementations for AppSettings and ConnectionStrings are different :angry: I'm pretty certain this is a difference baked into .NET years ago rather than a mistake in Azure.

adrianbanks commented 10 years ago

I wouldn't have thought that difference was coded into the deployment though. Strange. I'll make the change as we said.

alastairs commented 10 years ago

Sorry, lack of clarity on my part. What I meant was "the deployment breaks" in the general sense: it fails at runtime rather than during the deployment.

adrianbanks commented 10 years ago

I thought that the deployment is failing because a file is in the project that is not present on disk. If that is the case, the appsettings file is exactly the same, yet somehow that gets through the deployment. That's why I'm a bit confused about it.

alastairs commented 10 years ago

I thought that the deployment is failing because a file is in the project that is not present on disk.

No, deployment hasn't been attempted yet AFAIK. The build is failing for this reason :smile:

adrianbanks commented 10 years ago

Ah! That might explain it.

alastairs commented 10 years ago

:+1: