Search code examples
c#.netazureazure-service-fabricservice-fabric-actor

Azure Service Fabric Actor Initialization


How can I initialize an Azure Service Fabric Actor on creation?

I've tried overloading actor constructor with initialization method and it didn't worked.

Must I call initialization method from client after creating the actor or there's a way to make actor initialize itself automaticaly when during creating?


Solution

  • An Actor is first created when you call a method on it. So if you need to initialize an Actor that does not exist yet, you'll need to make sure it becomes alive first. It can't do that by itself.

    You could create a method to initialize the Actor and make it part of the Actor's interface.

    You can also use the OnActivateAsync method which will trigger for every activation.

    Read more about the Actor lifecycle here.