Azure Web App 临时文件清理责任 [英] Azure Web App Temp file cleaning responsibility

查看:34
本文介绍了Azure Web App 临时文件清理责任的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的一个 Azure Web App Web API 应用程序中,我在 Get 方法中使用此代码创建临时文件

 字符串路径 = Path.GetTempFileName();//在这个文件上写一些东西.然后阅读var fileStream = File.OpenRead(path);//然后将此流作为 HttpResponseMessage 响应返回

我的问题是,在这样的托管环境中(不是在 VM 中),我需要自己清除那些临时文件吗?Azure 本身不应该清除那些临时文件吗?

解决方案

只有在您的网站重新启动时才会清理这些文件.

如果您的网站在免费或共享模式下运行,它只会获得 300MB 的临时文件,因此如果您不清理,您可能会用完.

如果您的网站处于基本或标准模式,则空间会大得多(大约 200GB!).因此,您可能会逃脱不清理而不会遇到限制.最终,您的网站将重新启动(例如在平台升级期间),因此一切都会得到清理.

有关此主题的更多详细信息,请参阅此页面.p>

In one of my Azure Web App Web API application, I am creating temp files using this code in a Get method

    string path = Path.GetTempFileName();
    // do some writing on this file. then read 
    var fileStream = File.OpenRead(path);
    // then returning this stream as a HttpResponseMessage response

My question is, in a managed environment like this (not in VM), do I need to clear those temporary files by myself? Shouldn't Azure itself supposed to clear those temp files?

解决方案

Those files only get cleaned when your site is restarted.

If your site is running in Free or Shared mode, it only gets 300MB for temp files, so you could run out if you don't clean up.

If your site is in Basic or Standard mode, then there is significantly more space (around 200GB!). So you could probably get away with not cleaning up without running into the limit. Eventually, your site will get restarted (e.g. during platform upgrade), so things will get cleaned up.

See this page for some additional detail on this topic.

这篇关于Azure Web App 临时文件清理责任的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆