How to set environment variable asp.net core 5.0?
Local application is working fine because it have launchsetting and reading environment varible from launchsettings.
after deployed to production environment variable is null.
how to fix it. In production I set environment variable through control panel advanced setting environment variable I added. Is there any way how it fix it
Aravind GovindarajPosted Nov 22, 2022, 8:25 PM
Usually, the environment variables are set it up in the deployment pipeline. Whenever you do debugging on the local machine, you set all required variables in your configuration file, however if you doing deployment in server then all the variables are derived from deplyoment pipeline code, because the variables are not constant it may change environmen to environment.
Naresh BeniwalPosted Nov 22, 2022, 6:27 AM
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-7.0
Jignesh KumarPosted Nov 22, 2022, 6:09 AM
Hi Kavya,
// Set Environment variable
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-7.0
https://andrewlock.net/how-to-set-the-hosting-environment-in-asp-net-core/
//Read Environment Valriable
https://stackoverflow.com/questions/44437325/access-environment-name-in-program-main-in-asp-net-core
Vishal YelvePosted Nov 22, 2022, 5:46 AM
Please check below links
https://github.com/dotnet/aspnetcore/issues/1864
https://andrewlock.net/why-isnt-my-asp-net-core-environment-specific-configuration-loading/
https://stackoverflow.com/questions/46955538/launchsettings-json-appsettings-json-web-config