public ServiceFabricNode CopyPortsFrom(ServiceFabricNode prim)
        {
            ClientConnectionEndpointPort = prim.ClientConnectionEndpointPort;
            ApplicationPorts             = prim.ApplicationPorts;
            EphemeralPorts          = prim.EphemeralPorts;
            HttpGatewayEndpointPort = prim.HttpGatewayEndpointPort;


            return(this);
        }
        public async Task <ServiceFabricCluster> AddNodeAsync(Guid subscription, string resourceGroup, string clusterName, ServiceFabricNode node, bool copyPortsFromPrimary = true)
        {
            var resourceUrl = $"https://management.azure.com/subscriptions/{subscription}/resourceGroups/{resourceGroup}/providers/Microsoft.ServiceFabric/clusters/{clusterName}?api-version={ApiVersion}";

            var req = await Client.GetAsync(resourceUrl)
                      .As <ServiceFabricCluster>();


            req.Properties.NodeTypes.Add(node);
            if (copyPortsFromPrimary)
            {
                var prim = req.Properties.NodeTypes.Single(k => k.IsPrimary);
                node.EphemeralPorts               = prim.EphemeralPorts;
                node.ApplicationPorts             = prim.ApplicationPorts;
                node.ClientConnectionEndpointPort = prim.ClientConnectionEndpointPort;
                node.HttpGatewayEndpointPort      = prim.HttpGatewayEndpointPort;
            }

            Logger.Debug(() => JsonConvert.SerializeObject(req, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore, Formatting = Formatting.Indented, ContractResolver = new CamelCasePropertyNamesContractResolver()
            }));
            return(await Client.PutAsync(resourceUrl, new StringContent(JsonConvert.SerializeObject(req, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore, ContractResolver = new CamelCasePropertyNamesContractResolver()
            }), Encoding.UTF8, "application/json")).As <ServiceFabricCluster>());
        }