I built a stateless Azure Service Fabric service and later realized I would need a stateful service. Rather than try to comb through docs to see what the conversion looked like, I created a brand new stateless service and another stateful service and diff’d them. I’m sharing in case someone else needs to do the same.
You can see everything you need to do in this commit: https://github.com/jonbgallant/azure-service-fabric-stateless-to-stateful-conversion/commit/168c42776fbd4d23f5f8d0ebc943a9ee6fe2129f
Or you can follow along below…
Add Microsoft.ServiceFabric.Data.Collections namespace
Derive from StatefulService instead of Stateless service and inject StatefulServiceContext
Use ServiceReplicaListener instead of ServiceInstanceListener
Use ReliableDictionary/ReliableQueue as needed by your service logic.
Add ReplicatorConfig section to config
Set “HasPersistedState” variable in ServiceManifest
Change StatelessServiceType to StatefulServiceType
Inject StatefulService and set ReplicaId instead of InstanceId
Add Replica settings to ApplicationManifest
Change StatelessService element to StatefulService Element
Add Parameters to your Cloud and Local.xml files