Azure Functions Temp storage

梦想的初衷 提交于 2020-06-25 08:11:11

问题


When I try to save a file to the Temp storage in Azure Functions directory (D:\home\data\temp\response.pdf), I get the following error. Why can't I write to this directory?

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).

回答1:


I recommend using System.IO.Path.GetTempPath() as this will always give you a valid path for any given system.

Additionally, functions may execute multiple times simultaneously for a given instance, so it's best to ensure you have a unique path for each execution. Here's a simple example:

var tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());



回答2:


According to the exception, it seems that D:\home\data\temp\ is not existing in your function project. Please have a try to check it with Azure Kudu tool(https://yourwebsiteName.scm.azurewebsites.net). If the path is not existing, please have a try to add the temp folder and try again.

We could get more info about Azure WebApp from the Azure Web App sandbox. More detail info about file structure on azure,please refer to this document.



来源:https://stackoverflow.com/questions/46294790/azure-functions-temp-storage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!