Reek Reek - 1 year ago 117
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download