4.50.2 Does not use Environment Variables anymore

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
1 năm cách đây
So connection string got moved to appsettings.json but you guys completely removed the code to override with environment variables!

Assuming this was an oversight? Without this it makes it very hard to deploy a base container image for various clients.
1 năm cách đây
Please explain in more detail what is wrong.
Overriding app settings with environment variables works fine, for example, you can set the variable "ConnectionStrings:ConnectionString" and this value will be used as the connection string in the application, same for all other settings.
1 năm cách đây
So before it was "dataSettings__DataConnectionString"

I must have missed in the code where this is handled. Where should I go to see what I should be setting variables to?
1 năm cách đây
RomanovM wrote:
Please explain in more detail what is wrong.
Overriding app settings with environment variables works fine, for example, you can set the variable "ConnectionStrings:ConnectionString" and this value will be used as the connection string in the application, same for all other settings.


Oh I see! SectionName:KeyName

Now it works. Awesome thanks!
1 năm cách đây
How do we use environment variables?
Do we create a nop_settings_json.env file and put our secrets like ConnectionString:ConnectinString?
1 năm cách đây
jjcowo wrote:
How do we use environment variables?
Do we create a nop_settings_json.env file and put our secrets like ConnectionString:ConnectinString?


nopCommerce will automatically populate the config from Env Variables as long as you follow the naming convention. How you manage those depends on the environment. Where are you hosting?

For local development in Visual Studio right click the Nop.Web project, select properties and go to the debug section. Open the debug launch profiles window and you can add env variables in there.

For production that depends on how you are hosting. I'm hosting in kubernetes and set mine in a deployment yaml file with token replacement on an automated deployment.
1 năm cách đây
I am still a little bit confused since this isn't properly documented (I couldn't find any reference on how to setup environment variables on the nopCommerce docs).
Where should this file be located and what is the naming convention?
I do have a .env file but that doesn't work for me. My .env file is located on the root of the project.
1 năm cách đây
jjcowo wrote:
I am still a little bit confused since this isn't properly documented (I couldn't find any reference on how to setup environment variables on the nopCommerce docs).
Where should this file be located and what is the naming convention?
I do have a .env file but that doesn't work for me. My .env file is located on the root of the project.


That's because you don't set that up in nop. Hence the "environment" part of the name. That is pulled from the environment. You set that up outside of nop.

Again - are you trying to make this work in dev or a production environment? Answering that will help us guide you better.
1 năm cách đây
Hi, I am trying to use it on production.
I will also be using docker with it, and deploy it on Azure.
1 năm cách đây
jjcowo wrote:
Hi, I am trying to use it on production.
I will also be using docker with it, and deploy it on Azure.


So, what is your actual environment? A virtual machine (Windows or Linux)? Azure Web App? AKS? How are you planning to use Docker and what will you be deploying it on?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.