确定何时使用 Azure Blob、Azure 文件或 Azure 磁盘Deciding when to use Azure Blobs, Azure Files, or Azure Disks

Azure 在 Azure 存储中提供多种功能,用于在云中存储和访问数据。Azure provides several features in Azure Storage for storing and accessing your data in the cloud. 本文介绍 Azure 文件、Blob 和磁盘,旨在帮助用户选择合适的功能。This article covers Azure Files, Blobs, and Disks, and is designed to help you choose between these features.

方案Scenarios

下表比较了文件、Blob 和磁盘,并显示每种技术适合的示例情景。The following table compares Files, Blobs, and Disks, and shows example scenarios appropriate for each.

功能Feature 说明Description 何时使用When to use
Azure 文件Azure Files 提供 SMB 接口、客户端库和允许从任何位置访问存储文件的 REST 接口Provides an SMB interface, client libraries, and a REST interface that allows access from anywhere to stored files. 希望将应用程序“提升和移动”到已使用本机文件系统 API 的云中,以此在该应用程序和 Azure 中运行的其他应用程序之间共享数据时。You want to "lift and shift" an application to the cloud which already uses the native file system APIs to share data between it and other applications running in Azure.

希望存储需要从多个虚拟机访问的开发和调试工具时。You want to store development and debugging tools that need to be accessed from many virtual machines.
Azure BlobAzure Blobs 提供客户端库,以及一个可用于在块 blob 中大规模存储和访问非结构化数据的 REST 接口Provides client libraries and a REST interface that allows unstructured data to be stored and accessed at a massive scale in block blobs.

还支持 Azure Data Lake Storage Gen2,用于企业大数据分析解决方案。Also supports Azure Data Lake Storage Gen2 for enterprise big data analytics solutions.
希望应用程序支持流式处理和随机访问方案时。You want your application to support streaming and random access scenarios.

希望可以从任何位置访问应用程序数据时。You want to be able to access application data from anywhere.

想要在 Azure 上生成企业数据湖并执行大数据分析。You want to build an enterprise data lake on Azure and perform big data analytics.
Azure 磁盘Azure Disks 提供客户端库和 REST 接口,借助该接口可通过附加的虚拟硬盘永久地存储和访问数据。Provides client libraries and a REST interface that allows data to be persistently stored and accessed from an attached virtual hard disk. 希望提升和移动使用本机文件系统 API 将数据读写到永久性磁盘中应用程序时。You want to lift and shift applications that use native file system APIs to read and write data to persistent disks.

希望存储不要求从附加磁盘的虚拟机外进行访问的数据时。You want to store data that is not required to be accessed from outside the virtual machine to which the disk is attached.

比较:文件和 BlobComparison: Files and Blobs

下表将 Azure 文件和 Azure Blob 进行了比较。The following table compares Azure Files with Azure Blobs.

属性Attribute Azure BlobAzure Blobs Azure 文件Azure Files
持久性选项Durability options LRS、GRS、RA-GRSLRS, GRS, RA-GRS LRS、GRSLRS, GRS
辅助功能Accessibility REST APIREST APIs REST APIREST APIs

SMB 2.1 和 SMB 3.0(标准文件系统 API)SMB 2.1 and SMB 3.0 (standard file system APIs)
连接Connectivity REST API -- 全球范围REST APIs -- Worldwide REST API -- 全球范围REST APIs - Worldwide

SMB 2.1 -- 区域内SMB 2.1 -- Within region

SMB 3.0 -- 全球范围SMB 3.0 -- Worldwide
终结点Endpoints http://myaccount.blob.core.chinacloudapi.cn/mycontainer/myblob \\myaccount.file.core.chinacloudapi.cn\myshare\myfile.txt

http://myaccount.file.core.chinacloudapi.cn/myshare/myfile.txt
目录Directories 平面命名空间Flat namespace 真正的目录对象True directory objects
名称区分大小写Case sensitivity of names 区分大小写Case sensitive 不区分大小写,但保留大小写Case insensitive, but case preserving
容量Capacity 最多 2 个 PiB 帐户限制Up to 2 PiB Account Limit 5 TiB 文件共享5 TiB file shares
吞吐量Throughput 每个块 Blob 高达 60 MiB/秒Up to 60 MiB/s per block blob 每个共享高达 60 MiB/秒Up to 60 MiB/s per share
对象大小Object Size 每个块 blob 最多大约 4.75 TiBUp to about 4.75 TiB per block blob 每个文件最多为 1 TiBUp to 1 TiB per file
计费容量Billed capacity 基于写入的字节数Based on bytes written 基于文件大小Based on file size
客户端库Client libraries 多种语言Multiple languages 多种语言Multiple languages

比较:文件和磁盘Comparison: Files and Disks

Azure 文件是对 Azure 磁盘的补充。Azure Files complement Azure Disks. 一个磁盘每次只能附加到一个 Azure 虚拟机。A disk can only be attached to one Azure Virtual Machine at a time. 磁盘是作为页 blob 存储在 Azure 存储中的固定格式 VHD,由虚拟机用来存储持久性数据。Disks are fixed-format VHDs stored as page blobs in Azure Storage, and are used by the virtual machine to store durable data. Azure 文件中的文件共享可采用与访问本地磁盘相同的方式进行访问(通过本机文件系统 API),并可跨多个虚拟机进行共享。File shares in Azure Files can be accessed in the same way as the local disk is accessed (by using native file system APIs), and can be shared across many virtual machines.

下表将 Azure 文件和 Azure 磁盘进行比较。The following table compares Azure Files with Azure Disks.

属性Attribute Azure 磁盘Azure Disks Azure 文件Azure Files
作用域Scope 专用于单个虚拟机Exclusive to a single virtual machine 跨多个虚拟机共享访问Shared access across multiple virtual machines
快照和复制Snapshots and Copy Yes Yes
配置Configuration 虚拟机启动时连接Connected at startup of the virtual machine 虚拟机启动后连接Connected after the virtual machine has started
身份验证Authentication 内置Built-in 使用 net use 设置Set up with net use
使用 REST 访问Access using REST 无法访问 VHD 中的文件Files within the VHD cannot be accessed 可访问存储在共享中的文件Files stored in a share can be accessed
最大大小Max Size 4 TiB 磁盘4 TiB disk 5 TiB 文件共享,共享中可保存 1 TiB 文件5 TiB File Share and 1 TiB file within share
最大 IOPSMax IOps 500 IOps500 IOps 1000 IOps1000 IOps
吞吐量Throughput 每个磁盘高达 60 MiB/秒Up to 60 MiB/s per Disk 目标是每个文件共享 60 MiB/秒(更高 IO 大小可以达到更高目标)Target is 60 MiB/s per File Share (can get higher for higher IO sizes)

后续步骤Next steps

决定如何存储和访问数据时,还应考虑涉及的成本。When making decisions about how your data is stored and accessed, you should also consider the costs involved. 有关详细信息,请参阅 Azure 存储定价For more information, see Azure Storage Pricing.

某些 SMB 功能不适用于云。Some SMB features are not applicable to the cloud. 有关详细信息,请参阅 Features not supported by the Azure File service(Azure 文件服务不支持的功能)。For more information, see Features not supported by the Azure File service.

有关磁盘的详细信息,请参阅托管磁盘简介以及如何将数据磁盘附加到 Windows 虚拟机For more information about disks, see our Introduction to managed disks and How to Attach a Data Disk to a Windows Virtual Machine.