I am running a stand alone service fabric cluster on a single, albeit beefy, physical server. This cluster has three virtual nodes. That’s because I am using a modified version of the Unsecure.DevCluster configuration template. There are other templates that will allow you to deploy to multiple physical (or virtual) machines but I don’t see the need for what I’m trying to accomplish.

I guess this is common sense but when hosting a web project like a stateless ASP.NET Core Web API because you are deploying to a single machine you can only deploy to one node because when it tries to open the same port on the other nodes it will error out saying the port is already opened.

Alt

Unhealthy event: SourceId='System.RA', Property='ReplicaOpenStatus', HealthState='Warning', ConsiderWarningAsError=false.

Replica had multiple failures during open on vm1. API call: IStatelessServiceInstance.Open(); Error = System.IO.IOException (-2146232800)

Failed to bind to address http://[object 0]:8308: address already in use.

at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.d__5.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.d__7.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.d__2.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.d__0.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.d__21`1.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Microsoft.AspNetCore.Hosting.Internal.WebHost.d__26.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Microsoft.AspNetCore.Hosting.Internal.WebHost.Start()

at Microsoft.ServiceFabric.Services.Communication.AspNetCore.AspNetCoreCommunicationListener.OpenAsync(CancellationToken cancellationToken)

at Microsoft.ServiceFabric.Services.Runtime.StatelessServiceInstanceAdapter.d__19.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Microsoft.ServiceFabric.Services.Runtime.StatelessServiceInstanceAdapter.d__13.MoveNext()

For more information see: http://aka.ms/sfhealth

Normally, when you deploy to a cluster hosted on Microsoft Azure you want the number of instances for a stateless service to be set to “-1”. This will deploy the stateless service to ALL nodes. However, in Azure, each of your nodes being a separate virtual machine means that you can open the same port on every node.

So I’ll create a copy of the Cloud deployment profile and modify it to only deploy to one node.

Alt

The easiest way I’ve found is to add the profile from the Publish Service Fabric Application screen. It will modify all the configuration files on your behalf. You can access it from the “Target profile” drop down and the “Application Parameters File” drop down.

Alt

Select Cloud.xml and hit “Create Copy”. Do this for both the “Target profile” and the “Application Parameters” just to keep everything clean.

Alt

Change the instance count from “-1” to “1”. Then you will only see it deployed to one node and won’t get any errors about not being able to open up ports.

Alt

There you go. Now you can still deploy to your Azure cluster when you are good and ready but you can take advantage of your stand alone cluster for the time being.

Alt