是否可以浏览 Azure App Service 临时目录?

Is is possible to browse an Azure App Service temp directory?

我正在使用 Kudu Dashboard 浏览我的 Azure 应用服务的文件夹。具体来说,我正在浏览 D:\local\Temp\ 因为这应该是(据我所知)用于存储我的网络应用程序创建的临时文件的文件夹。作为参考,这里是 Kudu 仪表板的屏幕截图:

从截图中可以看到有一个文件叫xyz.tmp,这个文件是我通过Kudu dashboard手动创建的文件

这一切都很好,但是,当我尝试使用以下代码从我的 Web 应用程序读取文件时:

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

我收到一条错误消息,指出找不到该文件。

所以我的问题是,这是怎么回事?为什么我会收到错误消息?此外,我注意到当我使用以下代码在同一个 App Service 临时目录中创建文件时:

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

然后我尝试使用 Kudo 仪表板浏览文件,我在临时目录中没有看到它。

所以基本上,这一切似乎都指向 Kudo 仪表板显示的临时文件夹,而不是应用服务使用的真实临时文件夹。因此,如果不是这种情况,那么您究竟应该如何才能浏览 App Service 临时文件夹?

谢谢。

来自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.