title: Configuring Azure ServiceFabric for development lifecycle - how to parameterize host name?
body: <p>What's a good way to manage deploying code changes to Dev, Test, and Prod environments in Azure?  The Azure / Service Fabric site provides an article for specifying port numbers using parameters under How-to guides - Manage application lifecycle (<a href="https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-how-to-specify-port-number-using-parameters" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-how-to-specify-port-number-using-parameters</a>), but I'm not sure how one manages host names - is there a host name related property that can be included in Publish Profile .xml file (e.g., Cloud.xml)?</p>
  
  <p>Background: I'm migrating from a self hosted on premise WCF application running as a Windows Service and using WebHttpBinding with http and https endpoints (uses T4 config file templates to determine hostname and port number depending on the environment).  I'm migrating this to an Azure ServiceFabric WcfCommunicationListener application (similar to the sample found here: <a href="https://github.com/loekd/ServiceFabric.WcfCalc" rel="nofollow noreferrer">https://github.com/loekd/ServiceFabric.WcfCalc</a>)....</p>
  
  <pre><code>internal sealed class ServiceFabricWcfService : StatelessService
  {
      public ServiceFabricWcfService(StatelessServiceContext context) : base(context)
  
      protected override IEnumerable&lt;ServiceInstanceListener&gt; 
      CreateServiceInstanceListeners()
      {
          yield return new ServiceInstanceListener(CreateRestListener);   
      }
  
      private ICommunicationListener CreateRestListener(StatelessServiceContext context)
      {
          var host = context.NodeContext.IPAddressOrFQDN;
          var endpointConfig = context.CodePackageActivationContext.GetEndpoint("ServiceEndpoint");
          var port = endpointConfig.Port;
          var scheme = endpointConfig.Protocol.ToString();
          var uri = string.Format(CultureInfo.InvariantCulture, "{0}://{1}:{2}/webhost/", scheme, host, port);
          var listener = new WcfCommunicationListener&lt;IJsonService&gt;(context, new JsonServicePerCall(), new WebHttpBinding(WebHttpSecurityMode.None), new EndpointAddress(uri));
          var ep = listener.ServiceHost.Description.Endpoints.Last();
          ep.Behaviors.Add(new WebHttpBehavior());
          return listener;
      }
  }
  </code></pre>
  
  <p>As you can see, the host name is obtained from the StatelessServiceContext's NodeContext - is there a good way to set this up to target different host names for each environment?  My clients need to be able to make http/https calls based on host name to determine which environment they connect to.  Thanks!</p>