I am getting error FabricServiceNotFoundException: Service does not exist.
and I can't figure out why. The service name I am creating is exactly what it is deployed in my cluster.
This is the code where I create my service:
return ServiceProxy.Create<ICheckoutService>(
new Uri("fabric:/ECommerce/ECommerce.CheckoutService"),
new ServicePartitionKey(0));
This is the explorer view. The name of the service matches my code. I'm doing it with other services with no problem.
I tried a complete restart but I got the same error:
After testing around I found out that the error occurs depending on the order on which I call services through my API methods.
If I deploy the application and call methods checkout
and get basket
they give "Service not found" error.
However, if I call other methods first that perform some change (POST), then it works... weird right? This is my repo to help take a look at the code.
https://github.com/epomatti/azure-servicefabric-productcatalog
With help of @maf748 I turned on "Break When Thrown" configuration for all CLR exceptions, and I discovered that the actual exception was not "Service does not exist".
In my case, I left the following auto-generated method for an Actor service, which was setting my state in a wrong state, and it was later failing in my own code.
All I needed to do was to remove this method that Visual Studio created from my method and it worked properly.
/// <summary>
/// This method is called whenever an actor is activated.
/// An actor is activated the first time any of its methods are invoked.
/// </summary>
protected override Task OnActivateAsync()
{
ActorEventSource.Current.ActorMessage(this, "Actor activated.");
// The StateManager is this actor's private state store.
// Data stored in the StateManager will be replicated for high-availability for actors that use volatile or persisted state storage.
// Any serializable object can be saved in the StateManager.
// For more information, see https://aka.ms/servicefabricactorsstateserialization
return this.StateManager.TryAddStateAsync("count", 0);
}