/// <summary>
        /// Create NetworkSettings on the Device.
        /// </summary>
        private NetworkSettings CreateAndValidateNetworkSettings(string deviceName)
        {
            var networkSettingsBeforeUpdate = this.Client.DeviceSettings.GetNetworkSettings(
                deviceName.GetDoubleEncoded(),
                this.ResourceGroupName,
                this.ManagerName
                );

            DNSSettings dnsSettings = new DNSSettings();

            dnsSettings.PrimaryDnsServer    = networkSettingsBeforeUpdate.DnsSettings.PrimaryDnsServer;
            dnsSettings.SecondaryDnsServers = new List <string>()
            {
                "8.8.8.8"
            };

            NetworkSettingsPatch networkSettingsPatch = new NetworkSettingsPatch();

            networkSettingsPatch.DnsSettings = dnsSettings;

            return(this.Client.DeviceSettings.UpdateNetworkSettings(
                       deviceName.GetDoubleEncoded(),
                       networkSettingsPatch,
                       this.ResourceGroupName,
                       this.ManagerName));
        }
 /// <summary>
 /// Updates the network settings on the specified device.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='deviceName'>
 /// The device name
 /// </param>
 /// <param name='parameters'>
 /// The network settings to be updated.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The resource group name
 /// </param>
 /// <param name='managerName'>
 /// The manager name
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <NetworkSettings> BeginUpdateNetworkSettingsAsync(this IDeviceSettingsOperations operations, string deviceName, NetworkSettingsPatch parameters, string resourceGroupName, string managerName, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.BeginUpdateNetworkSettingsWithHttpMessagesAsync(deviceName, parameters, resourceGroupName, managerName, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Updates the network settings on the specified device.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='deviceName'>
 /// The device name
 /// </param>
 /// <param name='parameters'>
 /// The network settings to be updated.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The resource group name
 /// </param>
 /// <param name='managerName'>
 /// The manager name
 /// </param>
 public static NetworkSettings BeginUpdateNetworkSettings(this IDeviceSettingsOperations operations, string deviceName, NetworkSettingsPatch parameters, string resourceGroupName, string managerName)
 {
     return(operations.BeginUpdateNetworkSettingsAsync(deviceName, parameters, resourceGroupName, managerName).GetAwaiter().GetResult());
 }