I am working on a POC with azure service fabric. Deployed my service in a local cluster and it\'s working fine with default settings in Local.xml.
The moment I chang
According to the official Microsoft documentation , you need to ensure that only one instance of the service is running when you deploy to a local cluster.Otherwise you will run into conflicts with multiple processes listening to same port .You can set multiple instances when you deploy to Azure.
Refer the documentation :- https://azure.microsoft.com/en-us/documentation/articles/service-fabric-add-a-web-frontend/
When you are using local sf cluster and if you have fixed the service endpoint port, use only one instance. For example:
Service.Endpoint uses port 8090. This is defined in ServiceManifest.xml. In a local cluster actually everything just runs on one node i.e. your development machine. If you try to create 2 instances of same service with hard defined port, then you will get Port already in use error.
Try changing to one instance or move it to actual Azure cluster or remove hard coded port numbers.
I have not experienced this issue.
You can change the instance count programatically using the fabric client:
var fabricClient = new FabricClient();
var instanceCount = 3;
var services = await fabricClient.QueryManager.GetServiceListAsync(new Uri("fabric:/MyMicroServiceApp"));
var service = services.FirstOrDefault(e => e.ServiceName.AbsolutePath.Contains("MyService"));
var updateDescription = new StatelessServiceUpdateDescription();
updateDescription.InstanceCount = instanceCount;
await fabricClient.ServiceManager.UpdateServiceAsync(new Uri(service.ServiceName.AbsoluteUri), updateDescription);
I used this to develop a proof of concept to increase the number of worker processes depending on the size of a queue. As soon as you change the instance count of a service, the Service Fabric framework will automatically deploy / remove an instance of the service to / from a node.
If you are running some type of ASP.Net or Owin hosted service. You have to use an instance count of -1. This will setup one instance on each node. With an instance count of 2, you get 2 instances, which may or may not be on the same node.
We have a similar problem and solved it with build scripts. You can either replace the ServiceManififest via a build script or use Tokenizer to replace the port value.
Locally you can create and install the updated/adjsuted package files and deploy them with DeployFabricApplciation and test against it that way.