9

I am using the Kudu Dashboard to browse the folder of my Azure App Service. Specifically, I am browsing the D:\local\Temp\ since that is supposed to be (as far as I understand) the folder used to store temporary files created by my web app. For reference, here is a screenshot of the Kudu dashboard:

enter image description here

You can see from the screenshot that there is a file called xyz.tmp, this file is a file that I created manually trough the Kudu dashboard.

All this is good, however, when I try to read the file from my web app by using code such as:

var fileContent = System.IO.File.ReadAllText(@"D:\local\Temp\xyz.tmp");

I get an error stating that the file can't be found.

So my question is, what is going on? Why do I get the error? Also, I noticed that when I create a file in the same App Service temp director using code such as:

var fn = System.IO.Path.GetTempFileName();
System.IO.File.WriteAllText(fn, "abc123");

and then I try browsing for the file using the Kudo dashboard I don't see it in the temp directory.

So essentially, it all seems to point to the temp folder being displayed by the Kudo dashboard not representing the real temp folder used by the App Service. So if that is not the case then how exactly are you supposed to be able to browser the App Service temp folder?

Thanks.

T555
  • 217
  • 2
  • 9

1 Answers1

9

From https://github.com/projectkudu/kudu/wiki/Understanding-the-Azure-App-Service-file-system:

Another important note is that the Main site and the scm site do not share temp files. So if you write some files there from your site, you will not see them from Kudu Console (and vice versa). You can make them use the same temp space if you disable separation (via WEBSITE_DISABLE_SCM_SEPARATION). But note that this is a legacy flag, and its use is not recommended/supported.

David Ebbo
  • 42,443
  • 8
  • 103
  • 117
  • 2
    So other than using the WEBSITE_DISABLE_SCM_SEPARATION setting (which we should not use), is there an official and supported way to view the website temp folder? – T555 Aug 25 '18 at 02:35
  • 2
    There isn't, short of adding logic to your app itself to display temp files. Also, note that when you scale out, each instance has its own temp folder. – David Ebbo Aug 25 '18 at 05:02