【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
当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
2022-01-16 【Azure 微服务】Azure Service Fabric 因证书问题而使得 Node 一直处于 Down 状态
2021-01-16 【Azure 环境】如何解决Principal 2330xxxxxxxxxxxxxxxxxxxx31efc5 does not exist in the directory xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx问题
2021-01-16 【Azure Developer】Python代码通过AAD认证访问微软Azure密钥保管库(Azure Key Vault)中机密信息(Secret)