Azure功能临时存储

naa*_*aag 9 azure azure-web-sites azure-functions

当我尝试将文件保存到Azure Functions目录(D:\home\data\temp\response.pdf)中的Temp存储时,出现以下错误.为什么我不能写到这个目录?

mscorlib: Exception has been thrown by the target of an invocation. System: An exception occurred during a WebClient request. mscorlib: ***Could not find a part of the path 'D:\home\data\temp\response.pdf'.***
2017-09-19T07:05:24.353 Function completed (Failure, Id=3aa4b740-ba8a-465c-ad7c-75b38fa2a472, Duration=334ms)
2017-09-19T07:06:31  No new trace in the past 1 min(s).
Run Code Online (Sandbox Code Playgroud)

def*_*nes 12

我建议使用,System.IO.Path.GetTempPath()因为这将始终为您提供任何给定系统的有效路径.

此外,对于给定实例,函数可以同时执行多次,因此最好确保每次执行都有唯一的路径.这是一个简单的例子:

var tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
Run Code Online (Sandbox Code Playgroud)


小智 5

我找到了更好的选择。您可以使用System.IO.Path.GetTempFileName()此创建%userprofile%\Local\Temp\tmpE128.tmp文件


Tom*_*SFT 4

根据异常情况,D:\home\data\temp\您的功能项目中似乎不存在该异常。请尝试使用 Azure Kudu 工具(https://yourwebsiteName.scm.azurewebsites.net)检查它。如果路径不存在,请尝试添加临时文件夹并重试。

我们可以从Azure Web App沙箱中获取有关Azure WebApp的更多信息。有关azure上文件结构的更多详细信息,请参阅此文档