Nota
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare ad accedere o modificare le directory.
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare a modificare le directory.
Azure 文件同步 将您的本地服务器连接到 Azure 文件存储,实现多站点同步和云分层功能。 因此,本地服务器必须连接到互联网。 IT管理员需要决定服务器进入Azure云服务的最佳路径。
本文将深入介绍成功且安全地将服务器连接到Azure 文件同步的具体需求和选项。
在阅读这份操作指南之前,先了解一下Azure 文件同步网络的相关考虑。
Azure 文件同步 网络概览
Azure 文件同步 作为 Windows Server、Azure 文件共享以及其他多个 Azure 服务之间的编排服务,用于同步同步组中描述的数据。 为了让 Azure 文件同步 正常工作,你需要配置服务器与以下 Azure 服务通信:
- Azure 存储
- Azure 文件同步
- Azure 资源管理器
- 身份验证服务
注释
Windows Server上的Azure 文件同步代理发起所有云服务请求,因此只需从防火墙角度考虑出站流量。 没有任何 Azure 服务会发起连接到 Azure 文件同步 agent。
Azure 文件同步 的必要端口
Azure 文件同步 只通过 HTTPS 传输文件数据和元数据,并且要求端口 443 必须在出站时开启。 因此,所有流量都是加密的。
网络和到 Azure 的特殊连接
Azure 文件同步 代理对 Azure 的特殊通道如 ExpressRoute 等没有任何要求。
Azure 文件同步 通过任何允许访问 Azure 的可用方式工作。 它会自动适应带宽和延迟等网络特性,并提供管理员控制以进行微调。
Azure 文件同步代理设置
Azure 文件同步支持特定于应用和计算机范围的代理设置。
针对特定应用的代理设置
应用特定的代理设置允许专门配置针对 Azure 文件同步 流量的代理。 应用特定的代理设置在代理版本 4.0.1.0 或更新版本中支持,可以在代理安装时或使用 Set-StorageSyncProxyConfiguration PowerShell cmdlet 进行配置。 使用 Get-StorageSyncProxyConfiguration cmdlet返回当前配置中的代理设置。 结果为空白表示未配置代理设置。 要移除现有的代理配置,请使用 Remove-StorageSyncProxyConfiguration cmdlet。
用于配置特定于应用的代理设置的 PowerShell 命令:
Import-Module "C:\Program Files\Azure\StorageSyncAgent\StorageSync.Management.ServerCmdlets.dll"
Set-StorageSyncProxyConfiguration -Address <url> -Port <port number> -ProxyCredential <credentials>
例如,如果代理服务器要求使用用户名和密码进行身份验证,请运行以下 PowerShell 命令:
# IP address or name of the proxy server.
$Address="http://127.0.0.1"
# The port to use for the connection to the proxy.
$Port=8080
# The user name for a proxy.
$UserName="user_name"
# Please type or paste a string with a password for the proxy.
$SecurePassword = Read-Host -AsSecureString
$Creds = New-Object System.Management.Automation.PSCredential ($UserName, $SecurePassword)
# Please verify that you have entered the password correctly.
Write-Host $Creds.GetNetworkCredential().Password
Import-Module "C:\Program Files\Azure\StorageSyncAgent\StorageSync.Management.ServerCmdlets.dll"
Set-StorageSyncProxyConfiguration -Address $Address -Port $Port -ProxyCredential $Creds
计算机范围的代理设置
全机代理设置对 Azure 文件同步 代理来说是透明的,因为服务器的全部流量都经过代理。
要配置全机代理设置,请按照以下步骤操作:
配置 .NET 应用程序的代理设置
编辑这两个文件:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config在 machine.config 文件中(位于 <system.serviceModel> 节下方)添加 <system.net> 节。 将 127.0.01:8888 更改为代理服务器的 IP 地址和端口。
<system.net> <defaultProxy enabled="true" useDefaultCredentials="true"> <proxy autoDetect="false" bypassonlocal="false" proxyaddress="http://127.0.0.1:8888" usesystemdefault="false" /> </defaultProxy> </system.net>
设置 WinHTTP 代理设置
注释
要配置 Windows Server 使用代理服务器,可以使用多种方法,包括 WPAD、PAC 文件、netsh 等。 本文中的步骤介绍了如何使用
netsh配置代理设置。 不过,你可以使用Windows文档中“配置代理服务器设置”中列出的任何方法。从提升命令提示符或PowerShell中执行以下命令,查看现有代理设置:
netsh winhttp show proxy从提升命令提示符或PowerShell中执行以下命令来设置代理设置(将127.0.01:8888改为代理服务器的IP地址和端口):
netsh winhttp set proxy 127.0.0.1:8888
通过在提升权限的命令提示符或 PowerShell 中运行以下命令,重启存储同步代理服务:
net stop filesyncsvc注释
存储同步代理(filesyncsvc)服务在停止后会自动启动。
Azure 文件同步 防火墙设置
如前一节所述,你需要开放 443 端口的出站访问。 根据你数据中心、分支机构或地区的政策,你可能需要进一步限制该端口的流量仅限于特定域名。
下表描述了通信所需的域:
| Service | 由世纪互联终结点运营的Microsoft Azure |
|---|---|
| Azure 资源管理器 | https://management.chinacloudapi.cn |
| Microsoft Entra ID(身份验证) | https://login.chinacloudapi.cnhttps://login.partner.microsoftonline.cn |
| Microsoft Entra ID (service principal) | https://microsoftgraph.chinacloudapi.cn/ |
| Microsoft Entra ID (注册UI) | https://secure.aadcdn.microsoftonline-p.com |
| Azure 存储 | 用于核心服务的域名:*.core.chinacloudapi.cn |
| Azure 文件同步 | *.afs.azure.cn |
| Microsoft PKI | https://www.microsoft.com/pki/mscorp/cpshttp://crl.microsoft.com/pki/mscorp/crl/http://mscrl.microsoft.com/pki/mscorp/crl/http://ocsp.msocsp.comhttp://ocsp.digicert.com/http://crl3.digicert.com/ |
| Microsoft 更新 | *.update.microsoft.com *.download.windowsupdate.com *.ctldl.windowsupdate.com *.dl.delivery.mp.microsoft.com *.emdl.ws.microsoft.com |
下表描述了每个端点的用途:
| Service | Description |
|---|---|
| Azure 资源管理器 | 任何用户调用(如PowerShell)都会访问或通过该URL,包括最初的服务器注册调用。 |
| Microsoft Entra ID(身份验证) | Azure 资源管理器调用必须由经过身份验证的用户发出。 该URL负责用户认证。 |
| Microsoft Entra ID (service principal) | 作为部署 Azure 文件同步 的一部分,服务主体会在订阅的 Microsoft Entra ID 中创建。 该原则将最小的权限委托给 Azure 文件同步 服务。 执行初始设置的用户必须拥有订阅所有者权限。 |
| Microsoft Entra ID (注册UI) | 由 Azure 文件同步 服务器注册 UI 用于管理员登录的 Active Directory 身份验证库访问。 |
| Azure 存储 | 服务器通过直接与存储账户中的 Azure 文件共享通信,使用仅允许特定目标文件共享访问的 SAS 密钥,从而更高效地进行数据传输。 |
| Azure 文件同步 | 初始服务器注册后,服务器会收到该区域内 Azure 文件同步 服务实例的区域 URL,以便实现直接高效的同步通信。 |
| Microsoft PKI | 下载与 Azure 文件同步 服务和 Azure 文件共享通信所需的中间证书。 OCSP URL用于检查证书状态。 |
| Microsoft 更新 | 下载 Azure 文件同步 代理更新。 |
Important
当允许访问 *.afs.azure.cn 时,流量将只能到达同步服务。 目前没有其他 Microsoft 服务 使用该域。
如果 *.afs.azure.cn 太宽,则可以通过仅允许与Azure 文件同步服务的显式区域实例通信来限制服务器的通信。 选择哪个或哪些实例取决于您部署存储同步服务并将服务器注册到该服务所在的区域。 在下表中,该区域称为“主终结点 URL”。
出于业务连续性和灾难恢复(BCDR)原因,你可以在配置为地理冗余存储(GRS)的存储账户中创建Azure文件共享。 如果你选择这个选项,Azure 文件共享在发生持续区域故障时会切换到配对区域。 Azure 文件同步使用的区域配对与存储相同。 所以如果你使用 GRS 存储账户,你需要启用额外的 URL,以便服务器能与配对区域通信以实现 Azure 文件同步。下表称之为“配对区域”。 此外,还有一个流量管理器配置文件 URL 也需要启用。 该 URL 确保网络流量在故障切换时能无缝重定向到配对区域,表中称为“发现 URL”。
Microsoft Azure 由世纪互联运营
下表列出了由21Vianet区域运营的Microsoft Azure中Azure 文件同步的端点。
| Region | 主要端点网址 | 配对区域 | 发现网址 |
|---|---|---|---|
| 中国东部 2 | https://chinaeast201.afs.azure.cn | 中国北部 2 | https://tm-chinaeast201.afs.azure.cn |
| 中国北部 2 | https://chinanorth201.afs.azure.cn | 中国东部 2 | https://tm-chinanorth201.afs.azure.cn |
Azure 文件同步 IP 地址的允许列表
Azure 文件同步支持使用服务标记,这些标记表示给定 Azure 服务的一组 IP 地址前缀。 可以使用服务标记来创建防火墙规则,允许与 Azure 文件同步服务通信。 Azure 文件同步 的服务标签是 StorageSyncService。
如果你在 Azure 中使用 Azure 文件同步,可以在网络安全组中直接使用服务名称标签来允许流量。 想了解更多方法,请参见 网络安全组。
如果你在本地使用 Azure 文件同步,可以使用服务标签 API 获取防火墙允许列表的特定 IP 地址范围。 可以通过两种方法获取此信息:
- 支持服务标记的所有 Azure 服务的最新 IP 地址范围列表每周都会以 JSON 文档的形式在 Microsoft 下载中心上发布。
- Microsoft Azure 由21Vianet运营
- 服务标签发现API允许程序化检索当前服务标签列表。 可以根据自动化首选项使用 API 接口:
由于服务标签发现API的更新频率可能不如发布到Microsoft 下载中心的JSON文档,我们建议使用JSON文档来更新本地防火墙的允许列表。 可以按以下步骤来完成:
# The specific region to get the IP address ranges for. Replace chinaeast2 with the desired region code
# from Get-AzLocation.
$region = "chinaeast2"
# The service tag for Azure File Sync. Don't change unless you're adapting this
# script for another service.
$serviceTag = "StorageSyncService"
# Download date is the string matching the JSON document on the Download Center.
$possibleDownloadDates = 0..7 | `
ForEach-Object { [System.DateTime]::Now.AddDays($_ * -1).ToString("yyyyMMdd") }
# Verify the provided region
$validRegions = Get-AzLocation | `
Where-Object { $_.Providers -contains "Microsoft.StorageSync" } | `
Select-Object -ExpandProperty Location
if ($validRegions -notcontains $region) {
Write-Error `
-Message "The specified region $region isn't available. Either Azure File Sync isn't deployed there or the region doesn't exist." `
-ErrorAction Stop
}
# Get the Azure cloud. This should automatically based on the context of
# your Az PowerShell login, however if you manually need to populate, you can find
# the correct values using Get-AzEnvironment.
$azureCloud = Get-AzContext | `
Select-Object -ExpandProperty Environment | `
Select-Object -ExpandProperty Name
# Build the download URI
$downloadUris = @()
switch($azureCloud) {
"AzureCloud" {
$downloadUris = $possibleDownloadDates | ForEach-Object {
"https://download.microsoft.com/download/7/1/D/71D86715-5596-4529-9B13-DA13A5DE5B63/ServiceTags_Public_$_.json"
}
}
"AzureUSGovernment" {
$downloadUris = $possibleDownloadDates | ForEach-Object {
"https://download.microsoft.com/download/6/4/D/64DB03BF-895B-4173-A8B1-BA4AD5D4DF22/ServiceTags_AzureGovernment_$_.json"
}
}
"AzureChinaCloud" {
$downloadUris = $possibleDownloadDates | ForEach-Object {
"https://download.microsoft.com/download/9/D/0/9D03B7E2-4B80-4BF3-9B91-DA8C7D3EE9F9/ServiceTags_China_$_.json"
}
}
"AzureGermanCloud" {
$downloadUris = $possibleDownloadDates | ForEach-Object {
"https://download.microsoft.com/download/0/7/6/076274AB-4B0B-4246-A422-4BAF1E03F974/ServiceTags_AzureGermany_$_.json"
}
}
default {
Write-Error -Message "Unrecognized Azure Cloud: $_" -ErrorAction Stop
}
}
# Find most recent file
$found = $false
foreach($downloadUri in $downloadUris) {
try { $response = Invoke-WebRequest -Uri $downloadUri -UseBasicParsing } catch { }
if ($response.StatusCode -eq 200) {
$found = $true
break
}
}
if ($found) {
# Get the raw JSON
$content = [System.Text.Encoding]::UTF8.GetString($response.Content)
# Parse the JSON
$serviceTags = ConvertFrom-Json -InputObject $content -Depth 100
# Get the specific $ipAddressRanges
$ipAddressRanges = $serviceTags | `
Select-Object -ExpandProperty values | `
Where-Object { $_.id -eq "$serviceTag.$region" } | `
Select-Object -ExpandProperty properties | `
Select-Object -ExpandProperty addressPrefixes
} else {
# If the file cannot be found, that means there hasn't been an update in
# more than a week. Please verify the download URIs are still accurate
# by checking https://docs.azure.cn/virtual-network/service-tags-overview
Write-Verbose -Message "JSON service tag file not found."
return
}
然后你可以利用 的 $ipAddressRanges IP 地址范围来更新防火墙。 请查看防火墙/网络设备的网站,了解如何更新防火墙。
测试服务终结点的网络连接性
一旦服务器注册到Azure 文件同步服务,Test-StorageSyncNetworkConnectivitycmdlet 和 ServerRegistration.exe 就可以用来测试与该服务器所有特定端点(URL)的通信。 当通信不完整导致服务器无法完全配合 Azure 文件同步 时,该指令可以帮助排查问题,并可用于微调代理和防火墙配置。
若要运行网络连接测试,请运行以下 PowerShell 命令:
Import-Module "C:\Program Files\Azure\StorageSyncAgent\StorageSync.Management.ServerCmdlets.dll"
Test-StorageSyncNetworkConnectivity
如果测试失败,请收集 WinHTTP 跟踪日志以排查问题:netsh trace start scenario=InternetClient_dbg capture=yes overwrite=yes maxsize=1024
再次运行网络连接测试,然后停止收集痕迹: netsh trace stop
把生成 NetTrace.etl 的文件放进压缩包,打开支持案例,然后把文件分享给支持。
防火墙和代理要求摘要
本文档前面列出的列表包含 Azure 文件同步 与之通信的 URL。 防火墙必须允许向这些域的出站流量。 Microsoft 致力于保持这份名单的更新。
设置限制域的防火墙规则可以作为提升安全性的措施。 如果使用这些防火墙配置,请记住URL会被添加,甚至可能随着时间变化。 定期查看这篇文章。