Search code examples
azure-service-fabricservice-fabric-stateless

How to listen to the application deletion event in Service Fabric?


I am running a stateless service in Azure Service Fabric in the .NET Framework. I want to perform some clean up activities, and remove some configurations from the registry if all of my applications get deleted from a node in my Service Fabric Cluster. Is there any way that I can do this?


Solution

  • Yes, you can do this by registering notification callbacks. Register for all applications and services by using this code:

    var filterDescription = new ServiceNotificationFilterDescription
    {
        Name = new Uri("fabric:"),
        MatchNamePrefix = true
    };
    

    You interpret a notification with no endpoints as a service deletion.

    Have a look at this question too.