在 macOS 中通过 SMB 装载 Azure 文件共享Mount Azure file share over SMB with macOS

Azure 文件是易于使用的云文件系统。Azure Files is an easy-to-use cloud file system. Azure 文件共享可以通过 macOS El Capitan 10.11+ 使用标准的 SMB 3 协议进行装载。Azure file shares can be mounted with the industry standard SMB 3 protocol by macOS El Capitan 10.11+. 本文介绍如何使用两种不同的方法通过 Finder UI 和 Terminal 在 macOS 中装载 Azure 文件共享。This article shows two different ways to mount an Azure file share on macOS: with the Finder UI and using the Terminal.

备注

通过 SMB 装载 Azure 文件共享之前,建议禁用 SMB 数据包签名。Before mounting an Azure file share over SMB, we recommend disabling SMB packet signing. 如果不这样做,则从 macOS 访问 Azure 文件共享时,可能会导致性能不佳。Not doing so may yield poor performance when accessing the Azure file share from macOS. SMB 连接会加密,因此这不会影响连接的安全性。Your SMB connection will be encrypted, so this does not affect the security of your connection. 在 Terminal 中,以下命令会禁用 SMB 数据包签名,详见这篇有关如何禁用 SMB 数据包签名的 Apple 支持文章From the terminal, the following commands will disable SMB packet signing, as described by this Apple support article on disabling SMB packet signing:

sudo -s
echo "[default]" >> /etc/nsmb.conf
echo "signing_required=no" >> /etc/nsmb.conf
exit

在 macOS 中装载 Azure 文件共享的先决条件Prerequisites for mounting an Azure file share on macOS

  • 存储帐户名称:若要装载 Azure 文件共享,需要存储帐户的名称。Storage account name: To mount an Azure file share, you will need the name of the storage account.

  • 存储帐户密钥:若要装载 Azure 文件共享,需要主(或辅助)存储密钥。Storage account key: To mount an Azure file share, you will need the primary (or secondary) storage key. 目前不支持使用 SAS 密钥进行装载。SAS keys are not currently supported for mounting.

  • 确保端口 445 处于打开状态:SMB 通过 TCP 端口 445 通信。Ensure port 445 is open: SMB communicates over TCP port 445. 在客户端计算机 (Mac) 上检查,确保防火墙未阻止 TCP 端口 445。On your client machine (the Mac), check to make sure your firewall is not blocking TCP port 445.

通过 Finder 装载 Azure 文件共享Mount an Azure file share via Finder

  1. 打开 Finder:默认情况下,Finder 在 macOS 中处于打开状态,但你可以通过单击 Dock 中的“macOS 笑脸图标”来确保它是当前选定的应用程序:Open Finder: Finder is open on macOS by default, but you can ensure it is the currently selected application by clicking the "macOS face icon" on the dock:
    macOS 笑脸图标The macOS face icon

  2. 在“前往”菜单中选择“连接到服务器” :使用先决条件中的 UNC 路径,将开头的双反斜杠 (\\) 转换为 smb://,将所有其他的反斜杠 (\) 转换为斜杠 (/)。Select "Connect to Server" from the "Go" Menu: Using the UNC path from the prerequisites, convert the beginning double backslash (\\) to smb:// and all other backslashes (\) to forwards slashes (/). 链接应如下所示:“连接到服务器”对话框Your link should look like the following: The "Connect to Server" dialog

  3. 当系统提示你输入用户名和密码时,使用存储帐户名称和存储帐户密钥:单击“连接到服务器”对话框中的“连接”时,系统会提示你输入用户名和密码(系统会使用你的 macOS 用户名自动填充此用户名字段)。Use the storage account name and storage account key when prompted for a username and password: When you click "Connect" on the "Connect to Server" dialog, you will be prompted for the username and password (This will be autopopulated with your macOS username). 可以选择将存储帐户名称/存储帐户密钥置于 macOS 密钥链中。You have the option of placing the storage account name/storage account key in your macOS Keychain.

  4. 根据需要使用 Azure 文件共享:使用共享名称和存储帐户密钥替换用户名和密码以后,系统就会装载共享。Use the Azure file share as desired: After substituting the share name and storage account key in for the username and password, the share will be mounted. 可以像通常情况下使用本地文件夹/文件共享一样使用此功能,例如,可以将文件拖放到文件共享中:You may use this as you would normally use a local folder/file share, including dragging and dropping files into the file share:

    装载的 Azure 文件共享的快照

通过 Terminal 装载 Azure 文件共享Mount an Azure file share via Terminal

  1. 将  <storage-account-name>  替换为存储帐户的名称。Replace <storage-account-name> with the name of your storage account. 在系统提示时提供存储帐户密钥作为密码。Provide Storage Account Key as password when prompted.

    mount_smbfs //<storage-account-name>@<storage-account-name>.file.core.chinacloudapi.cn/<share-name> <desired-mount-point>
    
  2. 根据需要使用 Azure 文件共享:Azure 文件共享将装载到上一命令指定的装载点。Use the Azure file share as desired: The Azure file share will be mounted at the mount point specified by the previous command.

    装载的 Azure 文件共享的快照

后续步骤Next steps

请参阅以下链接,获取有关 Azure 文件的更多信息。See these links for more information about Azure Files.