Azure 文件存储提供两种用于装载 Azure 文件共享的行业标准协议:服务器消息块 (SMB) 协议和网络文件系统 (NFS) 协议。 Azure 文件存储可让你选择最适合你工作负载的文件系统协议。 尽管可以在同一存储帐户中创建 SMB 和 NFS 文件共享,但 Azure 文件共享不支持同时使用 SMB 和 NFS 协议访问单个 Azure 文件共享。 对于所有文件共享,Azure 文件存储提供企业级文件共享,这些共享可以纵向扩展以满足你的存储需求,并且可同时由数千个客户端访问。
本文将介绍 SMB Azure 文件共享。 有关 NFS Azure 文件共享的信息,请参阅 NFS Azure 文件共享。
SMB 文件共享用于各种应用程序,其中包括终端用户文件共享和支持数据库和应用程序的文件共享。 SMB 文件共享通常用于以下场景:
- 终端用户文件共享,例如团队共享和主目录等。
- 为基于 Windows 的应用程序提供存储支持,例如 SQL Server 数据库或为 Win32 或 .NET 本地文件系统 API 编写的业务线应用程序。
- 新的应用程序和服务开发,尤其是当该应用程序或服务需要随机 IO 和分层存储时。
Azure 文件存储支持 SMB 和 Azure 的主要功能,这些功能是 SMB 文件共享的生产部署所需的:
- AD 域加入和自定义访问控制列表 (DACL)。
- 使用 Azure 备份的集成的无服务器备份。
- 使用 Azure 专用终结点的网络隔离。
- 使用 SMB 多通道的高网络吞吐量(仅限高级文件共享)。
- SMB 通道加密,包括 AES-256-GCM、AES-128-GCM 和 AES-128-CCM。
- 通过 VSS 集成共享快照支持先前版本。
- 针对 Azure 文件共享的自动软删除以防止意外删除。
- 使用 Internet 安全的 SMB 3.0+ 的 Internet 可访问文件共享(可选)。
SMB 文件共享可以直接装载在本地,也可以使用 Azure 文件同步缓存在本地。
使用 Azure 存储服务加密 (SSE) 对存储在 Azure 文件存储中的所有数据进行静态加密。 存储服务加密的工作方式类似于 Windows 上的 BitLocker:在文件系统级别下对数据进行加密。 由于数据在 Azure 文件共享的文件系统下加密,因此,在将数据编码到磁盘时,无需访问客户端上的基础密钥即可读取或写入 Azure 文件共享。 静态加密同时适用于 SMB 和 NFS 协议。
默认情况下,所有 Azure 存储帐户均已启用传输中加密。 即通过 SMB 装载文件共享(或通过 FileREST 协议访问文件共享)时,Azure 文件存储仅允许通过加密或 HTTPS 使用 SMB 3.x 建立的连接。 如果启用了传输中加密,不支持使用 SMB 通道加密的 SMB 3.x 的客户端将无法装载 Azure 文件共享。
与 Windows Server 2022 或 Windows 11 一起使用时,Azure 文件存储通过 SMB 3.1.1 支持 AES-256-GCM。 SMB 3.1.1 还支持 AES-128-GCM,并且 SMB 3.0 支持 AES-128-CCM。 出于性能原因,AES-128-GCM 是 Windows 10 21H1 版本上默认协商的加密。
可以为 Azure 存储帐户禁用传输中加密。 禁用加密后,Azure 文件存储还将允许没有加密的 SMB 2.1 和 SMB 3.x。 禁用传输中加密的主要原因是为了支持必须在更低版本的操作系统(例如,Windows Server 2008 R2 或更低版本的 Linux 发行版)上运行的旧版应用程序。 Azure 文件存储仅允许在与 Azure 文件共享相同的 Azure 区域内建立 SMB 2.1 连接;Azure 文件共享的 Azure 区域之外的 SMB 2.1 客户端(例如,本地或其他 Azure 区域)将无法访问文件共享。
Azure 文件存储提供多个设置,这些设置会影响 SMB 协议的行为、性能和安全性。 这些设置是为存储帐户内的所有 Azure 文件共享配置的。
SMB 多通道使 SMB 3.x 客户端能够与 SMB 文件共享建立多个网络连接。 Azure 文件存储支持高级文件共享(FileStorage 存储帐户类型中的文件共享)上的 SMB 多通道。 在 Azure 文件存储中启用 SMB 多通道不会产生额外费用。 现在,所有 Azure 区域都默认启用 SMB 多通道。
若要查看 SMB 多通道的状态,请导航到包含高级文件共享的存储帐户,然后选择存储帐户目录中“数据存储”标题下的“文件共享” 。 可以在“文件共享设置”部分下查看 SMB 多通道的状态。

若要启用或禁用 SMB 多通道,请选择当前状态(“已启用”或“已禁用”,具体取决于状态) 。 生成的对话框提供用于启用或禁用 SMB 多通道的切换开关。 选择所需状态,然后选择“保存”。
若要获取 SMB 多通道的状态,请使用 Get-AzStorageFileServiceProperty
cmdlet。 在运行这些 PowerShell 命令之前,请记得将 <resource-group>
和 <storage-account>
替换为适合你的环境的值。
$resourceGroupName = "<resource-group>"
$storageAccountName = "<storage-account>"
# Get reference to storage account
$storageAccount = Get-AzStorageAccount `
-ResourceGroupName $resourceGroupName `
-StorageAccountName $storageAccountName
# If you've never enabled or disabled SMB Multichannel, the value for the SMB Multichannel
# property returned by Azure Files will be null. Null returned values should be interpreted
# as "default settings are in effect". To make this more user-friendly, the following
# PowerShell commands replace null values with the human-readable default values.
$defaultSmbMultichannelEnabled = $false
# Get the current value for SMB Multichannel
Get-AzStorageFileServiceProperty -StorageAccount $storageAccount | `
Select-Object -Property `
ResourceGroupName, `
StorageAccountName, `
@{
Name = "SmbMultichannelEnabled";
Expression = {
if ($null -eq $_.ProtocolSettings.Smb.Multichannel.Enabled) {
$defaultSmbMultichannelEnabled
} else {
$_.ProtocolSettings.Smb.Multichannel.Enabled
}
}
}
若要启用/禁用 SMB 多通道,请使用 Update-AzStorageFileServiceProperty
cmdlet。
Update-AzStorageFileServiceProperty `
-StorageAccount $storageAccount `
-EnableSmbMultichannel $true
若要获取 SMB 多通道的状态,请使用 az storage account file-service-properties show
命令。 在运行这些 Bash 命令前,请记得将 <resource-group>
和 <storage-account>
替换为适合环境的值。
RESOURCE_GROUP_NAME="<resource-group>"
STORAGE_ACCOUNT_NAME="<storage-account>"
# If you've never enabled or disabled SMB Multichannel, the value for the SMB Multichannel
# property returned by Azure Files will be null. Null returned values should be interpreted
# as "default settings are in effect". To make this more user-friendly, the following
# PowerShell commands replace null values with the human-readable default values.
## Search strings
REPLACESMBMULTICHANNEL="\"smbMultichannelEnabled\": null"
# Replacement values for null parameters.
DEFAULTSMBMULTICHANNELENABLED="\"smbMultichannelEnabled\": false"
# Build JMESPath query string
QUERY="{"
QUERY="${QUERY}smbMultichannelEnabled: protocolSettings.smb.multichannel.enabled"
QUERY="${QUERY}}"
# Get protocol settings from the Azure Files FileService object
protocolSettings=$(az storage account file-service-properties show \
--resource-group $RESOURCE_GROUP_NAME \
--account-name $STORAGE_ACCOUNT_NAME \
--query "${QUERY}")
# Replace returned values if null with default values
PROTOCOL_SETTINGS="${protocolSettings/$REPLACESMBMULTICHANNEL/$DEFAULTSMBMULTICHANNELENABLED}"
# Print returned settings
echo $PROTOCOL_SETTINGS
若要启用/禁用 SMB 多通道,请使用 az storage account file-service-properties update
命令。
az storage account file-service-properties update \
--resource-group $RESOURCE_GROUP_NAME \
--account-name $STORAGE_ACCOUNT_NAME \
--enable-smb-multichannel "true"
若要在 Azure 文件存储中支持 SMB 多通道,需要确保 Windows 应用了所有相关的修补程序。 某些较旧的 Windows 版本(包括 Windows Server 2016、Windows 10 版本 1607 和 Windows 10 版本 1507)要求为所有相关 SMB 多通道修补程序设置额外的注册表项才能应用于完全修补的安装。 如果运行的 Windows 版本高于上述三个版本,则无需执行其他操作。
Windows Server 2016 和 Windows 10 版本 1607
要为 Windows Server 2016 和 Windows 10 版本 1607 启用所有 SMB 多通道修复,请运行以下 PowerShell 命令:
Set-ItemProperty `
-Path "HKLM:SYSTEM\CurrentControlSet\Policies\Microsoft\FeatureManagement\Overrides" `
-Name "2291605642" `
-Value 1 `
-Force
要为 Windows 10 版本 1507 启用所有 SMB 多通道修复,请运行以下 PowerShell 命令:
Set-ItemProperty `
-Path "HKLM:\SYSTEM\CurrentControlSet\Services\MRxSmb\KBSwitch" `
-Name "{FFC376AE-A5D2-47DC-A36F-FE9A46D53D75}" `
-Value 1 `
-Force
Azure 文件存储公开了一些设置,可用于根据组织要求切换 SMB 协议,使其更具兼容性或更安全。 默认情况下,Azure 文件存储配置为最高兼容性,因此请记住,限制这些设置可能会导致某些客户端无法连接。
Azure 文件存储公开以下设置:
- SMB 版本:允许哪些 SMB 版本。 支持的协议版本为 SMB 3.1.1、SMB 3.0 和 SMB 2.1。 默认情况下,支持所有的 SMB 版本,但如果启用了“需要安全传输”,则不支持 SMB 2.1,因为 SMB 2.1 不支持传输中加密。
- 身份验证方法:允许哪些 SMB 身份验证方法。 支持的身份验证方法是 NTLMv2(仅存储帐户密钥)和 Kerberos。 默认情况下,允许所有的身份验证方法。 如果删除了 NTLMv2,则无法使用存储帐户密钥装载 Azure 文件共享。 Azure 文件存储不支持对域凭据使用 NTLM 身份验证。
- Kerberos 票证加密:允许哪些加密算法。 支持的加密算法为 AES-256(建议)和 RC4-HMAC。
- SMB 通道加密:允许哪些 SMB 通道加密算法。 支持的加密算法为 AES-256-GCM、AES-128-GCM 和 AES-128-CCM。 如果仅选择 AES-256-GCM,需要在每个客户端上以管理员身份打开 PowerShell 终端并运行
Set-SmbClientConfiguration -EncryptionCiphers "AES_256_GCM" -Confirm:$false
来告知连接客户端使用它。 低于 Windows 11/Windows Server 2022 的 Windows 客户端上不支持使用 AES-256-GCM。
可以使用 Azure 门户、PowerShell 或 CLI 查看和更改 SMB 安全设置。 选择所需的选项卡以查看有关如何获取和设置 SMB 安全设置的步骤。 请注意,在建立 SMB 会话时会检查这些设置,如果不符合要求,SMB 会话设置会失败,并出现错误“STATUS_ACCESS_DENIED”。
若要使用 Azure 门户查看或更改 SMB 安全设置,请执行以下步骤:
搜索“存储帐户”,然后选择要查看其安全设置的存储帐户。
选择“数据存储”>“文件共享”。
在“文件共享设置”下选择与“安全性”关联的值。 如果尚未修改安全设置,此值默认为“最大兼容性”。
在“配置文件”下,选择“最大兼容性”、“最大安全性”或“自定义”。 选择“自定义”可让你为 SMB 协议版本、SMB 通道加密、身份验证机制和 Kerberos 票证加密创建自定义配置文件。
输入所需的安全设置后,选择“保存”。
要获取 SMB 协议设置,请使用 Get-AzStorageFileServiceProperty
cmdlet。 请记得将 <resource-group>
和 <storage-account>
替换为适合环境的值。 如果你已特意将任何 SMB 安全设置设为 null(例如通过禁用 SMB 通道加密),请参阅脚本中关于注释禁止某些行的说明。
$resourceGroupName = "<resource-group>"
$storageAccountName = "<storage-account>"
# Get reference to storage account
$storageAccount = Get-AzStorageAccount `
-ResourceGroupName $resourceGroupName `
-StorageAccountName $storageAccountName
# If you've never changed any SMB security settings, the values for the SMB security
# settings returned by Azure Files will be null. Null returned values should be interpreted
# as "default settings are in effect". To make this more user-friendly, the following
# PowerShell commands replace null values with the human-readable default values.
# If you've deliberately set any of your SMB security settings to null, for example by
# disabling SMB channel encryption, comment out the following four lines to avoid
# changing the security settings back to defaults.
$smbProtocolVersions = "SMB2.1", "SMB3.0", "SMB3.1.1"
$smbAuthenticationMethods = "NTLMv2", "Kerberos"
$smbKerberosTicketEncryption = "RC4-HMAC", "AES-256"
$smbChannelEncryption = "AES-128-CCM", "AES-128-GCM", "AES-256-GCM"
# Gets the current values of the SMB security settings
Get-AzStorageFileServiceProperty -StorageAccount $storageAccount | `
Select-Object -Property `
ResourceGroupName, `
StorageAccountName, `
@{
Name = "SmbProtocolVersions";
Expression = {
if ($null -eq $_.ProtocolSettings.Smb.Versions) {
[String]::Join(", ", $smbProtocolVersions)
} else {
[String]::Join(", ", $_.ProtocolSettings.Smb.Versions)
}
}
},
@{
Name = "SmbChannelEncryption";
Expression = {
if ($null -eq $_.ProtocolSettings.Smb.ChannelEncryption) {
[String]::Join(", ", $smbChannelEncryption)
} else {
[String]::Join(", ", $_.ProtocolSettings.Smb.ChannelEncryption)
}
}
},
@{
Name = "SmbAuthenticationMethods";
Expression = {
if ($null -eq $_.ProtocolSettings.Smb.AuthenticationMethods) {
[String]::Join(", ", $smbAuthenticationMethods)
} else {
[String]::Join(", ", $_.ProtocolSettings.Smb.AuthenticationMethods)
}
}
},
@{
Name = "SmbKerberosTicketEncryption";
Expression = {
if ($null -eq $_.ProtocolSettings.Smb.KerberosTicketEncryption) {
[String]::Join(", ", $smbKerberosTicketEncryption)
} else {
[String]::Join(", ", $_.ProtocolSettings.Smb.KerberosTicketEncryption)
}
}
}
根据组织的安全性、性能和兼容性要求,你可能需要修改 SMB 协议设置。 以下 PowerShell 命令将 SMB 文件共享限制为仅使用最安全的选项。
重要
如果将 SMB Azure 文件共享限制为仅使用最安全的选项,可能会导致无法连接某些客户端。 例如,从 Windows Server 2022 和 Windows 11 开始,引入了 AES-256-GCM 作为 SMB 通道加密的一种选项。 这意味着不支持 AES-256-GCM 的旧客户端将无法连接。 如果仅选择 AES-256-GCM,需要在每个客户端上以管理员身份打开 PowerShell 终端并运行 Set-SmbClientConfiguration -EncryptionCiphers "AES_256_GCM" -Confirm:$false
来告知 Windows Server 2022 和 Windows 11 客户端仅使用 AES-256-GCM。
Update-AzStorageFileServiceProperty `
-ResourceGroupName $resourceGroupName `
-StorageAccountName $storageAccountName `
-SmbAuthenticationMethod "Kerberos" `
-SmbChannelEncryption "AES-256-GCM" `
-SmbKerberosTicketEncryption "AES-256" `
-SmbProtocolVersion "SMB3.1.1"
若要获取 SMB 安全设置的状态,请使用 az storage account file-service-properties show
命令。 在运行这些 Bash 命令前,请记得将 <resource-group>
和 <storage-account>
替换为适合环境的值。 如果你已特意将任何 SMB 安全设置设为 null(例如通过禁用 SMB 通道加密),请参阅脚本中关于注释禁止某些行的说明。
RESOURCE_GROUP_NAME="<resource-group>"
STORAGE_ACCOUNT_NAME="<storage-account>"
# If you've never changed any SMB security settings, the values for the SMB security
# settings returned by Azure Files will be null. Null returned values should be interpreted
# as "default settings are in effect". To make this more user-friendly, the commands in the
# following two sections replace null values with the human-readable default values.
# If you've deliberately set any of your SMB security settings to null, for example by
# disabling SMB channel encryption, comment out the following two sections before
# running the script to avoid changing the security settings back to defaults.
# Values to be replaced
REPLACESMBPROTOCOLVERSION="\"smbProtocolVersions\": null"
REPLACESMBCHANNELENCRYPTION="\"smbChannelEncryption\": null"
REPLACESMBAUTHENTICATIONMETHODS="\"smbAuthenticationMethods\": null"
REPLACESMBKERBEROSTICKETENCRYPTION="\"smbKerberosTicketEncryption\": null"
# Replacement values for null parameters. If you copy this into your own
# scripts, you will need to ensure that you keep these variables up-to-date with any new
# options we may add to these parameters in the future.
DEFAULTSMBPROTOCOLVERSIONS="\"smbProtocolVersions\": \"SMB2.1;SMB3.0;SMB3.1.1\""
DEFAULTSMBCHANNELENCRYPTION="\"smbChannelEncryption\": \"AES-128-CCM;AES-128-GCM;AES-256-GCM\""
DEFAULTSMBAUTHENTICATIONMETHODS="\"smbAuthenticationMethods\": \"NTLMv2;Kerberos\""
DEFAULTSMBKERBEROSTICKETENCRYPTION="\"smbKerberosTicketEncryption\": \"RC4-HMAC;AES-256\""
# Build JMESPath query string
QUERY="{"
QUERY="${QUERY}smbProtocolVersions: protocolSettings.smb.versions,"
QUERY="${QUERY}smbChannelEncryption: protocolSettings.smb.channelEncryption,"
QUERY="${QUERY}smbAuthenticationMethods: protocolSettings.smb.authenticationMethods,"
QUERY="${QUERY}smbKerberosTicketEncryption: protocolSettings.smb.kerberosTicketEncryption"
QUERY="${QUERY}}"
# Get protocol settings from the Azure Files FileService object
PROTOCOLSETTINGS=$(az storage account file-service-properties show \
--resource-group $RESOURCE_GROUP_NAME \
--account-name $STORAGE_ACCOUNT_NAME \
--query "${QUERY}")
# Replace returned values if null with default values
PROTOCOLSETTINGS="${protocolSettings/$REPLACESMBPROTOCOLVERSION/$DEFAULTSMBPROTOCOLVERSIONS}"
PROTOCOLSETTINGS="${protocolSettings/$REPLACESMBCHANNELENCRYPTION/$DEFAULTSMBCHANNELENCRYPTION}"
PROTOCOLSETTINGS="${protocolSettings/$REPLACESMBAUTHENTICATIONMETHODS/$DEFAULTSMBAUTHENTICATIONMETHODS}"
PROTOCOLSETTINGS="${protocolSettings/$REPLACESMBKERBEROSTICKETENCRYPTION/$DEFAULTSMBKERBEROSTICKETENCRYPTION}"
# Print returned settings
echo $PROTOCOLSETTINGS
根据组织的安全性、性能和兼容性要求,你可能需要修改 SMB 协议设置。 以下 Azure CLI 命令将 SMB 文件共享限制为仅使用最安全的选项。
重要
如果将 SMB Azure 文件共享限制为仅使用最安全的选项,可能会导致无法连接某些客户端。 例如,从 Windows Server 2022 和 Windows 11 开始,引入了 AES-256-GCM 作为 SMB 通道加密的一种选项。 这意味着不支持 AES-256-GCM 的旧客户端将无法连接。 如果仅选择 AES-256-GCM,需要在每个客户端上以管理员身份打开 PowerShell 终端并运行 Set-SmbClientConfiguration -EncryptionCiphers "AES_256_GCM" -Confirm:$false
来告知 Windows Server 2022 和 Windows 11 客户端仅使用 AES-256-GCM。
az storage account file-service-properties update \
--resource-group $RESOURCE_GROUP_NAME \
--account-name $STORAGE_ACCOUNT_NAME \
--versions "SMB3.1.1" \
--channel-encryption "AES-256-GCM" \
--auth-methods "Kerberos" \
--kerb-ticket-encryption "AES-256"
Azure 文件存储中的 SMB 文件共享支持 SMB 协议和 NTFS 文件系统支持的功能的子集。 尽管大多数用例和应用程序不需要这些功能,但如果某些应用程序依赖于不受支持的功能,这些应用程序则可能无法在 Azure 文件存储中正常工作。 不支持以下功能:
SMB Azure 文件共享在每个 Azure 区域中可用。 高级 SMB 文件共享在中国东部 2、中国北部 2 和中国北部 3 中可用。