var fs = require('fs');
var path = require('path');

var environmentVariables = [
    "WEBSITE_SITE_NAME",
    "WEBSITE_SKU",
    "WEBSITE_COMPUTE_MODE",
    "WEBSITE_HOSTNAME",
    "WEBSITE_INSTANCE_ID",
    "WEBSITE_NODE_DEFAULT_VERSION",
    "WEBSOCKET_CONCURRENT_REQUEST_LIMIT",
    "APPDATA",
    "TMP",
    "HOME",
    "SYSTEMDRIVE",
    "WEBJOBS_PATH",
    "WEBJOBS_NAME",
    "WEBJOBS_TYPE",
    "WEBJOBS_DATA_PATH",
    "WEBJOBS_RUN_ID",
    "WEBJOBS_SHUTDOWN_FILE",
    "WEBSITE_NODE_DEFAULT_VERSION",
    "WEBSITE_NPM_DEFAULT_VERSION"
]

module.exports = function (context, req, res) {
    context.log('function triggered');
    context.log(req);

    context.log('Environment Variables');
    context.log(process.env);

    context.log('process.cwd()', process.cwd());
    context.log('__dirname', __dirname);

    var tempDir = process.env["TMP"];
    var filePath = path.join(tempDir, 'message.txt');
    var fileContents = 'Hellow Node.js_' + req.body.message;

    context.log("writing: ", fileContents);

    fs.writeFile(filePath, fileContents, (err) => {
        if (err) {
            throw err;
        }

        context.log("File is saved!");
        context.res = {
            status: 200,
            body: {
                message: 'You successfully saved the file!'
            }
        };
        context.done();
    });
}

function getEnvironmentVarible(name) {
    return name + ": " + process.env[name];
}
@@ -862,17 +862,60 @@
     var 
-f
+homeDir = process.env%5B%22HOME%22%5D;%0A    var tempF
 ilePath 
@@ -947,24 +947,82 @@
 sage.txt');%0A
+    var homeFilePath = path.join(homeDir, 'message.txt');%0A
     var file
@@ -1092,54 +1092,324 @@
 og(%22
-writing: %22, fileContents);%0A%0A    fs.writeFile(f
+temp filepath: %22, tempFilePath);%0A    context.log(%22home filepath: %22, homeFilePath);%0A    context.log(%22writing: %22, fileContents);%0A%0A    fs.writeFile(tempFilePath, fileContents, (err) =%3E %7B%0A        if (err) %7B%0A            throw err;%0A        %7D%0A%0A        context.log(%22Temp File is saved!%22);%0A        %0A        fs.writeFile(homeF
 ileP
@@ -1438,32 +1438,36 @@
 r) =%3E %7B%0A        
+    
 if (err) %7B%0A     
@@ -1465,32 +1465,36 @@
 ) %7B%0A            
+  
+  
 throw err;%0A     
@@ -1480,32 +1480,36 @@
      throw err;%0A
+    
         %7D%0A%0A     
@@ -1503,32 +1503,36 @@
      %7D%0A%0A        
+    
 context.log(%22Fil
@@ -1528,16 +1528,26 @@
 xt.log(%22
+Persisted 
 File is 
@@ -1556,32 +1556,36 @@
 ved!%22);%0A        
+    
 context.res = %7B%0A
@@ -1584,16 +1584,20 @@
 res = %7B%0A
+    
         
@@ -1625,16 +1625,20 @@
         
+    
 body: %7B%0A
@@ -1653,16 +1653,20 @@
         
+ 
+   
 message:
@@ -1717,18 +1717,24 @@
     
-%7D%0A
+    %7D%0A  
         
 %7D;%0A 
@@ -1729,16 +1729,18 @@
         
+  
 %7D;%0A     
@@ -1734,32 +1734,36 @@
      %7D;%0A        
+   
+ 
 context.done();%0A
@@ -1762,16 +1762,28 @@
 done();%0A
+        %7D);%0A
     %7D);%0A

Add fs.writeFile to home directory