Containerization with Microsoft Service Fabric
This is a how-to for operators running containerised applications (which can be Docker images) on Microsoft Service Fabric. It covers one task I reach for often: manually rolling back an application upgrade that’s gone wrong mid-flight.
Before you start
You’ll need:
- The Service Fabric PowerShell module loaded (it ships with the Service Fabric SDK).
- The client certificate that authenticates you to the cluster, installed in your
CurrentUser\MYstore. You’ll need its thumbprint. - The cluster’s connection endpoint and the server certificate common name.
Roll back a broken application upgrade
When an upgrade is failing or stuck, this connects to the cluster and starts a rollback to the last known-good version.
1
2
3
4
5
6
# Manually rollback a broken application upgrade.
$ConnectArgs = @{ ConnectionEndpoint = 'YourEndPointName.cloudapp.azure.com:19000'; X509Credential = $True; StoreLocation = 'CurrentUser'; StoreName = "MY"; ServerCommonName = "YourCertServerCommonNameGoesHere"; FindType = 'FindByThumbprint'; FindValue = "TheThumprintOfTheCertificate" }
Connect-ServiceFabricCluster @ConnectArgs
Start-ServiceFabricApplicationRollback -ApplicationName fabric:/VisualStudio.ServiceFabricProjectName
# Navigate to Service Fabric explorer and confirm the main dashboard displays "Zero Application Upgrades in Progress".
Swap the placeholder values (YourEndPointName, the thumbprint, the common name, and the fabric:/... application name) for your own before running it.
Verify the rollback
Open Service Fabric Explorer and check the main dashboard. Once the rollback completes you should see Zero Application Upgrades in Progress. If an upgrade is still listed, give it a moment and refresh — a rollback is itself an upgrade operation and takes time to drain across nodes.