static void UpdateNic(LoadBalancerRequest parameters, string resourceId, string token)
        {
            var retryMax = 5;

            var client = s_netclient.HttpClient;
            client.DefaultRequestHeaders.Authorization =
                new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);

            var uri = s_netclient.BaseUri + resourceId + "?api-version=" + s_netclient.ApiVersion;

            //var response = client.PutAsJsonAsync(uri, parameters).Result;

            var body = new StringContent(
                JsonConvert.SerializeObject(parameters),
                Encoding.UTF8,
                "application/json");

            HttpResponseMessage response = null;

            while (retryMax > 0)
            {
                response = client.PutAsync(
                    uri,
                    body).Result;

                if (response.IsSuccessStatusCode && ((int)response.StatusCode) != 429)
                    break;
                else
                {
                    --retryMax;
                    Console.WriteLine(" Retrying operation... ");
                }
            }

            dynamic content = JsonConvert.DeserializeObject(
                response.Content.ReadAsStringAsync()
                .Result);

            if (! response.IsSuccessStatusCode)
            {
                Console.WriteLine("errors occured");
                Console.WriteLine(content);
            }
        }
        private static LoadBalancerRequest GetUpdateRequest(VirtualMachine vm, NetworkInterface nic)
        {
            var parametersNewMaster = new LoadBalancerRequest();

            parametersNewMaster.Id = nic.Id;
            parametersNewMaster.Name = nic.Name;
            parametersNewMaster.Location = vm.Location;
            parametersNewMaster.Type = "Microsoft.Network/networkInterfaces";
            parametersNewMaster.Properties.VirtualMachine.Id = vm.Id;

            var ipconfiguration = new IpConfigurationRequest
            {
                Id = nic.IpConfigurations[0].Id,
                Name = nic.IpConfigurations[0].Name,
                Properties = new IpConfigurationProperties
                {
                    LoadBalancerBackendAddressPools = new List<LoadBalancerBackendProperties>(),
                    Subnet = new SubnetRequest
                    {
                        Id = nic.IpConfigurations[0].Subnet.Id
                    }
                }
            };

            parametersNewMaster.Properties.IpConfigurations = new List<IpConfigurationRequest>();
            parametersNewMaster.Properties.IpConfigurations.Add(ipconfiguration);
            return parametersNewMaster;
        }