Hi I'am want to ask on how to switch between environment when publishing an app?
Currently I have my web api that in my local machine and the default environment is "Development" in appsettings.json. And when i publish the app then it override the appsettings,json in server. I know that we can have different appsettings.json for production
or development. My question is how can i tell the app that this is the appsettings that you will use when you in the server and that's when you are in the development machine
Hi I'am want to ask on how to switch between environment when publishing an app?
Currently I have my web api that in my local machine and the default environment is "Development" in appsettings.json. And when i publish the app then it override the appsettings,json in server. I know that we can have different appsettings.json for production
or development. My question is how can i tell the app that this is the appsettings that you will use when you in the server and that's when you are in the development machine
Just read the documentation, it has everything you need.
I prefer to set the ASPNETCORE_ENVIRONMENT Windows Environment variable in each server. You do this once. Name the configuration file to match the environment; appsettings.staging.json.
ASP.NET Core references a particular environment variable, ASPNETCORE_ENVIRONMENT to describe the environment the application is currently running in. This variable can be set to any value you like, but three values are used by convention: Development, Staging,
and Production.The following link shows the configuration method:
Member
30 Points
40 Posts
Switching environment when publishing asp.net core web api
Oct 28, 2019 03:52 AM|TinVin727|LINK
Hi I'am want to ask on how to switch between environment when publishing an app?
Currently I have my web api that in my local machine and the default environment is "Development" in appsettings.json. And when i publish the app then it override the appsettings,json in server. I know that we can have different appsettings.json for production or development. My question is how can i tell the app that this is the appsettings that you will use when you in the server and that's when you are in the development machine
All-Star
53131 Points
23682 Posts
Re: Switching environment when publishing asp.net core web api
Oct 28, 2019 12:10 PM|mgebhard|LINK
Just read the documentation, it has everything you need.
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-3.0
I prefer to set the ASPNETCORE_ENVIRONMENT Windows Environment variable in each server. You do this once. Name the configuration file to match the environment; appsettings.staging.json.
Member
180 Points
88 Posts
Re: Switching environment when publishing asp.net core web api
Oct 29, 2019 07:25 AM|Lewis Lu|LINK
Hi TinVin727,
ASP.NET Core references a particular environment variable, ASPNETCORE_ENVIRONMENT to describe the environment the application is currently running in. This variable can be set to any value you like, but three values are used by convention: Development, Staging, and Production.The following link shows the configuration method:
https://aspnetcore.readthedocs.io/en/stable/fundamentals/environments.html#determining-the-environment-at-runtime
Best Regards,
Lewis