问题
I have published service fabric application version 1.25.0 to the local cluster as well as a cluster in Azure through visual studio publish. All worked.
Visual studio gives me the option to upgrade the application too. But I could not able to find how to rollback and publish the previous version of my application let's say 1.23.0 from visual studio.
If it cannot be possible from the Visual studio is it possible to do it from service fabric explorer?
I have seen posts like Azure Service Fabric Rollback but they are related to PowerShell scripts I am more after looking to rollback from visual studio or service fabric explorer.
回答1:
There is no Service Fabric Explorer option or buttons to make rollbacks or upgrades, There are some caveats in the deployment that you must pay attention to correctly use the Rollback, if it was just a button, it would increase the chances of making mistakes.
The rollback using scripts are not that complex, you should be able to to with just a few lines of code like the option provided in the answer you linked.
Also, rollback is simple to do but can be complex in some scenarios, for example, changing the configuration of existing services, backups, restores and so on, would be tricky to do an UI to handle many scenarios, using scripts make it more flexible and dynamic. Today the scripts are simple, but in case new features are added in the future, it wouldn't need many changes to support it.
Regarding the scenarios, you could make use of other approaches like:
The first scenario is: Deployment is successful but application is not behaving correctly
This scenario is very common when the new version is successfully deployed, the service runs without errors, but the application has bugs or does not work as expect.
To rollback to a previous version you must upgrade the application and target the Application Version deployed previously. Is just a simple upgrade command, unfortunately there is no "Previous Version" stored somewhere, you have to keep track of previous versions somewhere so that you can find the previous versions.
The command must be run manually like:
Start-ServiceFabricApplicationUpgrade -ApplicationName fabric:/VisualObjects -ApplicationTypeVersion 2.0.0.0 -HealthCheckStableDurationSec 60 -UpgradeDomainTimeoutSec 1200 -UpgradeTimeout 3000 -FailureAction Rollback -Monitored
The script Deploy-FabricApplication.ps1
have a parameter UnregisterUnusedApplicationVersionsAfterUpgrade
that removes older versions from ServiceFabric Image store, if you use this approach you should avoid, because you have to copy the older version to SF and then apply the upgrade in case a rollback is needed. A better approach is implement an algorithm that runs nightly or after releases and remove old versions and keep the last N.
.
The other scenario is: Service failure during upgrade
In this case is easier to handle, because Service Fabric handles it for you, when you start the upgrade you have the option to make it automatic or manual.
In the automatic, if a service fails on startup, Service Fabric will see it and retry a few times, in case it persists, it will rollback to the service and the application to previous version automatically.
In the manual mode, Service Fabric will start the deployment, but won't take any action, and you should run scripts to continue the deployment to next stages or rollback. This approach is convenient if you have very sensitive services and updates need an extra caution, mainly to validate the behaviour and do manual tests before you continue with the deployment.
These settings can be found here
来源:https://stackoverflow.com/questions/53298526/service-fabric-rollback-to-previous-version-from-visual-stuido-or-service-fabric