无法将文件共享从 Azure 连接到 windows 笔记本电脑,端口 445 被阻止

Cannot connect file share from azure to windows laptop, port 445 is blocked

当我尝试将文件共享连接到我的 windows 笔记本电脑时,它说端口 445 正在阻塞。

请帮我解决这个问题。

感谢您的帮助。

错误:

if ($connectTestResult.TcpTestSucceeded) {
    # Save the password so the drive will persist on reboot
    cmd.exe /C "cmdkey /add:`"storagetestmy3.file.core.windows.net`" /user:`"localhost\storagetestmy3`"
/pass:`"ZvWYXdvAkX112rT8k2MxQLqlcDi1oA+EZNNoGeQ2Bv88DDUWFdtcmbXXfKk/mHNMlw1TDVX3Vrkb+AStoh/kOQ==`""
    # Mount the drive
    New-PSDrive -Name Z -PSProvider FileSystem -Root "\storagetestmy3.file.core.windows.net\fileshare3" -Persist
} else {
    Write-Error -Message "Unable to reach the Azure storage account via port 445. Check to make sure your organization
or ISP is not blocking port 445, or use Azure P2S VPN, Azure S2S VPN, or Express Route to tunnel SMB traffic over a
different port."
} : Unable to reach the Azure storage account via port 445. Check to make sure your organization or ISP is not
blocking port 445, or use Azure P2S VPN, Azure S2S VPN, or Express Route to tunnel SMB traffic over a different port.
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException

根据 MSFT Doc of 445 Port blocked by Windows File Connection to Azure File Share

  1. 您的客户端 OS 应该支持 SMB 3.0。确保此 SMB Direct 选项已在您的 windows 系统中启用。

  2. 运行 这个命令 Test-NetConnection 在 Windows PowerShell 中你应该得到 PingSucceeded 作为 True。此测试是为了验证端口 445 是否被您的 ISP 或 VPN 阻止。

如果您的测试结果是False,那么您的ISP或防火墙需要打开445端口(TCP Outbound)

另一种测试端口 445 是否被防火墙或 ISP 阻止的方法,使用 AzFileDiagnostics tool.

原因:

从区域或数据中心外部,Azure 文件仅允许具有加密支持连接的 SMB 3.0。

由于一些历史原因在低版本SMB中发现漏洞,445端口已被ISP或系统防火墙或组织封锁。

从 Windows 系统连接到 Azure 文件共享的其他方法:

  1. 您可以为您的 Azure 文件共享设置点到站点 VPN。参考此 GitHub article 设置 P2S VPN。
  2. 从您的本地计算机,您可以使用 SMB 3.0 协议装载文件共享。
  3. 您可以使用 Azure 存储资源管理器等工具访问文件共享中的文件。

示例: 从存储帐户生成 Azure 文件共享的 SAS URL。

打开 Azure 存储资源管理器并使用 SAS 登录存储帐户 URL: Select 下一个 windows 中的 SAS URL 选项并粘贴从 Azure 存储帐户门户复制的 URL 并单击连接。

结果:

  1. 您可以使用存储客户端库、REST API、PowerShell 或 Azure CLI 从您的应用程序访问 Azure 文件共享中的文件。