1

I have an existing ASP.NET Core Web API app (targeting .NET Core 2.0) which I want to deploy to a Service Fabric cluster. The app contains multiple environment-specific appsettings.{env}.json files. How can I deploy this to Service Fabric so that it picks DEV data from appsettings.Development.json file and PROD data from appsettings.Production.json.

At the moment, I use launchSettings.json file to set them during my development.

There is an existing StackOverflow question which is very similar but that is specific to the non-ServiceFabric way of deployment which assumes we have access to the deployed application or IIS. My question is specific to Service Fabric deployment.

user419022
  • 71
  • 1
  • 1
  • 4
  • Do you have a way of setting environment variables when running your application? – gunr2171 Aug 23 '22 at 03:06
  • You'll need a way to set the environment variable `ASPNETCORE_ENVIRONMENT` to `Development | Production | etc.` I'm not familiar with Service Fabric Cluster but this is the direction you should go to. – jegtugado Aug 23 '22 at 03:09
  • Does this answer your question? [Automatically set appsettings.json for dev and release environments in asp.net core?](https://stackoverflow.com/questions/46364293/automatically-set-appsettings-json-for-dev-and-release-environments-in-asp-net-c) – gunr2171 Aug 23 '22 at 03:12
  • @gunr2171 No. I just updated my question with the reason. – user419022 Aug 23 '22 at 03:30
  • Isn't this what you're looking for https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-how-to-specify-environment-variables? – davidfowl Aug 23 '22 at 05:51
  • Please refer [multiple configuration sources](https://dzimchuk.net/configuring-asp-net-core-applications-in-service-fabric/) – Harshitha Sep 03 '22 at 08:46

0 Answers0