Azure functions Azure函数临时文件清理
我有一个Azure Function v2,在专用应用程序服务计划上运行c#.net核心代码。该函数下载文件,然后通过Microsoft Graph将其上载到Sharepoint库Azure functions Azure函数临时文件清理,azure-functions,microsoft-graph-api,Azure Functions,Microsoft Graph Api,我有一个Azure Function v2,在专用应用程序服务计划上运行c#.net核心代码。该函数下载文件,然后通过Microsoft Graph将其上载到Sharepoint库 My code looks like this var path = System.IO.Path.GetTempPath() + downloadedfileName; using (var stream = System.IO.File.Create(path) {
My code looks like this
var path = System.IO.Path.GetTempPath() + downloadedfileName;
using (var stream = System.IO.File.Create(path)
{
//put content from downloaded file into stream
//call graph to use the stream and upload the content.
}
这段代码工作得很好,但我担心会耗尽临时空间。
我的问题是:
如果您想确定,为什么不在代码流末尾删除该文件呢?谢谢您的回复。我想知道Azure Function App是如何处理这些临时文件的。如果它们根本没有被清除,那么我将不得不按照你的建议去做。因为你是在应用程序服务模式下运行的:这应该是你的答案(对Functions也是如此)@AzureDev31是的,临时文件根本不会被自动清除。您需要手动重新启动启动站点。看看这个医生:谢谢@BowmanZhu。如果Azure功能能够自动处理未使用文件的清理,而不是通过重启手动进行清理,那就太好了。现在在我的代码中,我添加了使用(var stream=file.Create(filename,buffersize,FileOptions.DeleteOnClose))删除文件的选项。你认为我能在D:/home目录中看到这个临时文件吗?@AzureDev31不,它不在
D:/home
中。它应该是D:\local\Temp>
和D:\local\AppData>
。使用kudu工具转到该位置,然后您可以进行查看。:)