管理 Service Fabric 叢集升級

Azure Service Fabric 叢集是您所擁有,但部分由 Microsoft 管理的資源。 以下是如何管理 Microsoft 更新 Azure Service Fabric 叢集的時機和方式。

如需有關叢集升級概念和程序的深入背景,請參閱升級和更新 Azure Service Fabric 叢集

設定升級模式

您可以透過為叢集設定升級模式,將叢集設定為會在 Microsoft 發行 Service Fabric 升級時自動接收升級,或是從目前支援的版本清單中手動選擇。 您可以透過 Azure 入口網站中的 升級模式控制項或叢集部署範本中的 upgradeMode設定來完成此操作。

Azure 入口網站

使用 Azure 入口網站,您將會在建立新的 Service Fabric 叢集時,選擇自動升級或手動升級。

Choose between automatic or manual upgrades when creating a new cluster in Azure portal from the 'Advanced' options

您也可以從現有叢集資源的 [Fabric 升級] 區段中切換自動或手動升級。

Select Automatic or Manual upgrades in the 'Fabric upgrades' section of your cluster resource in Azure portal

透過 Azure 入口網站手動升級

當您選取手動升級選項時,起始升級所需的一切都會從 [可用版本] 下拉式清單中選取,然後再選取 [儲存]。 叢集升級會從該處立即開始。

升級期間會遵守叢集健康狀態原則 (綜合節點健康狀態和所有在叢集中執行之應用程式的健康狀態)。 如果不符合叢集健康狀態原則,則升級會復原。

在解決導致復原的問題後,您需要依照之前的相同步驟再次起始升級。

Resource Manager 範本

若要使用 Resource Manager 範本變更叢集升級模式,請針對 Microsoft.ServiceFabric/clusters 資源定義的 upgradeMode 屬性,指定 [自動] 或 [手動]。 如果您選擇手動升級,也請將 clusterCodeVersion 設定為目前支援的網狀架構版本

Screenshot shows a template, which is plaintext indented to reflect structure. The 'clusterCodeVersion' and 'upgradeMode' properties are highlighted.

成功部署範本之後,將會套用叢集升級模式的變更。 如果您的叢集處於手動模式,叢集升級將會自動啟動。

升級期間會遵守叢集健康狀態原則 (綜合節點健康狀態和所有在叢集中執行之應用程式的健康狀態)。 如果不符合叢集健康狀態原則,則升級會復原。

在解決導致復原的問題後,您需要依照之前的相同步驟再次起始升級。

自動升級的 Wave 部署

使用自動升級模式時,您可以選擇讓叢集進行 Wave 部署。 使用 Wave 部署時,您可以建立管線來依序升級測試、暫存和生產叢集,並依內建的「製作時間」作區隔,以在更新生產叢集之前驗證即將推出的 Service Fabric 版本。

啟用 Wave 部署

注意

Wave 部署需要 Microsoft.ServiceFabric/clusters 資源的 2020-12-01-preview (或更新) API 版本。

若要為自動升級啟用 Wave 部署,請先判斷要指派叢集的 Wave:

  • Wave 0 (Wave0):一有新的 Service Fabric 組建發行就更新叢集。 適用於測試/開發叢集。
  • Wave 1 (Wave1):在新組建發行一週 (七天) 後再更新叢集。 適用於生產階段前/預備叢集。
  • Wave 2 (Wave2):在新組建發行兩週 (14 天) 後再更新叢集。 適用於生產叢集。

然後,直接將 upgradeWave 屬性新增至您的叢集資源範本,並包含上面所列的其中一個 Wave 值。 確定您的叢集資源 API 版本是 2020-12-01-preview 或更新版本。

{
    "apiVersion": "2020-12-01-preview",
    "type": "Microsoft.ServiceFabric/clusters",
     ...
        "fabricSettings": [...],
        "managementEndpoint": ...,
        "nodeTypes": [...],
        "provisioningState": ...,
        "reliabilityLevel": ...,
        "upgradeMode": "Automatic",
        "upgradeWave": "Wave1",
       ...

當您部署更新的範本之後,您的叢集將會在指定的 Wave 中註冊,以決定下一次及之後的升級期間。

您可以註冊要收到電子郵件通知,以在叢集升級失敗時使用通知內所附的連結來獲得進一步的協助。

註冊通知

您可以註冊叢集升級失敗時的通知。 系統會將電子郵件傳送給您指定的電子郵件地址,其中會包含有關升級失敗的進一步詳細資料,以及進一步說明的連結。

注意

在 Wave 部署中不需要註冊,就能收到升級失敗的通知。

若要註冊通知,請將 notifications 區段新增至您的叢集資源範本,並指定一個或多個電子郵件地址 (收件者) 來接收通知:

    "apiVersion": "2020-12-01-preview",
    "type": "Microsoft.ServiceFabric/clusters",
     ...
        "upgradeMode": "Automatic",
        "upgradeWave": "Wave1",
        "notifications": [
        {
            "isEnabled": true,
            "notificationCategory": "WaveProgress",
            "notificationLevel": "Critical",
            "notificationTargets": [
            {
                "notificationChannel": "EmailUser",
                "receivers": [
                    "devops@contoso.com"
                ]
            }]
        }]

部署更新的範本之後,您將會註冊升級失敗通知。

手動升級的自訂原則

您可以針對手動的叢集升級來指定自訂健康情況原則。 每次您選取新的執行階段版本時便會套用這些原則,以觸發系統來啟動叢集的升級。 如果您不覆寫原則,則會使用預設值。

您可以在 Azure 入口網站的 [升級原則] 中選取 [自訂] 選項,以在叢集資源的 [Fabric 更新] 區段底下指定自訂的健康原則或檢查目前的設定。

Select the 'Custom' upgrade policy option in the 'Fabric upgrades' section of your cluster resource in Azure portal in order to set custom health policies during upgrade

檢查支援的叢集版本

您可以參考 Service Fabric 版本,以取得支援的版本和作業系統的進一步詳細資料。

您也可以使用 Azure REST API 來列出指定位置和您訂用帳戶的所有可用 Service Fabric 執行階段版本 (clusterVersions)。

GET https://<endpoint>/subscriptions/{{subscriptionId}}/providers/Microsoft.ServiceFabric/locations/{{location}}/clusterVersions?api-version=2018-02-01

"value": [
  {
    "id": "subscriptions/########-####-####-####-############/providers/Microsoft.ServiceFabric/environments/Windows/clusterVersions/5.0.1427.9490",
    "name": "5.0.1427.9490",
    "type": "Microsoft.ServiceFabric/environments/clusterVersions",
    "properties": {
      "codeVersion": "5.0.1427.9490",
      "supportExpiryUtc": "2016-11-26T23:59:59.9999999",
      "environment": "Windows"
    }
  },
  {
    "id": "subscriptions/########-####-####-####-############/providers/Microsoft.ServiceFabric/environments/Windows/clusterVersions/4.0.1427.9490",
    "name": "5.1.1427.9490",
    "type": " Microsoft.ServiceFabric/environments/clusterVersions",
    "properties": {
      "codeVersion": "5.1.1427.9490",
      "supportExpiryUtc": "9999-12-31T23:59:59.9999999",
      "environment": "Windows"
    }
  },
  {
    "id": "subscriptions/########-####-####-####-############/providers/Microsoft.ServiceFabric/environments/Windows/clusterVersions/4.4.1427.9490",
    "name": "4.4.1427.9490",
    "type": " Microsoft.ServiceFabric/environments/clusterVersions",
    "properties": {
      "codeVersion": "4.4.1427.9490",
      "supportExpiryUtc": "9999-12-31T23:59:59.9999999",
      "environment": "Linux"
    }
  }
]
}

supportExpiryUtc 輸出會報告指定版本即將到期或已過期。 最新版本並無有效日期,但有 9999-12-31T23:59:59.9999999 值,這只是表示尚未設定到期日。

檢查支援的升級路徑

您可以參考 Service Fabric 版本文件,以取得支援的升級路徑和相關版本資訊。

使用支援的目標版本資訊,您就可以使用下列 PowerShell 步驟來驗證支援的升級路徑。

  1. 登入 Azure

    Login-AzAccount
    
  2. 選取訂用帳戶

    Set-AzContext -SubscriptionId <your-subscription>
    
  3. 叫用 API

    $params = @{ "TargetVersion" = "<target version>"}
    Invoke-AzResourceAction -ResourceId <cluster resource id> -Parameters $params -Action listUpgradableVersions -Force
    

    範例:

    $params = @{ "TargetVersion" = "8.1.335.9590"}
    Invoke-AzResourceAction -ResourceId /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/myResourceGroup/providers/Microsoft.ServiceFabric/clusters/myCluster -Parameters $params -Action listUpgradableVersions -Force
    
    Output
    supportedPath
    -------------
    {8.1.329.9590, 8.1.335.9590}
    

下一步