Reek Reek - 2 months ago 11x
Java Question

Azure web app write and read files

I have made a simple Java web app that runs on tomcat to explore azure environment.

I can read files (deployed via FTP to web app's root) from the web app, in a path denoted by HOME environment variable (azure's own env variable, resolves to


String home = env.getProperty("HOME");

FileInputStream fis;
try {
fis = new FileInputStream(home + "/" + "input.txt");


} catch (IOException e) {

But I can't write files to the same path:

String home = env.getProperty("HOME");
File file = new File(home + "/output.txt");

try {
FileOutputStream fos = new FileOutputStream(file, true);


} catch (IOException e) { //ACCESS DENIED
return "ERROR :" + e.getMessage();

above code fails with access denied error.

Can I write persistent files to some path in azure, or do I need a cloud native storage for this?


You cannot create files directly under %HOME%, but you can created directories. And in there, you can create files. It's only files at the very root that it disallowed.