升级群集的 Service Fabric 版本Upgrade the Service Fabric version of a cluster

对于任何现代系统,设计可升级性都是实现产品长期成功的关键。For any modern system, designing for upgradability is key to achieving long-term success of your product. Azure Service Fabric 群集是你拥有的,但部分由 Azure 管理的资源。An Azure Service Fabric cluster is a resource that you own, but is partly managed by Azure. 本文介绍如何升级 Azure 群集中运行的 Service Fabric 版本。This article describes how to upgrade the version of Service Fabric running in your Azure cluster.

可以将群集设置为 Azure 发布自动结构升级时接收该升级,也可以选择想要群集安装的受支持结构版本。You can set your cluster to receive automatic fabric upgrades as they are released by Azure or you can select a supported fabric version you want your cluster to be on.

通过在门户设置“upgradeMode”群集配置,或者在创建实时群集时或在这之后使用 Resource Manager,来实现此目的You do this by setting the "upgradeMode" cluster configuration on the portal or using Resource Manager at the time of creation or later on a live cluster

备注

确保始终让群集运行受支持的结构版本。Make sure to keep your cluster running a supported fabric version always. 当我们公布新版本的 Service Fabric 发布后,则标志着自该日期起至少 60 天以后结束对旧版本的支持。As and when we announce the release of a new version of service fabric, the previous version is marked for end of support after a minimum of 60 days from that date. 新版本在 Service Fabric 团队博客上公布。The new releases are announced on the service fabric team blog. 之后新版本则可供选择。The new release is available to choose then.

群集运行的版本到期之前的 14 天内,生成运行状况事件,将群集置于警告运行状况状态。14 days prior to the expiry of the release your cluster is running, a health event is generated that puts your cluster into a warning health state. 群集将继续处于警告状态,直至升级至支持的结构版本。The cluster remains in a warning state until you upgrade to a supported fabric version.

在 Azure 门户中设置升级模式Set the upgrade mode in the Azure portal

创建群集时可以将群集设置为自动或手动模式。You can set the cluster to automatic or manual when you are creating the cluster.

显示“创建 Service Fabric 群集”窗格的屏幕截图,其中已选中“选项 2 - 群集配置”并打开了“群集配置”窗格。

在实时群集上可以利用管理经验将群集设置为自动或手动模式。You can set the cluster to automatic or manual when on a live cluster, using the manage experience.

在已通过门户设置为手动模式的群集上升级至新版本。Upgrading to a new version on a cluster that is set to Manual mode via portal.

若要升级至新版本,需要执行的全部操作就是从下拉列表中选择可用版本并保存。To upgrade to a new version, all you need to do is select the available version from the dropdown and save. 结构升级会被自动启动。The Fabric upgrade gets kicked off automatically. 在升级期间,将遵守群集运行状况策略(节点运行状况和所有在群集中运行的应用程序的运行状况的组合)。The cluster health policies (a combination of node health and the health all the applications running in the cluster) are adhered to during the upgrade.

如果不符合现行的群集运行状况策略,则回滚升级。If the cluster health policies are not met, the upgrade is rolled back. 向下滚动本文档,了解有关如何设置这些自定义运行状况策略的更多信息。Scroll down this document to read more on how to set those custom health policies.

修复造成回滚的问题后,需要按照与之前完全相同的步骤重新启动升级。Once you have fixed the issues that resulted in the rollback, you need to initiate the upgrade again, by following the same steps as before.

屏幕截图显示“Service Fabric 群集”窗口,其中“Fabric 升级”窗格已打开,并且突出显示了升级选项,包括“自动”和“手动”。

使用 Resource Manager 模板设置升级模式Set the upgrade mode using a Resource Manager template

将“upgradeMode”配置添加到 Microsoft.ServiceFabric/群集资源定义,并将“clusterCodeVersion”设置为下方列出的支持的结构版本之一,然后部署模板。Add the "upgradeMode" configuration to the Microsoft.ServiceFabric/clusters resource definition and set the "clusterCodeVersion" to one of the supported fabric versions as shown below and then deploy the template. “upgradeMode”的有效值为“Manual”或“Automatic”The valid values for "upgradeMode" are "Manual" or "Automatic"

屏幕截图显示一个模板,该模板以纯文本方式缩进来反映结构,并且突出显示了 clusterCodeVersion 和 upgradeMode。

在已通过 Resource Manager 模板设置为手动模式的群集上升级至新版本。Upgrading to a new version on a cluster that is set to Manual mode via a Resource Manager template.

当群集处于手动模式时,要升级到新版本,则可将“clusterCodeVersion”更改为支持的版本并部署此版本。When the cluster is in Manual mode, to upgrade to a new version, change the "clusterCodeVersion" to a supported version and deploy it. 模板的部署启动了结构升级自动被启动。The deployment of the template, kicks of the Fabric upgrade gets kicked off automatically. 在升级期间,将遵守群集运行状况策略(节点运行状况和所有在群集中运行的应用程序的运行状况的组合)。The cluster health policies (a combination of node health and the health all the applications running in the cluster) are adhered to during the upgrade.

如果不符合现行的群集运行状况策略,则回滚升级。If the cluster health policies are not met, the upgrade is rolled back.

修复造成回滚的问题后,需要按照与之前完全相同的步骤重新启动升级。Once you have fixed the issues that resulted in the rollback, you need to initiate the upgrade again, by following the same steps as before.

为升级设置自定义运行状况策略Set custom health polices for upgrades

可以为结构升级指定自定义运行状况策略。You can specify custom health polices for fabric upgrade. 如果已将群集设置为自动结构升级,则这些策略会应用到自动结构升级的阶段 1 中。If you have set your cluster to Automatic fabric upgrades, then these policies get applied to the Phase-1 of the automatic fabric upgrades. 如果已将群集设置为手动结构升级,则在每次选择新版本时应用这些策略,来触发系统启动群集中的结构升级。If you have set your cluster for Manual fabric upgrades, then these policies get applied each time you select a new version triggering the system to kick off the fabric upgrade in your cluster. 如果未重写这些策略,则会使用默认设置。If you do not override the policies, the defaults are used.

可以在“结构升级”边栏选项卡中选择高级升级设置来指定自定义运行状况策略或查看当前设置。You can specify the custom health policies or review the current settings under the "fabric upgrade" blade, by selecting the advanced upgrade settings. 查看以下图片了解操作方法。Review the following picture on how to.

管理自定义运行状况策略

列出适用于指定订阅所有环境的所有可用版本List all available versions for all environments for a given subscription

运行以下命令,应会获得类似于此的输出。Run the following command, and you should get an output similar to this.

“supportExpiryUtc”告知指定版本的过期日期。"supportExpiryUtc" tells your when a given release is expiring or has expired. 最新版本没有有效日期 - 它有一个值为“9999-12-31T23:59:59.9999999”,这表示尚未设置其到期日期。The latest release does not have a valid date - it has a value of "9999-12-31T23:59:59.9999999", which just means that the expiry date is not yet set.

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

Example: https://management.chinacloudapi.cn/subscriptions/1857f442-3bce-4b96-ad95-627f76437a67/providers/Microsoft.ServiceFabric/locations/chinaeast/clusterVersions?api-version=2016-09-01

Output:
{
"value": [
    {
      "id": "subscriptions/35349203-a0b3-405e-8a23-9f1450984307/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/35349203-a0b3-405e-8a23-9f1450984307/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/35349203-a0b3-405e-8a23-9f1450984307/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"
      }
    }
  ]
}

后续步骤Next steps