5
votes

I tried removing application from service fabric using service fabric explorer.

I deleted my application using Delete Application action. Then When I tried Unprovision application type I got error saying,

Error: Application Type of version 1.0.0 could not be unprovisioned as it still contains active applications.

I could see that even after deleting the application , the actor service inside the application is still active in some of the nodes. Am attaching a screenshot of my service fabric explorer.

Any help regarding completely removing the applications?

2

2 Answers

19
votes

This can happen if services in your application don't play nice by not shutting down when requested by the platform, for example by ignoring the cancellation token in RunAsync.

Here's a quick PowerShell script that will go through an application and force remove all replicas of all stateful services:

Connect-ServiceFabricCluster -ConnectionEndpoint localhost:19000

$nodes = Get-ServiceFabricNode

foreach($node in $nodes)
{
    $replicas = Get-ServiceFabricDeployedReplica -NodeName $node.NodeName -ApplicationName "fabric:/MyApp"

    foreach ($replica in $replicas)
    {
        Remove-ServiceFabricReplica -ForceRemove -NodeName $node.NodeName -PartitionId $replica.Partitionid -ReplicaOrInstanceId $replica.ReplicaOrInstanceId
    }
}
1
votes

Go to http://localhost:19080/-->Expand Cluster-->Applications-->Service Click on the 3 dots beside service and select option "Delete service" Similarly delete the application and then unprovision the type