Azure 檔案同步 Proxy 和防火牆設定

Azure 檔案同步會將您的內部部署伺服器連線到 Azure 檔案服務,以啟用多網站同步處理和雲端層功能。 因此,內部部署伺服器必須連線到網際網路。 IT 系統管理員必須決定進入 Azure 雲端服務之伺服器的最佳路徑。

本文提供特定需求的深入解析,以及可以將伺服器成功且安全地連線至 Azure 檔案同步的選項。

閱讀本操作說明指南之前,建議您先閱讀 Azure 檔案同步網路功能考量

概觀

Azure 檔案同步會作為 Windows Server、Azure 檔案共用和其他數個 Azure 服務之間的協調流程服務,以便如您的同步群組中所述同步處理資料。 為了讓 Azure 檔案同步正常運作,您必須將伺服器設定為與下列 Azure 服務通訊:

  • Azure 儲存體
  • Azure 檔案同步
  • Azure Resource Manager
  • 驗證服務

注意

Windows Server 上的 Azure 檔案同步代理程式會啟動對雲端服務的所有要求,因而只需要從防火牆的觀點考慮輸出流量。 沒有任何 Azure 服務會啟動與 Azure 檔案同步代理程式的連線。

連接埠

Azure 檔案同步會透過 HTTPS 以獨佔方式移動檔案資料和中繼資料,而且要求連接埠 443 開放連出。 如此一來,所有流量都會加密。

網路以及 Azure 的特殊連線

Azure 檔案同步代理程式沒有與 Azure 特殊通道 (例如 ExpressRoute 等) 相關的需求。

Azure 檔案同步會運用任何可用的方法來允許連線至 Azure,自動調整網路特性 (例如頻寬、延遲),以及提供系統管理控制權以進行微調。

Proxy

Azure 檔案同步支援應用程式特定和整部電腦的 Proxy 設定。

應用程式特定的 Proxy 設定可特別針對 Azure 檔案同步流量允許 Proxy 的組態。 代理程式 4.0.1.0 版或更新版本支援應用程式特定的 Proxy 設定,而且可在代理程式安裝期間進行設定,或使用 Set-StorageSyncProxyConfiguration PowerShell Cmdlet。

以下 PowerShell 命令可用來設定應用程式特定的 Proxy 設定:

Import-Module "C:\Program Files\Azure\StorageSyncAgent\StorageSync.Management.ServerCmdlets.dll"
Set-StorageSyncProxyConfiguration -Address <url> -Port <port number> -ProxyCredential <credentials>

例如,如果您的 Proxy 伺服器需要以使用者名稱和密碼進行驗證,請執行下列 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

整部電腦的 Proxy 設定對於 Azure 檔案同步代理程式而言是透明的,因為伺服器的整個流量都會透過 Proxy 路由傳送。

若要設定整部電腦的 Proxy 設定,請遵循下列步驟:

  1. 設定 .NET 應用程式的 Proxy 設定

    • 編輯這兩個檔案:
      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.net> 區段 (位於 <system.serviceModel> 區段下方)。 將 127.0.01:8888 變更為 Proxy 伺服器的 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>
      
  2. 設定 WinHTTP Proxy 設定

    注意

    有數種方法 (WPAD、PAC 檔案、netsh 等) 可設定 Windows Server 以使用 Proxy 伺服器。 下列步驟範圍涵蓋如何使用 netsh 設定 Proxy 設定,也支援用於在 Windows 中設定 Proxy 伺服器設定文件中所列的任何方法。

    • 從提高權限的命令提示字元或 PowerShell 中執行下列命令,以查看現有的 Proxy 設定:

      netsh winhttp show proxy

    • 從提高權限的命令提示字元或 PowerShell 中執行下列命令 (將 127.0.01:8888 變更為 Proxy 伺服器的 IP 位址和連接埠):

      netsh winhttp set proxy 127.0.0.1:8888

  3. 從提高權限的命令提示字元或 PowerShell 中執行下列命令,以重新啟動儲存體同步代理程式服務:

    net stop filesyncsvc

    注意:儲存體同步代理程式 (filesyncsvc) 服務會在停止後自動啟動。

防火牆

如前一節所述,連接埠 443 必須開放連出。 根據您資料中心、分公司或區域的原則,可能會想要或需要進一步限制透過此連接埠送至特定網域的流量。

下表描述通訊所需的網域:

服務 公用雲端端點 Azure Government 端點 使用方式
Azure Resource Manager https://management.azure.com https://management.usgovcloudapi.net 任何使用者呼叫 (例如 PowerShell) 都會通過這個 URL,包括初始伺服器註冊呼叫。
Microsoft Entra ID https://login.windows.net
https://login.microsoftonline.com
https://aadcdn.msftauth.net
https://login.microsoftonline.us Azure Resource Manager 呼叫必須由已驗證的使用者進行。 為了獲致成功,此 URL 用於進行使用者驗證。
Microsoft Entra ID https://graph.microsoft.com/ https://graph.microsoft.com/ 在部署 Azure 檔案同步時,將會在訂用帳戶的 Microsoft Entra ID 中建立服務主體。 針對該目的使用此 URL。 此主體用於將最小權限集合委派給 Azure 檔案同步服務。 執行 Azure 檔案同步之初始設定的使用者,必須是具有訂用帳戶擁有者權限的已驗證使用者。
Microsoft Entra ID https://secure.aadcdn.microsoftonline-p.com https://secure.aadcdn.microsoftonline-p.com
(與公用雲端端點 URL 相同)
Azure 檔案同步伺服器註冊 UI 用來登入系統管理員的 Active Directory 驗證程式庫會存取此 URL。
Azure 儲存體 *.core.windows.net *.core.usgovcloudapi.net 當伺服器下載檔案時,如果伺服器可以直接與儲存體帳戶中的 Azure 檔案共用通話,就可以更有效率地執行資料移動。 伺服器具有只允許存取目標檔案共用的 SAS 金鑰。
Azure 檔案同步 *.one.microsoft.com
*.afs.azure.net
*.afs.azure.us 初始伺服器註冊之後,伺服器會收到該區域中 Azure 檔案同步服務執行個體的區域 URL。 伺服器可以使用 URL 直接且有效率地與處理其同步的執行個體進行通訊。
Microsoft PKI https://www.microsoft.com/pki/mscorp/cps
http://crl.microsoft.com/pki/mscorp/crl/
http://mscrl.microsoft.com/pki/mscorp/crl/
http://ocsp.msocsp.com
http://ocsp.digicert.com/
http://crl3.digicert.com/
https://www.microsoft.com/pki/mscorp/cps
http://crl.microsoft.com/pki/mscorp/crl/
http://mscrl.microsoft.com/pki/mscorp/crl/
http://ocsp.msocsp.com
http://ocsp.digicert.com/
http://crl3.digicert.com/
一旦安裝了 Azure 檔案同步代理程式,系統就會使用 PKI URL 來下載與 Azure 檔案同步服務和 Azure 檔案共用通訊時所需的中繼憑證。 OCSP URL 是用來檢查憑證的狀態。
Microsoft Update *.update.microsoft.com
*.download.windowsupdate.com
*.ctldl.windowsupdate.com
*.dl.delivery.mp.microsoft.com
*.emdl.ws.microsoft.com
*.update.microsoft.com
*.download.windowsupdate.com
*.ctldl.windowsupdate.com
*.dl.delivery.mp.microsoft.com
*.emdl.ws.microsoft.com
安裝 Azure 檔案同步代理程式後,就會使用 Microsoft Update URL 來下載 Azure 檔案同步代理程式更新。

重要

允許前往 *.afs.azure.net 的流量時,流量只能前往同步服務。 沒有其他 Microsoft 服務使用此網域。 允許前往 *.one.microsoft.com 的流量時,伺服器可能會有前往同步服務以外的流量。 子網域底下有許多 Microsoft 服務可用。

如果 *.afs.azure.net 或 *.one.microsoft.com 太廣泛,您可以僅允許對 Azure 檔案同步服務的明確區域執行個體進行通訊,藉以限制伺服器的通訊。 要選擇哪個執行個體,取決於您將伺服器部署及註冊到哪個儲存體同步服務區域。 在下表中,該區域稱為「主要端點 URL」。

基於商務持續性和災害復原 (BCDR) 的原因,您可能已在針對異地備援儲存體 (GRS) 而設定的儲存體帳戶中建立了 Azure 檔案共用。 若是如此,在發生持久的區域中斷時,Azure 檔案共用會容錯移轉至配對的區域。 Azure 檔案同步會使用相同的區域配對作為儲存體。 因此,如果您使用 GRS 儲存體帳戶,則需要啟用其他 URL,以供伺服器向 Azure 檔案同步的配對區域聯繫。下表將此稱為「配對的區域」。 此外,也必須啟用流量管理員設定檔 URL。 這可確保在發生容錯移轉時,網路流量會順暢地重新路由傳送至配對的區域,這個行為在下表中稱為「探索 URL」。

雲端 區域 主要端點 URL 配對的區域 探索 URL
公開 澳大利亞東部 https://australiaeast01.afs.azure.net
https://kailani-aue.one.microsoft.com
澳大利亞東南部 https://tm-australiaeast01.afs.azure.net
https://tm-kailani-aue.one.microsoft.com
公開 澳大利亞東南部 https://australiasoutheast01.afs.azure.net
https://kailani-aus.one.microsoft.com
澳大利亞東部 https://tm-australiasoutheast01.afs.azure.net
https://tm-kailani-aus.one.microsoft.com
公開 巴西南部 https://brazilsouth01.afs.azure.net 美國中南部 https://tm-brazilsouth01.afs.azure.net
公開 加拿大中部 https://canadacentral01.afs.azure.net
https://kailani-cac.one.microsoft.com
加拿大東部 https://tm-canadacentral01.afs.azure.net
https://tm-kailani-cac.one.microsoft.com
公開 加拿大東部 https://canadaeast01.afs.azure.net
https://kailani-cae.one.microsoft.com
加拿大中部 https://tm-canadaeast01.afs.azure.net
https://tm-kailani.cae.one.microsoft.com
公開 印度中部 https://centralindia01.afs.azure.net
https://kailani-cin.one.microsoft.com
印度南部 https://tm-centralindia01.afs.azure.net
https://tm-kailani-cin.one.microsoft.com
公開 美國中部 https://centralus01.afs.azure.net
https://kailani-cus.one.microsoft.com
美國東部 2 https://tm-centralus01.afs.azure.net
https://tm-kailani-cus.one.microsoft.com
由 21Vianet 營運的 Microsoft Azure 中國東部 2 https://chinaeast201.afs.azure.cn 中國北部 2 https://tm-chinaeast201.afs.azure.cn
由 21Vianet 營運的 Microsoft Azure 中國北部 2 https://chinanorth201.afs.azure.cn 中國東部 2 https://tm-chinanorth201.afs.azure.cn
公開 東亞 https://eastasia01.afs.azure.net
https://kailani11.one.microsoft.com
東南亞 https://tm-eastasia01.afs.azure.net
https://tm-kailani11.one.microsoft.com
公開 美國東部 https://eastus01.afs.azure.net
https://kailani1.one.microsoft.com
美國西部 https://tm-eastus01.afs.azure.net
https://tm-kailani1.one.microsoft.com
公開 美國東部 2 https://eastus201.afs.azure.net
https://kailani-ess.one.microsoft.com
美國中部 https://tm-eastus201.afs.azure.net
https://tm-kailani-ess.one.microsoft.com
公開 德國北部 https://germanynorth01.afs.azure.net 德國中西部 https://tm-germanywestcentral01.afs.azure.net
公開 德國中西部 https://germanywestcentral01.afs.azure.net 德國北部 https://tm-germanynorth01.afs.azure.net
公開 日本東部 https://japaneast01.afs.azure.net 日本西部 https://tm-japaneast01.afs.azure.net
公開 日本西部 https://japanwest01.afs.azure.net 日本東部 https://tm-japanwest01.afs.azure.net
公開 南韓中部 https://koreacentral01.afs.azure.net/ 南韓南部 https://tm-koreacentral01.afs.azure.net/
公開 南韓南部 https://koreasouth01.afs.azure.net/ 南韓中部 https://tm-koreasouth01.afs.azure.net/
公開 美國中北部 https://northcentralus01.afs.azure.net 美國中南部 https://tm-northcentralus01.afs.azure.net
公開 北歐 https://northeurope01.afs.azure.net
https://kailani7.one.microsoft.com
西歐 https://tm-northeurope01.afs.azure.net
https://tm-kailani7.one.microsoft.com
公開 美國中南部 https://southcentralus01.afs.azure.net 美國中北部 https://tm-southcentralus01.afs.azure.net
公開 印度南部 https://southindia01.afs.azure.net
https://kailani-sin.one.microsoft.com
印度中部 https://tm-southindia01.afs.azure.net
https://tm-kailani-sin.one.microsoft.com
公開 東南亞 https://southeastasia01.afs.azure.net
https://kailani10.one.microsoft.com
東亞 https://tm-southeastasia01.afs.azure.net
https://tm-kailani10.one.microsoft.com
公開 瑞士北部 https://switzerlandnorth01.afs.azure.net
https://tm-switzerlandnorth01.afs.azure.net
瑞士西部 https://switzerlandwest01.afs.azure.net
https://tm-switzerlandwest01.afs.azure.net
公開 瑞士西部 https://switzerlandwest01.afs.azure.net
https://tm-switzerlandwest01.afs.azure.net
瑞士北部 https://switzerlandnorth01.afs.azure.net
https://tm-switzerlandnorth01.afs.azure.net
公開 阿拉伯聯合大公國中部 https://uaecentral01.afs.azure.net 阿拉伯聯合大公國北部 https://tm-uaecentral01.afs.azure.net
公開 阿拉伯聯合大公國北部 https://uaenorth01.afs.azure.net 阿拉伯聯合大公國中部 https://tm-uaenorth01.afs.azure.net
公開 英國南部 https://uksouth01.afs.azure.net
https://kailani-uks.one.microsoft.com
英國西部 https://tm-uksouth01.afs.azure.net
https://tm-kailani-uks.one.microsoft.com
公開 英國西部 https://ukwest01.afs.azure.net
https://kailani-ukw.one.microsoft.com
英國南部 https://tm-ukwest01.afs.azure.net
https://tm-kailani-ukw.one.microsoft.com
公開 美國中西部 https://westcentralus01.afs.azure.net 美國西部 2 https://tm-westcentralus01.afs.azure.net
公開 西歐 https://westeurope01.afs.azure.net
https://kailani6.one.microsoft.com
北歐 https://tm-westeurope01.afs.azure.net
https://tm-kailani6.one.microsoft.com
公開 美國西部 https://westus01.afs.azure.net
https://kailani.one.microsoft.com
美國東部 https://tm-westus01.afs.azure.net
https://tm-kailani.one.microsoft.com
公開 美國西部 2 https://westus201.afs.azure.net 美國中西部 https://tm-westus201.afs.azure.net
政府 US Gov 亞利桑那州 https://usgovarizona01.afs.azure.us US Gov 德克薩斯州 https://tm-usgovarizona01.afs.azure.us
政府 US Gov 德克薩斯州 https://usgovtexas01.afs.azure.us US Gov 亞利桑那州 https://tm-usgovtexas01.afs.azure.us
  • 如果您使用針對本地備援儲存體 (LRS) 或區域備援儲存體 (ZRS) 而設定的儲存體帳戶,您只需啟用 [主要端點 URL] 底下列出的 URL 即可。

  • 如果您使用針對 GRS 而設定的儲存體帳戶,請啟用三個 URL。

範例:您在 "West US" 部署儲存體同步服務,並向其註冊伺服器。 在此案例中,要允許伺服器與之通訊的 URL 是:

  • https://westus01.afs.azure.net (主要端點:美國西部)
  • https://eastus01.afs.azure.net (配對的容錯移轉區域:美國東部)
  • https://tm-westus01.afs.azure.net (主要區域的探索 URL)

Azure 檔案同步 IP 位址的允許清單

Azure 檔案同步支援使用服務標籤,這些標籤代表給定 Azure 服務的一組 IP 位址前置詞。 您可以使用服務標籤來建立防火牆規則,以啟用與 Azure 檔案同步服務間的通訊。 Azure 檔案同步的服務標籤為 StorageSyncService

如果在 Azure 中使用 Azure 檔案同步,您可以直接在網路安全性群組中使用服務標籤的名稱來允許流量。 若要深入了解如何執行此操作,請參閱網路安全性群組

如果您是使用 Azure 檔案同步內部部署,就可利用服務標籤 API 取得您防火牆允許清單的特定 IP 位址範圍。 有兩種方法可以取得此資訊:

由於服務標籤探索 API 可能不會像發佈至 Microsoft 下載中心的 JSON 文件一樣頻繁更新,建議您使用 JSON 文件更新內部部署防火牆的允許清單。 以下步驟可以達到此目的:

# The specific region to get the IP address ranges for. Replace westus2 with the desired region code 
# from Get-AzLocation.
$region = "westus2"

# The service tag for Azure File Sync. Do not 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 is not available. Either Azure File Sync is not deployed there or the region does not 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://learn.microsoft.com/azure/virtual-network/service-tags-overview
    Write-Verbose -Message "JSON service tag file not found."
    return
}

然後,您可以使用 $ipAddressRanges 中的 IP 位址範圍來更新您的防火牆。 請查看防火牆/網路設備的網站,以取得如何更新防火牆的相關資訊。

測試服務端點的網路連線

向 Azure 檔案同步服務註冊伺服器之後,就可以使用 Test-StorageSyncNetworkConnectivity Cmdlet 和 ServerRegistration.exe 測試與此伺服器特有的所有端點 (URL) 間的通訊。 當未完成的通訊防止伺服器與 Azure 檔案同步完全合作時,此 Cmdlet 有助於疑難排解,而且還可以用來微調 Proxy 和防火牆設定。

若要執行網路連線能力測試,請執行下列 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 檔案放入 ZIP 封存中、開啟支援案例,並與支援共用檔案。

摘要和風險限制

本文件中稍早的清單包含 Azure 檔案同步目前與其通訊的 URL。 防火牆必須能夠允許輸出至這些網域的流量。 Microsoft 致力於讓這份清單保持最新狀態。

設定網域限制防火牆規則可以提高安全性。 如果使用這些防火牆組態,請記得 URL 會新增,甚至可能隨著時間而改變。 請定期查看此文章。

下一步