question

MichaelMillares-2060 avatar image
0 Votes"
MichaelMillares-2060 asked ajkuma-MSFT answered

File Creation and Download on Azure tomcat

I have following code that create file to download. This code execute from tomcat to create a downloadable file. This is working fine on my local tomcat but not working on azure web app tomcat. Please let me know what I am missing.

 String rootFilePath=env.getProperty("file.root_folder_path");
             String folderName= rootFilePath + File.separator + "physician";
    
             File f = new File(rootFilePath);
             if (!f.exists())
                 f.mkdir();
    
             f = new File(folderName);
             if (!f.exists())
                 f.mkdir();
    
             folderName= folderName + File.separator + physicianId;
             f = new File(folderName);
             if (!f.exists())
                 f.mkdir();
    
             folderName= folderName + File.separator + "PDF";
             f = new File(folderName);
             if (!f.exists())
                 f.mkdir();
             fileName= folderName + File.separator + "PhysicianPdf_"+physicianId+".pdf";
         }
         return fileName;
azure-webapps
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ajkuma-MSFT avatar image
0 Votes"
ajkuma-MSFT answered

Thanks for the good question.

Just to highlight on how it works on App Service, the Tomcat installations on App Service on Windows exist in shared space on the App Service Plan. You can't directly modify a Tomcat installation for server-wide configuration.

For Linux:
"Adding a shared, server-level data source will require you to edit Tomcat's server.xml. First, upload a startup script and set the path to the script in Configuration > Startup Command. You can upload the startup script using FTP."

For Windows:
To make server-level configuration changes to your Tomcat installation, you must copy Tomcat to a local folder, in which you can modify Tomcat's configuration.
For Windows sites, create a file named startup.cmd or startup.ps1 in the wwwroot directory. This will automatically be executed before the Tomcat server starts.

Please see this doc for more details: configure-data-sources

Based on your requirement, you may adjust the code accordingly.
Please let us know if it helps point you in the right direction, or if I have misunderstood your scenario/requirement. Kindly share more details on your requirement to better assist you.

As a side note, to deploy .war files to Tomcat, use the /api/wardeploy/ endpoint to POST your archive file. For more information on this API, please see this documentation.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.