Azure App service not able to find root folder path "Could not find a part of the path 'D:\home\site\wwwroot\lfc_artifacts\lfc_artifact.pdf'"

HemantSudehely-0557 266 Reputation points
2020-07-14T22:23:05.923+00:00

Hi,

I am facing one weird issue.
I have created one web application that read the pdf file available in root location of web application "lfc_artifacts" and this is working fine locally.
but when i publish on Azure App service and run, use to get error
Could not find a part of the path 'D:\home\site\wwwroot\lfc_artifacts\lfc_artifact.pdf'

I searched and found various options but nothing is working for me
https://social.msdn.microsoft.com/Forums/en-US/6b185de7-dcdd-4046-bec1-e617da7b5d21/azure-web-app-could-not-find-existent-path-or-file?forum=windowsazurewebsitespreview
https://stackoverflow.com/questions/45600943/azure-web-deploy-could-not-find-a-part-of-the-path-d-home-site-wwwroot-bin-ro

Here is the code, i am using in Azure App Service
var lfcPath = Server.MapPath("~/lfc_artifacts/");
string[] lfcPaths = Directory.GetFiles(lfcPath, ".");

            var mcpPath = Server.MapPath("~/mcp_artifacts/");  
            string[] mcpPaths = Directory.GetFiles(mcpPath, "*.*");![12050-capture.png][1]  

///Attached is my folder structure...

Please suggest if you know any solution around...

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,094 questions
0 comments No comments
{count} votes

Accepted answer
  1. singhh-msft 2,431 Reputation points
    2020-07-15T04:23:31.013+00:00

    Hi @HemantSudehely-0557,

    Welcome to Microsoft Q&A and thanks for your query.

    Could you please share the screenshot of the folder contents you are trying to read using Kudu?

    You can follow below steps to operate Kudu -

    • Open your App Service on Azure portal - 12662-1.png
    • Navigate to "Advanced Tools" and then click on "Go" - 12560-2.png
    • Now, you will be redirected to Kudu Console Page - 12671-3.png
    • Click on "Debug console" in the top menu bar and then on "CMD" in the dropdown.
    • Open folder "site" - 12614-4.png
    • Now, in "wwwroot" folder, you are good to navigate to the folder contents you are trying to read.

    Edited: Adjusted screenshots to remove whitespace.

    4 people found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. MaruthiPrasad 21 Reputation points
    2021-02-10T07:27:59.87+00:00

    Hello Team,

    Facing the same issue which HemantSudehely-0557 reported in this thread.

    Using Web API , unable to create a folder (with two approaches with two folders - test1 and test2) within existing folder(ExLogger) which is in application root folder. Unable to attach files for reference. Below is the code as well as application folder structure.

    Code :

    var appPath = AppDomain.CurrentDomain.RelativeSearchPath;
    var tempappPath = Path.GetFullPath(Path.Combine(appPath, @"..\"));
    DirectoryInfo dir = new DirectoryInfo(Path.Combine(tempappPath, "ExLogger\test1\"));
    if (!dir.Exists)
    {
    dir.Create();
    }
    //app 1
    dir = new DirectoryInfo(System.Web.Hosting.HostingEnvironment.MapPath("~/ExLogger/" + "test2"));
    if (!dir.Exists)
    {
    dir.Create();
    }

    App Folder Structure :

    MyWebAPI
    -- Areas
    --bin
    --Content
    -- ExLogger

    Please help us on this.

    Thanks & Regards,
    MaruthiPrasad


  2. MaruthiPrasad 21 Reputation points
    2021-02-10T14:15:08.947+00:00

    Sure, did create as suggested here.

    0 comments No comments