Updating Service Fabric after updating .Net Core 3.1 and the Nuget packages

December 13, 2019    ServiceFabric DevOps .Net

Updating Service Fabric after updating .Net Core 3.1 and the Nuget packages

While working on a SF Stateful Service that was .Net Core 2.2, .Net Core 3.1 was released. After I upgraded all the Nuget Packages I started getting a runtime exception in the SF explorer for my service that it couldn’t find C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code\NS_7.

On 12/13/2019, I had these versions local: 6.3.176.9494, SDK 3.2.176.9494. We are quite behind.

We want to upgrade to MicrosoftServiceFabric.7.0.457.9590.exe (released 11/2019) and the latest SDK.

The challenge is that we have a lot of developers who will have to update. We also have Dev/QA and RC environments. Then we also have production environments to update.

Uninstall Service Fabric

  1. Make a zip backup of C:\Program Files\Microsoft Service Fabric\
  2. Consider creating a system restore point
  3. Open Add/remove
  4. Uninstall the Service Fabric SDK (for developers)
  5. Uninstall the Service Fabric Runtime
  6. If it doesn’t uninstall Uninstall SF Runtime issues below

Install Service Fabric - Developers

  1. Install the Web Platform Installer
  2. Start the Web Platform Installer
  3. Find Service Fabric
  4. Install the 4.0.457 version of the SDK (or latest)
  5. This will install the runtime as well

Install Service Fabric - Servers

  1. Download this version (or find the latest one) https://download.microsoft.com/download/5/e/e/5ee43eba-5c87-4d11-8a7c-bb26fd162b29/MicrosoftServiceFabric.7.0.457.9590.exe
  2. In an administrator PS window, run .\MicrosoftServiceFabric.7.0.457.9590.exe /accepteula

You may have to set the correct server certificate thumbprint and dns url name. With a PowerShell script similar to this.

Connect-ServiceFabricCluster -ConnectionEndpoint $ClusterEndpoint -KeepAliveIntervalInSec 10 -X509Credential -ServerCertThumbprint $Thumbprint -FindType FindByThumbprint -FindValue $Thumbprint -StoreLocation LocalMachine -StoreName Root
$currentSFVersion = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Service Fabric' -Name 'FabricVersion'

if($currentSFVersion.FabricVersion -ne $SFUpgradeVersion)
{
    Write-Host "Upgrading Service Fabric Cluster from Verison $($currentSFVersion.FabricVersion) to Version $SFUpgradeVersion"
    Start-ServiceFabricClusterUpgrade -Code -CodePackageVersion $SFUpgradeVersion -Monitored -FailureAction Rollback
}
else
{
    Write-Host "Current Service Fabric Version($($currentSFVersion.FabricVersion)) matches desired Version($SFUpgradeVersion)"
}

Verify the versions in add/remove programs.

If you don’t have the Fabric manager running, Start Menu > Service Fabric Cluster Manager

Now create your cluster.

create SF cluster

When that is done, click Manage Local Cluster and check out the explorer in the browser

For devs:

  • Make sure Visual Studio can still build the EAPI or an SF solution
  • Deploy EAPI locally to check it out

Note: C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code\NS_7 now exists and fixes the .Net Core 3.1 and newer packages problem.

Uninstall SF Runtime issues

I hope add or remove programs works for you. If not, these steps should save you a few hours.

This may have been caused when I tried to run the Web Platform installer before uninstalling. I clicked the cancel button after it ran without progress for a long time.

I uninstalled in add/remove. All it did was flash the PS and then nothing.

I checked C:\Program Files\Microsoft Service Fabric\ and only had a bin folder left. I deleted it manually and restarted, but it’s still there.

Install from the Web Platform Installer failed.

I downloaded the runtime installer and ran it myself from https://download.microsoft.com/download/5/e/e/5ee43eba-5c87-4d11-8a7c-bb26fd162b29/MicrosoftServiceFabric.7.0.457.9590.exe (as found in https://github.com/Azure/service-fabric/blob/master/release_notes/Service_Fabric_ReleaseNotes_70.md#service-fabric-runtime )

.\MicrosoftServiceFabric.7.0.457.9590.exe /accepteula

12/13/2019 5:21:42 PM,Error,Uninstallation hit an issue.```

I don't have that CleanFabric.ps1 file anymore, but Brian did. I placed a copy of his on my hard-drive and ran it again

`.\MicrosoftServiceFabric.7.0.457.9590.exe /accepteula`


### RegEdit - I hope I don't break things!

First export for a backup

Follow: https://support.microsoft.com/en-us/help/17588/windows-fix-problems-that-block-programs-being-installed-or-removed - it wasn't listed in this tool. After that, it was removed from the add or remove programs.

### The places to delete

I kept searching for "Fabric" and remove all that matched. Be careful :).

* Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Channels\Microsoft-ServiceFabric/Admin and others in this area
* Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Publishers\{3f68b79e-a1cf-4b10-8cfd-3dfe322f07cb}
* Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Publishers\{cbd93bc2-71e5-4566-b3a7-595d8eeca6e8}
* Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Publishers\{e658f859-2416-4aef-9dfc-4d303897a37a}
* Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\*
* Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\_V2Providers\{11477d28-dcf0-442e-978c-bcbcb71f4ad1}
* Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\_V2Providers\{b8225977-fe30-42b6-a071-e8f591988f9c}
* and more, I just kept searching for "Fabric" and kept deleting.

This removed it from add/remove program.

Reboot

I also got a full zip of the C:\Program Files\Microsoft Service Fabric\ from Brian and put that in before running the install. This is why I suggest backing up the folder before starting.

Run exe again

It works!

``` txt
12/13/2019 6:05:28 PM,Info,Installing... Logs written to C:\WINDOWS\TEMP\InstallFabricRuntime.log
12/13/2019 6:05:28 PM,Info,Running extract in parallel.
12/13/2019 6:05:28 PM,Info,Removing temporary directory C:\Program Files\Microsoft Service Fabric.mk3hvblt.2bn
12/13/2019 6:05:28 PM,Info,12/13/2019 12:05:28 PM Running Process: powershell.exe -NoProfile Get-ExecutionPolicy -Scope CurrentUser with timeout 00:01:00
12/13/2019 6:05:28 PM,Info,Unpackaging autoextractor...
12/13/2019 6:05:29 PM,Info,Current Powershell Execution Policy: Unrestricted
12/13/2019 6:05:29 PM,Info,Searching for legacy installation registry key.
12/13/2019 6:05:29 PM,Info,Service Fabric Product not detected in registry.
12/13/2019 6:05:29 PM,Info,Found legacy fabric files at C:\Program Files\Microsoft Service Fabric. Start removal...
12/13/2019 6:05:29 PM,Info,Executing powershell.exe with parameters: -NoProfile -Command & 'C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code\CleanFabric.ps1' -LogPath C:\WINDOWS\TEMP\FabricSetupLog.Uninstall.log
12/13/2019 6:05:29 PM,Info,12/13/2019 12:05:29 PM Running Process: powershell.exe -NoProfile -Command & 'C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code\CleanFabric.ps1' -LogPath C:\WINDOWS\TEMP\FabricSetupLog.Uninstall.log with timeout 00:10:00
12/13/2019 6:05:31 PM,Info,Extracting runtime cab to C:\Program Files\Microsoft Service Fabric.4wvzqpx2.01e...
12/13/2019 6:05:31 PM,Info,12/13/2019 12:05:31 PM Running Process: C:\WINDOWS\TEMP\MicrosoftServiceFabricAutoextractor.exe /L "C:\Program Files\Microsoft Service Fabric.4wvzqpx2.01e" /E /Y with timeout 01:00:00
12/13/2019 6:05:37 PM,Info,Successfully extracted cab file to C:\Program Files\Microsoft Service Fabric.4wvzqpx2.01e
12/13/2019 6:05:49 PM,Info,Legacy Fabric Uninstalled using CleanFabric.ps1!
12/13/2019 6:05:49 PM,Info,Moving FabricRoot files from 'C:\Program Files\Microsoft Service Fabric.4wvzqpx2.01e' to 'C:\Program Files\Microsoft Service Fabric'.
12/13/2019 6:05:49 PM,Info,Installing Service Fabric Runtime... Logs written to: C:\WINDOWS\TEMP\FabricSetupLog.log
12/13/2019 6:05:49 PM,Info,Executing powershell.exe with parameters: -NoProfile -Command & 'C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code\InstallFabric.ps1' -FabricRootIsPreInstalled -AcceptEULA -LogPath C:\WINDOWS\TEMP\FabricSetupLog.log
12/13/2019 6:05:49 PM,Info,12/13/2019 12:05:49 PM Running Process: powershell.exe -NoProfile -Command & 'C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code\InstallFabric.ps1' -FabricRootIsPreInstalled -AcceptEULA -LogPath C:\WINDOWS\TEMP\FabricSetupLog.log with timeout 00:10:00
12/13/2019 6:05:52 PM,Info,Successfully installed Service Fabric Runtime

Reboot

Testing

Remove SF runtime from Add/remove programs

It uninstalled

Run Web platform installer, 4.0.457

That was done in about a minute

Other info about installing: https://github.com/Azure/service-fabric-issues/issues/1498 .

I hope this is much easier for you!

Now I have to do some proding to get all the environments updated and developers updated. I did test our existing Service Fabric APIs that are .Net Framework 4.6.1 and .Net Core 2.2 and every thing works so far. It’d be concerning if it didn’t, since SF shouldn’t really care what is running on it.

Our automation team is looking at using Ansible to keep our servers in sync. That will simplify and make this process much more consistent for our servers.

I created an issue on 12/10/2019 , but I’m going to close it out. The solution is to upgrade things.



Watch the Story for Good News
I gladly accept BTC Lightning Network tips at [email protected]

Please consider using Brave and adding me to your BAT payment ledger. Then you won't have to see ads! (when I get to $100 in Google Ads for a payout, I pledge to turn off ads)

Use Brave

Also check out my Resources Page for referrals that would help me.


Swan logo
Use Swan Bitcoin to onramp with low fees and automatic daily cost averaging and get $10 in BTC when you sign up.