Azure Service Fabric 从 Visual Studio 发布升级 - PowerShell 脚本错误
Azure Service Fabric publish upgrade from Visual Studio - PowerShell Script Error
我正在尝试将 Service Fabric 应用程序从 Visual Studio 2017 升级到我们的 Azure Service Fabric 集群。 9 月中旬,我使用相同的 PowerShell 脚本成功发布了同一应用程序到 SFC 的升级,没有任何问题。我现在正尝试在下一个版本号升级它并突然收到此错误。
我在发布期间收到以下与 Powershell 相关的错误。
2>Started executing script 'Deploy-FabricApplication.ps1'.
2>powershell -NonInteractive -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -Command ". 'C:\Users\pj\Source\Workspaces\VDevelopment\trunk\Services\Sources\src\For.Application.ServiceFabric.Sources\Scripts\Deploy-FabricApplication.ps1' -ApplicationPackagePath 'C:\Users\pj\Source\Workspaces\VDevelopment\trunk\Services\Sources\src\For.Application.ServiceFabric.Sources\pkg\Debug' -PublishProfileFile 'C:\Users\pj\Source\Workspaces\VDevelopment\trunk\Services\Sources\src\For.Application.ServiceFabric.Sources\PublishProfiles\Cloud.xml' -DeployOnly:$false -ApplicationParameter:@{} -UnregisterUnusedApplicationVersionsAfterUpgrade $false -OverrideUpgradeBehavior 'None' -OverwriteBehavior 'SameAppTypeAndVersion' -SkipPackageValidation:$false -ErrorAction Stop"
2>Copying application package to image store...
2>Upload to Image Store succeeded
2>Registering application type...
2>Register application type started. Use Get-ServiceFabricApplicationType to query for status.
2>Running Image Builder process ...
2>Application package is registered.
2>Start upgrading application...
2>aka.ms/upgrade-defaultservices
2>Start-ServiceFabricApplicationUpgrade : aka.ms/upgrade-defaultservices
2>At C:\Program Files\Microsoft SDKs\Service
2>Fabric\Tools\PSModule\ServiceFabricSDK\Publish-UpgradedServiceFabricApplication.ps1:317 char:13
2>+ Start-ServiceFabricApplicationUpgrade @UpgradeParameters
2>+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2> + CategoryInfo : InvalidOperation: (Microsoft.Servi...usterConnection:ClusterConnection) [Start-ServiceFa
2> bricApplicationUpgrade], FabricException
2> + FullyQualifiedErrorId : UpgradeApplicationErrorId,Microsoft.ServiceFabric.Powershell.StartApplicationUpgrade
2>
2>Finished executing script 'Deploy-FabricApplication.ps1'.
2>Time elapsed: 00:07:39.0407526
2>The PowerShell script failed to execute.
========== Build: 1 succeeded, 0 failed, 10 up-to-date, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========
知道这里发生了什么吗?同样,当我上次在 9 月发布此内容时,使用相同的脚本,完全没有问题,除了升级清单版本以将其作为新的升级版本推出之外,我没有对解决方案进行任何更改。
我注意到这个 S/O 线程: 并看到用户的错误是相似的,但答案不适用于我的问题,因为提供的答案中的所有三个步骤肯定都包含在我的问题中powershell 部署脚本。
如果有帮助,我可以添加部署脚本,但会等到有人要求它,因为它很长,我只想 post 如果有人觉得需要诊断,我就在这里
您收到此错误是因为您正在更改默认情况下不允许的 DefaultService 中的某些参数。
错误日志中显示的 link aka.ms/upgrade-defaultservices 解释了这一点。
Some default service parameters defined in the application manifest
can also be upgraded as part of an application upgrade.
Only the service parameters that support being changed through
Update-ServiceFabricService can be changed as part of an upgrade. The
behavior of changing default services during application upgrade is as
follows:
- Default services in the new application manifest that do not already exist in the cluster are created.
- Default services that exist in both the previous and new application manifests are updated. The parameters of the default
service in the new application manifest overwrite the parameters of
the existing service. The application upgrade will rollback
automatically if updating a default service fails.
- Default services that do not exist in the new application manifest are deleted if they exist in the cluster. Note that deleting a default
service will result in deleting all that service's state and cannot be
undone.
此外,还有关于同一件事的另一个 SO 问题:
上面的第 1 项是一种常见的方法,其中新服务被添加到解决方案中,然后在升级过程中无错误地创建,第 2 项和第 3 项是需要 EnableDefaultServicesUpgrade
的受限方法。
第 2 项与您添加的答案中描述的一样,您在手动更新期间将 MinReplicaSize
和 TargetReplicaSize
更改为 1,当时 SF 验证了您的服务状态以进行升级,它识别出差异并阻止升级继续,如果您将集群设置 EnableDefaultServicesUpgrade
设置为 true
它将继续并覆盖默认值。
第3项,当您删除该服务并再次添加时,您更改或拼写错误的名称,顺丰默认设置将阻止删除该服务。
关于您找到的解决方案(删除并重新创建),并不理想,
在生产中有状态服务 运行 的情况下,应用会有风险,因为在某些情况下,您必须备份状态、重新部署服务并恢复备份,具体取决于这些更改是的,您将无法恢复备份,因为它们必须与原始服务定义(分区类型、编号等)相匹配。您还会失去滚动更新的好处,如果这些备份很大,您的服务可能会中断一段时间。
这个问题与我们试图推出具有不匹配节点实例的应用程序有关。我们在这个应用程序下有一个有状态服务 运行,它应该将 MinReplicaSize 和 TargetReplicaSize 设置为 3。昨天,由于一个问题,我们在 SF Explorer 中删除并重新创建了这个服务。这样做后,它将副本大小参数重置回 1。因此我们使用 Powershell 脚本将它们改回 3,但该脚本不包含使服务恢复到之前的确切状态所需的所有命令我们删除了它。所以今天当我们去升级应用程序时,SFC 中的应用程序不接受从 VS 部署升级,因为解决方案参数与我们的 SFC 中的内容不匹配。解决,我们先把那些服务重新删除,然后从VS部署,就没有再报错了。
我正在尝试将 Service Fabric 应用程序从 Visual Studio 2017 升级到我们的 Azure Service Fabric 集群。 9 月中旬,我使用相同的 PowerShell 脚本成功发布了同一应用程序到 SFC 的升级,没有任何问题。我现在正尝试在下一个版本号升级它并突然收到此错误。
我在发布期间收到以下与 Powershell 相关的错误。
2>Started executing script 'Deploy-FabricApplication.ps1'.
2>powershell -NonInteractive -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -Command ". 'C:\Users\pj\Source\Workspaces\VDevelopment\trunk\Services\Sources\src\For.Application.ServiceFabric.Sources\Scripts\Deploy-FabricApplication.ps1' -ApplicationPackagePath 'C:\Users\pj\Source\Workspaces\VDevelopment\trunk\Services\Sources\src\For.Application.ServiceFabric.Sources\pkg\Debug' -PublishProfileFile 'C:\Users\pj\Source\Workspaces\VDevelopment\trunk\Services\Sources\src\For.Application.ServiceFabric.Sources\PublishProfiles\Cloud.xml' -DeployOnly:$false -ApplicationParameter:@{} -UnregisterUnusedApplicationVersionsAfterUpgrade $false -OverrideUpgradeBehavior 'None' -OverwriteBehavior 'SameAppTypeAndVersion' -SkipPackageValidation:$false -ErrorAction Stop"
2>Copying application package to image store...
2>Upload to Image Store succeeded
2>Registering application type...
2>Register application type started. Use Get-ServiceFabricApplicationType to query for status.
2>Running Image Builder process ...
2>Application package is registered.
2>Start upgrading application...
2>aka.ms/upgrade-defaultservices
2>Start-ServiceFabricApplicationUpgrade : aka.ms/upgrade-defaultservices
2>At C:\Program Files\Microsoft SDKs\Service
2>Fabric\Tools\PSModule\ServiceFabricSDK\Publish-UpgradedServiceFabricApplication.ps1:317 char:13
2>+ Start-ServiceFabricApplicationUpgrade @UpgradeParameters
2>+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2> + CategoryInfo : InvalidOperation: (Microsoft.Servi...usterConnection:ClusterConnection) [Start-ServiceFa
2> bricApplicationUpgrade], FabricException
2> + FullyQualifiedErrorId : UpgradeApplicationErrorId,Microsoft.ServiceFabric.Powershell.StartApplicationUpgrade
2>
2>Finished executing script 'Deploy-FabricApplication.ps1'.
2>Time elapsed: 00:07:39.0407526
2>The PowerShell script failed to execute.
========== Build: 1 succeeded, 0 failed, 10 up-to-date, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========
知道这里发生了什么吗?同样,当我上次在 9 月发布此内容时,使用相同的脚本,完全没有问题,除了升级清单版本以将其作为新的升级版本推出之外,我没有对解决方案进行任何更改。
我注意到这个 S/O 线程:
如果有帮助,我可以添加部署脚本,但会等到有人要求它,因为它很长,我只想 post 如果有人觉得需要诊断,我就在这里
您收到此错误是因为您正在更改默认情况下不允许的 DefaultService 中的某些参数。
错误日志中显示的 link aka.ms/upgrade-defaultservices 解释了这一点。
Some default service parameters defined in the application manifest can also be upgraded as part of an application upgrade.
Only the service parameters that support being changed through Update-ServiceFabricService can be changed as part of an upgrade. The behavior of changing default services during application upgrade is as follows:
- Default services in the new application manifest that do not already exist in the cluster are created.
- Default services that exist in both the previous and new application manifests are updated. The parameters of the default service in the new application manifest overwrite the parameters of the existing service. The application upgrade will rollback automatically if updating a default service fails.
- Default services that do not exist in the new application manifest are deleted if they exist in the cluster. Note that deleting a default service will result in deleting all that service's state and cannot be undone.
此外,还有关于同一件事的另一个 SO 问题:
上面的第 1 项是一种常见的方法,其中新服务被添加到解决方案中,然后在升级过程中无错误地创建,第 2 项和第 3 项是需要 EnableDefaultServicesUpgrade
的受限方法。
第 2 项与您添加的答案中描述的一样,您在手动更新期间将 MinReplicaSize
和 TargetReplicaSize
更改为 1,当时 SF 验证了您的服务状态以进行升级,它识别出差异并阻止升级继续,如果您将集群设置 EnableDefaultServicesUpgrade
设置为 true
它将继续并覆盖默认值。
第3项,当您删除该服务并再次添加时,您更改或拼写错误的名称,顺丰默认设置将阻止删除该服务。
关于您找到的解决方案(删除并重新创建),并不理想, 在生产中有状态服务 运行 的情况下,应用会有风险,因为在某些情况下,您必须备份状态、重新部署服务并恢复备份,具体取决于这些更改是的,您将无法恢复备份,因为它们必须与原始服务定义(分区类型、编号等)相匹配。您还会失去滚动更新的好处,如果这些备份很大,您的服务可能会中断一段时间。
这个问题与我们试图推出具有不匹配节点实例的应用程序有关。我们在这个应用程序下有一个有状态服务 运行,它应该将 MinReplicaSize 和 TargetReplicaSize 设置为 3。昨天,由于一个问题,我们在 SF Explorer 中删除并重新创建了这个服务。这样做后,它将副本大小参数重置回 1。因此我们使用 Powershell 脚本将它们改回 3,但该脚本不包含使服务恢复到之前的确切状态所需的所有命令我们删除了它。所以今天当我们去升级应用程序时,SFC 中的应用程序不接受从 VS 部署升级,因为解决方案参数与我们的 SFC 中的内容不匹配。解决,我们先把那些服务重新删除,然后从VS部署,就没有再报错了。