Reputation: 399
I'm following an introductory course on Azure Web Apps. One specific tutorial shows how to get an environmental parameter, previously set from the Azure portal, and display it in your webpage, but this doesn't work for me.
The code is really simple and I'm only pasting the server response where the env parameter should go
var server = http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/html"});
response.write("<!DOCTYPE html>");
response.write("<html>");
response.write("<head>");
response.write("<title>Hello</title>");
response.write("</head>");
response.write("<body>");
response.write(`Hello from ${process.env.MyParameter}!`); //PROBLEM HERE
response.write("</body>");
response.write("</html>");
response.end();
});
Of course, I've set up a new application setting in my Azure app Configuration that is called MyParameter.
Now if I want to display some plain text such as response.write("Hello world");
it works perfectly, but when I try to get the env variable I get a HTTP ERROR 500 - This page isn't working error.
What am I doing wrong?
Upvotes: 1
Views: 170
Reputation: 15609
response.write(
Hello from ${process.env.MyParameter}!
);
This is not correct.
You should use
response.write("hello from" + process.env.MyParameter);
Upvotes: 2