I need to replace .env variables in the Azure DevOps release pipeline. I have used 'Replace tokens' task for the same. I have verified that the task is able to replace my variables from the variable group, but still, the application is not able to read the deployed variables. Adding screenshots below for more understanding.
Here is my CI build pipeline
.env file from the code
I use replace tokens to replace the env variables from the artifact drop
Task to show content post the replacement of variables
Logs confirming tokens replaced in the task
show content logs confirming the replaced variables
But, when I run the application for making an api call, I still see Not replaced token variable in the console.log. I'm reading the variables in the code using process.env.{VariableName}
I think the variables are getting replaced in the .env file but as the .env file is not a part of the build folder which gets deployed, the changes are not reflecting in the target environment. Could someone help here?







Based on your description, you built your NodeJS app and then updated the
.envfile for deployment. You may check the file contents by accessing Kudu for your appOnce confirmed the deployed
.envfile had the updated contents, it meant the deployment was succeeded, but your app couldn't read the.envfile.For this, you may run the
Replace Tokentask in your CI pipeline beforenpm buildor you may test to run startup command after deployment.