Azure Functions 和临时文件存储

huangapple go评论61阅读模式
英文:

Azure Functions and temporary File Storage

问题

我是初学者,以前从未涉足过基于云的解决方案,所以对于这个愚蠢的问题我深感抱歉。

我有一个包含PDF文件的Azure Blob存储,我想使用PDFBox提取数据。因为PDFBox不能直接加载blobs,所以我目前首先将这些文件下载到本地。然而,最终我的项目需要完全基于云,最好是作为Azure函数。

因此,主要的障碍是弄清楚我的Azure函数应该如何访问这些文件。当在我的Azure函数内部使用控制台时,我注意到它带有文件存储功能。函数能够在处理文件之前下载并将它们存储在这里吗?这个文件存储与本地环境是否相同,还是需要注意一些不同之处?

我只想在这里临时存储文件,每次存储几分钟。

英文:

I'm a beginner and have never dealt with cloud-based solutions yet before, so apologies for the dumb question.

I have an Azure Blob Storage containing PDF files from which I want to extract data using PDFBox. Because PDFbox can't load blobs directly, I currently download these files locally first. However, eventually my project will need to become fully Cloud-based, preferably as an Azure Function.

The main hurdle therefore is figuring out how my Azure Function should access the files. When using the console inside my Azure Function I noticed it comes with a file storage. Can the Function download blobs and store them here before processing it? Does this file storage work the same as a local environment or are there differences to keep in mind?

I'm only looking to store files temporarily here, for only a few minutes at a time.

答案1

得分: 3

> 因此,主要难题在于弄清楚我的Azure函数应该如何访问这些文件。在使用Azure函数内部的控制台时,我注意到它附带了文件存储功能。

是的,您部署的Azure函数的所有信息都存储在您设置的文件存储中。(这是在创建函数应用时定义的。)

> 函数能够下载这些 blob 并在处理之前存储它们在这里吗?这个文件存储与本地环境是否相同,还是需要注意一些区别?

是的,您可以这样做。根目录是 D:/home/site/wwwroot。因此,如果您不指定,您创建的文件将位于此目录中。

请记得删除这些文件,因为存储空间是有限的。这是基于您选择的计划。

> 我只想在这里临时存储文件,每次只需存储几分钟。

顺便说一下,如果您从 blob 存储中获取文件,在此时您已完全获得了其数据。您可以直接在代码中处理获取到的数据,而无需将其临时存储在当前文件夹中。(当然,如果您有特殊需求,请忽略这个建议。)

英文:

> The main hurdle therefore is figuring out how my Azure Function should
> access the files. When using the console inside my Azure Function I
> noticed it comes with a file storage.

Yes, all of the information of your deployed azure function is stored in the file storage you set.(It is defined when you create the function app.)

> Can the Function download blobs and store them here before processing
> it? Does this file storage work the same as a local environment or are
> there differences to keep in mind?

Yes, you can. And the root directory is D:/home/site/wwwroot. So if you don't specify, the file you create will be in this directory.

Remember to delete the files, because the storage space is limited. It is based on the plan you selected.

> I'm only looking to store files temporarily here, for only a few
> minutes at a time.

By the way, if you get a file from blob storage, at this time you have completely got its data. You can process the obtained data directly in the code without temporarily storing it in the current folder. (Of course, if you have special needs, please ignore this one.)

答案2

得分: 1

你可以使用Blob 触发器输入绑定将一个 blob 加载到函数的内存中,以便通过 PDFBox 进行处理。

关于本地文件系统,你可以在这里阅读更多信息。根据你描述的问题,我认为 blob 触发器或输入绑定应该足够满足你的需求。

英文:

You can use a blob trigger or input binding to load a blob into memory of your function for processing by PDFBox.

With regards to the local file system, you can read about more about it here. From the description of your problem I think a blob trigger or input binding should be sufficient for you.

huangapple
  • 本文由 发表于 2020年8月19日 02:25:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/63474528.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定