File Creation and Download on Azure tomcat

Michael Millares 1 Reputation point
2021-08-05T14:15:11.717+00:00

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 App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,901 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. ajkuma 26,626 Reputation points Microsoft Employee
    2021-08-09T12:54:18.17+00:00

    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.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.