I went to publish an ASP.NET Core web application using Azure through the Publish screen in Visual Studio 2017. I used all of the defaults, though my app uses migra
One easy solution would be to put the azure-db connectionstring in the appsettings.json
instead of the appsettings.Development.json
.
When running the default generated asp.net core application in VS2017, you can find the launchSettings.Json
file in the Properties folder with the profiles which will be run locally.
There, under the profiles section you can see that the ASPNETCORE_ENVIRONMENT
property is set to Development.
"WebApp": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
This means that if you define the local db connectionstring in your appsettings.Development.json it will use its connectionstring when running locally.
If you don't define the ASPNETCORE_ENVIRONMENT
property then the runtime will only use the appsettings.json values (Runtime will set the ASPNETCORE_ENVIRONMENT
to Production as default but if you don't have any appsettings.Production.json
defined then only the values in appSettings.json
will be used).
So when running the Azure Web App you don't need to specify the ASPNETCORE_ENVIRONMENT
at all if you put the azure-db connectionstring in the appsettings.json
.