[英]Copying file from mounted share much slower in Function than in Startup
I have an Azure Function App running on Linux Consumption Plan with a storage file share mounted with the CLI command我有一个 Azure Function 应用程序在 Linux 消费计划上运行,并使用 CLI 命令安装存储文件共享
az webapp config storage-account add --resource-group <resgroupname> --name <functionappname> --storage-type AzureFiles --share-name <filesharename> --account-name <storageaccountname> --mount-path /sharedata --access-key <accesskey>
In this file share there is a folder with 200-250 mb data that is needed for one of the functions.在此文件共享中,有一个文件夹包含其中一项功能所需的 200-250 MB 数据。 Copying from /sharedata to /tmp takes only a few ms if done in
public override void Configure(IFunctionsHostBuilder builder)
in Startup class for entire Function app.如果在 Startup class 中对整个 Function 应用程序在
public override void Configure(IFunctionsHostBuilder builder)
中完成,从 /sharedata 复制到 /tmp 只需要几毫秒。 However, since only one function needs the data I would rather have the copying done first thing in the function needing it.但是,由于只有一个 function 需要数据,所以我宁愿在需要它的 function 中首先完成复制。 But then the exact same code that copies a directory recursively takes 15-20 seconds to complete.
但是递归复制目录的完全相同的代码需要 15-20 秒才能完成。
Is this expected behavior?这是预期的行为吗? I can't find anything in the docs I've read (quite a lot of ground to cover there) that could serve as an explanation.
我在我读过的文档中找不到任何可以作为解释的内容(那里有很多基础)。 The copy code uses standard c# System.IO functions for listing and copying dirs and files.
复制代码使用标准 c# System.IO 函数列出和复制目录和文件。
You might see slow performance when you try to transfer files to the Azure File service.
当您尝试将文件传输到 Azure 文件服务时,您可能会发现性能下降。
If you don't have a specific minimum I/O size requirement, we recommend that you use 1 MiB as the I/O size for optimal performance.
如果您没有特定的最小 I/O 大小要求,我们建议您使用 1 MiB 作为 I/O 大小以获得最佳性能。
If you know the final size of a file that you are extending with writes, and your software doesn't have compatibility problems when the unwritten tail on the file contains zeros, then set the file size in advance instead of making every write an extending write.
如果您知道要通过写入扩展的文件的最终大小,并且当文件上未写入的尾部包含零时您的软件没有兼容性问题,那么请提前设置文件大小,而不是让每次写入都是扩展写入.
You can also use AzCopy to copy one file to another or to copy a blob to a file or the other way around.
您还可以使用 AzCopy 将一个文件复制到另一个文件,或将 blob 复制到文件,或反之。 See Get started with AzCopy .
请参阅AzCopy 入门。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.