Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

azure - Strategy to unprovision old applicationtype versions in Service Fabric

Is there a way to set some sort of configuration on the cluster to remove service fabric application type versions? Like only keep the last 5 versions or something?

For example i have CI/CD deploying new versions of a service fabric app to our cluster, it leaves a bunch of application version types in the cluster. Is there a way to automatically unprovision them over time or only keep a certain number of versions?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There are two options that cross my mind -

  • Specify UnregisterUnusedApplicationVersionsAfterUpgrade = $true when you execute Deploy-FabricApplication.ps1. This parameter indicates whether to unregister any unused application versions that exist after an upgrade is finished.

  • Add custom script into your release defintion, deployment script or whereever you want that will resolve all the deployed app types and unprovision those ones that you think are obsolete. Here is the command that you will need to use - Unregister-ServiceFabricApplicationType. Here is some example of the script that unregisters all the app types except running ones -

    #resolve all app types
    $appTypes = Get-ServiceFabricApplicationType
    foreach($appType in $appTypes)
    {
       #try to find the match with any of installed applications
       $match = Get-ServiceFabricApplication -ApplicationTypeName $appType.ApplicationTypeName | Where-Object {$_.ApplicationTypeVersion -eq $appType.ApplicationTypeVersion}
       if(!$match)
       {
           Write-Host "Deleting $($appType.ApplicationTypeName) $($appType.ApplicationTypeVersion)"
           Unregister-ServiceFabricApplicationType -ApplicationTypeName $appType.ApplicationTypeName -ApplicationTypeVersion $appType.ApplicationTypeVersion -Force -Confirm
       }    
    }
    

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...