【Azure Data Lake Storage】如何才能保留Blob中的文件目录结构(即使文件夹中文件数量为0的情况下)?

问题描述

在使用Azure Storage Account Blob时候,发现当文件夹中的Blob(文件)被全部输出后,文件夹也会消失?

为什么它不能像Windows系统中的文件夹一样,即使是一个空文件夹。也会一直保留呢?

 

问题解答

这是因为 Azure Storage Account Blob 对 Container下的文件管理采用的是扁平化的命名方式( Flat Namespace ),它并没有Windows操作系统中的“文件夹”概念,而在页面中显示的一级一级的文件结构,只是一个虚拟结构。当其中的全部文件(Blob)被清空后,这些虚拟的文件夹结构也会被清空。

而ADLS(Azure Data Lake Storage Gen2)则提供了分层命名空间( Hierarchical Namespace ),允许使用目录和子目录组织和管理数据,就像在本地文件系统中一样。

 

扁平化的命名方式( Flat Namespace )  vs 分层命名空间( Hierarchical Namespace )

扁平命名空间(FNS):一种在 Azure 存储帐户中组织对象的模式,其中对象使用扁平结构(即对象的扁平列表)进行组织。这是存储帐户的默认配置。

Flat namespace (FNS): A mode of organization in a storage account on Azure where objects are organized using a flat structure - aka a flat list of objects. This is the default configuration for a storage account.

 

分层命名空间(HNS):使用分层命名空间,您可以将数据组织到结构化的文件夹和目录中。分层命名空间允许像文件夹重命名和删除这样的操作以单个原子操作执行,而扁平命名空间则需要与结构中对象数量成比例的操作数。分层命名空间存储您的目录和文件夹结构的附加元数据,并允许文件系统 ACL。然而,随着您的数据量增长,分层命名空间保持您的数据有组织,并且更重要的是,它为您的分析作业提供更好的存储性能,从而降低了运行分析作业的总体 TCO。

Hierarchical namespace (HNS): With hierarchical namespaces, you can organize data into structured folders and directories. A hierarchical namespace allows operations like folder renames and deletes to be performed in a single atomic operation, which with a flat namespace requires a number of operations proportionate to the number of objects in the structure. Hierarchical namespaces store additional meta-data for your directory and folder structure, and allows Filesystem ACLs. However, as your data volume grows, hierarchical namespaces keeps your data organized and more importantly yields better storage performance on your analytic jobs – thus lowering your overall TCO to run analytic jobs

 

所以,为了保留Blob的的文件夹结构(目录和子目录), 有如下两种方式:

方式一:把Stroage Account升级为ADLS Gen 2, Azure门户提供了非常方便的升级方式,只需要在页面中点击升级按钮

 

方式二:始终保留一个文件在所需要保留的文件夹(目录或子目录)中

 

参考资料

Flat namespace (FNS) vs Hierarchical namespace (HNS) : https://azure.github.io/Storage/docs/analytics/azure-storage-data-lake-gen2-billing-faq/

升级具有 Azure Data Lake Storage Gen2 功能的 Azure Blob 存储 : https://docs.azure.cn/zh-cn/storage/blobs/upgrade-to-data-lake-storage-gen2

Do we have an option for hierarchical folder options in blob storage? https://learn.microsoft.com/en-us/answers/questions/904103/do-we-have-an-option-for-hierarchical-folder-optio

 

posted @ 2024-01-16 21:26  路边两盏灯  阅读(15)  评论(0编辑  收藏  举报