today I want to write few words about Azure Fabric Services lifecycle.
Initially I'll describe what is going to happen in words, and then later I'll add picture. In any service creation participates two actors: Azure Service Fabric runtime and Service instance which will be created by Azure Service Fabric. Basically for each stateless as well as statetfull service following 5 steps are happening:
1. Azure Service Fabric will create instance of your service
2. Then Azure Service Fabric will ask your service to create listeners
3. Azure Service Fabric will get list of your listeners.
4. For each listener in the array Azure Service Fabric will try to open listener
5. RunAsync with CancelationToken.
Take a look at diagram below in order to visualize what was said :
From standpoint of death of Service instance following steps are happening:
- Azure Service Fabric Runtime will Cancel cancelation token.
- In loop close each listener
- Destroy instance of Service
On picture it looks like this:
I hope this explanation with pictures will help you better understand how service is born and killed.