Easily allow publishing the same application twice but listening on different endpoints
I want to have a Web API lets say in have it listen on https://localhost/Environment1/api/
Now a completely separate instance of the same application deployed in the same cluster except now Web API is listening on https://localhost/Environment2/api/
I also want to do this with WCF, and the built in Remoting listeners very easily as well so that I can I have multiple different instances of the same application at the same version running in the same cluster just with different parameters like listeners, etc...
I had the same idea but turns out its pretty easy to do in either. Basically what i did was add the application name from the activation context in the connection listening address. In the Web API project you can pass it in service listener like this
new ServiceInstanceListener(serviceContext => new OwinCommunicationListener(Startup.ConfigureApp, serviceContext, ServiceEventSource.Current, "ServiceEndpoint", FabricRuntime.GetActivationContext().ApplicationName.Substring((8))))
I use the above in some services we've containerized and it works well. Basically when you create an instance of your application type you can name it "environment1" and the result will be exactly what you are requesting above. That code snippet pulls the application name from the context without the "fabric:/" and uses it in the listener path. You can do the same with wcf gateway services but with the endpoint address instead of using the default net tcp address endpoint it creates. For internal wcf services its not needed because all net tcp endpoints with default addresses have guids to make them unique as well as having the partition and replica id.