7

I have some integration tests that I'd like to run against LocalDB.

My config.json file has the following section...

{
  "ConnectionStrings": {
    "DefaultConnection": ""
  }
}

Is it possible to set this value in the build config?

Ian Warburton
  • 15,170
  • 23
  • 107
  • 189

2 Answers2

7

You can achieve this in several ways. Like Powershell scripts to replace the values and ofcourse this replace token extension

You should define your variable like below

{
  "ConnectionStrings": {
    "DefaultConnection": "#{connectstring}#"
  }
}

During the deployment it will get replaced with your actual values.

Refer this SO for more details

Jayendran
  • 9,638
  • 8
  • 60
  • 103
0

I solved it using the Configuration of Connection Strings in the target App Service for my Azure Web App. Within the App startup I use this code to access it, and if running local for debugging it uses the config.json or secrets.json.

Configuration.GetConnectionString("My_ConnectionString_Name");

So you can have your local db mentioned in the secrets.json and set the productive database in the Azure App connection string (if applicable).

Dominic
  • 13
  • 4