1

This may seem a bit trivial...but how do you go about transforming the db connection for a nopcommerce app as it is deployed to various environments.

The db connection is set in app_data\datasettings.json.

Normally this type of stuff is handled with web.config transforms.

How do you go about setting up build transforms for different environments (dev, test, prod)?

JDBennett
  • 1,323
  • 17
  • 45
  • The question is unclear to me, what would like to do? Do you want to make connection string configurable from admin side? – Divyang Desai May 19 '18 at 10:32

1 Answers1

2

I am also looking around this topic. In my humble opinion, the nopCommerce config is a pain, because it makes it really hard to do proper Continuous Integration/Continuous Delivery while keeping secrets safe.

At initial deployment you are greeted with the install page. The problem is that the installation process writes a a bunch of files to on server, including datasettings.json, where the connection string to the DB is hard-coded.

This means that when I deploy nopCommerce to Azure App Service, for deployments after installation, I have to make sure NOT to delete "additional files on the server" or the config will be deleted, since these config files written by the installer, are not in source control.

It is really impractical not to be able to use standards ASP.NET connection strings, environment variables or KeyVault.

To answer your question on how you do transformation on the config file, one possibility is to use a PowerShell script to read, transform, and write the config file directly on the App Service instance. There is an API for that.

https://blogs.msdn.microsoft.com/gabeshapiro/2017/01/01/samples-for-using-the-azure-app-service-kudu-rest-api-to-programmatically-manage-files-in-your-site/

https://github.com/projectkudu/kudu/wiki/REST-API

Alternatively, you can modify the source to read from Web.Config:

Change the connection string of nopCommerce?

VRPF
  • 3,118
  • 1
  • 14
  • 15