Azure Functions: Nodejs, What are restrictions / limitations when using file system?

后端 未结 1 507
-上瘾入骨i
-上瘾入骨i 2021-01-13 19:33

I have not been able to get an azure function working that uses the node file system module.

I created a brand new function app with most basic HTTP trigger function

相关标签:
1条回答
  • 2021-01-13 20:34

    Yes you can use the file system, with some restrictions as described here. That page describes some directories you can access like D:\HOME and D:\LOCAL\TEMP. I've modified your code below to write to the temp dir and it works:

    var fs = require('fs');
    
     module.exports = function (context, input) {
        fs.writeFile('D:/local/Temp/message.txt', input, (err) => {
        if (err) {
            context.log(err);
            throw err;
        }
        context.log('It\'s saved!');
            context.done();
        });
    }
    

    Your initial code was failing because it was trying to write to D:\Windows\system32 which is not allowed.

    0 讨论(0)
提交回复
热议问题