/* jshint latedef:false */
/* jshint forin:false */
/* jshint noempty:false */

// 
// Copyright (c) Microsoft and contributors.  All rights reserved.
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//   http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// 
// See the License for the specific language governing permissions and
// limitations under the License.
// 

// Warning: This code was generated by a tool.
// 
// Changes to this file may cause incorrect behavior and will be lost if the
// code is regenerated.

'use strict';

var util = require('util');
var azureCommon = require('azure-common');
var xml = azureCommon.xml2js;
var js2xml = azureCommon.js2xml;
var Service = azureCommon.Service;
var WebResource = azureCommon.WebResource;

var ComputeManagementClient = ( /** @lends ComputeManagementClient */ function() {
  /**
   * @class
   * The Service Management API provides programmatic access to much of the
   * functionality available through the Management Portal. The Service
   * Management API is a REST API. All API operations are performed over SSL,
   * and are mutually authenticated using X.509 v3 certificates.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460799.aspx for
   * more information)
   * Initializes a new instance of the ComputeManagementClient class.
   * @constructor
   * 
   * @param {SubscriptionCloudCredentials} credentials Gets subscription
   * credentials which uniquely identify Microsoft Azure subscription. The
   * subscription ID forms part of the URI for every service call.
   * 
   * @param {string} [credentials.subscriptionId]
   * 
   * @param {string} [baseUri] Gets the URI used as the base for all cloud
   * service requests.
   * 
   * @param {Array} filters
   */
  function ComputeManagementClient(credentials, baseUri, filters) {
    if (credentials === null || credentials === undefined) {
      throw new Error('credentials cannot be null.');
    }
    
    ComputeManagementClient['super_'].call(this, credentials, filters);
    
    this.credentials = credentials;
    this.baseUri = baseUri;
    if (this.baseUri === null || this.baseUri === undefined) {
      this.baseUri = 'https://management.core.windows.net';
    }
    if (this.apiVersion === null || this.apiVersion === undefined) {
      this.apiVersion = '2016-06-01';
    }
    if (this.longRunningOperationInitialTimeout === null || this.longRunningOperationInitialTimeout === undefined) {
      this.longRunningOperationInitialTimeout = -1;
    }
    if (this.longRunningOperationRetryTimeout === null || this.longRunningOperationRetryTimeout === undefined) {
      this.longRunningOperationRetryTimeout = -1;
    }
    /**
     * Provides an instance of the
     * [DeploymentOperations](-DeploymentOperations.html) object.
     * @type {object}
     */
    this.deployments = new DeploymentOperations(this);
    /**
     * Provides an instance of the
     * [DNSServerOperations](-DNSServerOperations.html) object.
     * @type {object}
     */
    this.dnsServer = new DNSServerOperations(this);
    /**
     * Provides an instance of the
     * [ExtensionImageOperations](-ExtensionImageOperations.html) object.
     * @type {object}
     */
    this.extensionImages = new ExtensionImageOperations(this);
    /**
     * Provides an instance of the
     * [HostedServiceOperations](-HostedServiceOperations.html) object.
     * @type {object}
     */
    this.hostedServices = new HostedServiceOperations(this);
    /**
     * Provides an instance of the
     * [LoadBalancerOperations](-LoadBalancerOperations.html) object.
     * @type {object}
     */
    this.loadBalancers = new LoadBalancerOperations(this);
    /**
     * Provides an instance of the
     * [OperatingSystemOperations](-OperatingSystemOperations.html) object.
     * @type {object}
     */
    this.operatingSystems = new OperatingSystemOperations(this);
    /**
     * Provides an instance of the
     * [ServiceCertificateOperations](-ServiceCertificateOperations.html)
     * object.
     * @type {object}
     */
    this.serviceCertificates = new ServiceCertificateOperations(this);
    /**
     * Provides an instance of the
     * [VirtualMachineDiskOperations](-VirtualMachineDiskOperations.html)
     * object.
     * @type {object}
     */
    this.virtualMachineDisks = new VirtualMachineDiskOperations(this);
    /**
     * Provides an instance of the
     * [VirtualMachineExtensionOperations](-VirtualMachineExtensionOperations.html)
     * object.
     * @type {object}
     */
    this.virtualMachineExtensions = new VirtualMachineExtensionOperations(this);
    /**
     * Provides an instance of the
     * [VirtualMachineOperations](-VirtualMachineOperations.html) object.
     * @type {object}
     */
    this.virtualMachines = new VirtualMachineOperations(this);
    /**
     * Provides an instance of the
     * [VirtualMachineOSImageOperations](-VirtualMachineOSImageOperations.html)
     * object.
     * @type {object}
     */
    this.virtualMachineOSImages = new VirtualMachineOSImageOperations(this);
    /**
     * Provides an instance of the
     * [VirtualMachineVMImageOperations](-VirtualMachineVMImageOperations.html)
     * object.
     * @type {object}
     */
    this.virtualMachineVMImages = new VirtualMachineVMImageOperations(this);
  }
  
  util.inherits(ComputeManagementClient, Service);
  
  /**
   * The Get Operation Status operation returns the status of the specified
   * operation. After calling an asynchronous operation, you can call Get
   * Operation Status to determine whether the operation has succeeded,
   * failed, or is still in progress.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460783.aspx for
   * more information)
   * 
   * @param {string} requestId The request ID for the request you wish to
   * track. The request ID is returned in the x-ms-request-id response header
   * for every request.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ComputeManagementClient.prototype.getOperationStatus = function(requestId, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (requestId === null || requestId === undefined) {
      return callback(new Error('requestId cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.credentials.subscriptionId !== null && this.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.credentials.subscriptionId);
    }
    url2 = url2 + '/operations/';
    url2 = url2 + encodeURIComponent(requestId);
    var baseUrl = this.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var operationElement = js2xml.getElement(responseDoc, responseDoc, 'OPERATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (operationElement !== null && operationElement !== undefined) {
            var idElement = js2xml.getElement(responseDoc, operationElement, 'ID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (idElement !== null && idElement !== undefined) {
              var idInstance = idElement;
              result.id = idInstance;
            }
            
            var statusElement = js2xml.getElement(responseDoc, operationElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (statusElement !== null && statusElement !== undefined && statusElement.length !== 0) {
              var statusInstance = statusElement;
              result.status = statusInstance;
            }
            
            var httpStatusCodeElement = js2xml.getElement(responseDoc, operationElement, 'HTTPSTATUSCODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (httpStatusCodeElement !== null && httpStatusCodeElement !== undefined && httpStatusCodeElement.length !== 0) {
              var httpStatusCodeInstance = httpStatusCodeElement;
              result.httpStatusCode = httpStatusCodeInstance;
            }
            
            var errorElement = js2xml.getElement(responseDoc, operationElement, 'ERROR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (errorElement !== null && errorElement !== undefined) {
              var errorInstance = {};
              result.error = errorInstance;
              
              var codeElement = js2xml.getElement(responseDoc, errorElement, 'CODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (codeElement !== null && codeElement !== undefined) {
                var codeInstance = codeElement;
                errorInstance.code = codeInstance;
              }
              
              var messageElement = js2xml.getElement(responseDoc, errorElement, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (messageElement !== null && messageElement !== undefined) {
                var messageInstance = messageElement;
                errorInstance.message = messageInstance;
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return ComputeManagementClient;
})();
exports.ComputeManagementClient = ComputeManagementClient;

var DeploymentOperations = ( /** @lends DeploymentOperations */ function() {
  /**
   * @class
   * The Service Management API includes operations for managing the
   * deployments in your subscription.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460812.aspx for
   * more information)
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [ComputeManagementClient] {@link
   * ComputeManagementClient~ComputeManagementClient}.
   * See [deployments] {@link
   * ComputeManagementClient~ComputeManagementClient#deployments}.
   * Initializes a new instance of the DeploymentOperations class.
   * @constructor
   * 
   * @param {ComputeManagementClient} client Reference to the service client.
   */
  function DeploymentOperations(client) {
    this.client = client;
  }
  
  /**
   * The Abort Deployment Operation validates and aborts your deployment for
   * IaaS Classic to ARM migration.
   * 
   * @param {string} serviceName Name of the cloud service.
   * 
   * @param {string} deploymentName Name of the deployment to be migrated.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.abortMigration = function(serviceName, deploymentName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.deployments.beginAbortMigration(serviceName, deploymentName, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Abort Deployment Operation validates and aborts your deployment for
   * IaaS Classic to ARM migration.
   * 
   * @param {string} serviceName Name of the cloud service.
   * 
   * @param {string} deploymentName Name of the deployment to be migrated.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.beginAbortMigration = function(serviceName, deploymentName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/migration';
    var queryParameters = [];
    queryParameters.push('comp=abort');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Changing Deployment Configuration By Name operation initiates a
   * change to the deployment configuration. This operation is an asynchronous
   * operation. To determine whether the Management service has finished
   * processing the request, call Get Operation Status. For more information
   * on asynchronous operations, see Tracking Asynchronous Service Management
   * Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460809.aspx for
   * more information)
   * 
   * @param {string} serviceName The cloud service to change deployment
   * configuration for.
   * 
   * @param {string} deploymentName The deployment to change configuration for.
   * 
   * @param {DeploymentChangeConfigurationParameters} parameters Parameters
   * supplied to the Begin Changing Configuration Deployment By Name operation.
   * 
   * @param {string} parameters.configuration The encoded service configuration
   * file for the deployment.
   * 
   * @param {boolean} [parameters.treatWarningsAsError] Indicates whether to
   * treat package validation warnings as errors. The default value is false.
   * If set to true, the Created Deployment operation fails if there are
   * validation warnings on the service package.
   * 
   * @param {DeploymentChangeConfigurationMode} [parameters.mode] The Change
   * Configuration Deployment mode. Possible values are: Auto and Manual. If
   * not specified, the default value is Auto. If set to Manual,
   * WalkUpgradeDomain must be called to apply the update. If set to Auto, the
   * update is automatically applied to each update domain for the service.
   * 
   * @param {object} [parameters.extendedProperties] Represents the name of an
   * extended deployment property. Each extended property must have a defined
   * name and a value. You can have a maximum of 25 extended property
   * name/value pairs. The maximum length of the name element is 64
   * characters, only alphanumeric characters and underscores are valid in the
   * name, and the name must start with a letter. Attempting to use other
   * characters, starting the name with a non-letter character, or entering a
   * name that is identical to that of another extended property owned by the
   * same hosted service will result in a status code 400 (Bad Request) error.
   * 
   * @param {ExtensionConfiguration} [parameters.extensionConfiguration]
   * Represents an extension that is added to the cloud service. In Azure, a
   * process can run as an extension of a cloud service. For example, Remote
   * Desktop Access or the Azure Diagnostics Agent can run as extensions to
   * the cloud service. You must add an extension to the cloud service by
   * using Add Extension before it can be added to the deployment.
   * 
   * @param {array} [parameters.extensionConfiguration.allRoles] Specifies a
   * list of extensions that are applied to all roles in a deployment.
   * 
   * @param {array} [parameters.extensionConfiguration.namedRoles] Specifies a
   * list of extensions that are applied to specific roles in a deployment.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.beginChangingConfigurationByName = function(serviceName, deploymentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    // TODO: Validate serviceName is a valid DNS name.
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.configuration === null || parameters.configuration === undefined) {
      return callback(new Error('parameters.configuration cannot be null.'));
    }
    if (parameters.extensionConfiguration !== null && parameters.extensionConfiguration !== undefined) {
      if (parameters.extensionConfiguration.allRoles !== null && parameters.extensionConfiguration.allRoles !== undefined) {
        for (var loweredIndex1 = 0; loweredIndex1 < parameters.extensionConfiguration.allRoles.length; loweredIndex1 = loweredIndex1 + 1) {
          var allRolesParameterItem = parameters.extensionConfiguration.allRoles[loweredIndex1];
          if (allRolesParameterItem.id === null || allRolesParameterItem.id === undefined) {
            return callback(new Error('parameters.extensionConfiguration.allRoles. cannot be null.'));
          }
        }
      }
      if (parameters.extensionConfiguration.namedRoles !== null && parameters.extensionConfiguration.namedRoles !== undefined) {
        for (var loweredIndex2 = 0; loweredIndex2 < parameters.extensionConfiguration.namedRoles.length; loweredIndex2 = loweredIndex2 + 1) {
          var namedRolesParameterItem = parameters.extensionConfiguration.namedRoles[loweredIndex2];
          if (namedRolesParameterItem.extensions === null || namedRolesParameterItem.extensions === undefined) {
            return callback(new Error('parameters.extensionConfiguration.namedRoles. cannot be null.'));
          }
          if (namedRolesParameterItem.extensions !== null && namedRolesParameterItem.extensions !== undefined) {
            for (var loweredIndex3 = 0; loweredIndex3 < namedRolesParameterItem.extensions.length; loweredIndex3 = loweredIndex3 + 1) {
              var extensionsParameterItem = namedRolesParameterItem.extensions[loweredIndex3];
              if (extensionsParameterItem.id === null || extensionsParameterItem.id === undefined) {
                return callback(new Error('parameters.extensionConfiguration.namedRoles.. cannot be null.'));
              }
            }
          }
          if (namedRolesParameterItem.roleName === null || namedRolesParameterItem.roleName === undefined) {
            return callback(new Error('parameters.extensionConfiguration.namedRoles. cannot be null.'));
          }
        }
      }
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/';
    var queryParameters = [];
    queryParameters.push('comp=config');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var changeConfigurationElement = js2xml.createElement('ChangeConfiguration', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, changeConfigurationElement);
    
    var configurationElement = js2xml.createElement('Configuration', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(configurationElement, new Buffer(parameters.configuration).toString('base64'));
    js2xml.addChildElement(changeConfigurationElement, configurationElement);
    
    if (parameters.treatWarningsAsError !== null && parameters.treatWarningsAsError !== undefined) {
      var treatWarningsAsErrorElement = js2xml.createElement('TreatWarningsAsError', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(treatWarningsAsErrorElement, parameters.treatWarningsAsError.toString());
      js2xml.addChildElement(changeConfigurationElement, treatWarningsAsErrorElement);
    }
    
    if (parameters.mode !== null && parameters.mode !== undefined) {
      var modeElement = js2xml.createElement('Mode', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(modeElement, parameters.mode !== null && parameters.mode !== undefined ? parameters.mode.toString() : 'Auto');
      js2xml.addChildElement(changeConfigurationElement, modeElement);
    }
    
    if (parameters.extendedProperties !== null && parameters.extendedProperties !== undefined) {
      var extendedPropertiesDictionaryElement = js2xml.createElement('ExtendedProperties', 'http://schemas.microsoft.com/windowsazure');
      for (var extendedPropertiesKey in parameters.extendedProperties) {
        var extendedPropertiesValue = parameters.extendedProperties[extendedPropertiesKey];
        var extendedPropertiesElement = js2xml.createElement('ExtendedProperty', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(extendedPropertiesDictionaryElement, extendedPropertiesElement);
        
        var extendedPropertiesKeyElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(extendedPropertiesKeyElement, extendedPropertiesKey);
        js2xml.addChildElement(extendedPropertiesElement, extendedPropertiesKeyElement);
        
        var extendedPropertiesValueElement = js2xml.createElement('Value', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(extendedPropertiesValueElement, extendedPropertiesValue);
        js2xml.addChildElement(extendedPropertiesElement, extendedPropertiesValueElement);
      }
      js2xml.addChildElement(changeConfigurationElement, extendedPropertiesDictionaryElement);
    }
    
    if (parameters.extensionConfiguration !== null && parameters.extensionConfiguration !== undefined) {
      var extensionConfigurationElement = js2xml.createElement('ExtensionConfiguration', 'http://schemas.microsoft.com/windowsazure');
      js2xml.addChildElement(changeConfigurationElement, extensionConfigurationElement);
      
      if (parameters.extensionConfiguration.allRoles !== null && parameters.extensionConfiguration.allRoles !== undefined) {
        var allRolesSequenceElement = js2xml.createElement('AllRoles', 'http://schemas.microsoft.com/windowsazure');
        for (var loweredIndex4 = 0; loweredIndex4 < parameters.extensionConfiguration.allRoles.length; loweredIndex4 = loweredIndex4 + 1) {
          var allRolesItem = parameters.extensionConfiguration.allRoles[loweredIndex4];
          var extensionElement = js2xml.createElement('Extension', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(allRolesSequenceElement, extensionElement);
          
          var idElement = js2xml.createElement('Id', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(idElement, allRolesItem.id);
          js2xml.addChildElement(extensionElement, idElement);
          
          if (allRolesItem.state !== null && allRolesItem.state !== undefined) {
            var stateElement = js2xml.createElement('State', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(stateElement, allRolesItem.state);
            js2xml.addChildElement(extensionElement, stateElement);
          }
        }
        js2xml.addChildElement(extensionConfigurationElement, allRolesSequenceElement);
      }
      
      if (parameters.extensionConfiguration.namedRoles !== null && parameters.extensionConfiguration.namedRoles !== undefined) {
        var namedRolesSequenceElement = js2xml.createElement('NamedRoles', 'http://schemas.microsoft.com/windowsazure');
        for (var loweredIndex5 = 0; loweredIndex5 < parameters.extensionConfiguration.namedRoles.length; loweredIndex5 = loweredIndex5 + 1) {
          var namedRolesItem = parameters.extensionConfiguration.namedRoles[loweredIndex5];
          var roleElement = js2xml.createElement('Role', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(namedRolesSequenceElement, roleElement);
          
          var roleNameElement = js2xml.createElement('RoleName', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(roleNameElement, namedRolesItem.roleName);
          js2xml.addChildElement(roleElement, roleNameElement);
          
          var extensionsSequenceElement = js2xml.createElement('Extensions', 'http://schemas.microsoft.com/windowsazure');
          for (var loweredIndex6 = 0; loweredIndex6 < namedRolesItem.extensions.length; loweredIndex6 = loweredIndex6 + 1) {
            var extensionsItem = namedRolesItem.extensions[loweredIndex6];
            var extensionElement2 = js2xml.createElement('Extension', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(extensionsSequenceElement, extensionElement2);
            
            var idElement2 = js2xml.createElement('Id', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(idElement2, extensionsItem.id);
            js2xml.addChildElement(extensionElement2, idElement2);
            
            if (extensionsItem.state !== null && extensionsItem.state !== undefined) {
              var stateElement2 = js2xml.createElement('State', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(stateElement2, extensionsItem.state);
              js2xml.addChildElement(extensionElement2, stateElement2);
            }
          }
          js2xml.addChildElement(roleElement, extensionsSequenceElement);
        }
        js2xml.addChildElement(extensionConfigurationElement, namedRolesSequenceElement);
      }
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Changing Deployment Configuration By Slot operation initiates a
   * change to the deployment configuration. This operation is an asynchronous
   * operation. To determine whether the Management service has finished
   * processing the request, call Get Operation Status. For more information
   * on asynchronous operations, see Tracking Asynchronous Service Management
   * Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460809.aspx for
   * more information)
   * 
   * @param {string} serviceName The cloud service to change deployment
   * configuration for.
   * 
   * @param {DeploymentSlot} deploymentSlot The slot to change deployment
   * configuration for.
   * 
   * @param {DeploymentChangeConfigurationParameters} parameters Parameters
   * supplied to the Begin Changing Configuration Deployment By Slot operation.
   * 
   * @param {string} parameters.configuration The encoded service configuration
   * file for the deployment.
   * 
   * @param {boolean} [parameters.treatWarningsAsError] Indicates whether to
   * treat package validation warnings as errors. The default value is false.
   * If set to true, the Created Deployment operation fails if there are
   * validation warnings on the service package.
   * 
   * @param {DeploymentChangeConfigurationMode} [parameters.mode] The Change
   * Configuration Deployment mode. Possible values are: Auto and Manual. If
   * not specified, the default value is Auto. If set to Manual,
   * WalkUpgradeDomain must be called to apply the update. If set to Auto, the
   * update is automatically applied to each update domain for the service.
   * 
   * @param {object} [parameters.extendedProperties] Represents the name of an
   * extended deployment property. Each extended property must have a defined
   * name and a value. You can have a maximum of 25 extended property
   * name/value pairs. The maximum length of the name element is 64
   * characters, only alphanumeric characters and underscores are valid in the
   * name, and the name must start with a letter. Attempting to use other
   * characters, starting the name with a non-letter character, or entering a
   * name that is identical to that of another extended property owned by the
   * same hosted service will result in a status code 400 (Bad Request) error.
   * 
   * @param {ExtensionConfiguration} [parameters.extensionConfiguration]
   * Represents an extension that is added to the cloud service. In Azure, a
   * process can run as an extension of a cloud service. For example, Remote
   * Desktop Access or the Azure Diagnostics Agent can run as extensions to
   * the cloud service. You must add an extension to the cloud service by
   * using Add Extension before it can be added to the deployment.
   * 
   * @param {array} [parameters.extensionConfiguration.allRoles] Specifies a
   * list of extensions that are applied to all roles in a deployment.
   * 
   * @param {array} [parameters.extensionConfiguration.namedRoles] Specifies a
   * list of extensions that are applied to specific roles in a deployment.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.beginChangingConfigurationBySlot = function(serviceName, deploymentSlot, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    // TODO: Validate serviceName is a valid DNS name.
    if (deploymentSlot === null || deploymentSlot === undefined) {
      return callback(new Error('deploymentSlot cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.configuration === null || parameters.configuration === undefined) {
      return callback(new Error('parameters.configuration cannot be null.'));
    }
    if (parameters.extensionConfiguration !== null && parameters.extensionConfiguration !== undefined) {
      if (parameters.extensionConfiguration.allRoles !== null && parameters.extensionConfiguration.allRoles !== undefined) {
        for (var loweredIndex1 = 0; loweredIndex1 < parameters.extensionConfiguration.allRoles.length; loweredIndex1 = loweredIndex1 + 1) {
          var allRolesParameterItem = parameters.extensionConfiguration.allRoles[loweredIndex1];
          if (allRolesParameterItem.id === null || allRolesParameterItem.id === undefined) {
            return callback(new Error('parameters.extensionConfiguration.allRoles. cannot be null.'));
          }
        }
      }
      if (parameters.extensionConfiguration.namedRoles !== null && parameters.extensionConfiguration.namedRoles !== undefined) {
        for (var loweredIndex2 = 0; loweredIndex2 < parameters.extensionConfiguration.namedRoles.length; loweredIndex2 = loweredIndex2 + 1) {
          var namedRolesParameterItem = parameters.extensionConfiguration.namedRoles[loweredIndex2];
          if (namedRolesParameterItem.extensions === null || namedRolesParameterItem.extensions === undefined) {
            return callback(new Error('parameters.extensionConfiguration.namedRoles. cannot be null.'));
          }
          if (namedRolesParameterItem.extensions !== null && namedRolesParameterItem.extensions !== undefined) {
            for (var loweredIndex3 = 0; loweredIndex3 < namedRolesParameterItem.extensions.length; loweredIndex3 = loweredIndex3 + 1) {
              var extensionsParameterItem = namedRolesParameterItem.extensions[loweredIndex3];
              if (extensionsParameterItem.id === null || extensionsParameterItem.id === undefined) {
                return callback(new Error('parameters.extensionConfiguration.namedRoles.. cannot be null.'));
              }
            }
          }
          if (namedRolesParameterItem.roleName === null || namedRolesParameterItem.roleName === undefined) {
            return callback(new Error('parameters.extensionConfiguration.namedRoles. cannot be null.'));
          }
        }
      }
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deploymentslots/';
    url2 = url2 + encodeURIComponent(deploymentSlot !== null && deploymentSlot !== undefined ? deploymentSlot.toString() : 'Staging');
    url2 = url2 + '/';
    var queryParameters = [];
    queryParameters.push('comp=config');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var changeConfigurationElement = js2xml.createElement('ChangeConfiguration', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, changeConfigurationElement);
    
    var configurationElement = js2xml.createElement('Configuration', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(configurationElement, new Buffer(parameters.configuration).toString('base64'));
    js2xml.addChildElement(changeConfigurationElement, configurationElement);
    
    if (parameters.treatWarningsAsError !== null && parameters.treatWarningsAsError !== undefined) {
      var treatWarningsAsErrorElement = js2xml.createElement('TreatWarningsAsError', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(treatWarningsAsErrorElement, parameters.treatWarningsAsError.toString());
      js2xml.addChildElement(changeConfigurationElement, treatWarningsAsErrorElement);
    }
    
    if (parameters.mode !== null && parameters.mode !== undefined) {
      var modeElement = js2xml.createElement('Mode', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(modeElement, parameters.mode !== null && parameters.mode !== undefined ? parameters.mode.toString() : 'Auto');
      js2xml.addChildElement(changeConfigurationElement, modeElement);
    }
    
    if (parameters.extendedProperties !== null && parameters.extendedProperties !== undefined) {
      var extendedPropertiesDictionaryElement = js2xml.createElement('ExtendedProperties', 'http://schemas.microsoft.com/windowsazure');
      for (var extendedPropertiesKey in parameters.extendedProperties) {
        var extendedPropertiesValue = parameters.extendedProperties[extendedPropertiesKey];
        var extendedPropertiesElement = js2xml.createElement('ExtendedProperty', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(extendedPropertiesDictionaryElement, extendedPropertiesElement);
        
        var extendedPropertiesKeyElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(extendedPropertiesKeyElement, extendedPropertiesKey);
        js2xml.addChildElement(extendedPropertiesElement, extendedPropertiesKeyElement);
        
        var extendedPropertiesValueElement = js2xml.createElement('Value', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(extendedPropertiesValueElement, extendedPropertiesValue);
        js2xml.addChildElement(extendedPropertiesElement, extendedPropertiesValueElement);
      }
      js2xml.addChildElement(changeConfigurationElement, extendedPropertiesDictionaryElement);
    }
    
    if (parameters.extensionConfiguration !== null && parameters.extensionConfiguration !== undefined) {
      var extensionConfigurationElement = js2xml.createElement('ExtensionConfiguration', 'http://schemas.microsoft.com/windowsazure');
      js2xml.addChildElement(changeConfigurationElement, extensionConfigurationElement);
      
      if (parameters.extensionConfiguration.allRoles !== null && parameters.extensionConfiguration.allRoles !== undefined) {
        var allRolesSequenceElement = js2xml.createElement('AllRoles', 'http://schemas.microsoft.com/windowsazure');
        for (var loweredIndex4 = 0; loweredIndex4 < parameters.extensionConfiguration.allRoles.length; loweredIndex4 = loweredIndex4 + 1) {
          var allRolesItem = parameters.extensionConfiguration.allRoles[loweredIndex4];
          var extensionElement = js2xml.createElement('Extension', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(allRolesSequenceElement, extensionElement);
          
          var idElement = js2xml.createElement('Id', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(idElement, allRolesItem.id);
          js2xml.addChildElement(extensionElement, idElement);
          
          if (allRolesItem.state !== null && allRolesItem.state !== undefined) {
            var stateElement = js2xml.createElement('State', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(stateElement, allRolesItem.state);
            js2xml.addChildElement(extensionElement, stateElement);
          }
        }
        js2xml.addChildElement(extensionConfigurationElement, allRolesSequenceElement);
      }
      
      if (parameters.extensionConfiguration.namedRoles !== null && parameters.extensionConfiguration.namedRoles !== undefined) {
        var namedRolesSequenceElement = js2xml.createElement('NamedRoles', 'http://schemas.microsoft.com/windowsazure');
        for (var loweredIndex5 = 0; loweredIndex5 < parameters.extensionConfiguration.namedRoles.length; loweredIndex5 = loweredIndex5 + 1) {
          var namedRolesItem = parameters.extensionConfiguration.namedRoles[loweredIndex5];
          var roleElement = js2xml.createElement('Role', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(namedRolesSequenceElement, roleElement);
          
          var roleNameElement = js2xml.createElement('RoleName', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(roleNameElement, namedRolesItem.roleName);
          js2xml.addChildElement(roleElement, roleNameElement);
          
          var extensionsSequenceElement = js2xml.createElement('Extensions', 'http://schemas.microsoft.com/windowsazure');
          for (var loweredIndex6 = 0; loweredIndex6 < namedRolesItem.extensions.length; loweredIndex6 = loweredIndex6 + 1) {
            var extensionsItem = namedRolesItem.extensions[loweredIndex6];
            var extensionElement2 = js2xml.createElement('Extension', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(extensionsSequenceElement, extensionElement2);
            
            var idElement2 = js2xml.createElement('Id', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(idElement2, extensionsItem.id);
            js2xml.addChildElement(extensionElement2, idElement2);
            
            if (extensionsItem.state !== null && extensionsItem.state !== undefined) {
              var stateElement2 = js2xml.createElement('State', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(stateElement2, extensionsItem.state);
              js2xml.addChildElement(extensionElement2, stateElement2);
            }
          }
          js2xml.addChildElement(roleElement, extensionsSequenceElement);
        }
        js2xml.addChildElement(extensionConfigurationElement, namedRolesSequenceElement);
      }
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Commit Deployment Operation validates and commits your deployment for
   * IaaS Classic to ARM migration.
   * 
   * @param {string} serviceName Name of the cloud service.
   * 
   * @param {string} deploymentName Name of the deployment to be migrated.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.beginCommitMigration = function(serviceName, deploymentName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/migration';
    var queryParameters = [];
    queryParameters.push('comp=commit');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Creating Deployment operation uploads a new service package and
   * creates a new deployment in the staging or production environments. This
   * operation is an asynchronous operation. To determine whether the
   * management service has finished processing the request, call Get
   * Operation Status. For more information on asynchronous operations, see
   * Tracking Asynchronous Service Management Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460813.aspx for
   * more information)
   * 
   * @param {string} serviceName The cloud service to create a deployment for.
   * 
   * @param {DeploymentSlot} deploymentSlot The slot to create a deployment for.
   * 
   * @param {DeploymentCreateParameters} parameters Parameters supplied to the
   * Begin Creating Deployment operation.
   * 
   * @param {string} parameters.name The name for the deployment. The
   * deployment name must be unique among other deployments for the cloud
   * service.
   * 
   * @param {string} parameters.packageUri A URL that refers to the location of
   * the service package in the Blob service. The service package can be
   * located either in a storage account beneath the same subscription or a
   * Shared Access Signature (SAS) URI from any storage account. For more info
   * about Shared Access Signatures, see Delegating Access with a Shared
   * Access Signature (REST API) at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee395415.aspx.
   * 
   * @param {string} parameters.label A name for the hosted service. The name
   * can be up to 100 characters in length. It is recommended that the label
   * be unique within the subscription. The name can be used identify the
   * hosted service for your tracking purposes.
   * 
   * @param {string} parameters.configuration The service configuration file
   * for the deployment. The client library does the base-64 encoding from the
   * plain text input.
   * 
   * @param {boolean} [parameters.startDeployment] Indicates whether to start
   * the deployment immediately after it is created. The default value is
   * false. If false, the service model is still deployed to the virtual
   * machines but the code is not run immediately. Instead, the service is
   * Suspended until you call Update Deployment Status and set the status
   * toRunning, at which time the service will be started. A deployed service
   * still incurs charges, even if it is suspended.
   * 
   * @param {boolean} [parameters.treatWarningsAsError] Indicates whether to
   * treat package validation warnings as errors. The default value is false.
   * If set to true, the Created Deployment operation fails if there are
   * validation warnings on the service package.
   * 
   * @param {object} [parameters.extendedProperties] Represents the name of an
   * extended deployment property. Each extended property must have a defined
   * name and a value. You can have a maximum of 25 extended property
   * name/value pairs. The maximum length of the name element is 64
   * characters, only alphanumeric characters and underscores are valid in the
   * name, and the name must start with a letter. Attempting to use other
   * characters, starting the name with a non-letter character, or entering a
   * name that is identical to that of another extended property owned by the
   * same hosted service will result in a status code 400 (Bad Request) error.
   * 
   * @param {ExtensionConfiguration} [parameters.extensionConfiguration]
   * Represents an extension that is added to the cloud service. In Azure, a
   * process can run as an extension of a cloud service. For example, Remote
   * Desktop Access or the Azure Diagnostics Agent can run as extensions to
   * the cloud service. You must add an extension to the cloud service by
   * using Add Extension before it can be added to the deployment.
   * 
   * @param {array} [parameters.extensionConfiguration.allRoles] Specifies a
   * list of extensions that are applied to all roles in a deployment.
   * 
   * @param {array} [parameters.extensionConfiguration.namedRoles] Specifies a
   * list of extensions that are applied to specific roles in a deployment.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.beginCreating = function(serviceName, deploymentSlot, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    // TODO: Validate serviceName is a valid DNS name.
    if (deploymentSlot === null || deploymentSlot === undefined) {
      return callback(new Error('deploymentSlot cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.configuration === null || parameters.configuration === undefined) {
      return callback(new Error('parameters.configuration cannot be null.'));
    }
    if (parameters.extensionConfiguration !== null && parameters.extensionConfiguration !== undefined) {
      if (parameters.extensionConfiguration.allRoles !== null && parameters.extensionConfiguration.allRoles !== undefined) {
        for (var loweredIndex1 = 0; loweredIndex1 < parameters.extensionConfiguration.allRoles.length; loweredIndex1 = loweredIndex1 + 1) {
          var allRolesParameterItem = parameters.extensionConfiguration.allRoles[loweredIndex1];
          if (allRolesParameterItem.id === null || allRolesParameterItem.id === undefined) {
            return callback(new Error('parameters.extensionConfiguration.allRoles. cannot be null.'));
          }
        }
      }
      if (parameters.extensionConfiguration.namedRoles !== null && parameters.extensionConfiguration.namedRoles !== undefined) {
        for (var loweredIndex2 = 0; loweredIndex2 < parameters.extensionConfiguration.namedRoles.length; loweredIndex2 = loweredIndex2 + 1) {
          var namedRolesParameterItem = parameters.extensionConfiguration.namedRoles[loweredIndex2];
          if (namedRolesParameterItem.extensions === null || namedRolesParameterItem.extensions === undefined) {
            return callback(new Error('parameters.extensionConfiguration.namedRoles. cannot be null.'));
          }
          if (namedRolesParameterItem.extensions !== null && namedRolesParameterItem.extensions !== undefined) {
            for (var loweredIndex3 = 0; loweredIndex3 < namedRolesParameterItem.extensions.length; loweredIndex3 = loweredIndex3 + 1) {
              var extensionsParameterItem = namedRolesParameterItem.extensions[loweredIndex3];
              if (extensionsParameterItem.id === null || extensionsParameterItem.id === undefined) {
                return callback(new Error('parameters.extensionConfiguration.namedRoles.. cannot be null.'));
              }
            }
          }
          if (namedRolesParameterItem.roleName === null || namedRolesParameterItem.roleName === undefined) {
            return callback(new Error('parameters.extensionConfiguration.namedRoles. cannot be null.'));
          }
        }
      }
    }
    if (parameters.label === null || parameters.label === undefined) {
      return callback(new Error('parameters.label cannot be null.'));
    }
    if (parameters.label.length > 100) {
      return callback(new Error('parameters.label is outside the valid range.'));
    }
    if (parameters.name === null || parameters.name === undefined) {
      return callback(new Error('parameters.name cannot be null.'));
    }
    if (parameters.packageUri === null || parameters.packageUri === undefined) {
      return callback(new Error('parameters.packageUri cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deploymentslots/';
    url2 = url2 + encodeURIComponent(deploymentSlot !== null && deploymentSlot !== undefined ? deploymentSlot.toString() : 'Staging');
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var createDeploymentElement = js2xml.createElement('CreateDeployment', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, createDeploymentElement);
    
    var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(nameElement, parameters.name);
    js2xml.addChildElement(createDeploymentElement, nameElement);
    
    var packageUrlElement = js2xml.createElement('PackageUrl', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(packageUrlElement, parameters.packageUri);
    js2xml.addChildElement(createDeploymentElement, packageUrlElement);
    
    var labelElement = js2xml.createElement('Label', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(labelElement, new Buffer(parameters.label).toString('base64'));
    js2xml.addChildElement(createDeploymentElement, labelElement);
    
    var configurationElement = js2xml.createElement('Configuration', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(configurationElement, new Buffer(parameters.configuration).toString('base64'));
    js2xml.addChildElement(createDeploymentElement, configurationElement);
    
    if (parameters.startDeployment !== null && parameters.startDeployment !== undefined) {
      var startDeploymentElement = js2xml.createElement('StartDeployment', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(startDeploymentElement, parameters.startDeployment.toString());
      js2xml.addChildElement(createDeploymentElement, startDeploymentElement);
    }
    
    if (parameters.treatWarningsAsError !== null && parameters.treatWarningsAsError !== undefined) {
      var treatWarningsAsErrorElement = js2xml.createElement('TreatWarningsAsError', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(treatWarningsAsErrorElement, parameters.treatWarningsAsError.toString());
      js2xml.addChildElement(createDeploymentElement, treatWarningsAsErrorElement);
    }
    
    if (parameters.extendedProperties !== null && parameters.extendedProperties !== undefined) {
      var extendedPropertiesDictionaryElement = js2xml.createElement('ExtendedProperties', 'http://schemas.microsoft.com/windowsazure');
      for (var extendedPropertiesKey in parameters.extendedProperties) {
        var extendedPropertiesValue = parameters.extendedProperties[extendedPropertiesKey];
        var extendedPropertiesElement = js2xml.createElement('ExtendedProperty', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(extendedPropertiesDictionaryElement, extendedPropertiesElement);
        
        var extendedPropertiesKeyElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(extendedPropertiesKeyElement, extendedPropertiesKey);
        js2xml.addChildElement(extendedPropertiesElement, extendedPropertiesKeyElement);
        
        var extendedPropertiesValueElement = js2xml.createElement('Value', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(extendedPropertiesValueElement, extendedPropertiesValue);
        js2xml.addChildElement(extendedPropertiesElement, extendedPropertiesValueElement);
      }
      js2xml.addChildElement(createDeploymentElement, extendedPropertiesDictionaryElement);
    }
    
    if (parameters.extensionConfiguration !== null && parameters.extensionConfiguration !== undefined) {
      var extensionConfigurationElement = js2xml.createElement('ExtensionConfiguration', 'http://schemas.microsoft.com/windowsazure');
      js2xml.addChildElement(createDeploymentElement, extensionConfigurationElement);
      
      if (parameters.extensionConfiguration.allRoles !== null && parameters.extensionConfiguration.allRoles !== undefined) {
        var allRolesSequenceElement = js2xml.createElement('AllRoles', 'http://schemas.microsoft.com/windowsazure');
        for (var loweredIndex4 = 0; loweredIndex4 < parameters.extensionConfiguration.allRoles.length; loweredIndex4 = loweredIndex4 + 1) {
          var allRolesItem = parameters.extensionConfiguration.allRoles[loweredIndex4];
          var extensionElement = js2xml.createElement('Extension', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(allRolesSequenceElement, extensionElement);
          
          var idElement = js2xml.createElement('Id', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(idElement, allRolesItem.id);
          js2xml.addChildElement(extensionElement, idElement);
          
          if (allRolesItem.state !== null && allRolesItem.state !== undefined) {
            var stateElement = js2xml.createElement('State', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(stateElement, allRolesItem.state);
            js2xml.addChildElement(extensionElement, stateElement);
          }
        }
        js2xml.addChildElement(extensionConfigurationElement, allRolesSequenceElement);
      }
      
      if (parameters.extensionConfiguration.namedRoles !== null && parameters.extensionConfiguration.namedRoles !== undefined) {
        var namedRolesSequenceElement = js2xml.createElement('NamedRoles', 'http://schemas.microsoft.com/windowsazure');
        for (var loweredIndex5 = 0; loweredIndex5 < parameters.extensionConfiguration.namedRoles.length; loweredIndex5 = loweredIndex5 + 1) {
          var namedRolesItem = parameters.extensionConfiguration.namedRoles[loweredIndex5];
          var roleElement = js2xml.createElement('Role', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(namedRolesSequenceElement, roleElement);
          
          var roleNameElement = js2xml.createElement('RoleName', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(roleNameElement, namedRolesItem.roleName);
          js2xml.addChildElement(roleElement, roleNameElement);
          
          var extensionsSequenceElement = js2xml.createElement('Extensions', 'http://schemas.microsoft.com/windowsazure');
          for (var loweredIndex6 = 0; loweredIndex6 < namedRolesItem.extensions.length; loweredIndex6 = loweredIndex6 + 1) {
            var extensionsItem = namedRolesItem.extensions[loweredIndex6];
            var extensionElement2 = js2xml.createElement('Extension', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(extensionsSequenceElement, extensionElement2);
            
            var idElement2 = js2xml.createElement('Id', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(idElement2, extensionsItem.id);
            js2xml.addChildElement(extensionElement2, idElement2);
            
            if (extensionsItem.state !== null && extensionsItem.state !== undefined) {
              var stateElement2 = js2xml.createElement('State', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(stateElement2, extensionsItem.state);
              js2xml.addChildElement(extensionElement2, stateElement2);
            }
          }
          js2xml.addChildElement(roleElement, extensionsSequenceElement);
        }
        js2xml.addChildElement(extensionConfigurationElement, namedRolesSequenceElement);
      }
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Deleting Deployment By Name operation deletes the specified
   * deployment. This operation is an asynchronous operation. To determine
   * whether the Management service has finished processing the request, call
   * Get Operation Status. For more information on asynchronous operations,
   * see Tracking Asynchronous Service Management Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460815.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {boolean} [deleteFromStorage] Specifies that the source blob for
   * the disk should also be deleted from storage.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.beginDeletingByName = function(serviceName, deploymentName, deleteFromStorage, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    var queryParameters = [];
    if (deleteFromStorage !== null && deleteFromStorage !== undefined && deleteFromStorage === true) {
      queryParameters.push('comp=media');
    }
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Deleting Deployment By Slot operation deletes the specified
   * deployment. This operation is an asynchronous operation. To determine
   * whether the Management service has finished processing the request, call
   * Get Operation Status. For more information on asynchronous operations,
   * see Tracking Asynchronous Service Management Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460815.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {DeploymentSlot} deploymentSlot The deployment slot.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.beginDeletingBySlot = function(serviceName, deploymentSlot, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentSlot === null || deploymentSlot === undefined) {
      return callback(new Error('deploymentSlot cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deploymentslots/';
    url2 = url2 + encodeURIComponent(deploymentSlot !== null && deploymentSlot !== undefined ? deploymentSlot.toString() : 'Staging');
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Delete Role Instances operation deletes a role instance from a
   * deployment in a cloud service.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn469418.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {string} deploymentSlot The name of the deployment slot.
   * 
   * @param {DeploymentDeleteRoleInstanceParameters} parameters The parameters
   * to delete the role.
   * 
   * @param {array} [parameters.name] The names of role instances to delete
   * from the deployment
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.beginDeletingRoleInstanceByBeploymentSlot = function(serviceName, deploymentSlot, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentSlot === null || deploymentSlot === undefined) {
      return callback(new Error('deploymentSlot cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deploymentslots/';
    url2 = url2 + encodeURIComponent(deploymentSlot);
    url2 = url2 + '/roleinstances/';
    var queryParameters = [];
    queryParameters.push('comp=delete');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    if (parameters.name !== null && parameters.name !== undefined) {
      var roleInstancesSequenceElement = js2xml.createElement('RoleInstances', 'http://schemas.microsoft.com/windowsazure');
      for (var loweredIndex1 = 0; loweredIndex1 < parameters.name.length; loweredIndex1 = loweredIndex1 + 1) {
        var roleInstancesItem = parameters.name[loweredIndex1];
        var roleInstancesItemElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(roleInstancesItemElement, roleInstancesItem);
        js2xml.addChildElement(roleInstancesSequenceElement, roleInstancesItemElement);
      }
      js2xml.addChildElement(requestDoc, roleInstancesSequenceElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Delete Role Instances operation deletes a role instance from a
   * deployment in a cloud service.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn469418.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {string} deploymentName The name of the deployment.
   * 
   * @param {DeploymentDeleteRoleInstanceParameters} parameters The parameters
   * to delete the role.
   * 
   * @param {array} [parameters.name] The names of role instances to delete
   * from the deployment
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.beginDeletingRoleInstanceByDeploymentName = function(serviceName, deploymentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/roleinstances/';
    var queryParameters = [];
    queryParameters.push('comp=delete');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    if (parameters.name !== null && parameters.name !== undefined) {
      var roleInstancesSequenceElement = js2xml.createElement('RoleInstances', 'http://schemas.microsoft.com/windowsazure');
      for (var loweredIndex1 = 0; loweredIndex1 < parameters.name.length; loweredIndex1 = loweredIndex1 + 1) {
        var roleInstancesItem = parameters.name[loweredIndex1];
        var roleInstancesItemElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(roleInstancesItemElement, roleInstancesItem);
        js2xml.addChildElement(roleInstancesSequenceElement, roleInstancesItemElement);
      }
      js2xml.addChildElement(requestDoc, roleInstancesSequenceElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Get Package By Name operation retrieves a cloud service package for a
   * deployment and stores the package files in Azure Blob storage. The
   * following package files are placed in storage: the cloud service
   * configuration file (.cscfg), providing configuration settings for the
   * cloud service and individual roles, including the number of role
   * instances; and the service package (.cspkg), containing the application
   * code and the service definition file.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj154121.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {DeploymentGetPackageParameters} parameters Parameters supplied to
   * the Get Package By Name operation.
   * 
   * @param {string} parameters.containerUri Specifies the URI of the container
   * to which the packages will be saved.
   * 
   * @param {boolean} [parameters.overwriteExisting] Specifies whether an
   * existing package in the storage container should be overwritten.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.beginGettingPackageByName = function(serviceName, deploymentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.containerUri === null || parameters.containerUri === undefined) {
      return callback(new Error('parameters.containerUri cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/package';
    var queryParameters = [];
    queryParameters.push('containerUri=' + encodeURIComponent(parameters.containerUri) + ' +');
    if (parameters.overwriteExisting !== null && parameters.overwriteExisting !== undefined) {
      queryParameters.push('overwriteExisting=' + encodeURIComponent(parameters.overwriteExisting.toString()));
    }
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Get Package By Slot operation retrieves a cloud service package for a
   * deployment and stores the package files in Azure Blob storage. The
   * following package files are placed in storage: the cloud service
   * configuration file (.cscfg), providing configuration settings for the
   * cloud service and individual roles, including the number of role
   * instances; and the service package (.cspkg), containing the application
   * code and the service definition file.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj154121.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {DeploymentSlot} deploymentSlot The deployment slot.
   * 
   * @param {DeploymentGetPackageParameters} parameters Parameters supplied to
   * the Get Package By Slot operation.
   * 
   * @param {string} parameters.containerUri Specifies the URI of the container
   * to which the packages will be saved.
   * 
   * @param {boolean} [parameters.overwriteExisting] Specifies whether an
   * existing package in the storage container should be overwritten.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.beginGettingPackageBySlot = function(serviceName, deploymentSlot, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentSlot === null || deploymentSlot === undefined) {
      return callback(new Error('deploymentSlot cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.containerUri === null || parameters.containerUri === undefined) {
      return callback(new Error('parameters.containerUri cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deploymentslots/';
    url2 = url2 + encodeURIComponent(deploymentSlot !== null && deploymentSlot !== undefined ? deploymentSlot.toString() : 'Staging');
    url2 = url2 + '/package';
    var queryParameters = [];
    queryParameters.push('containerUri=' + encodeURIComponent(parameters.containerUri) + ' +');
    if (parameters.overwriteExisting !== null && parameters.overwriteExisting !== undefined) {
      queryParameters.push('overwriteExisting=' + encodeURIComponent(parameters.overwriteExisting.toString()));
    }
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Prepare Deployment Operation validates and prepares your deployment
   * for IaaS Classic to ARM migration.
   * 
   * @param {string} serviceName Name of the cloud service.
   * 
   * @param {string} deploymentName Name of the deployment to be migrated.
   * 
   * @param {PrepareDeploymentMigrationParameters} parameters Deployment
   * Network resource parameters for migration.
   * 
   * @param {string} parameters.resourceGroupName Name of the resource group
   * for migration.
   * 
   * @param {string} parameters.virtualNetworkName Name of the Virtual Network
   * for migration.
   * 
   * @param {string} parameters.subNetName Subnet name for migration.
   * 
   * @param {string} parameters.destinationVirtualNetwork Destination Virtual
   * Network type for migration.Accepted values are Default, New, Existing.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.beginPrepareMigration = function(serviceName, deploymentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.destinationVirtualNetwork === null || parameters.destinationVirtualNetwork === undefined) {
      return callback(new Error('parameters.destinationVirtualNetwork cannot be null.'));
    }
    if (parameters.resourceGroupName === null || parameters.resourceGroupName === undefined) {
      return callback(new Error('parameters.resourceGroupName cannot be null.'));
    }
    if (parameters.subNetName === null || parameters.subNetName === undefined) {
      return callback(new Error('parameters.subNetName cannot be null.'));
    }
    if (parameters.virtualNetworkName === null || parameters.virtualNetworkName === undefined) {
      return callback(new Error('parameters.virtualNetworkName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/migration';
    var queryParameters = [];
    queryParameters.push('comp=prepare');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var deploymentNetworkResourceElement = js2xml.createElement('DeploymentNetworkResource', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, deploymentNetworkResourceElement);
    
    var resourceGroupNameElement = js2xml.createElement('ResourceGroupName', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(resourceGroupNameElement, parameters.resourceGroupName);
    js2xml.addChildElement(deploymentNetworkResourceElement, resourceGroupNameElement);
    
    var virtualNetworkNameElement = js2xml.createElement('VirtualNetworkName', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(virtualNetworkNameElement, parameters.virtualNetworkName);
    js2xml.addChildElement(deploymentNetworkResourceElement, virtualNetworkNameElement);
    
    var subNetNameElement = js2xml.createElement('SubNetName', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(subNetNameElement, parameters.subNetName);
    js2xml.addChildElement(deploymentNetworkResourceElement, subNetNameElement);
    
    var destinationVirtualNetworkElement = js2xml.createElement('DestinationVirtualNetwork', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(destinationVirtualNetworkElement, parameters.destinationVirtualNetwork);
    js2xml.addChildElement(deploymentNetworkResourceElement, destinationVirtualNetworkElement);
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Rebooting Role Instance By Deployment Name operation requests a
   * reboot of a role instance that is running in a deployment. This operation
   * is an asynchronous operation. To determine whether the Management service
   * has finished processing the request, call Get Operation Status. For more
   * information on asynchronous operations, see Tracking Asynchronous Service
   * Management Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/gg441298.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {string} roleInstanceName The name of your role instance.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.beginRebootingRoleInstanceByDeploymentName = function(serviceName, deploymentName, roleInstanceName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (roleInstanceName === null || roleInstanceName === undefined) {
      return callback(new Error('roleInstanceName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/roleinstances/';
    url2 = url2 + encodeURIComponent(roleInstanceName);
    var queryParameters = [];
    queryParameters.push('comp=reboot');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Length'] = '0';
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Rebooting Role Instance By Deployment Slot operation requests a
   * reboot of a role instance that is running in a deployment. This operation
   * is an asynchronous operation. To determine whether the Management service
   * has finished processing the request, call Get Operation Status. For more
   * information on asynchronous operations, see Tracking Asynchronous Service
   * Management Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/gg441298.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {DeploymentSlot} deploymentSlot The deployment slot.
   * 
   * @param {string} roleInstanceName The name of your role instance.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.beginRebootingRoleInstanceByDeploymentSlot = function(serviceName, deploymentSlot, roleInstanceName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentSlot === null || deploymentSlot === undefined) {
      return callback(new Error('deploymentSlot cannot be null.'));
    }
    if (roleInstanceName === null || roleInstanceName === undefined) {
      return callback(new Error('roleInstanceName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deploymentslots/';
    url2 = url2 + encodeURIComponent(deploymentSlot !== null && deploymentSlot !== undefined ? deploymentSlot.toString() : 'Staging');
    url2 = url2 + '/roleinstances/';
    url2 = url2 + encodeURIComponent(roleInstanceName);
    var queryParameters = [];
    queryParameters.push('comp=reboot');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Length'] = '0';
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Rebuild Role Instance asynchronous operation reinstalls the operating
   * system on instances of web roles or worker roles and initializes the
   * storage resources that are used by them. If you do not want to initialize
   * storage resources, you can use Reimage Role Instance
   * athttp://msdn.microsoft.com/en-us/library/azure/gg441292.aspx.For more
   * information on asynchronous operations, see Tracking Asynchronous Service
   * Management Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx.  (see
   * http://msdn.microsoft.com/en-us/library/azure/dn627518.aspx for more
   * information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {string} roleInstanceName The name of your role instance.
   * 
   * @param {string} resources Specifies the resources that must be rebuilt.
   * Currently, the only supported value is 'allLocalDrives'.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.beginRebuildingRoleInstanceByDeploymentName = function(serviceName, deploymentName, roleInstanceName, resources, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (roleInstanceName === null || roleInstanceName === undefined) {
      return callback(new Error('roleInstanceName cannot be null.'));
    }
    if (resources === null || resources === undefined) {
      return callback(new Error('resources cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/roleinstances/';
    url2 = url2 + encodeURIComponent(roleInstanceName);
    var queryParameters = [];
    queryParameters.push('comp=rebuild');
    queryParameters.push('resources=' + encodeURIComponent(resources));
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Length'] = '0';
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Rebuild Role Instance asynchronous operation reinstalls the operating
   * system on instances of web roles or worker roles and initializes the
   * storage resources that are used by them. If you do not want to initialize
   * storage resources, you can use Reimage Role Instance
   * athttp://msdn.microsoft.com/en-us/library/azure/gg441292.aspx.For more
   * information on asynchronous operations, see Tracking Asynchronous Service
   * Management Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx.  (see
   * http://msdn.microsoft.com/en-us/library/azure/dn627518.aspx for more
   * information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {string} deploymentSlot The deployment slot.
   * 
   * @param {string} roleInstanceName The name of your role instance.
   * 
   * @param {string} resources Specifies the resources that must be rebuilt.
   * Currently, the only supported value is 'allLocalDrives'.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.beginRebuildingRoleInstanceByDeploymentSlot = function(serviceName, deploymentSlot, roleInstanceName, resources, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentSlot === null || deploymentSlot === undefined) {
      return callback(new Error('deploymentSlot cannot be null.'));
    }
    if (roleInstanceName === null || roleInstanceName === undefined) {
      return callback(new Error('roleInstanceName cannot be null.'));
    }
    if (resources === null || resources === undefined) {
      return callback(new Error('resources cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deploymentslots/';
    url2 = url2 + encodeURIComponent(deploymentSlot);
    url2 = url2 + '/roleinstances/';
    url2 = url2 + encodeURIComponent(roleInstanceName);
    var queryParameters = [];
    queryParameters.push('comp=rebuild');
    queryParameters.push('resources=' + encodeURIComponent(resources));
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Length'] = '0';
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Reimaging Role Instance By Deployment Name operation requests a
   * reimage of a role instance that is running in a deployment. This
   * operation is an asynchronous operation. To determine whether the
   * Management service has finished processing the request, call Get
   * Operation Status. For more information on asynchronous operations, see
   * Tracking Asynchronous Service Management Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/gg441292.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {string} roleInstanceName The name of your role instance.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.beginReimagingRoleInstanceByDeploymentName = function(serviceName, deploymentName, roleInstanceName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (roleInstanceName === null || roleInstanceName === undefined) {
      return callback(new Error('roleInstanceName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/roleinstances/';
    url2 = url2 + encodeURIComponent(roleInstanceName);
    var queryParameters = [];
    queryParameters.push('comp=reimage');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Length'] = '0';
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Reimaging Role Instance By Deployment Slot operation requests a
   * reimage of a role instance that is running in a deployment. This
   * operation is an asynchronous operation. To determine whether the
   * Management service has finished processing the request, call Get
   * Operation Status. For more information on asynchronous operations, see
   * Tracking Asynchronous Service Management Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/gg441292.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {DeploymentSlot} deploymentSlot The deployment slot.
   * 
   * @param {string} roleInstanceName The name of your role instance.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.beginReimagingRoleInstanceByDeploymentSlot = function(serviceName, deploymentSlot, roleInstanceName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentSlot === null || deploymentSlot === undefined) {
      return callback(new Error('deploymentSlot cannot be null.'));
    }
    if (roleInstanceName === null || roleInstanceName === undefined) {
      return callback(new Error('roleInstanceName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deploymentslots/';
    url2 = url2 + encodeURIComponent(deploymentSlot !== null && deploymentSlot !== undefined ? deploymentSlot.toString() : 'Staging');
    url2 = url2 + '/roleinstances/';
    url2 = url2 + encodeURIComponent(roleInstanceName);
    var queryParameters = [];
    queryParameters.push('comp=reimage');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Length'] = '0';
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Swapping Deployment operation initiates a virtual IP address
   * swap between the staging and production deployment environments for a
   * service. If the service is currently running in the staging environment,
   * it will be swapped to the production environment. If it is running in the
   * production environment, it will be swapped to staging. For more
   * information on this type of upgrade, see Performing Virtual IP Swap
   * Upgrades at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee517253.aspx.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460814.aspx for
   * more information)
   * 
   * @param {string} serviceName The cloud service to swap deployments for.
   * 
   * @param {DeploymentSwapParameters} parameters Parameters supplied to the
   * Begin Swapping Deployment operation.
   * 
   * @param {string} [parameters.productionDeployment] The optional name of the
   * production deployment.
   * 
   * @param {string} parameters.sourceDeployment The name of the source
   * deployment.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.beginSwapping = function(serviceName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    // TODO: Validate serviceName is a valid DNS name.
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.sourceDeployment === null || parameters.sourceDeployment === undefined) {
      return callback(new Error('parameters.sourceDeployment cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var swapElement = js2xml.createElement('Swap', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, swapElement);
    
    if (parameters.productionDeployment !== null && parameters.productionDeployment !== undefined) {
      var productionElement = js2xml.createElement('Production', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(productionElement, parameters.productionDeployment);
      js2xml.addChildElement(swapElement, productionElement);
    }
    
    var sourceDeploymentElement = js2xml.createElement('SourceDeployment', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(sourceDeploymentElement, parameters.sourceDeployment);
    js2xml.addChildElement(swapElement, sourceDeploymentElement);
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Updating Deployment Status By Deployment Name operation
   * initiates a change in the running status of a deployment. The status of a
   * deployment can be running or suspended. This operation is an asynchronous
   * operation. To determine whether the Management service has finished
   * processing the request, call Get Operation Status. For more information
   * on asynchronous operations, see Tracking Asynchronous Service Management
   * Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460808.aspx for
   * more information)
   * 
   * @param {string} serviceName The cloud service to swap deployments for.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {DeploymentUpdateStatusParameters} parameters Parameters supplied
   * to the Begin Updating Deployment Status By Deployment Name operation.
   * 
   * @param {UpdatedDeploymentStatus} parameters.status The new status of the
   * deployment.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.beginUpdatingStatusByDeploymentName = function(serviceName, deploymentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    // TODO: Validate serviceName is a valid DNS name.
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.status === null || parameters.status === undefined) {
      return callback(new Error('parameters.status cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/';
    var queryParameters = [];
    queryParameters.push('comp=status');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var updateDeploymentStatusElement = js2xml.createElement('UpdateDeploymentStatus', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, updateDeploymentStatusElement);
    
    var statusElement = js2xml.createElement('Status', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(statusElement, parameters.status !== null && parameters.status !== undefined ? parameters.status.toString() : 'Running');
    js2xml.addChildElement(updateDeploymentStatusElement, statusElement);
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Updating Deployment Status By Deployment Slot operation
   * initiates a change in the running status of a deployment. The status of a
   * deployment can be running or suspended. This operation is an asynchronous
   * operation. To determine whether the Management service has finished
   * processing the request, call Get Operation Status. For more information
   * on asynchronous operations, see Tracking Asynchronous Service Management
   * Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460808.aspx for
   * more information)
   * 
   * @param {string} serviceName The cloud service to swap deployments for.
   * 
   * @param {DeploymentSlot} deploymentSlot The deployment slot.
   * 
   * @param {DeploymentUpdateStatusParameters} parameters Parameters supplied
   * to the Begin Updating Deployment Status By Deployment Slot operation.
   * 
   * @param {UpdatedDeploymentStatus} parameters.status The new status of the
   * deployment.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.beginUpdatingStatusByDeploymentSlot = function(serviceName, deploymentSlot, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    // TODO: Validate serviceName is a valid DNS name.
    if (deploymentSlot === null || deploymentSlot === undefined) {
      return callback(new Error('deploymentSlot cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.status === null || parameters.status === undefined) {
      return callback(new Error('parameters.status cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deploymentslots/';
    url2 = url2 + encodeURIComponent(deploymentSlot !== null && deploymentSlot !== undefined ? deploymentSlot.toString() : 'Staging');
    url2 = url2 + '/';
    var queryParameters = [];
    queryParameters.push('comp=status');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var updateDeploymentStatusElement = js2xml.createElement('UpdateDeploymentStatus', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, updateDeploymentStatusElement);
    
    var statusElement = js2xml.createElement('Status', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(statusElement, parameters.status !== null && parameters.status !== undefined ? parameters.status.toString() : 'Running');
    js2xml.addChildElement(updateDeploymentStatusElement, statusElement);
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Upgrading Deployment By Name operation initiates an update of
   * role instances in a deployment using the package and configuration that
   * you specify. For more information about updating role instances, see
   * Update an Azure Service at
   * http://msdn.microsoft.com/en-us/library/windowsazure/hh472157.aspx. This
   * operation is an asynchronous operation. To determine whether the request
   * has been processed, call Get Operation Status. For more information on
   * asynchronous operations, see Tracking Asynchronous Service Management
   * Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx. To
   * perform an automatic update of a deployment, call Upgrade Deployment or
   * Change Deployment Configuration with the Mode element set to automatic.
   * The update proceeds from that point without a need for further input. You
   * can call Get Operation Status to determine when the update is complete.
   * To perform a manual update, first call Upgrade Deployment with the Mode
   * element set to manual. Next, call Walk Upgrade Domain to update each
   * domain within the deployment. You should make sure that the operation is
   * complete by calling Get Operation Status before updating the next domain.
   * Important: An update that adds or removes role instances will result in a
   * configuration update to all roles that are deployed in the cloud service.
   * Existing role instances need to be notified of new role instances so that
   * all role instances can communicate together in the cloud service. By
   * default, a cloud service is deployed with five update domains, which are
   * updated one at a time during an in-place update. For information on
   * modifying the number of update domains in the service definition file,
   * see the Azure Service Definition Schema (.csdef File). To determine the
   * update domain in which a particular instance is running in Windows Azure,
   * use the UpdateDomain property of the RoleInstance class. See the Azure
   * Managed Library Reference at
   * http://msdn.microsoft.com/en-us/library/windowsazure/dd179380.aspx for
   * more information.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460793.aspx for
   * more information)
   * 
   * @param {string} serviceName The cloud service to upgrade.
   * 
   * @param {string} deploymentName The deployment to upgrade.
   * 
   * @param {DeploymentUpgradeParameters} parameters Parameters supplied to the
   * Begin Upgrading Deployment By Name operation.
   * 
   * @param {DeploymentUpgradeMode} parameters.mode The type of update to
   * initiate. Role instances are allocated to update domains when the service
   * is deployed. Updates can be initiated manually in each update domain or
   * initiated automatically in all update domains. Possible values are Auto
   * or Manual. If not specified, the default value is Auto. If set to Manual,
   * WalkUpgradeDomain must be called to apply the update. If set to Auto, the
   * update is automatically applied to each update domain in sequence.
   * 
   * @param {string} parameters.packageUri A URL that refers to the location of
   * the service package in the Blob service. The service package can be
   * located either in a storage account beneath the same subscription or a
   * Shared Access Signature (SAS) URI from any storage account. For more
   * information about Shared Access Signatures, see Delegating Access with a
   * Shared Access Signature (REST API) at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee395415.aspx.
   * 
   * @param {string} parameters.configuration The service configuration file
   * for the deployment. The client library does the base-64 encoding from the
   * plain text input.
   * 
   * @param {string} parameters.label A name for the hosted service. The name
   * can be up to 100 characters in length. It is recommended that the label
   * be unique within the subscription. The name can be used identify the
   * hosted service for your tracking purposes.
   * 
   * @param {string} [parameters.roleToUpgrade] The name of the specific role
   * instance to update.
   * 
   * @param {boolean} parameters.force Specifies whether the rollback should
   * proceed even when it will cause local data to be lost from some role
   * instances.
   * 
   * @param {object} [parameters.extendedProperties] Represents the name of an
   * extended deployment property. Each extended property must have a defined
   * name and a value. You can have a maximum of 25 extended property
   * name/value pairs. The maximum length of the name element is 64
   * characters, only alphanumeric characters and underscores are valid in the
   * name, and the name must start with a letter. Attempting to use other
   * characters, starting the name with a non-letter character, or entering a
   * name that is identical to that of another extended property owned by the
   * same hosted service will result in a status code 400 (Bad Request) error.
   * 
   * @param {ExtensionConfiguration} [parameters.extensionConfiguration]
   * Represents an extension that is added to the cloud service. In Azure, a
   * process can run as an extension of a cloud service. For example, Remote
   * Desktop Access or the Azure Diagnostics Agent can run as extensions to
   * the cloud service. You must add an extension to the cloud service by
   * using Add Extension before it can be added to the deployment.
   * 
   * @param {array} [parameters.extensionConfiguration.allRoles] Specifies a
   * list of extensions that are applied to all roles in a deployment.
   * 
   * @param {array} [parameters.extensionConfiguration.namedRoles] Specifies a
   * list of extensions that are applied to specific roles in a deployment.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.beginUpgradingByName = function(serviceName, deploymentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    // TODO: Validate serviceName is a valid DNS name.
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.configuration === null || parameters.configuration === undefined) {
      return callback(new Error('parameters.configuration cannot be null.'));
    }
    if (parameters.extensionConfiguration !== null && parameters.extensionConfiguration !== undefined) {
      if (parameters.extensionConfiguration.allRoles !== null && parameters.extensionConfiguration.allRoles !== undefined) {
        for (var loweredIndex1 = 0; loweredIndex1 < parameters.extensionConfiguration.allRoles.length; loweredIndex1 = loweredIndex1 + 1) {
          var allRolesParameterItem = parameters.extensionConfiguration.allRoles[loweredIndex1];
          if (allRolesParameterItem.id === null || allRolesParameterItem.id === undefined) {
            return callback(new Error('parameters.extensionConfiguration.allRoles. cannot be null.'));
          }
        }
      }
      if (parameters.extensionConfiguration.namedRoles !== null && parameters.extensionConfiguration.namedRoles !== undefined) {
        for (var loweredIndex2 = 0; loweredIndex2 < parameters.extensionConfiguration.namedRoles.length; loweredIndex2 = loweredIndex2 + 1) {
          var namedRolesParameterItem = parameters.extensionConfiguration.namedRoles[loweredIndex2];
          if (namedRolesParameterItem.extensions === null || namedRolesParameterItem.extensions === undefined) {
            return callback(new Error('parameters.extensionConfiguration.namedRoles. cannot be null.'));
          }
          if (namedRolesParameterItem.extensions !== null && namedRolesParameterItem.extensions !== undefined) {
            for (var loweredIndex3 = 0; loweredIndex3 < namedRolesParameterItem.extensions.length; loweredIndex3 = loweredIndex3 + 1) {
              var extensionsParameterItem = namedRolesParameterItem.extensions[loweredIndex3];
              if (extensionsParameterItem.id === null || extensionsParameterItem.id === undefined) {
                return callback(new Error('parameters.extensionConfiguration.namedRoles.. cannot be null.'));
              }
            }
          }
          if (namedRolesParameterItem.roleName === null || namedRolesParameterItem.roleName === undefined) {
            return callback(new Error('parameters.extensionConfiguration.namedRoles. cannot be null.'));
          }
        }
      }
    }
    if (parameters.force === null || parameters.force === undefined) {
      return callback(new Error('parameters.force cannot be null.'));
    }
    if (parameters.label === null || parameters.label === undefined) {
      return callback(new Error('parameters.label cannot be null.'));
    }
    if (parameters.label.length > 100) {
      return callback(new Error('parameters.label is outside the valid range.'));
    }
    if (parameters.mode === null || parameters.mode === undefined) {
      return callback(new Error('parameters.mode cannot be null.'));
    }
    if (parameters.packageUri === null || parameters.packageUri === undefined) {
      return callback(new Error('parameters.packageUri cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/';
    var queryParameters = [];
    queryParameters.push('comp=upgrade');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var upgradeDeploymentElement = js2xml.createElement('UpgradeDeployment', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, upgradeDeploymentElement);
    
    var modeElement = js2xml.createElement('Mode', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(modeElement, parameters.mode !== null && parameters.mode !== undefined ? parameters.mode.toString() : 'Auto');
    js2xml.addChildElement(upgradeDeploymentElement, modeElement);
    
    var packageUrlElement = js2xml.createElement('PackageUrl', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(packageUrlElement, parameters.packageUri);
    js2xml.addChildElement(upgradeDeploymentElement, packageUrlElement);
    
    var configurationElement = js2xml.createElement('Configuration', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(configurationElement, new Buffer(parameters.configuration).toString('base64'));
    js2xml.addChildElement(upgradeDeploymentElement, configurationElement);
    
    var labelElement = js2xml.createElement('Label', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(labelElement, new Buffer(parameters.label).toString('base64'));
    js2xml.addChildElement(upgradeDeploymentElement, labelElement);
    
    if (parameters.roleToUpgrade !== null && parameters.roleToUpgrade !== undefined) {
      var roleToUpgradeElement = js2xml.createElement('RoleToUpgrade', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(roleToUpgradeElement, parameters.roleToUpgrade);
      js2xml.addChildElement(upgradeDeploymentElement, roleToUpgradeElement);
    }
    
    var forceElement = js2xml.createElement('Force', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(forceElement, parameters.force.toString());
    js2xml.addChildElement(upgradeDeploymentElement, forceElement);
    
    if (parameters.extendedProperties !== null && parameters.extendedProperties !== undefined) {
      var extendedPropertiesDictionaryElement = js2xml.createElement('ExtendedProperties', 'http://schemas.microsoft.com/windowsazure');
      for (var extendedPropertiesKey in parameters.extendedProperties) {
        var extendedPropertiesValue = parameters.extendedProperties[extendedPropertiesKey];
        var extendedPropertiesElement = js2xml.createElement('ExtendedProperty', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(extendedPropertiesDictionaryElement, extendedPropertiesElement);
        
        var extendedPropertiesKeyElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(extendedPropertiesKeyElement, extendedPropertiesKey);
        js2xml.addChildElement(extendedPropertiesElement, extendedPropertiesKeyElement);
        
        var extendedPropertiesValueElement = js2xml.createElement('Value', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(extendedPropertiesValueElement, extendedPropertiesValue);
        js2xml.addChildElement(extendedPropertiesElement, extendedPropertiesValueElement);
      }
      js2xml.addChildElement(upgradeDeploymentElement, extendedPropertiesDictionaryElement);
    }
    
    if (parameters.extensionConfiguration !== null && parameters.extensionConfiguration !== undefined) {
      var extensionConfigurationElement = js2xml.createElement('ExtensionConfiguration', 'http://schemas.microsoft.com/windowsazure');
      js2xml.addChildElement(upgradeDeploymentElement, extensionConfigurationElement);
      
      if (parameters.extensionConfiguration.allRoles !== null && parameters.extensionConfiguration.allRoles !== undefined) {
        var allRolesSequenceElement = js2xml.createElement('AllRoles', 'http://schemas.microsoft.com/windowsazure');
        for (var loweredIndex4 = 0; loweredIndex4 < parameters.extensionConfiguration.allRoles.length; loweredIndex4 = loweredIndex4 + 1) {
          var allRolesItem = parameters.extensionConfiguration.allRoles[loweredIndex4];
          var extensionElement = js2xml.createElement('Extension', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(allRolesSequenceElement, extensionElement);
          
          var idElement = js2xml.createElement('Id', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(idElement, allRolesItem.id);
          js2xml.addChildElement(extensionElement, idElement);
          
          if (allRolesItem.state !== null && allRolesItem.state !== undefined) {
            var stateElement = js2xml.createElement('State', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(stateElement, allRolesItem.state);
            js2xml.addChildElement(extensionElement, stateElement);
          }
        }
        js2xml.addChildElement(extensionConfigurationElement, allRolesSequenceElement);
      }
      
      if (parameters.extensionConfiguration.namedRoles !== null && parameters.extensionConfiguration.namedRoles !== undefined) {
        var namedRolesSequenceElement = js2xml.createElement('NamedRoles', 'http://schemas.microsoft.com/windowsazure');
        for (var loweredIndex5 = 0; loweredIndex5 < parameters.extensionConfiguration.namedRoles.length; loweredIndex5 = loweredIndex5 + 1) {
          var namedRolesItem = parameters.extensionConfiguration.namedRoles[loweredIndex5];
          var roleElement = js2xml.createElement('Role', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(namedRolesSequenceElement, roleElement);
          
          var roleNameElement = js2xml.createElement('RoleName', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(roleNameElement, namedRolesItem.roleName);
          js2xml.addChildElement(roleElement, roleNameElement);
          
          var extensionsSequenceElement = js2xml.createElement('Extensions', 'http://schemas.microsoft.com/windowsazure');
          for (var loweredIndex6 = 0; loweredIndex6 < namedRolesItem.extensions.length; loweredIndex6 = loweredIndex6 + 1) {
            var extensionsItem = namedRolesItem.extensions[loweredIndex6];
            var extensionElement2 = js2xml.createElement('Extension', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(extensionsSequenceElement, extensionElement2);
            
            var idElement2 = js2xml.createElement('Id', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(idElement2, extensionsItem.id);
            js2xml.addChildElement(extensionElement2, idElement2);
            
            if (extensionsItem.state !== null && extensionsItem.state !== undefined) {
              var stateElement2 = js2xml.createElement('State', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(stateElement2, extensionsItem.state);
              js2xml.addChildElement(extensionElement2, stateElement2);
            }
          }
          js2xml.addChildElement(roleElement, extensionsSequenceElement);
        }
        js2xml.addChildElement(extensionConfigurationElement, namedRolesSequenceElement);
      }
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Upgrading Deployment By Slot operation initiates an update of
   * role instances in a deployment using the package and configuration that
   * you specify. For more information about updating role instances, see
   * Update an Azure Service at
   * http://msdn.microsoft.com/en-us/library/windowsazure/hh472157.aspx.This
   * operation is an asynchronous operation. To determine whether the request
   * has been processed, call Get Operation Status. For more information on
   * asynchronous operations, see Tracking Asynchronous Service Management
   * Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx. To
   * perform an automatic update of a deployment, call Upgrade Deployment or
   * Change Deployment Configuration with the Mode element set to automatic.
   * The update proceeds from that point without a need for further input. You
   * can call Get Operation Status to determine when the update is complete.
   * To perform a manual update, first call Upgrade Deployment with the Mode
   * element set to manual. Next, call Walk Upgrade Domain to update each
   * domain within the deployment. You should make sure that the operation is
   * complete by calling Get Operation Status before updating the next domain.
   * Important: An update that adds or removes role instances will result in a
   * configuration update to all roles that are deployed in the cloud service.
   * Existing role instances need to be notified of new role instances so that
   * all role instances can communicate together in the cloud service. By
   * default, a cloud service is deployed with five update domains, which are
   * updated one at a time during an in-place update. For information on
   * modifying the number of update domains in the service definition file,
   * see the Azure Service Definition Schema (.csdef File). To determine the
   * update domain in which a particular instance is running in Windows Azure,
   * use the UpdateDomain property of the RoleInstance class. See the Azure
   * Managed Library Reference at
   * http://msdn.microsoft.com/en-us/library/windowsazure/dd179380.aspx for
   * more information.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460793.aspx for
   * more information)
   * 
   * @param {string} serviceName The cloud service to upgrade.
   * 
   * @param {DeploymentSlot} deploymentSlot The slot to upgrade.
   * 
   * @param {DeploymentUpgradeParameters} parameters Parameters supplied to the
   * Begin Upgrading Deployment By Slot operation.
   * 
   * @param {DeploymentUpgradeMode} parameters.mode The type of update to
   * initiate. Role instances are allocated to update domains when the service
   * is deployed. Updates can be initiated manually in each update domain or
   * initiated automatically in all update domains. Possible values are Auto
   * or Manual. If not specified, the default value is Auto. If set to Manual,
   * WalkUpgradeDomain must be called to apply the update. If set to Auto, the
   * update is automatically applied to each update domain in sequence.
   * 
   * @param {string} parameters.packageUri A URL that refers to the location of
   * the service package in the Blob service. The service package can be
   * located either in a storage account beneath the same subscription or a
   * Shared Access Signature (SAS) URI from any storage account. For more
   * information about Shared Access Signatures, see Delegating Access with a
   * Shared Access Signature (REST API) at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee395415.aspx.
   * 
   * @param {string} parameters.configuration The service configuration file
   * for the deployment. The client library does the base-64 encoding from the
   * plain text input.
   * 
   * @param {string} parameters.label A name for the hosted service. The name
   * can be up to 100 characters in length. It is recommended that the label
   * be unique within the subscription. The name can be used identify the
   * hosted service for your tracking purposes.
   * 
   * @param {string} [parameters.roleToUpgrade] The name of the specific role
   * instance to update.
   * 
   * @param {boolean} parameters.force Specifies whether the rollback should
   * proceed even when it will cause local data to be lost from some role
   * instances.
   * 
   * @param {object} [parameters.extendedProperties] Represents the name of an
   * extended deployment property. Each extended property must have a defined
   * name and a value. You can have a maximum of 25 extended property
   * name/value pairs. The maximum length of the name element is 64
   * characters, only alphanumeric characters and underscores are valid in the
   * name, and the name must start with a letter. Attempting to use other
   * characters, starting the name with a non-letter character, or entering a
   * name that is identical to that of another extended property owned by the
   * same hosted service will result in a status code 400 (Bad Request) error.
   * 
   * @param {ExtensionConfiguration} [parameters.extensionConfiguration]
   * Represents an extension that is added to the cloud service. In Azure, a
   * process can run as an extension of a cloud service. For example, Remote
   * Desktop Access or the Azure Diagnostics Agent can run as extensions to
   * the cloud service. You must add an extension to the cloud service by
   * using Add Extension before it can be added to the deployment.
   * 
   * @param {array} [parameters.extensionConfiguration.allRoles] Specifies a
   * list of extensions that are applied to all roles in a deployment.
   * 
   * @param {array} [parameters.extensionConfiguration.namedRoles] Specifies a
   * list of extensions that are applied to specific roles in a deployment.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.beginUpgradingBySlot = function(serviceName, deploymentSlot, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    // TODO: Validate serviceName is a valid DNS name.
    if (deploymentSlot === null || deploymentSlot === undefined) {
      return callback(new Error('deploymentSlot cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.configuration === null || parameters.configuration === undefined) {
      return callback(new Error('parameters.configuration cannot be null.'));
    }
    if (parameters.extensionConfiguration !== null && parameters.extensionConfiguration !== undefined) {
      if (parameters.extensionConfiguration.allRoles !== null && parameters.extensionConfiguration.allRoles !== undefined) {
        for (var loweredIndex1 = 0; loweredIndex1 < parameters.extensionConfiguration.allRoles.length; loweredIndex1 = loweredIndex1 + 1) {
          var allRolesParameterItem = parameters.extensionConfiguration.allRoles[loweredIndex1];
          if (allRolesParameterItem.id === null || allRolesParameterItem.id === undefined) {
            return callback(new Error('parameters.extensionConfiguration.allRoles. cannot be null.'));
          }
        }
      }
      if (parameters.extensionConfiguration.namedRoles !== null && parameters.extensionConfiguration.namedRoles !== undefined) {
        for (var loweredIndex2 = 0; loweredIndex2 < parameters.extensionConfiguration.namedRoles.length; loweredIndex2 = loweredIndex2 + 1) {
          var namedRolesParameterItem = parameters.extensionConfiguration.namedRoles[loweredIndex2];
          if (namedRolesParameterItem.extensions === null || namedRolesParameterItem.extensions === undefined) {
            return callback(new Error('parameters.extensionConfiguration.namedRoles. cannot be null.'));
          }
          if (namedRolesParameterItem.extensions !== null && namedRolesParameterItem.extensions !== undefined) {
            for (var loweredIndex3 = 0; loweredIndex3 < namedRolesParameterItem.extensions.length; loweredIndex3 = loweredIndex3 + 1) {
              var extensionsParameterItem = namedRolesParameterItem.extensions[loweredIndex3];
              if (extensionsParameterItem.id === null || extensionsParameterItem.id === undefined) {
                return callback(new Error('parameters.extensionConfiguration.namedRoles.. cannot be null.'));
              }
            }
          }
          if (namedRolesParameterItem.roleName === null || namedRolesParameterItem.roleName === undefined) {
            return callback(new Error('parameters.extensionConfiguration.namedRoles. cannot be null.'));
          }
        }
      }
    }
    if (parameters.force === null || parameters.force === undefined) {
      return callback(new Error('parameters.force cannot be null.'));
    }
    if (parameters.label === null || parameters.label === undefined) {
      return callback(new Error('parameters.label cannot be null.'));
    }
    if (parameters.label.length > 100) {
      return callback(new Error('parameters.label is outside the valid range.'));
    }
    if (parameters.mode === null || parameters.mode === undefined) {
      return callback(new Error('parameters.mode cannot be null.'));
    }
    if (parameters.packageUri === null || parameters.packageUri === undefined) {
      return callback(new Error('parameters.packageUri cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deploymentslots/';
    url2 = url2 + encodeURIComponent(deploymentSlot !== null && deploymentSlot !== undefined ? deploymentSlot.toString() : 'Staging');
    url2 = url2 + '/';
    var queryParameters = [];
    queryParameters.push('comp=upgrade');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var upgradeDeploymentElement = js2xml.createElement('UpgradeDeployment', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, upgradeDeploymentElement);
    
    var modeElement = js2xml.createElement('Mode', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(modeElement, parameters.mode !== null && parameters.mode !== undefined ? parameters.mode.toString() : 'Auto');
    js2xml.addChildElement(upgradeDeploymentElement, modeElement);
    
    var packageUrlElement = js2xml.createElement('PackageUrl', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(packageUrlElement, parameters.packageUri);
    js2xml.addChildElement(upgradeDeploymentElement, packageUrlElement);
    
    var configurationElement = js2xml.createElement('Configuration', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(configurationElement, new Buffer(parameters.configuration).toString('base64'));
    js2xml.addChildElement(upgradeDeploymentElement, configurationElement);
    
    var labelElement = js2xml.createElement('Label', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(labelElement, new Buffer(parameters.label).toString('base64'));
    js2xml.addChildElement(upgradeDeploymentElement, labelElement);
    
    if (parameters.roleToUpgrade !== null && parameters.roleToUpgrade !== undefined) {
      var roleToUpgradeElement = js2xml.createElement('RoleToUpgrade', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(roleToUpgradeElement, parameters.roleToUpgrade);
      js2xml.addChildElement(upgradeDeploymentElement, roleToUpgradeElement);
    }
    
    var forceElement = js2xml.createElement('Force', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(forceElement, parameters.force.toString());
    js2xml.addChildElement(upgradeDeploymentElement, forceElement);
    
    if (parameters.extendedProperties !== null && parameters.extendedProperties !== undefined) {
      var extendedPropertiesDictionaryElement = js2xml.createElement('ExtendedProperties', 'http://schemas.microsoft.com/windowsazure');
      for (var extendedPropertiesKey in parameters.extendedProperties) {
        var extendedPropertiesValue = parameters.extendedProperties[extendedPropertiesKey];
        var extendedPropertiesElement = js2xml.createElement('ExtendedProperty', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(extendedPropertiesDictionaryElement, extendedPropertiesElement);
        
        var extendedPropertiesKeyElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(extendedPropertiesKeyElement, extendedPropertiesKey);
        js2xml.addChildElement(extendedPropertiesElement, extendedPropertiesKeyElement);
        
        var extendedPropertiesValueElement = js2xml.createElement('Value', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(extendedPropertiesValueElement, extendedPropertiesValue);
        js2xml.addChildElement(extendedPropertiesElement, extendedPropertiesValueElement);
      }
      js2xml.addChildElement(upgradeDeploymentElement, extendedPropertiesDictionaryElement);
    }
    
    if (parameters.extensionConfiguration !== null && parameters.extensionConfiguration !== undefined) {
      var extensionConfigurationElement = js2xml.createElement('ExtensionConfiguration', 'http://schemas.microsoft.com/windowsazure');
      js2xml.addChildElement(upgradeDeploymentElement, extensionConfigurationElement);
      
      if (parameters.extensionConfiguration.allRoles !== null && parameters.extensionConfiguration.allRoles !== undefined) {
        var allRolesSequenceElement = js2xml.createElement('AllRoles', 'http://schemas.microsoft.com/windowsazure');
        for (var loweredIndex4 = 0; loweredIndex4 < parameters.extensionConfiguration.allRoles.length; loweredIndex4 = loweredIndex4 + 1) {
          var allRolesItem = parameters.extensionConfiguration.allRoles[loweredIndex4];
          var extensionElement = js2xml.createElement('Extension', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(allRolesSequenceElement, extensionElement);
          
          var idElement = js2xml.createElement('Id', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(idElement, allRolesItem.id);
          js2xml.addChildElement(extensionElement, idElement);
          
          if (allRolesItem.state !== null && allRolesItem.state !== undefined) {
            var stateElement = js2xml.createElement('State', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(stateElement, allRolesItem.state);
            js2xml.addChildElement(extensionElement, stateElement);
          }
        }
        js2xml.addChildElement(extensionConfigurationElement, allRolesSequenceElement);
      }
      
      if (parameters.extensionConfiguration.namedRoles !== null && parameters.extensionConfiguration.namedRoles !== undefined) {
        var namedRolesSequenceElement = js2xml.createElement('NamedRoles', 'http://schemas.microsoft.com/windowsazure');
        for (var loweredIndex5 = 0; loweredIndex5 < parameters.extensionConfiguration.namedRoles.length; loweredIndex5 = loweredIndex5 + 1) {
          var namedRolesItem = parameters.extensionConfiguration.namedRoles[loweredIndex5];
          var roleElement = js2xml.createElement('Role', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(namedRolesSequenceElement, roleElement);
          
          var roleNameElement = js2xml.createElement('RoleName', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(roleNameElement, namedRolesItem.roleName);
          js2xml.addChildElement(roleElement, roleNameElement);
          
          var extensionsSequenceElement = js2xml.createElement('Extensions', 'http://schemas.microsoft.com/windowsazure');
          for (var loweredIndex6 = 0; loweredIndex6 < namedRolesItem.extensions.length; loweredIndex6 = loweredIndex6 + 1) {
            var extensionsItem = namedRolesItem.extensions[loweredIndex6];
            var extensionElement2 = js2xml.createElement('Extension', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(extensionsSequenceElement, extensionElement2);
            
            var idElement2 = js2xml.createElement('Id', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(idElement2, extensionsItem.id);
            js2xml.addChildElement(extensionElement2, idElement2);
            
            if (extensionsItem.state !== null && extensionsItem.state !== undefined) {
              var stateElement2 = js2xml.createElement('State', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(stateElement2, extensionsItem.state);
              js2xml.addChildElement(extensionElement2, stateElement2);
            }
          }
          js2xml.addChildElement(roleElement, extensionsSequenceElement);
        }
        js2xml.addChildElement(extensionConfigurationElement, namedRolesSequenceElement);
      }
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Walking Upgrade Domain By Deployment Name operation specifies an
   * update domain in which a role instance must be updated. For more
   * information about updating role instances, see Update an Azure Service at
   * http://msdn.microsoft.com/en-us/library/windowsazure/hh472157.aspx. This
   * operation is an asynchronous operation. To determine whether the
   * Management service has finished processing the request, call Get
   * Operation Status. For more information on asynchronous operations, see
   * Tracking Asynchronous Service Management Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx. Prior
   * to calling the Walk Upgrade Domain operation you must have called Upgrade
   * Deployment, Change Deployment Configuration, or Rollback Update Or
   * Upgrade. By default, a service is deployed with five update domains,
   * which are updated one at a time during an in-place update. For
   * information on modifying the number of update domains in the service
   * definition file, see the Azure Service Definition Schema (.csdef File).
   * To perform a manual update of your deployment, proceed in this order:
   * Call Upgrade Deployment with the Mode element set to manual. Call Walk
   * Upgrade Domain to update each domain within the deployment. Update
   * domains must be updated in order. For example, begin with domain 0,
   * proceed to domain 1, and so on. Important: An update that adds or removes
   * role instances will result in a configuration update to all roles that
   * are deployed in the cloud service. Existing role instances need to be
   * notified of new role instances so that all role instances can communicate
   * together in the cloud service. While an update is in progress, call Get
   * Deployment to determine its status. If the update is in progress, Get
   * Deployment returns an UpgradeStatus element that contains information
   * about the update. If the update is complete, or if no update is in
   * progress, then the UpgradeStatus element is null.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460800.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {DeploymentWalkUpgradeDomainParameters} parameters Parameters
   * supplied to the Begin Walking Upgrade Domain By Deployment Name operation.
   * 
   * @param {number} parameters.upgradeDomain An integer value that identifies
   * the update domain to update. Update domains are identified with a
   * zero-based index: the first update domain has an ID of 0, the second has
   * an ID of 1, and so on.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.beginWalkingUpgradeDomainByDeploymentName = function(serviceName, deploymentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.upgradeDomain === null || parameters.upgradeDomain === undefined) {
      return callback(new Error('parameters.upgradeDomain cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    var queryParameters = [];
    queryParameters.push('comp=walkupgradedomain');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var walkUpgradeDomainElement = js2xml.createElement('WalkUpgradeDomain', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, walkUpgradeDomainElement);
    
    var upgradeDomainElement = js2xml.createElement('UpgradeDomain', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(upgradeDomainElement, parameters.upgradeDomain.toString());
    js2xml.addChildElement(walkUpgradeDomainElement, upgradeDomainElement);
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Walking Upgrade Domain By Deployment Slot operation specifies an
   * update domain in which a role instance must be updated. For more
   * information about updating role instances, see Update an Azure Service at
   * http://msdn.microsoft.com/en-us/library/windowsazure/hh472157.aspx. This
   * operation is an asynchronous operation. To determine whether the
   * Management service has finished processing the request, call Get
   * Operation Status. For more information on asynchronous operations, see
   * Tracking Asynchronous Service Management Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx. Prior
   * to calling the Walk Upgrade Domain operation you must have called Upgrade
   * Deployment, Change Deployment Configuration, or Rollback Update Or
   * Upgrade. By default, a service is deployed with five update domains,
   * which are updated one at a time during an in-place update. For
   * information on modifying the number of update domains in the service
   * definition file, see the Azure Service Definition Schema (.csdef File).
   * To perform a manual update of your deployment, proceed in this order:
   * Call Upgrade Deployment with the Mode element set to manual. Call Walk
   * Upgrade Domain to update each domain within the deployment. Update
   * domains must be updated in order. For example, begin with domain 0,
   * proceed to domain 1, and so on. Important: An update that adds or removes
   * role instances will result in a configuration update to all roles that
   * are deployed in the cloud service. Existing role instances need to be
   * notified of new role instances so that all role instances can communicate
   * together in the cloud service. While an update is in progress, call Get
   * Deployment to determine its status. If the update is in progress, Get
   * Deployment returns an UpgradeStatus element that contains information
   * about the update. If the update is complete, or if no update is in
   * progress, then the UpgradeStatus element is null.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460800.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {DeploymentSlot} deploymentSlot The deployment slot.
   * 
   * @param {DeploymentWalkUpgradeDomainParameters} parameters Parameters
   * supplied to the Begin Walking Upgrade Domain By Deployment Slot operation.
   * 
   * @param {number} parameters.upgradeDomain An integer value that identifies
   * the update domain to update. Update domains are identified with a
   * zero-based index: the first update domain has an ID of 0, the second has
   * an ID of 1, and so on.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.beginWalkingUpgradeDomainByDeploymentSlot = function(serviceName, deploymentSlot, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentSlot === null || deploymentSlot === undefined) {
      return callback(new Error('deploymentSlot cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.upgradeDomain === null || parameters.upgradeDomain === undefined) {
      return callback(new Error('parameters.upgradeDomain cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deploymentslots/';
    url2 = url2 + encodeURIComponent(deploymentSlot !== null && deploymentSlot !== undefined ? deploymentSlot.toString() : 'Staging');
    url2 = url2 + '/';
    var queryParameters = [];
    queryParameters.push('comp=walkupgradedomain');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var walkUpgradeDomainElement = js2xml.createElement('WalkUpgradeDomain', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, walkUpgradeDomainElement);
    
    var upgradeDomainElement = js2xml.createElement('UpgradeDomain', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(upgradeDomainElement, parameters.upgradeDomain.toString());
    js2xml.addChildElement(walkUpgradeDomainElement, upgradeDomainElement);
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Change Deployment Configuration By Name operation initiates a change
   * to the deployment configuration. This operation is an asynchronous
   * operation. To determine whether the Management service has finished
   * processing the request, call Get Operation Status. For more information
   * on asynchronous operations, see Tracking Asynchronous Service Management
   * Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460809.aspx for
   * more information)
   * 
   * @param {string} serviceName The cloud service to change deployment
   * configuration for.
   * 
   * @param {string} deploymentName The deployment to change configuration for.
   * 
   * @param {DeploymentChangeConfigurationParameters} parameters Parameters
   * supplied to the Change ConfigurationDeployment By Name operation.
   * 
   * @param {string} parameters.configuration The encoded service configuration
   * file for the deployment.
   * 
   * @param {boolean} [parameters.treatWarningsAsError] Indicates whether to
   * treat package validation warnings as errors. The default value is false.
   * If set to true, the Created Deployment operation fails if there are
   * validation warnings on the service package.
   * 
   * @param {DeploymentChangeConfigurationMode} [parameters.mode] The Change
   * Configuration Deployment mode. Possible values are: Auto and Manual. If
   * not specified, the default value is Auto. If set to Manual,
   * WalkUpgradeDomain must be called to apply the update. If set to Auto, the
   * update is automatically applied to each update domain for the service.
   * 
   * @param {object} [parameters.extendedProperties] Represents the name of an
   * extended deployment property. Each extended property must have a defined
   * name and a value. You can have a maximum of 25 extended property
   * name/value pairs. The maximum length of the name element is 64
   * characters, only alphanumeric characters and underscores are valid in the
   * name, and the name must start with a letter. Attempting to use other
   * characters, starting the name with a non-letter character, or entering a
   * name that is identical to that of another extended property owned by the
   * same hosted service will result in a status code 400 (Bad Request) error.
   * 
   * @param {ExtensionConfiguration} [parameters.extensionConfiguration]
   * Represents an extension that is added to the cloud service. In Azure, a
   * process can run as an extension of a cloud service. For example, Remote
   * Desktop Access or the Azure Diagnostics Agent can run as extensions to
   * the cloud service. You must add an extension to the cloud service by
   * using Add Extension before it can be added to the deployment.
   * 
   * @param {array} [parameters.extensionConfiguration.allRoles] Specifies a
   * list of extensions that are applied to all roles in a deployment.
   * 
   * @param {array} [parameters.extensionConfiguration.namedRoles] Specifies a
   * list of extensions that are applied to specific roles in a deployment.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.changeConfigurationByName = function(serviceName, deploymentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.deployments.beginChangingConfigurationByName(serviceName, deploymentName, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Change Deployment Configuration By Slot operation initiates a change
   * to the deployment configuration. This operation is an asynchronous
   * operation. To determine whether the Management service has finished
   * processing the request, call Get Operation Status. For more information
   * on asynchronous operations, see Tracking Asynchronous Service Management
   * Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460809.aspx for
   * more information)
   * 
   * @param {string} serviceName The cloud service to change deployment
   * configuration for.
   * 
   * @param {DeploymentSlot} deploymentSlot The slot to change deployment
   * configuration for.
   * 
   * @param {DeploymentChangeConfigurationParameters} parameters Parameters
   * supplied to the Change Configuration Deployment By Slot operation.
   * 
   * @param {string} parameters.configuration The encoded service configuration
   * file for the deployment.
   * 
   * @param {boolean} [parameters.treatWarningsAsError] Indicates whether to
   * treat package validation warnings as errors. The default value is false.
   * If set to true, the Created Deployment operation fails if there are
   * validation warnings on the service package.
   * 
   * @param {DeploymentChangeConfigurationMode} [parameters.mode] The Change
   * Configuration Deployment mode. Possible values are: Auto and Manual. If
   * not specified, the default value is Auto. If set to Manual,
   * WalkUpgradeDomain must be called to apply the update. If set to Auto, the
   * update is automatically applied to each update domain for the service.
   * 
   * @param {object} [parameters.extendedProperties] Represents the name of an
   * extended deployment property. Each extended property must have a defined
   * name and a value. You can have a maximum of 25 extended property
   * name/value pairs. The maximum length of the name element is 64
   * characters, only alphanumeric characters and underscores are valid in the
   * name, and the name must start with a letter. Attempting to use other
   * characters, starting the name with a non-letter character, or entering a
   * name that is identical to that of another extended property owned by the
   * same hosted service will result in a status code 400 (Bad Request) error.
   * 
   * @param {ExtensionConfiguration} [parameters.extensionConfiguration]
   * Represents an extension that is added to the cloud service. In Azure, a
   * process can run as an extension of a cloud service. For example, Remote
   * Desktop Access or the Azure Diagnostics Agent can run as extensions to
   * the cloud service. You must add an extension to the cloud service by
   * using Add Extension before it can be added to the deployment.
   * 
   * @param {array} [parameters.extensionConfiguration.allRoles] Specifies a
   * list of extensions that are applied to all roles in a deployment.
   * 
   * @param {array} [parameters.extensionConfiguration.namedRoles] Specifies a
   * list of extensions that are applied to specific roles in a deployment.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.changeConfigurationBySlot = function(serviceName, deploymentSlot, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.deployments.beginChangingConfigurationBySlot(serviceName, deploymentSlot, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Commit Deployment Operation validates and commits your deployment for
   * IaaS Classic to ARM migration.
   * 
   * @param {string} serviceName Name of the cloud service.
   * 
   * @param {string} deploymentName Name of the deployment to be migrated.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.commitMigration = function(serviceName, deploymentName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.deployments.beginCommitMigration(serviceName, deploymentName, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Create Deployment operation uploads a new service package and creates
   * a new deployment in the staging or production environments. This
   * operation is an asynchronous operation. To determine whether the
   * management service has finished processing the request, call Get
   * Operation Status. For more information on asynchronous operations, see
   * Tracking Asynchronous Service Management Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460813.aspx for
   * more information)
   * 
   * @param {string} serviceName The cloud service to create a deployment for.
   * 
   * @param {DeploymentSlot} deploymentSlot The slot to create a deployment for.
   * 
   * @param {DeploymentCreateParameters} parameters Parameters supplied to the
   * Create Deployment operation.
   * 
   * @param {string} parameters.name The name for the deployment. The
   * deployment name must be unique among other deployments for the cloud
   * service.
   * 
   * @param {string} parameters.packageUri A URL that refers to the location of
   * the service package in the Blob service. The service package can be
   * located either in a storage account beneath the same subscription or a
   * Shared Access Signature (SAS) URI from any storage account. For more info
   * about Shared Access Signatures, see Delegating Access with a Shared
   * Access Signature (REST API) at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee395415.aspx.
   * 
   * @param {string} parameters.label A name for the hosted service. The name
   * can be up to 100 characters in length. It is recommended that the label
   * be unique within the subscription. The name can be used identify the
   * hosted service for your tracking purposes.
   * 
   * @param {string} parameters.configuration The service configuration file
   * for the deployment. The client library does the base-64 encoding from the
   * plain text input.
   * 
   * @param {boolean} [parameters.startDeployment] Indicates whether to start
   * the deployment immediately after it is created. The default value is
   * false. If false, the service model is still deployed to the virtual
   * machines but the code is not run immediately. Instead, the service is
   * Suspended until you call Update Deployment Status and set the status
   * toRunning, at which time the service will be started. A deployed service
   * still incurs charges, even if it is suspended.
   * 
   * @param {boolean} [parameters.treatWarningsAsError] Indicates whether to
   * treat package validation warnings as errors. The default value is false.
   * If set to true, the Created Deployment operation fails if there are
   * validation warnings on the service package.
   * 
   * @param {object} [parameters.extendedProperties] Represents the name of an
   * extended deployment property. Each extended property must have a defined
   * name and a value. You can have a maximum of 25 extended property
   * name/value pairs. The maximum length of the name element is 64
   * characters, only alphanumeric characters and underscores are valid in the
   * name, and the name must start with a letter. Attempting to use other
   * characters, starting the name with a non-letter character, or entering a
   * name that is identical to that of another extended property owned by the
   * same hosted service will result in a status code 400 (Bad Request) error.
   * 
   * @param {ExtensionConfiguration} [parameters.extensionConfiguration]
   * Represents an extension that is added to the cloud service. In Azure, a
   * process can run as an extension of a cloud service. For example, Remote
   * Desktop Access or the Azure Diagnostics Agent can run as extensions to
   * the cloud service. You must add an extension to the cloud service by
   * using Add Extension before it can be added to the deployment.
   * 
   * @param {array} [parameters.extensionConfiguration.allRoles] Specifies a
   * list of extensions that are applied to all roles in a deployment.
   * 
   * @param {array} [parameters.extensionConfiguration.namedRoles] Specifies a
   * list of extensions that are applied to specific roles in a deployment.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.create = function(serviceName, deploymentSlot, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.deployments.beginCreating(serviceName, deploymentSlot, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Delete Deployment By Name operation deletes the specified deployment.
   * This operation is an asynchronous operation. To determine whether the
   * Management service has finished processing the request, call Get
   * Operation Status. For more information on asynchronous operations, see
   * Tracking Asynchronous Service Management Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460815.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {boolean} [deleteFromStorage] Specifies that the source blob for
   * the disk should also be deleted from storage.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.deleteByName = function(serviceName, deploymentName, deleteFromStorage, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.deployments.beginDeletingByName(serviceName, deploymentName, deleteFromStorage, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Delete Deployment By Slot operation deletes the specified deployment.
   * This operation is an asynchronous operation. To determine whether the
   * Management service has finished processing the request, call Get
   * Operation Status. For more information on asynchronous operations, see
   * Tracking Asynchronous Service Management Requests.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460815.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {DeploymentSlot} deploymentSlot The deployment slot.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.deleteBySlot = function(serviceName, deploymentSlot, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.deployments.beginDeletingBySlot(serviceName, deploymentSlot, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Delete Role Instances operation deletes a role instance from a
   * deployment in a cloud service.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn469418.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {string} deploymentName The name of the deployment.
   * 
   * @param {DeploymentDeleteRoleInstanceParameters} roleInstanceName The
   * parameters to delete the role.
   * 
   * @param {array} [roleInstanceName.name] The names of role instances to
   * delete from the deployment
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.deleteRoleInstanceByDeploymentName = function(serviceName, deploymentName, roleInstanceName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.deployments.beginDeletingRoleInstanceByDeploymentName(serviceName, deploymentName, roleInstanceName, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Delete Role Instances operation deletes the role instances from a
   * deployment in a cloud service.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn469418.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {string} deploymentSlot The name of the deployment slot.
   * 
   * @param {DeploymentDeleteRoleInstanceParameters} parameters The parameters
   * to delete the role.
   * 
   * @param {array} [parameters.name] The names of role instances to delete
   * from the deployment
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.deleteRoleInstanceByDeploymentSlot = function(serviceName, deploymentSlot, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.deployments.beginDeletingRoleInstanceByBeploymentSlot(serviceName, deploymentSlot, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Get Deployment By Name operation returns configuration information,
   * status, and system properties for a deployment.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460804.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {string} deploymentName The name of the deployment.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.getByName = function(serviceName, deploymentName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { extendedProperties: {}, loadBalancers: [], roleInstances: [], roles: [], virtualIPAddresses: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var deploymentElement = js2xml.getElement(responseDoc, responseDoc, 'DEPLOYMENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (deploymentElement !== null && deploymentElement !== undefined) {
            var nameElement = js2xml.getElement(responseDoc, deploymentElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (nameElement !== null && nameElement !== undefined) {
              var nameInstance = nameElement;
              result.name = nameInstance;
            }
            
            var deploymentSlotElement = js2xml.getElement(responseDoc, deploymentElement, 'DEPLOYMENTSLOT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (deploymentSlotElement !== null && deploymentSlotElement !== undefined && deploymentSlotElement.length !== 0) {
              var deploymentSlotInstance = deploymentSlotElement;
              result.deploymentSlot = deploymentSlotInstance;
            }
            
            var privateIDElement = js2xml.getElement(responseDoc, deploymentElement, 'PRIVATEID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (privateIDElement !== null && privateIDElement !== undefined) {
              var privateIDInstance = privateIDElement;
              result.privateId = privateIDInstance;
            }
            
            var statusElement = js2xml.getElement(responseDoc, deploymentElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (statusElement !== null && statusElement !== undefined && statusElement.length !== 0) {
              var statusInstance = statusElement;
              result.status = statusInstance;
            }
            
            var labelElement = js2xml.getElement(responseDoc, deploymentElement, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (labelElement !== null && labelElement !== undefined) {
              var labelInstance = new Buffer(labelElement, 'base64').toString('utf8');
              result.label = labelInstance;
            }
            
            var urlElement = js2xml.getElement(responseDoc, deploymentElement, 'URL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (urlElement !== null && urlElement !== undefined) {
              var urlInstance = urlElement;
              result.uri = urlInstance;
            }
            
            var configurationElement = js2xml.getElement(responseDoc, deploymentElement, 'CONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (configurationElement !== null && configurationElement !== undefined) {
              var configurationInstance = new Buffer(configurationElement, 'base64').toString('utf8');
              result.configuration = configurationInstance;
            }
            
            var roleInstanceListSequenceElement = js2xml.getElement(responseDoc, deploymentElement, 'ROLEINSTANCELIST', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (roleInstanceListSequenceElement !== null && roleInstanceListSequenceElement !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, roleInstanceListSequenceElement, 'ROLEINSTANCE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
                var roleInstanceListElement = js2xml.getElements(responseDoc, roleInstanceListSequenceElement, 'ROLEINSTANCE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
                var roleInstanceInstance = { instanceEndpoints: [], networkInterfaces: [], publicIPs: [], resourceExtensionStatusList: [] };
                result.roleInstances.push(roleInstanceInstance);
                
                var roleNameElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'ROLENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (roleNameElement !== null && roleNameElement !== undefined) {
                  var roleNameInstance = roleNameElement;
                  roleInstanceInstance.roleName = roleNameInstance;
                }
                
                var instanceNameElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'INSTANCENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (instanceNameElement !== null && instanceNameElement !== undefined) {
                  var instanceNameInstance = instanceNameElement;
                  roleInstanceInstance.instanceName = instanceNameInstance;
                }
                
                var instanceStatusElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'INSTANCESTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (instanceStatusElement !== null && instanceStatusElement !== undefined) {
                  var instanceStatusInstance = instanceStatusElement;
                  roleInstanceInstance.instanceStatus = instanceStatusInstance;
                }
                
                var instanceUpgradeDomainElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'INSTANCEUPGRADEDOMAIN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (instanceUpgradeDomainElement !== null && instanceUpgradeDomainElement !== undefined && instanceUpgradeDomainElement.length !== 0) {
                  var instanceUpgradeDomainInstance = parseInt(instanceUpgradeDomainElement, 10);
                  roleInstanceInstance.instanceUpgradeDomain = instanceUpgradeDomainInstance;
                }
                
                var instanceFaultDomainElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'INSTANCEFAULTDOMAIN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (instanceFaultDomainElement !== null && instanceFaultDomainElement !== undefined && instanceFaultDomainElement.length !== 0) {
                  var instanceFaultDomainInstance = parseInt(instanceFaultDomainElement, 10);
                  roleInstanceInstance.instanceFaultDomain = instanceFaultDomainInstance;
                }
                
                var instanceSizeElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'INSTANCESIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (instanceSizeElement !== null && instanceSizeElement !== undefined) {
                  var instanceSizeInstance = instanceSizeElement;
                  roleInstanceInstance.instanceSize = instanceSizeInstance;
                }
                
                var instanceStateDetailsElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'INSTANCESTATEDETAILS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (instanceStateDetailsElement !== null && instanceStateDetailsElement !== undefined) {
                  var instanceStateDetailsInstance = instanceStateDetailsElement;
                  roleInstanceInstance.instanceStateDetails = instanceStateDetailsInstance;
                }
                
                var instanceErrorCodeElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'INSTANCEERRORCODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (instanceErrorCodeElement !== null && instanceErrorCodeElement !== undefined) {
                  var instanceErrorCodeInstance = instanceErrorCodeElement;
                  roleInstanceInstance.instanceErrorCode = instanceErrorCodeInstance;
                }
                
                var ipAddressElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'IPADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (ipAddressElement !== null && ipAddressElement !== undefined) {
                  var ipAddressInstance = ipAddressElement;
                  roleInstanceInstance.iPAddress = ipAddressInstance;
                }
                
                var instanceEndpointsSequenceElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'INSTANCEENDPOINTS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (instanceEndpointsSequenceElement !== null && instanceEndpointsSequenceElement !== undefined) {
                  for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, instanceEndpointsSequenceElement, 'INSTANCEENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex2 = loweredIndex2 + 1) {
                    var instanceEndpointsElement = js2xml.getElements(responseDoc, instanceEndpointsSequenceElement, 'INSTANCEENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex2];
                    var instanceEndpointInstance = {};
                    roleInstanceInstance.instanceEndpoints.push(instanceEndpointInstance);
                    
                    var localPortElement = js2xml.getElement(responseDoc, instanceEndpointsElement, 'LOCALPORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (localPortElement !== null && localPortElement !== undefined && localPortElement.length !== 0) {
                      var localPortInstance = parseInt(localPortElement, 10);
                      instanceEndpointInstance.localPort = localPortInstance;
                    }
                    
                    var nameElement2 = js2xml.getElement(responseDoc, instanceEndpointsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (nameElement2 !== null && nameElement2 !== undefined) {
                      var nameInstance2 = nameElement2;
                      instanceEndpointInstance.name = nameInstance2;
                    }
                    
                    var publicPortElement = js2xml.getElement(responseDoc, instanceEndpointsElement, 'PUBLICPORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (publicPortElement !== null && publicPortElement !== undefined && publicPortElement.length !== 0) {
                      var publicPortInstance = parseInt(publicPortElement, 10);
                      instanceEndpointInstance.port = publicPortInstance;
                    }
                    
                    var protocolElement = js2xml.getElement(responseDoc, instanceEndpointsElement, 'PROTOCOL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (protocolElement !== null && protocolElement !== undefined) {
                      var protocolInstance = protocolElement;
                      instanceEndpointInstance.protocol = protocolInstance;
                    }
                    
                    var vipElement = js2xml.getElement(responseDoc, instanceEndpointsElement, 'VIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (vipElement !== null && vipElement !== undefined) {
                      var vipInstance = vipElement;
                      instanceEndpointInstance.virtualIPAddress = vipInstance;
                    }
                    
                    var idleTimeoutInMinutesElement = js2xml.getElement(responseDoc, instanceEndpointsElement, 'IDLETIMEOUTINMINUTES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (idleTimeoutInMinutesElement !== null && idleTimeoutInMinutesElement !== undefined && idleTimeoutInMinutesElement.length !== 0) {
                      var idleTimeoutInMinutesInstance = parseInt(idleTimeoutInMinutesElement, 10);
                      instanceEndpointInstance.idleTimeoutInMinutes = idleTimeoutInMinutesInstance;
                    }
                  }
                }
                
                var guestAgentStatusElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'GUESTAGENTSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (guestAgentStatusElement !== null && guestAgentStatusElement !== undefined) {
                  var guestAgentStatusInstance = {};
                  roleInstanceInstance.guestAgentStatus = guestAgentStatusInstance;
                  
                  var protocolVersionElement = js2xml.getElement(responseDoc, guestAgentStatusElement, 'PROTOCOLVERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (protocolVersionElement !== null && protocolVersionElement !== undefined) {
                    var protocolVersionInstance = protocolVersionElement;
                    guestAgentStatusInstance.protocolVersion = protocolVersionInstance;
                  }
                  
                  var timestampElement = js2xml.getElement(responseDoc, guestAgentStatusElement, 'TIMESTAMP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (timestampElement !== null && timestampElement !== undefined && timestampElement.length !== 0) {
                    var timestampInstance = new Date(timestampElement);
                    guestAgentStatusInstance.timestamp = timestampInstance;
                  }
                  
                  var guestAgentVersionElement = js2xml.getElement(responseDoc, guestAgentStatusElement, 'GUESTAGENTVERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (guestAgentVersionElement !== null && guestAgentVersionElement !== undefined) {
                    var guestAgentVersionInstance = guestAgentVersionElement;
                    guestAgentStatusInstance.guestAgentVersion = guestAgentVersionInstance;
                  }
                  
                  var statusElement2 = js2xml.getElement(responseDoc, guestAgentStatusElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (statusElement2 !== null && statusElement2 !== undefined) {
                    var statusInstance2 = statusElement2;
                    guestAgentStatusInstance.status = statusInstance2;
                  }
                  
                  var codeElement = js2xml.getElement(responseDoc, guestAgentStatusElement, 'CODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (codeElement !== null && codeElement !== undefined && codeElement.length !== 0) {
                    var codeInstance = parseInt(codeElement, 10);
                    guestAgentStatusInstance.code = codeInstance;
                  }
                  
                  var messageElement = js2xml.getElement(responseDoc, guestAgentStatusElement, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (messageElement !== null && messageElement !== undefined) {
                    var messageInstance = { paramList: [] };
                    guestAgentStatusInstance.message = messageInstance;
                    
                    var messageResourceIdElement = js2xml.getElement(responseDoc, messageElement, 'MESSAGERESOURCEID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (messageResourceIdElement !== null && messageResourceIdElement !== undefined) {
                      var messageResourceIdInstance = messageResourceIdElement;
                      messageInstance.messageResourceId = messageResourceIdInstance;
                    }
                    
                    var paramListSequenceElement = js2xml.getElement(responseDoc, messageElement, 'PARAMLIST', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (paramListSequenceElement !== null && paramListSequenceElement !== undefined) {
                      for (var loweredIndex3 = 0; loweredIndex3 < js2xml.getElements(responseDoc, paramListSequenceElement, 'PARAM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex3 = loweredIndex3 + 1) {
                        var paramListElement = js2xml.getElements(responseDoc, paramListSequenceElement, 'PARAM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex3];
                        messageInstance.paramList.push(paramListElement);
                      }
                    }
                  }
                  
                  var formattedMessageElement = js2xml.getElement(responseDoc, guestAgentStatusElement, 'FORMATTEDMESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (formattedMessageElement !== null && formattedMessageElement !== undefined) {
                    var formattedMessageInstance = {};
                    guestAgentStatusInstance.formattedMessage = formattedMessageInstance;
                    
                    var languageElement = js2xml.getElement(responseDoc, formattedMessageElement, 'LANGUAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (languageElement !== null && languageElement !== undefined) {
                      var languageInstance = languageElement;
                      formattedMessageInstance.language = languageInstance;
                    }
                    
                    var messageElement2 = js2xml.getElement(responseDoc, formattedMessageElement, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (messageElement2 !== null && messageElement2 !== undefined) {
                      var messageInstance2 = messageElement2;
                      formattedMessageInstance.message = messageInstance2;
                    }
                  }
                }
                
                var resourceExtensionStatusListSequenceElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'RESOURCEEXTENSIONSTATUSLIST', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (resourceExtensionStatusListSequenceElement !== null && resourceExtensionStatusListSequenceElement !== undefined) {
                  for (var loweredIndex4 = 0; loweredIndex4 < js2xml.getElements(responseDoc, resourceExtensionStatusListSequenceElement, 'RESOURCEEXTENSIONSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex4 = loweredIndex4 + 1) {
                    var resourceExtensionStatusListElement = js2xml.getElements(responseDoc, resourceExtensionStatusListSequenceElement, 'RESOURCEEXTENSIONSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex4];
                    var resourceExtensionStatusInstance = {};
                    roleInstanceInstance.resourceExtensionStatusList.push(resourceExtensionStatusInstance);
                    
                    var handlerNameElement = js2xml.getElement(responseDoc, resourceExtensionStatusListElement, 'HANDLERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (handlerNameElement !== null && handlerNameElement !== undefined) {
                      var handlerNameInstance = handlerNameElement;
                      resourceExtensionStatusInstance.handlerName = handlerNameInstance;
                    }
                    
                    var versionElement = js2xml.getElement(responseDoc, resourceExtensionStatusListElement, 'VERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (versionElement !== null && versionElement !== undefined) {
                      var versionInstance = versionElement;
                      resourceExtensionStatusInstance.version = versionInstance;
                    }
                    
                    var statusElement3 = js2xml.getElement(responseDoc, resourceExtensionStatusListElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (statusElement3 !== null && statusElement3 !== undefined) {
                      var statusInstance3 = statusElement3;
                      resourceExtensionStatusInstance.status = statusInstance3;
                    }
                    
                    var codeElement2 = js2xml.getElement(responseDoc, resourceExtensionStatusListElement, 'CODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (codeElement2 !== null && codeElement2 !== undefined && codeElement2.length !== 0) {
                      var codeInstance2 = parseInt(codeElement2, 10);
                      resourceExtensionStatusInstance.code = codeInstance2;
                    }
                    
                    var messageElement3 = js2xml.getElement(responseDoc, resourceExtensionStatusListElement, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (messageElement3 !== null && messageElement3 !== undefined) {
                      var messageInstance3 = { paramList: [] };
                      resourceExtensionStatusInstance.message = messageInstance3;
                      
                      var messageResourceIdElement2 = js2xml.getElement(responseDoc, messageElement3, 'MESSAGERESOURCEID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (messageResourceIdElement2 !== null && messageResourceIdElement2 !== undefined) {
                        var messageResourceIdInstance2 = messageResourceIdElement2;
                        messageInstance3.messageResourceId = messageResourceIdInstance2;
                      }
                      
                      var paramListSequenceElement2 = js2xml.getElement(responseDoc, messageElement3, 'PARAMLIST', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (paramListSequenceElement2 !== null && paramListSequenceElement2 !== undefined) {
                        for (var loweredIndex5 = 0; loweredIndex5 < js2xml.getElements(responseDoc, paramListSequenceElement2, 'PARAM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex5 = loweredIndex5 + 1) {
                          var paramListElement2 = js2xml.getElements(responseDoc, paramListSequenceElement2, 'PARAM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex5];
                          messageInstance3.paramList.push(paramListElement2);
                        }
                      }
                    }
                    
                    var formattedMessageElement2 = js2xml.getElement(responseDoc, resourceExtensionStatusListElement, 'FORMATTEDMESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (formattedMessageElement2 !== null && formattedMessageElement2 !== undefined) {
                      var formattedMessageInstance2 = {};
                      resourceExtensionStatusInstance.formattedMessage = formattedMessageInstance2;
                      
                      var languageElement2 = js2xml.getElement(responseDoc, formattedMessageElement2, 'LANGUAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (languageElement2 !== null && languageElement2 !== undefined) {
                        var languageInstance2 = languageElement2;
                        formattedMessageInstance2.language = languageInstance2;
                      }
                      
                      var messageElement4 = js2xml.getElement(responseDoc, formattedMessageElement2, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (messageElement4 !== null && messageElement4 !== undefined) {
                        var messageInstance4 = messageElement4;
                        formattedMessageInstance2.message = messageInstance4;
                      }
                    }
                    
                    var extensionSettingStatusElement = js2xml.getElement(responseDoc, resourceExtensionStatusListElement, 'EXTENSIONSETTINGSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (extensionSettingStatusElement !== null && extensionSettingStatusElement !== undefined) {
                      var extensionSettingStatusInstance = { subStatusList: [] };
                      resourceExtensionStatusInstance.extensionSettingStatus = extensionSettingStatusInstance;
                      
                      var timestampElement2 = js2xml.getElement(responseDoc, extensionSettingStatusElement, 'TIMESTAMP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (timestampElement2 !== null && timestampElement2 !== undefined && timestampElement2.length !== 0) {
                        var timestampInstance2 = new Date(timestampElement2);
                        extensionSettingStatusInstance.timestamp = timestampInstance2;
                      }
                      
                      var configurationAppliedTimeElement = js2xml.getElement(responseDoc, extensionSettingStatusElement, 'CONFIGURATIONAPPLIEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (configurationAppliedTimeElement !== null && configurationAppliedTimeElement !== undefined && configurationAppliedTimeElement.length !== 0) {
                        var configurationAppliedTimeInstance = new Date(configurationAppliedTimeElement);
                        extensionSettingStatusInstance.configurationAppliedTime = configurationAppliedTimeInstance;
                      }
                      
                      var nameElement3 = js2xml.getElement(responseDoc, extensionSettingStatusElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (nameElement3 !== null && nameElement3 !== undefined) {
                        var nameInstance3 = nameElement3;
                        extensionSettingStatusInstance.name = nameInstance3;
                      }
                      
                      var operationElement = js2xml.getElement(responseDoc, extensionSettingStatusElement, 'OPERATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (operationElement !== null && operationElement !== undefined) {
                        var operationInstance = operationElement;
                        extensionSettingStatusInstance.operation = operationInstance;
                      }
                      
                      var statusElement4 = js2xml.getElement(responseDoc, extensionSettingStatusElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (statusElement4 !== null && statusElement4 !== undefined) {
                        var statusInstance4 = statusElement4;
                        extensionSettingStatusInstance.status = statusInstance4;
                      }
                      
                      var codeElement3 = js2xml.getElement(responseDoc, extensionSettingStatusElement, 'CODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (codeElement3 !== null && codeElement3 !== undefined && codeElement3.length !== 0) {
                        var codeInstance3 = parseInt(codeElement3, 10);
                        extensionSettingStatusInstance.code = codeInstance3;
                      }
                      
                      var messageElement5 = js2xml.getElement(responseDoc, extensionSettingStatusElement, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (messageElement5 !== null && messageElement5 !== undefined) {
                        var messageInstance5 = { paramList: [] };
                        extensionSettingStatusInstance.message = messageInstance5;
                        
                        var messageResourceIdElement3 = js2xml.getElement(responseDoc, messageElement5, 'MESSAGERESOURCEID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (messageResourceIdElement3 !== null && messageResourceIdElement3 !== undefined) {
                          var messageResourceIdInstance3 = messageResourceIdElement3;
                          messageInstance5.messageResourceId = messageResourceIdInstance3;
                        }
                        
                        var paramListSequenceElement3 = js2xml.getElement(responseDoc, messageElement5, 'PARAMLIST', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (paramListSequenceElement3 !== null && paramListSequenceElement3 !== undefined) {
                          for (var loweredIndex6 = 0; loweredIndex6 < js2xml.getElements(responseDoc, paramListSequenceElement3, 'PARAM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex6 = loweredIndex6 + 1) {
                            var paramListElement3 = js2xml.getElements(responseDoc, paramListSequenceElement3, 'PARAM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex6];
                            messageInstance5.paramList.push(paramListElement3);
                          }
                        }
                      }
                      
                      var formattedMessageElement3 = js2xml.getElement(responseDoc, extensionSettingStatusElement, 'FORMATTEDMESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (formattedMessageElement3 !== null && formattedMessageElement3 !== undefined) {
                        var formattedMessageInstance3 = {};
                        extensionSettingStatusInstance.formattedMessage = formattedMessageInstance3;
                        
                        var languageElement3 = js2xml.getElement(responseDoc, formattedMessageElement3, 'LANGUAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (languageElement3 !== null && languageElement3 !== undefined) {
                          var languageInstance3 = languageElement3;
                          formattedMessageInstance3.language = languageInstance3;
                        }
                        
                        var messageElement6 = js2xml.getElement(responseDoc, formattedMessageElement3, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (messageElement6 !== null && messageElement6 !== undefined) {
                          var messageInstance6 = messageElement6;
                          formattedMessageInstance3.message = messageInstance6;
                        }
                      }
                      
                      var subStatusListSequenceElement = js2xml.getElement(responseDoc, extensionSettingStatusElement, 'SUBSTATUSLIST', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (subStatusListSequenceElement !== null && subStatusListSequenceElement !== undefined) {
                        for (var loweredIndex7 = 0; loweredIndex7 < js2xml.getElements(responseDoc, subStatusListSequenceElement, 'SUBSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex7 = loweredIndex7 + 1) {
                          var subStatusListElement = js2xml.getElements(responseDoc, subStatusListSequenceElement, 'SUBSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex7];
                          var subStatusInstance = {};
                          extensionSettingStatusInstance.subStatusList.push(subStatusInstance);
                          
                          var nameElement4 = js2xml.getElement(responseDoc, subStatusListElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (nameElement4 !== null && nameElement4 !== undefined) {
                            var nameInstance4 = nameElement4;
                            subStatusInstance.name = nameInstance4;
                          }
                          
                          var statusElement5 = js2xml.getElement(responseDoc, subStatusListElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (statusElement5 !== null && statusElement5 !== undefined) {
                            var statusInstance5 = statusElement5;
                            subStatusInstance.status = statusInstance5;
                          }
                          
                          var codeElement4 = js2xml.getElement(responseDoc, subStatusListElement, 'CODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (codeElement4 !== null && codeElement4 !== undefined && codeElement4.length !== 0) {
                            var codeInstance4 = parseInt(codeElement4, 10);
                            subStatusInstance.code = codeInstance4;
                          }
                          
                          var messageElement7 = js2xml.getElement(responseDoc, subStatusListElement, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (messageElement7 !== null && messageElement7 !== undefined) {
                            var messageInstance7 = { paramList: [] };
                            subStatusInstance.message = messageInstance7;
                            
                            var messageResourceIdElement4 = js2xml.getElement(responseDoc, messageElement7, 'MESSAGERESOURCEID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (messageResourceIdElement4 !== null && messageResourceIdElement4 !== undefined) {
                              var messageResourceIdInstance4 = messageResourceIdElement4;
                              messageInstance7.messageResourceId = messageResourceIdInstance4;
                            }
                            
                            var paramListSequenceElement4 = js2xml.getElement(responseDoc, messageElement7, 'PARAMLIST', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (paramListSequenceElement4 !== null && paramListSequenceElement4 !== undefined) {
                              for (var loweredIndex8 = 0; loweredIndex8 < js2xml.getElements(responseDoc, paramListSequenceElement4, 'PARAM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex8 = loweredIndex8 + 1) {
                                var paramListElement4 = js2xml.getElements(responseDoc, paramListSequenceElement4, 'PARAM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex8];
                                messageInstance7.paramList.push(paramListElement4);
                              }
                            }
                          }
                          
                          var formattedMessageElement4 = js2xml.getElement(responseDoc, subStatusListElement, 'FORMATTEDMESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (formattedMessageElement4 !== null && formattedMessageElement4 !== undefined) {
                            var formattedMessageInstance4 = {};
                            subStatusInstance.formattedMessage = formattedMessageInstance4;
                            
                            var languageElement4 = js2xml.getElement(responseDoc, formattedMessageElement4, 'LANGUAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (languageElement4 !== null && languageElement4 !== undefined) {
                              var languageInstance4 = languageElement4;
                              formattedMessageInstance4.language = languageInstance4;
                            }
                            
                            var messageElement8 = js2xml.getElement(responseDoc, formattedMessageElement4, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (messageElement8 !== null && messageElement8 !== undefined) {
                              var messageInstance8 = messageElement8;
                              formattedMessageInstance4.message = messageInstance8;
                            }
                          }
                        }
                      }
                    }
                  }
                }
                
                var powerStateElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'POWERSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (powerStateElement !== null && powerStateElement !== undefined && powerStateElement.length !== 0) {
                  var powerStateInstance = powerStateElement;
                  roleInstanceInstance.powerState = powerStateInstance;
                }
                
                var hostNameElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'HOSTNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (hostNameElement !== null && hostNameElement !== undefined) {
                  var hostNameInstance = hostNameElement;
                  roleInstanceInstance.hostName = hostNameInstance;
                }
                
                var remoteAccessCertificateThumbprintElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'REMOTEACCESSCERTIFICATETHUMBPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (remoteAccessCertificateThumbprintElement !== null && remoteAccessCertificateThumbprintElement !== undefined) {
                  var remoteAccessCertificateThumbprintInstance = remoteAccessCertificateThumbprintElement;
                  roleInstanceInstance.remoteAccessCertificateThumbprint = remoteAccessCertificateThumbprintInstance;
                }
                
                var publicIPsSequenceElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'PUBLICIPS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (publicIPsSequenceElement !== null && publicIPsSequenceElement !== undefined) {
                  for (var loweredIndex9 = 0; loweredIndex9 < js2xml.getElements(responseDoc, publicIPsSequenceElement, 'PUBLICIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex9 = loweredIndex9 + 1) {
                    var publicIPsElement = js2xml.getElements(responseDoc, publicIPsSequenceElement, 'PUBLICIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex9];
                    var publicIPInstance = { fqdns: [] };
                    roleInstanceInstance.publicIPs.push(publicIPInstance);
                    
                    var nameElement5 = js2xml.getElement(responseDoc, publicIPsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (nameElement5 !== null && nameElement5 !== undefined) {
                      var nameInstance5 = nameElement5;
                      publicIPInstance.name = nameInstance5;
                    }
                    
                    var addressElement = js2xml.getElement(responseDoc, publicIPsElement, 'ADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (addressElement !== null && addressElement !== undefined) {
                      var addressInstance = addressElement;
                      publicIPInstance.address = addressInstance;
                    }
                    
                    var idleTimeoutInMinutesElement2 = js2xml.getElement(responseDoc, publicIPsElement, 'IDLETIMEOUTINMINUTES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (idleTimeoutInMinutesElement2 !== null && idleTimeoutInMinutesElement2 !== undefined && idleTimeoutInMinutesElement2.length !== 0) {
                      var idleTimeoutInMinutesInstance2 = parseInt(idleTimeoutInMinutesElement2, 10);
                      publicIPInstance.idleTimeoutInMinutes = idleTimeoutInMinutesInstance2;
                    }
                    
                    var domainNameLabelElement = js2xml.getElement(responseDoc, publicIPsElement, 'DOMAINNAMELABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (domainNameLabelElement !== null && domainNameLabelElement !== undefined) {
                      var domainNameLabelInstance = domainNameLabelElement;
                      publicIPInstance.domainNameLabel = domainNameLabelInstance;
                    }
                    
                    var fqdnsSequenceElement = js2xml.getElement(responseDoc, publicIPsElement, 'FQDNS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (fqdnsSequenceElement !== null && fqdnsSequenceElement !== undefined) {
                      for (var loweredIndex10 = 0; loweredIndex10 < js2xml.getElements(responseDoc, fqdnsSequenceElement, 'FQDN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex10 = loweredIndex10 + 1) {
                        var fqdnsElement = js2xml.getElements(responseDoc, fqdnsSequenceElement, 'FQDN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex10];
                        publicIPInstance.fqdns.push(fqdnsElement);
                      }
                    }
                  }
                }
                
                var networkInterfacesSequenceElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'NETWORKINTERFACES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (networkInterfacesSequenceElement !== null && networkInterfacesSequenceElement !== undefined) {
                  for (var loweredIndex11 = 0; loweredIndex11 < js2xml.getElements(responseDoc, networkInterfacesSequenceElement, 'NETWORKINTERFACE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex11 = loweredIndex11 + 1) {
                    var networkInterfacesElement = js2xml.getElements(responseDoc, networkInterfacesSequenceElement, 'NETWORKINTERFACE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex11];
                    var networkInterfaceInstance = { iPConfigurations: [] };
                    roleInstanceInstance.networkInterfaces.push(networkInterfaceInstance);
                    
                    var nameElement6 = js2xml.getElement(responseDoc, networkInterfacesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (nameElement6 !== null && nameElement6 !== undefined) {
                      var nameInstance6 = nameElement6;
                      networkInterfaceInstance.name = nameInstance6;
                    }
                    
                    var macAddressElement = js2xml.getElement(responseDoc, networkInterfacesElement, 'MACADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (macAddressElement !== null && macAddressElement !== undefined) {
                      var macAddressInstance = macAddressElement;
                      networkInterfaceInstance.macAddress = macAddressInstance;
                    }
                    
                    var iPConfigurationsSequenceElement = js2xml.getElement(responseDoc, networkInterfacesElement, 'IPCONFIGURATIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (iPConfigurationsSequenceElement !== null && iPConfigurationsSequenceElement !== undefined) {
                      for (var loweredIndex12 = 0; loweredIndex12 < js2xml.getElements(responseDoc, iPConfigurationsSequenceElement, 'IPCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex12 = loweredIndex12 + 1) {
                        var iPConfigurationsElement = js2xml.getElements(responseDoc, iPConfigurationsSequenceElement, 'IPCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex12];
                        var iPConfigurationInstance = {};
                        networkInterfaceInstance.iPConfigurations.push(iPConfigurationInstance);
                        
                        var subnetNameElement = js2xml.getElement(responseDoc, iPConfigurationsElement, 'SUBNETNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (subnetNameElement !== null && subnetNameElement !== undefined) {
                          var subnetNameInstance = subnetNameElement;
                          iPConfigurationInstance.subnetName = subnetNameInstance;
                        }
                        
                        var addressElement2 = js2xml.getElement(responseDoc, iPConfigurationsElement, 'ADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (addressElement2 !== null && addressElement2 !== undefined) {
                          var addressInstance2 = addressElement2;
                          iPConfigurationInstance.address = addressInstance2;
                        }
                      }
                    }
                  }
                }
              }
            }
            
            var upgradeStatusElement = js2xml.getElement(responseDoc, deploymentElement, 'UPGRADESTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (upgradeStatusElement !== null && upgradeStatusElement !== undefined) {
              var upgradeStatusInstance = {};
              result.upgradeStatus = upgradeStatusInstance;
              
              var upgradeTypeElement = js2xml.getElement(responseDoc, upgradeStatusElement, 'UPGRADETYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (upgradeTypeElement !== null && upgradeTypeElement !== undefined && upgradeTypeElement.length !== 0) {
                var upgradeTypeInstance = upgradeTypeElement;
                upgradeStatusInstance.upgradeType = upgradeTypeInstance;
              }
              
              var currentUpgradeDomainStateElement = js2xml.getElement(responseDoc, upgradeStatusElement, 'CURRENTUPGRADEDOMAINSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (currentUpgradeDomainStateElement !== null && currentUpgradeDomainStateElement !== undefined && currentUpgradeDomainStateElement.length !== 0) {
                var currentUpgradeDomainStateInstance = currentUpgradeDomainStateElement;
                upgradeStatusInstance.currentUpgradeDomainState = currentUpgradeDomainStateInstance;
              }
              
              var currentUpgradeDomainElement = js2xml.getElement(responseDoc, upgradeStatusElement, 'CURRENTUPGRADEDOMAIN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (currentUpgradeDomainElement !== null && currentUpgradeDomainElement !== undefined && currentUpgradeDomainElement.length !== 0) {
                var currentUpgradeDomainInstance = parseInt(currentUpgradeDomainElement, 10);
                upgradeStatusInstance.currentUpgradeDomain = currentUpgradeDomainInstance;
              }
            }
            
            var upgradeDomainCountElement = js2xml.getElement(responseDoc, deploymentElement, 'UPGRADEDOMAINCOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (upgradeDomainCountElement !== null && upgradeDomainCountElement !== undefined && upgradeDomainCountElement.length !== 0) {
              var upgradeDomainCountInstance = parseInt(upgradeDomainCountElement, 10);
              result.upgradeDomainCount = upgradeDomainCountInstance;
            }
            
            var roleListSequenceElement = js2xml.getElement(responseDoc, deploymentElement, 'ROLELIST', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (roleListSequenceElement !== null && roleListSequenceElement !== undefined) {
              for (var loweredIndex13 = 0; loweredIndex13 < js2xml.getElements(responseDoc, roleListSequenceElement, 'ROLE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex13 = loweredIndex13 + 1) {
                var roleListElement = js2xml.getElements(responseDoc, roleListSequenceElement, 'ROLE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex13];
                var roleInstance = { configurationSets: [], dataVirtualHardDisks: [], resourceExtensionReferences: [] };
                result.roles.push(roleInstance);
                
                var roleNameElement2 = js2xml.getElement(responseDoc, roleListElement, 'ROLENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (roleNameElement2 !== null && roleNameElement2 !== undefined) {
                  var roleNameInstance2 = roleNameElement2;
                  roleInstance.roleName = roleNameInstance2;
                }
                
                var osVersionElement = js2xml.getElement(responseDoc, roleListElement, 'OSVERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (osVersionElement !== null && osVersionElement !== undefined) {
                  var osVersionInstance = osVersionElement;
                  roleInstance.oSVersion = osVersionInstance;
                }
                
                var roleTypeElement = js2xml.getElement(responseDoc, roleListElement, 'ROLETYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (roleTypeElement !== null && roleTypeElement !== undefined) {
                  var roleTypeInstance = roleTypeElement;
                  roleInstance.roleType = roleTypeInstance;
                }
                
                var configurationSetsSequenceElement = js2xml.getElement(responseDoc, roleListElement, 'CONFIGURATIONSETS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (configurationSetsSequenceElement !== null && configurationSetsSequenceElement !== undefined) {
                  for (var loweredIndex14 = 0; loweredIndex14 < js2xml.getElements(responseDoc, configurationSetsSequenceElement, 'CONFIGURATIONSET', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex14 = loweredIndex14 + 1) {
                    var configurationSetsElement = js2xml.getElements(responseDoc, configurationSetsSequenceElement, 'CONFIGURATIONSET', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex14];
                    var configurationSetInstance = { inputEndpoints: [], networkInterfaces: [], publicIPs: [], storedCertificateSettings: [], subnetNames: [] };
                    roleInstance.configurationSets.push(configurationSetInstance);
                    
                    var configurationSetTypeElement = js2xml.getElement(responseDoc, configurationSetsElement, 'CONFIGURATIONSETTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (configurationSetTypeElement !== null && configurationSetTypeElement !== undefined) {
                      var configurationSetTypeInstance = configurationSetTypeElement;
                      configurationSetInstance.configurationSetType = configurationSetTypeInstance;
                    }
                    
                    var inputEndpointsSequenceElement = js2xml.getElement(responseDoc, configurationSetsElement, 'INPUTENDPOINTS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (inputEndpointsSequenceElement !== null && inputEndpointsSequenceElement !== undefined) {
                      for (var loweredIndex15 = 0; loweredIndex15 < js2xml.getElements(responseDoc, inputEndpointsSequenceElement, 'INPUTENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex15 = loweredIndex15 + 1) {
                        var inputEndpointsElement = js2xml.getElements(responseDoc, inputEndpointsSequenceElement, 'INPUTENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex15];
                        var inputEndpointInstance = {};
                        configurationSetInstance.inputEndpoints.push(inputEndpointInstance);
                        
                        var loadBalancedEndpointSetNameElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'LOADBALANCEDENDPOINTSETNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (loadBalancedEndpointSetNameElement !== null && loadBalancedEndpointSetNameElement !== undefined) {
                          var loadBalancedEndpointSetNameInstance = loadBalancedEndpointSetNameElement;
                          inputEndpointInstance.loadBalancedEndpointSetName = loadBalancedEndpointSetNameInstance;
                        }
                        
                        var localPortElement2 = js2xml.getElement(responseDoc, inputEndpointsElement, 'LOCALPORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (localPortElement2 !== null && localPortElement2 !== undefined && localPortElement2.length !== 0) {
                          var localPortInstance2 = parseInt(localPortElement2, 10);
                          inputEndpointInstance.localPort = localPortInstance2;
                        }
                        
                        var nameElement7 = js2xml.getElement(responseDoc, inputEndpointsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (nameElement7 !== null && nameElement7 !== undefined) {
                          var nameInstance7 = nameElement7;
                          inputEndpointInstance.name = nameInstance7;
                        }
                        
                        var portElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'PORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (portElement !== null && portElement !== undefined && portElement.length !== 0) {
                          var portInstance = parseInt(portElement, 10);
                          inputEndpointInstance.port = portInstance;
                        }
                        
                        var loadBalancerProbeElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'LOADBALANCERPROBE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (loadBalancerProbeElement !== null && loadBalancerProbeElement !== undefined) {
                          var loadBalancerProbeInstance = {};
                          inputEndpointInstance.loadBalancerProbe = loadBalancerProbeInstance;
                          
                          var pathElement = js2xml.getElement(responseDoc, loadBalancerProbeElement, 'PATH', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (pathElement !== null && pathElement !== undefined) {
                            var pathInstance = pathElement;
                            loadBalancerProbeInstance.path = pathInstance;
                          }
                          
                          var portElement2 = js2xml.getElement(responseDoc, loadBalancerProbeElement, 'PORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (portElement2 !== null && portElement2 !== undefined && portElement2.length !== 0) {
                            var portInstance2 = parseInt(portElement2, 10);
                            loadBalancerProbeInstance.port = portInstance2;
                          }
                          
                          var protocolElement2 = js2xml.getElement(responseDoc, loadBalancerProbeElement, 'PROTOCOL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (protocolElement2 !== null && protocolElement2 !== undefined && protocolElement2.length !== 0) {
                            var protocolInstance2 = protocolElement2;
                            loadBalancerProbeInstance.protocol = protocolInstance2;
                          }
                          
                          var intervalInSecondsElement = js2xml.getElement(responseDoc, loadBalancerProbeElement, 'INTERVALINSECONDS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (intervalInSecondsElement !== null && intervalInSecondsElement !== undefined && intervalInSecondsElement.length !== 0) {
                            var intervalInSecondsInstance = parseInt(intervalInSecondsElement, 10);
                            loadBalancerProbeInstance.intervalInSeconds = intervalInSecondsInstance;
                          }
                          
                          var timeoutInSecondsElement = js2xml.getElement(responseDoc, loadBalancerProbeElement, 'TIMEOUTINSECONDS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (timeoutInSecondsElement !== null && timeoutInSecondsElement !== undefined && timeoutInSecondsElement.length !== 0) {
                            var timeoutInSecondsInstance = parseInt(timeoutInSecondsElement, 10);
                            loadBalancerProbeInstance.timeoutInSeconds = timeoutInSecondsInstance;
                          }
                        }
                        
                        var protocolElement3 = js2xml.getElement(responseDoc, inputEndpointsElement, 'PROTOCOL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (protocolElement3 !== null && protocolElement3 !== undefined) {
                          var protocolInstance3 = protocolElement3;
                          inputEndpointInstance.protocol = protocolInstance3;
                        }
                        
                        var vipElement2 = js2xml.getElement(responseDoc, inputEndpointsElement, 'VIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (vipElement2 !== null && vipElement2 !== undefined) {
                          var vipInstance2 = vipElement2;
                          inputEndpointInstance.virtualIPAddress = vipInstance2;
                        }
                        
                        var enableDirectServerReturnElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'ENABLEDIRECTSERVERRETURN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (enableDirectServerReturnElement !== null && enableDirectServerReturnElement !== undefined && enableDirectServerReturnElement.length !== 0) {
                          var enableDirectServerReturnInstance = enableDirectServerReturnElement === 'true';
                          inputEndpointInstance.enableDirectServerReturn = enableDirectServerReturnInstance;
                        }
                        
                        var loadBalancerNameElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'LOADBALANCERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (loadBalancerNameElement !== null && loadBalancerNameElement !== undefined) {
                          var loadBalancerNameInstance = loadBalancerNameElement;
                          inputEndpointInstance.loadBalancerName = loadBalancerNameInstance;
                        }
                        
                        var endpointAclElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'ENDPOINTACL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (endpointAclElement !== null && endpointAclElement !== undefined) {
                          var endpointAclInstance = { rules: [] };
                          inputEndpointInstance.endpointAcl = endpointAclInstance;
                          
                          var rulesSequenceElement = js2xml.getElement(responseDoc, endpointAclElement, 'RULES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (rulesSequenceElement !== null && rulesSequenceElement !== undefined) {
                            for (var loweredIndex16 = 0; loweredIndex16 < js2xml.getElements(responseDoc, rulesSequenceElement, 'RULE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex16 = loweredIndex16 + 1) {
                              var rulesElement = js2xml.getElements(responseDoc, rulesSequenceElement, 'RULE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex16];
                              var ruleInstance = {};
                              endpointAclInstance.rules.push(ruleInstance);
                              
                              var orderElement = js2xml.getElement(responseDoc, rulesElement, 'ORDER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (orderElement !== null && orderElement !== undefined && orderElement.length !== 0) {
                                var orderInstance = parseInt(orderElement, 10);
                                ruleInstance.order = orderInstance;
                              }
                              
                              var actionElement = js2xml.getElement(responseDoc, rulesElement, 'ACTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (actionElement !== null && actionElement !== undefined) {
                                var actionInstance = actionElement;
                                ruleInstance.action = actionInstance;
                              }
                              
                              var remoteSubnetElement = js2xml.getElement(responseDoc, rulesElement, 'REMOTESUBNET', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (remoteSubnetElement !== null && remoteSubnetElement !== undefined) {
                                var remoteSubnetInstance = remoteSubnetElement;
                                ruleInstance.remoteSubnet = remoteSubnetInstance;
                              }
                              
                              var descriptionElement = js2xml.getElement(responseDoc, rulesElement, 'DESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (descriptionElement !== null && descriptionElement !== undefined) {
                                var descriptionInstance = descriptionElement;
                                ruleInstance.description = descriptionInstance;
                              }
                            }
                          }
                        }
                        
                        var idleTimeoutInMinutesElement3 = js2xml.getElement(responseDoc, inputEndpointsElement, 'IDLETIMEOUTINMINUTES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (idleTimeoutInMinutesElement3 !== null && idleTimeoutInMinutesElement3 !== undefined && idleTimeoutInMinutesElement3.length !== 0) {
                          var idleTimeoutInMinutesInstance3 = parseInt(idleTimeoutInMinutesElement3, 10);
                          inputEndpointInstance.idleTimeoutInMinutes = idleTimeoutInMinutesInstance3;
                        }
                        
                        var loadBalancerDistributionElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'LOADBALANCERDISTRIBUTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (loadBalancerDistributionElement !== null && loadBalancerDistributionElement !== undefined) {
                          var loadBalancerDistributionInstance = loadBalancerDistributionElement;
                          inputEndpointInstance.loadBalancerDistribution = loadBalancerDistributionInstance;
                        }
                        
                        var virtualIPNameElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'VIRTUALIPNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (virtualIPNameElement !== null && virtualIPNameElement !== undefined) {
                          var virtualIPNameInstance = virtualIPNameElement;
                          inputEndpointInstance.virtualIPName = virtualIPNameInstance;
                        }
                      }
                    }
                    
                    var subnetNamesSequenceElement = js2xml.getElement(responseDoc, configurationSetsElement, 'SUBNETNAMES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (subnetNamesSequenceElement !== null && subnetNamesSequenceElement !== undefined) {
                      for (var loweredIndex17 = 0; loweredIndex17 < js2xml.getElements(responseDoc, subnetNamesSequenceElement, 'SUBNETNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex17 = loweredIndex17 + 1) {
                        var subnetNamesElement = js2xml.getElements(responseDoc, subnetNamesSequenceElement, 'SUBNETNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex17];
                        configurationSetInstance.subnetNames.push(subnetNamesElement);
                      }
                    }
                    
                    var staticVirtualNetworkIPAddressElement = js2xml.getElement(responseDoc, configurationSetsElement, 'STATICVIRTUALNETWORKIPADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (staticVirtualNetworkIPAddressElement !== null && staticVirtualNetworkIPAddressElement !== undefined) {
                      var staticVirtualNetworkIPAddressInstance = staticVirtualNetworkIPAddressElement;
                      configurationSetInstance.staticVirtualNetworkIPAddress = staticVirtualNetworkIPAddressInstance;
                    }
                    
                    var publicIPsSequenceElement2 = js2xml.getElement(responseDoc, configurationSetsElement, 'PUBLICIPS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (publicIPsSequenceElement2 !== null && publicIPsSequenceElement2 !== undefined) {
                      for (var loweredIndex18 = 0; loweredIndex18 < js2xml.getElements(responseDoc, publicIPsSequenceElement2, 'PUBLICIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex18 = loweredIndex18 + 1) {
                        var publicIPsElement2 = js2xml.getElements(responseDoc, publicIPsSequenceElement2, 'PUBLICIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex18];
                        var publicIPInstance2 = {};
                        configurationSetInstance.publicIPs.push(publicIPInstance2);
                        
                        var nameElement8 = js2xml.getElement(responseDoc, publicIPsElement2, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (nameElement8 !== null && nameElement8 !== undefined) {
                          var nameInstance8 = nameElement8;
                          publicIPInstance2.name = nameInstance8;
                        }
                        
                        var idleTimeoutInMinutesElement4 = js2xml.getElement(responseDoc, publicIPsElement2, 'IDLETIMEOUTINMINUTES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (idleTimeoutInMinutesElement4 !== null && idleTimeoutInMinutesElement4 !== undefined && idleTimeoutInMinutesElement4.length !== 0) {
                          var idleTimeoutInMinutesInstance4 = parseInt(idleTimeoutInMinutesElement4, 10);
                          publicIPInstance2.idleTimeoutInMinutes = idleTimeoutInMinutesInstance4;
                        }
                        
                        var domainNameLabelElement2 = js2xml.getElement(responseDoc, publicIPsElement2, 'DOMAINNAMELABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (domainNameLabelElement2 !== null && domainNameLabelElement2 !== undefined) {
                          var domainNameLabelInstance2 = domainNameLabelElement2;
                          publicIPInstance2.domainNameLabel = domainNameLabelInstance2;
                        }
                      }
                    }
                    
                    var networkInterfacesSequenceElement2 = js2xml.getElement(responseDoc, configurationSetsElement, 'NETWORKINTERFACES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (networkInterfacesSequenceElement2 !== null && networkInterfacesSequenceElement2 !== undefined) {
                      for (var loweredIndex19 = 0; loweredIndex19 < js2xml.getElements(responseDoc, networkInterfacesSequenceElement2, 'NETWORKINTERFACE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex19 = loweredIndex19 + 1) {
                        var networkInterfacesElement2 = js2xml.getElements(responseDoc, networkInterfacesSequenceElement2, 'NETWORKINTERFACE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex19];
                        var networkInterfaceInstance2 = { iPConfigurations: [] };
                        configurationSetInstance.networkInterfaces.push(networkInterfaceInstance2);
                        
                        var nameElement9 = js2xml.getElement(responseDoc, networkInterfacesElement2, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (nameElement9 !== null && nameElement9 !== undefined) {
                          var nameInstance9 = nameElement9;
                          networkInterfaceInstance2.name = nameInstance9;
                        }
                        
                        var iPConfigurationsSequenceElement2 = js2xml.getElement(responseDoc, networkInterfacesElement2, 'IPCONFIGURATIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (iPConfigurationsSequenceElement2 !== null && iPConfigurationsSequenceElement2 !== undefined) {
                          for (var loweredIndex20 = 0; loweredIndex20 < js2xml.getElements(responseDoc, iPConfigurationsSequenceElement2, 'IPCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex20 = loweredIndex20 + 1) {
                            var iPConfigurationsElement2 = js2xml.getElements(responseDoc, iPConfigurationsSequenceElement2, 'IPCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex20];
                            var iPConfigurationInstance2 = {};
                            networkInterfaceInstance2.iPConfigurations.push(iPConfigurationInstance2);
                            
                            var subnetNameElement2 = js2xml.getElement(responseDoc, iPConfigurationsElement2, 'SUBNETNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (subnetNameElement2 !== null && subnetNameElement2 !== undefined) {
                              var subnetNameInstance2 = subnetNameElement2;
                              iPConfigurationInstance2.subnetName = subnetNameInstance2;
                            }
                            
                            var staticVirtualNetworkIPAddressElement2 = js2xml.getElement(responseDoc, iPConfigurationsElement2, 'STATICVIRTUALNETWORKIPADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (staticVirtualNetworkIPAddressElement2 !== null && staticVirtualNetworkIPAddressElement2 !== undefined) {
                              var staticVirtualNetworkIPAddressInstance2 = staticVirtualNetworkIPAddressElement2;
                              iPConfigurationInstance2.staticVirtualNetworkIPAddress = staticVirtualNetworkIPAddressInstance2;
                            }
                          }
                        }
                        
                        var networkSecurityGroupElement = js2xml.getElement(responseDoc, networkInterfacesElement2, 'NETWORKSECURITYGROUP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (networkSecurityGroupElement !== null && networkSecurityGroupElement !== undefined) {
                          var networkSecurityGroupInstance = networkSecurityGroupElement;
                          networkInterfaceInstance2.networkSecurityGroup = networkSecurityGroupInstance;
                        }
                        
                        var iPForwardingElement = js2xml.getElement(responseDoc, networkInterfacesElement2, 'IPFORWARDING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (iPForwardingElement !== null && iPForwardingElement !== undefined) {
                          var iPForwardingInstance = iPForwardingElement;
                          networkInterfaceInstance2.iPForwarding = iPForwardingInstance;
                        }
                      }
                    }
                    
                    var networkSecurityGroupElement2 = js2xml.getElement(responseDoc, configurationSetsElement, 'NETWORKSECURITYGROUP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (networkSecurityGroupElement2 !== null && networkSecurityGroupElement2 !== undefined) {
                      var networkSecurityGroupInstance2 = networkSecurityGroupElement2;
                      configurationSetInstance.networkSecurityGroup = networkSecurityGroupInstance2;
                    }
                    
                    var iPForwardingElement2 = js2xml.getElement(responseDoc, configurationSetsElement, 'IPFORWARDING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (iPForwardingElement2 !== null && iPForwardingElement2 !== undefined) {
                      var iPForwardingInstance2 = iPForwardingElement2;
                      configurationSetInstance.iPForwarding = iPForwardingInstance2;
                    }
                    
                    var computerNameElement = js2xml.getElement(responseDoc, configurationSetsElement, 'COMPUTERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (computerNameElement !== null && computerNameElement !== undefined) {
                      var computerNameInstance = computerNameElement;
                      configurationSetInstance.computerName = computerNameInstance;
                    }
                    
                    var adminPasswordElement = js2xml.getElement(responseDoc, configurationSetsElement, 'ADMINPASSWORD', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (adminPasswordElement !== null && adminPasswordElement !== undefined) {
                      var adminPasswordInstance = adminPasswordElement;
                      configurationSetInstance.adminPassword = adminPasswordInstance;
                    }
                    
                    var resetPasswordOnFirstLogonElement = js2xml.getElement(responseDoc, configurationSetsElement, 'RESETPASSWORDONFIRSTLOGON', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (resetPasswordOnFirstLogonElement !== null && resetPasswordOnFirstLogonElement !== undefined && resetPasswordOnFirstLogonElement.length !== 0) {
                      var resetPasswordOnFirstLogonInstance = resetPasswordOnFirstLogonElement === 'true';
                      configurationSetInstance.resetPasswordOnFirstLogon = resetPasswordOnFirstLogonInstance;
                    }
                    
                    var enableAutomaticUpdatesElement = js2xml.getElement(responseDoc, configurationSetsElement, 'ENABLEAUTOMATICUPDATES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (enableAutomaticUpdatesElement !== null && enableAutomaticUpdatesElement !== undefined && enableAutomaticUpdatesElement.length !== 0) {
                      var enableAutomaticUpdatesInstance = enableAutomaticUpdatesElement === 'true';
                      configurationSetInstance.enableAutomaticUpdates = enableAutomaticUpdatesInstance;
                    }
                    
                    var timeZoneElement = js2xml.getElement(responseDoc, configurationSetsElement, 'TIMEZONE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (timeZoneElement !== null && timeZoneElement !== undefined) {
                      var timeZoneInstance = timeZoneElement;
                      configurationSetInstance.timeZone = timeZoneInstance;
                    }
                    
                    var domainJoinElement = js2xml.getElement(responseDoc, configurationSetsElement, 'DOMAINJOIN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (domainJoinElement !== null && domainJoinElement !== undefined) {
                      var domainJoinInstance = {};
                      configurationSetInstance.domainJoin = domainJoinInstance;
                      
                      var credentialsElement = js2xml.getElement(responseDoc, domainJoinElement, 'CREDENTIALS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (credentialsElement !== null && credentialsElement !== undefined) {
                        var credentialsInstance = {};
                        domainJoinInstance.credentials = credentialsInstance;
                        
                        var domainElement = js2xml.getElement(responseDoc, credentialsElement, 'DOMAIN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (domainElement !== null && domainElement !== undefined) {
                          var domainInstance = domainElement;
                          credentialsInstance.domain = domainInstance;
                        }
                        
                        var usernameElement = js2xml.getElement(responseDoc, credentialsElement, 'USERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (usernameElement !== null && usernameElement !== undefined) {
                          var usernameInstance = usernameElement;
                          credentialsInstance.userName = usernameInstance;
                        }
                        
                        var passwordElement = js2xml.getElement(responseDoc, credentialsElement, 'PASSWORD', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (passwordElement !== null && passwordElement !== undefined) {
                          var passwordInstance = passwordElement;
                          credentialsInstance.password = passwordInstance;
                        }
                      }
                      
                      var joinDomainElement = js2xml.getElement(responseDoc, domainJoinElement, 'JOINDOMAIN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (joinDomainElement !== null && joinDomainElement !== undefined) {
                        var joinDomainInstance = joinDomainElement;
                        domainJoinInstance.domainToJoin = joinDomainInstance;
                      }
                      
                      var machineObjectOUElement = js2xml.getElement(responseDoc, domainJoinElement, 'MACHINEOBJECTOU', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (machineObjectOUElement !== null && machineObjectOUElement !== undefined) {
                        var machineObjectOUInstance = machineObjectOUElement;
                        domainJoinInstance.ldapMachineObjectOU = machineObjectOUInstance;
                      }
                      
                      var provisioningElement = js2xml.getElement(responseDoc, domainJoinElement, 'PROVISIONING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (provisioningElement !== null && provisioningElement !== undefined) {
                        var provisioningInstance = {};
                        domainJoinInstance.provisioning = provisioningInstance;
                        
                        var accountDataElement = js2xml.getElement(responseDoc, provisioningElement, 'ACCOUNTDATA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (accountDataElement !== null && accountDataElement !== undefined) {
                          var accountDataInstance = accountDataElement;
                          provisioningInstance.accountData = accountDataInstance;
                        }
                      }
                    }
                    
                    var storedCertificateSettingsSequenceElement = js2xml.getElement(responseDoc, configurationSetsElement, 'STOREDCERTIFICATESETTINGS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (storedCertificateSettingsSequenceElement !== null && storedCertificateSettingsSequenceElement !== undefined) {
                      for (var loweredIndex21 = 0; loweredIndex21 < js2xml.getElements(responseDoc, storedCertificateSettingsSequenceElement, 'CERTIFICATESETTING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex21 = loweredIndex21 + 1) {
                        var storedCertificateSettingsElement = js2xml.getElements(responseDoc, storedCertificateSettingsSequenceElement, 'CERTIFICATESETTING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex21];
                        var certificateSettingInstance = {};
                        configurationSetInstance.storedCertificateSettings.push(certificateSettingInstance);
                        
                        var storeLocationElement = js2xml.getElement(responseDoc, storedCertificateSettingsElement, 'STORELOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (storeLocationElement !== null && storeLocationElement !== undefined) {
                        }
                        
                        var storeNameElement = js2xml.getElement(responseDoc, storedCertificateSettingsElement, 'STORENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (storeNameElement !== null && storeNameElement !== undefined) {
                          var storeNameInstance = storeNameElement;
                          certificateSettingInstance.storeName = storeNameInstance;
                        }
                        
                        var thumbprintElement = js2xml.getElement(responseDoc, storedCertificateSettingsElement, 'THUMBPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (thumbprintElement !== null && thumbprintElement !== undefined) {
                          var thumbprintInstance = thumbprintElement;
                          certificateSettingInstance.thumbprint = thumbprintInstance;
                        }
                      }
                    }
                    
                    var winRMElement = js2xml.getElement(responseDoc, configurationSetsElement, 'WINRM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (winRMElement !== null && winRMElement !== undefined) {
                      var winRMInstance = { listeners: [] };
                      configurationSetInstance.windowsRemoteManagement = winRMInstance;
                      
                      var listenersSequenceElement = js2xml.getElement(responseDoc, winRMElement, 'LISTENERS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (listenersSequenceElement !== null && listenersSequenceElement !== undefined) {
                        for (var loweredIndex22 = 0; loweredIndex22 < js2xml.getElements(responseDoc, listenersSequenceElement, 'LISTENER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex22 = loweredIndex22 + 1) {
                          var listenersElement = js2xml.getElements(responseDoc, listenersSequenceElement, 'LISTENER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex22];
                          var listenerInstance = {};
                          winRMInstance.listeners.push(listenerInstance);
                          
                          var protocolElement4 = js2xml.getElement(responseDoc, listenersElement, 'PROTOCOL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (protocolElement4 !== null && protocolElement4 !== undefined && protocolElement4.length !== 0) {
                            var protocolInstance4 = protocolElement4;
                            listenerInstance.listenerType = protocolInstance4;
                          }
                          
                          var certificateThumbprintElement = js2xml.getElement(responseDoc, listenersElement, 'CERTIFICATETHUMBPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (certificateThumbprintElement !== null && certificateThumbprintElement !== undefined) {
                            var certificateThumbprintInstance = certificateThumbprintElement;
                            listenerInstance.certificateThumbprint = certificateThumbprintInstance;
                          }
                        }
                      }
                    }
                    
                    var adminUsernameElement = js2xml.getElement(responseDoc, configurationSetsElement, 'ADMINUSERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (adminUsernameElement !== null && adminUsernameElement !== undefined) {
                      var adminUsernameInstance = adminUsernameElement;
                      configurationSetInstance.adminUserName = adminUsernameInstance;
                    }
                    
                    var additionalUnattendContentElement = js2xml.getElement(responseDoc, configurationSetsElement, 'ADDITIONALUNATTENDCONTENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (additionalUnattendContentElement !== null && additionalUnattendContentElement !== undefined) {
                      var additionalUnattendContentInstance = { unattendPasses: [] };
                      configurationSetInstance.additionalUnattendContent = additionalUnattendContentInstance;
                      
                      var passesSequenceElement = js2xml.getElement(responseDoc, additionalUnattendContentElement, 'PASSES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (passesSequenceElement !== null && passesSequenceElement !== undefined) {
                        for (var loweredIndex23 = 0; loweredIndex23 < js2xml.getElements(responseDoc, passesSequenceElement, 'UNATTENDPASS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex23 = loweredIndex23 + 1) {
                          var passesElement = js2xml.getElements(responseDoc, passesSequenceElement, 'UNATTENDPASS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex23];
                          var unattendPassInstance = { unattendComponents: [] };
                          additionalUnattendContentInstance.unattendPasses.push(unattendPassInstance);
                          
                          var passNameElement = js2xml.getElement(responseDoc, passesElement, 'PASSNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (passNameElement !== null && passNameElement !== undefined) {
                            var passNameInstance = passNameElement;
                            unattendPassInstance.passName = passNameInstance;
                          }
                          
                          var componentsSequenceElement = js2xml.getElement(responseDoc, passesElement, 'COMPONENTS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (componentsSequenceElement !== null && componentsSequenceElement !== undefined) {
                            for (var loweredIndex24 = 0; loweredIndex24 < js2xml.getElements(responseDoc, componentsSequenceElement, 'UNATTENDCOMPONENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex24 = loweredIndex24 + 1) {
                              var componentsElement = js2xml.getElements(responseDoc, componentsSequenceElement, 'UNATTENDCOMPONENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex24];
                              var unattendComponentInstance = { unattendComponentSettings: [] };
                              unattendPassInstance.unattendComponents.push(unattendComponentInstance);
                              
                              var componentNameElement = js2xml.getElement(responseDoc, componentsElement, 'COMPONENTNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (componentNameElement !== null && componentNameElement !== undefined) {
                                var componentNameInstance = componentNameElement;
                                unattendComponentInstance.componentName = componentNameInstance;
                              }
                              
                              var componentSettingsSequenceElement = js2xml.getElement(responseDoc, componentsElement, 'COMPONENTSETTINGS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (componentSettingsSequenceElement !== null && componentSettingsSequenceElement !== undefined) {
                                for (var loweredIndex25 = 0; loweredIndex25 < js2xml.getElements(responseDoc, componentSettingsSequenceElement, 'COMPONENTSETTING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex25 = loweredIndex25 + 1) {
                                  var componentSettingsElement = js2xml.getElements(responseDoc, componentSettingsSequenceElement, 'COMPONENTSETTING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex25];
                                  var componentSettingInstance = {};
                                  unattendComponentInstance.unattendComponentSettings.push(componentSettingInstance);
                                  
                                  var settingNameElement = js2xml.getElement(responseDoc, componentSettingsElement, 'SETTINGNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                                  if (settingNameElement !== null && settingNameElement !== undefined) {
                                    var settingNameInstance = settingNameElement;
                                    componentSettingInstance.settingName = settingNameInstance;
                                  }
                                  
                                  var contentElement = js2xml.getElement(responseDoc, componentSettingsElement, 'CONTENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                                  if (contentElement !== null && contentElement !== undefined) {
                                    var contentInstance = new Buffer(contentElement, 'base64').toString('utf8');
                                    componentSettingInstance.content = contentInstance;
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                    
                    var hostNameElement2 = js2xml.getElement(responseDoc, configurationSetsElement, 'HOSTNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (hostNameElement2 !== null && hostNameElement2 !== undefined) {
                      var hostNameInstance2 = hostNameElement2;
                      configurationSetInstance.hostName = hostNameInstance2;
                    }
                    
                    var userNameElement = js2xml.getElement(responseDoc, configurationSetsElement, 'USERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (userNameElement !== null && userNameElement !== undefined) {
                      var userNameInstance = userNameElement;
                      configurationSetInstance.userName = userNameInstance;
                    }
                    
                    var userPasswordElement = js2xml.getElement(responseDoc, configurationSetsElement, 'USERPASSWORD', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (userPasswordElement !== null && userPasswordElement !== undefined) {
                      var userPasswordInstance = userPasswordElement;
                      configurationSetInstance.userPassword = userPasswordInstance;
                    }
                    
                    var disableSshPasswordAuthenticationElement = js2xml.getElement(responseDoc, configurationSetsElement, 'DISABLESSHPASSWORDAUTHENTICATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (disableSshPasswordAuthenticationElement !== null && disableSshPasswordAuthenticationElement !== undefined && disableSshPasswordAuthenticationElement.length !== 0) {
                      var disableSshPasswordAuthenticationInstance = disableSshPasswordAuthenticationElement === 'true';
                      configurationSetInstance.disableSshPasswordAuthentication = disableSshPasswordAuthenticationInstance;
                    }
                    
                    var sSHElement = js2xml.getElement(responseDoc, configurationSetsElement, 'SSH', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (sSHElement !== null && sSHElement !== undefined) {
                      var sSHInstance = { keyPairs: [], publicKeys: [] };
                      configurationSetInstance.sshSettings = sSHInstance;
                      
                      var publicKeysSequenceElement = js2xml.getElement(responseDoc, sSHElement, 'PUBLICKEYS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (publicKeysSequenceElement !== null && publicKeysSequenceElement !== undefined) {
                        for (var loweredIndex26 = 0; loweredIndex26 < js2xml.getElements(responseDoc, publicKeysSequenceElement, 'PUBLICKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex26 = loweredIndex26 + 1) {
                          var publicKeysElement = js2xml.getElements(responseDoc, publicKeysSequenceElement, 'PUBLICKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex26];
                          var publicKeyInstance = {};
                          sSHInstance.publicKeys.push(publicKeyInstance);
                          
                          var fingerprintElement = js2xml.getElement(responseDoc, publicKeysElement, 'FINGERPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (fingerprintElement !== null && fingerprintElement !== undefined) {
                            var fingerprintInstance = fingerprintElement;
                            publicKeyInstance.fingerprint = fingerprintInstance;
                          }
                          
                          var pathElement2 = js2xml.getElement(responseDoc, publicKeysElement, 'PATH', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (pathElement2 !== null && pathElement2 !== undefined) {
                            var pathInstance2 = pathElement2;
                            publicKeyInstance.path = pathInstance2;
                          }
                        }
                      }
                      
                      var keyPairsSequenceElement = js2xml.getElement(responseDoc, sSHElement, 'KEYPAIRS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (keyPairsSequenceElement !== null && keyPairsSequenceElement !== undefined) {
                        for (var loweredIndex27 = 0; loweredIndex27 < js2xml.getElements(responseDoc, keyPairsSequenceElement, 'KEYPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex27 = loweredIndex27 + 1) {
                          var keyPairsElement = js2xml.getElements(responseDoc, keyPairsSequenceElement, 'KEYPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex27];
                          var keyPairInstance = {};
                          sSHInstance.keyPairs.push(keyPairInstance);
                          
                          var fingerprintElement2 = js2xml.getElement(responseDoc, keyPairsElement, 'FINGERPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (fingerprintElement2 !== null && fingerprintElement2 !== undefined) {
                            var fingerprintInstance2 = fingerprintElement2;
                            keyPairInstance.fingerprint = fingerprintInstance2;
                          }
                          
                          var pathElement3 = js2xml.getElement(responseDoc, keyPairsElement, 'PATH', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (pathElement3 !== null && pathElement3 !== undefined) {
                            var pathInstance3 = pathElement3;
                            keyPairInstance.path = pathInstance3;
                          }
                        }
                      }
                    }
                    
                    var customDataElement = js2xml.getElement(responseDoc, configurationSetsElement, 'CUSTOMDATA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (customDataElement !== null && customDataElement !== undefined) {
                      var customDataInstance = customDataElement;
                      configurationSetInstance.customData = customDataInstance;
                    }
                  }
                }
                
                var resourceExtensionReferencesSequenceElement = js2xml.getElement(responseDoc, roleListElement, 'RESOURCEEXTENSIONREFERENCES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (resourceExtensionReferencesSequenceElement !== null && resourceExtensionReferencesSequenceElement !== undefined) {
                  for (var loweredIndex28 = 0; loweredIndex28 < js2xml.getElements(responseDoc, resourceExtensionReferencesSequenceElement, 'RESOURCEEXTENSIONREFERENCE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex28 = loweredIndex28 + 1) {
                    var resourceExtensionReferencesElement = js2xml.getElements(responseDoc, resourceExtensionReferencesSequenceElement, 'RESOURCEEXTENSIONREFERENCE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex28];
                    var resourceExtensionReferenceInstance = { resourceExtensionParameterValues: [] };
                    roleInstance.resourceExtensionReferences.push(resourceExtensionReferenceInstance);
                    
                    var referenceNameElement = js2xml.getElement(responseDoc, resourceExtensionReferencesElement, 'REFERENCENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (referenceNameElement !== null && referenceNameElement !== undefined) {
                      var referenceNameInstance = referenceNameElement;
                      resourceExtensionReferenceInstance.referenceName = referenceNameInstance;
                    }
                    
                    var publisherElement = js2xml.getElement(responseDoc, resourceExtensionReferencesElement, 'PUBLISHER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (publisherElement !== null && publisherElement !== undefined) {
                      var publisherInstance = publisherElement;
                      resourceExtensionReferenceInstance.publisher = publisherInstance;
                    }
                    
                    var nameElement10 = js2xml.getElement(responseDoc, resourceExtensionReferencesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (nameElement10 !== null && nameElement10 !== undefined) {
                      var nameInstance10 = nameElement10;
                      resourceExtensionReferenceInstance.name = nameInstance10;
                    }
                    
                    var versionElement2 = js2xml.getElement(responseDoc, resourceExtensionReferencesElement, 'VERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (versionElement2 !== null && versionElement2 !== undefined) {
                      var versionInstance2 = versionElement2;
                      resourceExtensionReferenceInstance.version = versionInstance2;
                    }
                    
                    var resourceExtensionParameterValuesSequenceElement = js2xml.getElement(responseDoc, resourceExtensionReferencesElement, 'RESOURCEEXTENSIONPARAMETERVALUES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (resourceExtensionParameterValuesSequenceElement !== null && resourceExtensionParameterValuesSequenceElement !== undefined) {
                      for (var loweredIndex29 = 0; loweredIndex29 < js2xml.getElements(responseDoc, resourceExtensionParameterValuesSequenceElement, 'RESOURCEEXTENSIONPARAMETERVALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex29 = loweredIndex29 + 1) {
                        var resourceExtensionParameterValuesElement = js2xml.getElements(responseDoc, resourceExtensionParameterValuesSequenceElement, 'RESOURCEEXTENSIONPARAMETERVALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex29];
                        var resourceExtensionParameterValueInstance = {};
                        resourceExtensionReferenceInstance.resourceExtensionParameterValues.push(resourceExtensionParameterValueInstance);
                        
                        var keyElement = js2xml.getElement(responseDoc, resourceExtensionParameterValuesElement, 'KEY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (keyElement !== null && keyElement !== undefined) {
                          var keyInstance = keyElement;
                          resourceExtensionParameterValueInstance.key = keyInstance;
                        }
                        
                        var valueElement = js2xml.getElement(responseDoc, resourceExtensionParameterValuesElement, 'VALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (valueElement !== null && valueElement !== undefined) {
                          var valueInstance = new Buffer(valueElement, 'base64').toString('utf8');
                          resourceExtensionParameterValueInstance.value = valueInstance;
                        }
                        
                        var typeElement = js2xml.getElement(responseDoc, resourceExtensionParameterValuesElement, 'TYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (typeElement !== null && typeElement !== undefined) {
                          var typeInstance = typeElement;
                          resourceExtensionParameterValueInstance.type = typeInstance;
                        }
                      }
                    }
                    
                    var stateElement = js2xml.getElement(responseDoc, resourceExtensionReferencesElement, 'STATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (stateElement !== null && stateElement !== undefined) {
                      var stateInstance = stateElement;
                      resourceExtensionReferenceInstance.state = stateInstance;
                    }
                    
                    var forceUpdateElement = js2xml.getElement(responseDoc, resourceExtensionReferencesElement, 'FORCEUPDATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (forceUpdateElement !== null && forceUpdateElement !== undefined && forceUpdateElement.length !== 0) {
                      var forceUpdateInstance = forceUpdateElement === 'true';
                      resourceExtensionReferenceInstance.forceUpdate = forceUpdateInstance;
                    }
                  }
                }
                
                var vMImageNameElement = js2xml.getElement(responseDoc, roleListElement, 'VMIMAGENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (vMImageNameElement !== null && vMImageNameElement !== undefined) {
                  var vMImageNameInstance = vMImageNameElement;
                  roleInstance.vMImageName = vMImageNameInstance;
                }
                
                var mediaLocationElement = js2xml.getElement(responseDoc, roleListElement, 'MEDIALOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (mediaLocationElement !== null && mediaLocationElement !== undefined) {
                  var mediaLocationInstance = mediaLocationElement;
                  roleInstance.mediaLocation = mediaLocationInstance;
                }
                
                var availabilitySetNameElement = js2xml.getElement(responseDoc, roleListElement, 'AVAILABILITYSETNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (availabilitySetNameElement !== null && availabilitySetNameElement !== undefined) {
                  var availabilitySetNameInstance = availabilitySetNameElement;
                  roleInstance.availabilitySetName = availabilitySetNameInstance;
                }
                
                var dataVirtualHardDisksSequenceElement = js2xml.getElement(responseDoc, roleListElement, 'DATAVIRTUALHARDDISKS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (dataVirtualHardDisksSequenceElement !== null && dataVirtualHardDisksSequenceElement !== undefined) {
                  for (var loweredIndex30 = 0; loweredIndex30 < js2xml.getElements(responseDoc, dataVirtualHardDisksSequenceElement, 'DATAVIRTUALHARDDISK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex30 = loweredIndex30 + 1) {
                    var dataVirtualHardDisksElement = js2xml.getElements(responseDoc, dataVirtualHardDisksSequenceElement, 'DATAVIRTUALHARDDISK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex30];
                    var dataVirtualHardDiskInstance = {};
                    roleInstance.dataVirtualHardDisks.push(dataVirtualHardDiskInstance);
                    
                    var hostCachingElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'HOSTCACHING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (hostCachingElement !== null && hostCachingElement !== undefined) {
                      var hostCachingInstance = hostCachingElement;
                      dataVirtualHardDiskInstance.hostCaching = hostCachingInstance;
                    }
                    
                    var diskLabelElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'DISKLABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (diskLabelElement !== null && diskLabelElement !== undefined) {
                      var diskLabelInstance = diskLabelElement;
                      dataVirtualHardDiskInstance.label = diskLabelInstance;
                    }
                    
                    var diskNameElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'DISKNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (diskNameElement !== null && diskNameElement !== undefined) {
                      var diskNameInstance = diskNameElement;
                      dataVirtualHardDiskInstance.name = diskNameInstance;
                    }
                    
                    var lunElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'LUN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (lunElement !== null && lunElement !== undefined && lunElement.length !== 0) {
                      var lunInstance = parseInt(lunElement, 10);
                      dataVirtualHardDiskInstance.logicalUnitNumber = lunInstance;
                    }
                    
                    var logicalDiskSizeInGBElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'LOGICALDISKSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (logicalDiskSizeInGBElement !== null && logicalDiskSizeInGBElement !== undefined && logicalDiskSizeInGBElement.length !== 0) {
                      var logicalDiskSizeInGBInstance = parseInt(logicalDiskSizeInGBElement, 10);
                      dataVirtualHardDiskInstance.logicalDiskSizeInGB = logicalDiskSizeInGBInstance;
                    }
                    
                    var mediaLinkElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'MEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (mediaLinkElement !== null && mediaLinkElement !== undefined) {
                      var mediaLinkInstance = mediaLinkElement;
                      dataVirtualHardDiskInstance.mediaLink = mediaLinkInstance;
                    }
                    
                    var sourceMediaLinkElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'SOURCEMEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (sourceMediaLinkElement !== null && sourceMediaLinkElement !== undefined) {
                      var sourceMediaLinkInstance = sourceMediaLinkElement;
                      dataVirtualHardDiskInstance.sourceMediaLink = sourceMediaLinkInstance;
                    }
                    
                    var iOTypeElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'IOTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (iOTypeElement !== null && iOTypeElement !== undefined) {
                      var iOTypeInstance = iOTypeElement;
                      dataVirtualHardDiskInstance.iOType = iOTypeInstance;
                    }
                  }
                }
                
                var labelElement2 = js2xml.getElement(responseDoc, roleListElement, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (labelElement2 !== null && labelElement2 !== undefined) {
                  var labelInstance2 = labelElement2;
                  roleInstance.label = labelInstance2;
                }
                
                var oSVirtualHardDiskElement = js2xml.getElement(responseDoc, roleListElement, 'OSVIRTUALHARDDISK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (oSVirtualHardDiskElement !== null && oSVirtualHardDiskElement !== undefined) {
                  var oSVirtualHardDiskInstance = {};
                  roleInstance.oSVirtualHardDisk = oSVirtualHardDiskInstance;
                  
                  var hostCachingElement2 = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'HOSTCACHING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (hostCachingElement2 !== null && hostCachingElement2 !== undefined) {
                    var hostCachingInstance2 = hostCachingElement2;
                    oSVirtualHardDiskInstance.hostCaching = hostCachingInstance2;
                  }
                  
                  var diskLabelElement2 = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'DISKLABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (diskLabelElement2 !== null && diskLabelElement2 !== undefined) {
                    var diskLabelInstance2 = diskLabelElement2;
                    oSVirtualHardDiskInstance.label = diskLabelInstance2;
                  }
                  
                  var diskNameElement2 = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'DISKNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (diskNameElement2 !== null && diskNameElement2 !== undefined) {
                    var diskNameInstance2 = diskNameElement2;
                    oSVirtualHardDiskInstance.name = diskNameInstance2;
                  }
                  
                  var mediaLinkElement2 = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'MEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (mediaLinkElement2 !== null && mediaLinkElement2 !== undefined) {
                    var mediaLinkInstance2 = mediaLinkElement2;
                    oSVirtualHardDiskInstance.mediaLink = mediaLinkInstance2;
                  }
                  
                  var sourceImageNameElement = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'SOURCEIMAGENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (sourceImageNameElement !== null && sourceImageNameElement !== undefined) {
                    var sourceImageNameInstance = sourceImageNameElement;
                    oSVirtualHardDiskInstance.sourceImageName = sourceImageNameInstance;
                  }
                  
                  var osElement = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'OS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (osElement !== null && osElement !== undefined) {
                    var osInstance = osElement;
                    oSVirtualHardDiskInstance.operatingSystem = osInstance;
                  }
                  
                  var remoteSourceImageLinkElement = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'REMOTESOURCEIMAGELINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (remoteSourceImageLinkElement !== null && remoteSourceImageLinkElement !== undefined) {
                    var remoteSourceImageLinkInstance = remoteSourceImageLinkElement;
                    oSVirtualHardDiskInstance.remoteSourceImageLink = remoteSourceImageLinkInstance;
                  }
                  
                  var iOTypeElement2 = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'IOTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (iOTypeElement2 !== null && iOTypeElement2 !== undefined) {
                    var iOTypeInstance2 = iOTypeElement2;
                    oSVirtualHardDiskInstance.iOType = iOTypeInstance2;
                  }
                  
                  var resizedSizeInGBElement = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'RESIZEDSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (resizedSizeInGBElement !== null && resizedSizeInGBElement !== undefined && resizedSizeInGBElement.length !== 0) {
                    var resizedSizeInGBInstance = parseInt(resizedSizeInGBElement, 10);
                    oSVirtualHardDiskInstance.resizedSizeInGB = resizedSizeInGBInstance;
                  }
                }
                
                var roleSizeElement = js2xml.getElement(responseDoc, roleListElement, 'ROLESIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (roleSizeElement !== null && roleSizeElement !== undefined) {
                  var roleSizeInstance = roleSizeElement;
                  roleInstance.roleSize = roleSizeInstance;
                }
                
                var defaultWinRmCertificateThumbprintElement = js2xml.getElement(responseDoc, roleListElement, 'DEFAULTWINRMCERTIFICATETHUMBPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (defaultWinRmCertificateThumbprintElement !== null && defaultWinRmCertificateThumbprintElement !== undefined) {
                  var defaultWinRmCertificateThumbprintInstance = defaultWinRmCertificateThumbprintElement;
                  roleInstance.defaultWinRmCertificateThumbprint = defaultWinRmCertificateThumbprintInstance;
                }
                
                var provisionGuestAgentElement = js2xml.getElement(responseDoc, roleListElement, 'PROVISIONGUESTAGENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (provisionGuestAgentElement !== null && provisionGuestAgentElement !== undefined && provisionGuestAgentElement.length !== 0) {
                  var provisionGuestAgentInstance = provisionGuestAgentElement === 'true';
                  roleInstance.provisionGuestAgent = provisionGuestAgentInstance;
                }
                
                var vMImageInputElement = js2xml.getElement(responseDoc, roleListElement, 'VMIMAGEINPUT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (vMImageInputElement !== null && vMImageInputElement !== undefined) {
                  var vMImageInputInstance = { dataDiskConfigurations: [] };
                  roleInstance.vMImageInput = vMImageInputInstance;
                  
                  var oSDiskConfigurationElement = js2xml.getElement(responseDoc, vMImageInputElement, 'OSDISKCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (oSDiskConfigurationElement !== null && oSDiskConfigurationElement !== undefined) {
                    var oSDiskConfigurationInstance = {};
                    vMImageInputInstance.oSDiskConfiguration = oSDiskConfigurationInstance;
                    
                    var resizedSizeInGBElement2 = js2xml.getElement(responseDoc, oSDiskConfigurationElement, 'RESIZEDSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (resizedSizeInGBElement2 !== null && resizedSizeInGBElement2 !== undefined && resizedSizeInGBElement2.length !== 0) {
                      var resizedSizeInGBInstance2 = parseInt(resizedSizeInGBElement2, 10);
                      oSDiskConfigurationInstance.resizedSizeInGB = resizedSizeInGBInstance2;
                    }
                  }
                  
                  var dataDiskConfigurationsSequenceElement = js2xml.getElement(responseDoc, vMImageInputElement, 'DATADISKCONFIGURATIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (dataDiskConfigurationsSequenceElement !== null && dataDiskConfigurationsSequenceElement !== undefined) {
                    for (var loweredIndex31 = 0; loweredIndex31 < js2xml.getElements(responseDoc, dataDiskConfigurationsSequenceElement, 'DATADISKCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex31 = loweredIndex31 + 1) {
                      var dataDiskConfigurationsElement = js2xml.getElements(responseDoc, dataDiskConfigurationsSequenceElement, 'DATADISKCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex31];
                      var dataDiskConfigurationInstance = {};
                      vMImageInputInstance.dataDiskConfigurations.push(dataDiskConfigurationInstance);
                      
                      var nameElement11 = js2xml.getElement(responseDoc, dataDiskConfigurationsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (nameElement11 !== null && nameElement11 !== undefined) {
                        var nameInstance11 = nameElement11;
                        dataDiskConfigurationInstance.diskName = nameInstance11;
                      }
                      
                      var resizedSizeInGBElement3 = js2xml.getElement(responseDoc, dataDiskConfigurationsElement, 'RESIZEDSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (resizedSizeInGBElement3 !== null && resizedSizeInGBElement3 !== undefined && resizedSizeInGBElement3.length !== 0) {
                        var resizedSizeInGBInstance3 = parseInt(resizedSizeInGBElement3, 10);
                        dataDiskConfigurationInstance.resizedSizeInGB = resizedSizeInGBInstance3;
                      }
                    }
                  }
                }
                
                var debugSettingsElement = js2xml.getElement(responseDoc, roleListElement, 'DEBUGSETTINGS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (debugSettingsElement !== null && debugSettingsElement !== undefined) {
                  var debugSettingsInstance = {};
                  roleInstance.debugSettings = debugSettingsInstance;
                  
                  var bootDiagnosticsEnabledElement = js2xml.getElement(responseDoc, debugSettingsElement, 'BOOTDIAGNOSTICSENABLED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (bootDiagnosticsEnabledElement !== null && bootDiagnosticsEnabledElement !== undefined && bootDiagnosticsEnabledElement.length !== 0) {
                    var bootDiagnosticsEnabledInstance = bootDiagnosticsEnabledElement === 'true';
                    debugSettingsInstance.bootDiagnosticsEnabled = bootDiagnosticsEnabledInstance;
                  }
                  
                  var consoleScreenshotBlobUriElement = js2xml.getElement(responseDoc, debugSettingsElement, 'CONSOLESCREENSHOTBLOBURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (consoleScreenshotBlobUriElement !== null && consoleScreenshotBlobUriElement !== undefined) {
                    var consoleScreenshotBlobUriInstance = consoleScreenshotBlobUriElement;
                    debugSettingsInstance.consoleScreenshotBlobUri = consoleScreenshotBlobUriInstance;
                  }
                  
                  var serialOutputBlobUriElement = js2xml.getElement(responseDoc, debugSettingsElement, 'SERIALOUTPUTBLOBURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (serialOutputBlobUriElement !== null && serialOutputBlobUriElement !== undefined) {
                    var serialOutputBlobUriInstance = serialOutputBlobUriElement;
                    debugSettingsInstance.serialOutputBlobUri = serialOutputBlobUriInstance;
                  }
                }
                
                var licenseTypeElement = js2xml.getElement(responseDoc, roleListElement, 'LICENSETYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (licenseTypeElement !== null && licenseTypeElement !== undefined) {
                  var licenseTypeInstance = licenseTypeElement;
                  roleInstance.licenseType = licenseTypeInstance;
                }
                
                var migrationStateElement = js2xml.getElement(responseDoc, roleListElement, 'MIGRATIONSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (migrationStateElement !== null && migrationStateElement !== undefined) {
                  var migrationStateInstance = migrationStateElement;
                  roleInstance.migrationState = migrationStateInstance;
                }
              }
            }
            
            var sdkVersionElement = js2xml.getElement(responseDoc, deploymentElement, 'SDKVERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (sdkVersionElement !== null && sdkVersionElement !== undefined) {
              var sdkVersionInstance = sdkVersionElement;
              result.sdkVersion = sdkVersionInstance;
            }
            
            var lockedElement = js2xml.getElement(responseDoc, deploymentElement, 'LOCKED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (lockedElement !== null && lockedElement !== undefined && lockedElement.length !== 0) {
              var lockedInstance = lockedElement === 'true';
              result.locked = lockedInstance;
            }
            
            var rollbackAllowedElement = js2xml.getElement(responseDoc, deploymentElement, 'ROLLBACKALLOWED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (rollbackAllowedElement !== null && rollbackAllowedElement !== undefined && rollbackAllowedElement.length !== 0) {
              var rollbackAllowedInstance = rollbackAllowedElement === 'true';
              result.rollbackAllowed = rollbackAllowedInstance;
            }
            
            var virtualNetworkNameElement = js2xml.getElement(responseDoc, deploymentElement, 'VIRTUALNETWORKNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (virtualNetworkNameElement !== null && virtualNetworkNameElement !== undefined) {
              var virtualNetworkNameInstance = virtualNetworkNameElement;
              result.virtualNetworkName = virtualNetworkNameInstance;
            }
            
            var createdTimeElement = js2xml.getElement(responseDoc, deploymentElement, 'CREATEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (createdTimeElement !== null && createdTimeElement !== undefined && createdTimeElement.length !== 0) {
              var createdTimeInstance = new Date(createdTimeElement);
              result.createdTime = createdTimeInstance;
            }
            
            var lastModifiedTimeElement = js2xml.getElement(responseDoc, deploymentElement, 'LASTMODIFIEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (lastModifiedTimeElement !== null && lastModifiedTimeElement !== undefined && lastModifiedTimeElement.length !== 0) {
              var lastModifiedTimeInstance = new Date(lastModifiedTimeElement);
              result.lastModifiedTime = lastModifiedTimeInstance;
            }
            
            var extendedPropertiesSequenceElement = js2xml.getElement(responseDoc, deploymentElement, 'EXTENDEDPROPERTIES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (extendedPropertiesSequenceElement !== null && extendedPropertiesSequenceElement !== undefined) {
              for (var loweredIndex32 = 0; loweredIndex32 < js2xml.getElements(responseDoc, extendedPropertiesSequenceElement, 'EXTENDEDPROPERTY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex32 = loweredIndex32 + 1) {
                var extendedPropertiesElement = js2xml.getElements(responseDoc, extendedPropertiesSequenceElement, 'EXTENDEDPROPERTY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex32];
                var extendedPropertiesKey = js2xml.getElement(responseDoc, extendedPropertiesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                var extendedPropertiesValue = js2xml.getElement(responseDoc, extendedPropertiesElement, 'VALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                result.extendedProperties[extendedPropertiesKey] = extendedPropertiesValue;
              }
            }
            
            var dnsElement = js2xml.getElement(responseDoc, deploymentElement, 'DNS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (dnsElement !== null && dnsElement !== undefined) {
              var dnsInstance = { dnsServers: [] };
              result.dnsSettings = dnsInstance;
              
              var dnsServersSequenceElement = js2xml.getElement(responseDoc, dnsElement, 'DNSSERVERS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (dnsServersSequenceElement !== null && dnsServersSequenceElement !== undefined) {
                for (var loweredIndex33 = 0; loweredIndex33 < js2xml.getElements(responseDoc, dnsServersSequenceElement, 'DNSSERVER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex33 = loweredIndex33 + 1) {
                  var dnsServersElement = js2xml.getElements(responseDoc, dnsServersSequenceElement, 'DNSSERVER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex33];
                  var dnsServerInstance = {};
                  dnsInstance.dnsServers.push(dnsServerInstance);
                  
                  var nameElement12 = js2xml.getElement(responseDoc, dnsServersElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (nameElement12 !== null && nameElement12 !== undefined) {
                    var nameInstance12 = nameElement12;
                    dnsServerInstance.name = nameInstance12;
                  }
                  
                  var addressElement3 = js2xml.getElement(responseDoc, dnsServersElement, 'ADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (addressElement3 !== null && addressElement3 !== undefined) {
                    var addressInstance3 = addressElement3;
                    dnsServerInstance.address = addressInstance3;
                  }
                }
              }
            }
            
            var persistentVMDowntimeElement = js2xml.getElement(responseDoc, deploymentElement, 'PERSISTENTVMDOWNTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (persistentVMDowntimeElement !== null && persistentVMDowntimeElement !== undefined) {
              var persistentVMDowntimeInstance = {};
              result.persistentVMDowntime = persistentVMDowntimeInstance;
              
              var startTimeElement = js2xml.getElement(responseDoc, persistentVMDowntimeElement, 'STARTTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (startTimeElement !== null && startTimeElement !== undefined && startTimeElement.length !== 0) {
                var startTimeInstance = new Date(startTimeElement);
                persistentVMDowntimeInstance.startTime = startTimeInstance;
              }
              
              var endTimeElement = js2xml.getElement(responseDoc, persistentVMDowntimeElement, 'ENDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (endTimeElement !== null && endTimeElement !== undefined && endTimeElement.length !== 0) {
                var endTimeInstance = new Date(endTimeElement);
                persistentVMDowntimeInstance.endTime = endTimeInstance;
              }
              
              var statusElement6 = js2xml.getElement(responseDoc, persistentVMDowntimeElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (statusElement6 !== null && statusElement6 !== undefined) {
                var statusInstance6 = statusElement6;
                persistentVMDowntimeInstance.status = statusInstance6;
              }
            }
            
            var virtualIPsSequenceElement = js2xml.getElement(responseDoc, deploymentElement, 'VIRTUALIPS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (virtualIPsSequenceElement !== null && virtualIPsSequenceElement !== undefined) {
              for (var loweredIndex34 = 0; loweredIndex34 < js2xml.getElements(responseDoc, virtualIPsSequenceElement, 'VIRTUALIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex34 = loweredIndex34 + 1) {
                var virtualIPsElement = js2xml.getElements(responseDoc, virtualIPsSequenceElement, 'VIRTUALIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex34];
                var virtualIPInstance = {};
                result.virtualIPAddresses.push(virtualIPInstance);
                
                var addressElement4 = js2xml.getElement(responseDoc, virtualIPsElement, 'ADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (addressElement4 !== null && addressElement4 !== undefined) {
                  var addressInstance4 = addressElement4;
                  virtualIPInstance.address = addressInstance4;
                }
                
                var isDnsProgrammedElement = js2xml.getElement(responseDoc, virtualIPsElement, 'ISDNSPROGRAMMED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (isDnsProgrammedElement !== null && isDnsProgrammedElement !== undefined && isDnsProgrammedElement.length !== 0) {
                  var isDnsProgrammedInstance = isDnsProgrammedElement === 'true';
                  virtualIPInstance.isDnsProgrammed = isDnsProgrammedInstance;
                }
                
                var nameElement13 = js2xml.getElement(responseDoc, virtualIPsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (nameElement13 !== null && nameElement13 !== undefined) {
                  var nameInstance13 = nameElement13;
                  virtualIPInstance.name = nameInstance13;
                }
                
                var reservedIPNameElement = js2xml.getElement(responseDoc, virtualIPsElement, 'RESERVEDIPNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (reservedIPNameElement !== null && reservedIPNameElement !== undefined) {
                  var reservedIPNameInstance = reservedIPNameElement;
                  virtualIPInstance.reservedIPName = reservedIPNameInstance;
                }
              }
            }
            
            var extensionConfigurationElement = js2xml.getElement(responseDoc, deploymentElement, 'EXTENSIONCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (extensionConfigurationElement !== null && extensionConfigurationElement !== undefined) {
              var extensionConfigurationInstance = { allRoles: [], namedRoles: [] };
              result.extensionConfiguration = extensionConfigurationInstance;
              
              var allRolesSequenceElement = js2xml.getElement(responseDoc, extensionConfigurationElement, 'ALLROLES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (allRolesSequenceElement !== null && allRolesSequenceElement !== undefined) {
                for (var loweredIndex35 = 0; loweredIndex35 < js2xml.getElements(responseDoc, allRolesSequenceElement, 'EXTENSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex35 = loweredIndex35 + 1) {
                  var allRolesElement = js2xml.getElements(responseDoc, allRolesSequenceElement, 'EXTENSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex35];
                  var extensionInstance = {};
                  extensionConfigurationInstance.allRoles.push(extensionInstance);
                  
                  var idElement = js2xml.getElement(responseDoc, allRolesElement, 'ID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (idElement !== null && idElement !== undefined) {
                    var idInstance = idElement;
                    extensionInstance.id = idInstance;
                  }
                  
                  var stateElement2 = js2xml.getElement(responseDoc, allRolesElement, 'STATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (stateElement2 !== null && stateElement2 !== undefined) {
                    var stateInstance2 = stateElement2;
                    extensionInstance.state = stateInstance2;
                  }
                }
              }
              
              var namedRolesSequenceElement = js2xml.getElement(responseDoc, extensionConfigurationElement, 'NAMEDROLES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (namedRolesSequenceElement !== null && namedRolesSequenceElement !== undefined) {
                for (var loweredIndex36 = 0; loweredIndex36 < js2xml.getElements(responseDoc, namedRolesSequenceElement, 'ROLE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex36 = loweredIndex36 + 1) {
                  var namedRolesElement = js2xml.getElements(responseDoc, namedRolesSequenceElement, 'ROLE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex36];
                  var roleInstance2 = { extensions: [] };
                  extensionConfigurationInstance.namedRoles.push(roleInstance2);
                  
                  var roleNameElement3 = js2xml.getElement(responseDoc, namedRolesElement, 'ROLENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (roleNameElement3 !== null && roleNameElement3 !== undefined) {
                    var roleNameInstance3 = roleNameElement3;
                    roleInstance2.roleName = roleNameInstance3;
                  }
                  
                  var extensionsSequenceElement = js2xml.getElement(responseDoc, namedRolesElement, 'EXTENSIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (extensionsSequenceElement !== null && extensionsSequenceElement !== undefined) {
                    for (var loweredIndex37 = 0; loweredIndex37 < js2xml.getElements(responseDoc, extensionsSequenceElement, 'EXTENSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex37 = loweredIndex37 + 1) {
                      var extensionsElement = js2xml.getElements(responseDoc, extensionsSequenceElement, 'EXTENSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex37];
                      var extensionInstance2 = {};
                      roleInstance2.extensions.push(extensionInstance2);
                      
                      var idElement2 = js2xml.getElement(responseDoc, extensionsElement, 'ID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (idElement2 !== null && idElement2 !== undefined) {
                        var idInstance2 = idElement2;
                        extensionInstance2.id = idInstance2;
                      }
                      
                      var stateElement3 = js2xml.getElement(responseDoc, extensionsElement, 'STATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (stateElement3 !== null && stateElement3 !== undefined) {
                        var stateInstance3 = stateElement3;
                        extensionInstance2.state = stateInstance3;
                      }
                    }
                  }
                }
              }
            }
            
            var reservedIPNameElement2 = js2xml.getElement(responseDoc, deploymentElement, 'RESERVEDIPNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (reservedIPNameElement2 !== null && reservedIPNameElement2 !== undefined) {
              var reservedIPNameInstance2 = reservedIPNameElement2;
              result.reservedIPName = reservedIPNameInstance2;
            }
            
            var loadBalancersSequenceElement = js2xml.getElement(responseDoc, deploymentElement, 'LOADBALANCERS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (loadBalancersSequenceElement !== null && loadBalancersSequenceElement !== undefined) {
              for (var loweredIndex38 = 0; loweredIndex38 < js2xml.getElements(responseDoc, loadBalancersSequenceElement, 'LOADBALANCER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex38 = loweredIndex38 + 1) {
                var loadBalancersElement = js2xml.getElements(responseDoc, loadBalancersSequenceElement, 'LOADBALANCER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex38];
                var loadBalancerInstance = {};
                result.loadBalancers.push(loadBalancerInstance);
                
                var nameElement14 = js2xml.getElement(responseDoc, loadBalancersElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (nameElement14 !== null && nameElement14 !== undefined) {
                  var nameInstance14 = nameElement14;
                  loadBalancerInstance.name = nameInstance14;
                }
                
                var frontendIpConfigurationElement = js2xml.getElement(responseDoc, loadBalancersElement, 'FRONTENDIPCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (frontendIpConfigurationElement !== null && frontendIpConfigurationElement !== undefined) {
                  var frontendIpConfigurationInstance = {};
                  loadBalancerInstance.frontendIPConfiguration = frontendIpConfigurationInstance;
                  
                  var typeElement2 = js2xml.getElement(responseDoc, frontendIpConfigurationElement, 'TYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (typeElement2 !== null && typeElement2 !== undefined) {
                    var typeInstance2 = typeElement2;
                    frontendIpConfigurationInstance.type = typeInstance2;
                  }
                  
                  var subnetNameElement3 = js2xml.getElement(responseDoc, frontendIpConfigurationElement, 'SUBNETNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (subnetNameElement3 !== null && subnetNameElement3 !== undefined) {
                    var subnetNameInstance3 = subnetNameElement3;
                    frontendIpConfigurationInstance.subnetName = subnetNameInstance3;
                  }
                  
                  var staticVirtualNetworkIPAddressElement3 = js2xml.getElement(responseDoc, frontendIpConfigurationElement, 'STATICVIRTUALNETWORKIPADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (staticVirtualNetworkIPAddressElement3 !== null && staticVirtualNetworkIPAddressElement3 !== undefined) {
                    var staticVirtualNetworkIPAddressInstance3 = staticVirtualNetworkIPAddressElement3;
                    frontendIpConfigurationInstance.staticVirtualNetworkIPAddress = staticVirtualNetworkIPAddressInstance3;
                  }
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Get Deployment By Slot operation returns configuration information,
   * status, and system properties for a deployment.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460804.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {DeploymentSlot} deploymentSlot The deployment slot.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.getBySlot = function(serviceName, deploymentSlot, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentSlot === null || deploymentSlot === undefined) {
      return callback(new Error('deploymentSlot cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deploymentslots/';
    url2 = url2 + encodeURIComponent(deploymentSlot !== null && deploymentSlot !== undefined ? deploymentSlot.toString() : 'Staging');
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { extendedProperties: {}, loadBalancers: [], roleInstances: [], roles: [], virtualIPAddresses: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var deploymentElement = js2xml.getElement(responseDoc, responseDoc, 'DEPLOYMENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (deploymentElement !== null && deploymentElement !== undefined) {
            var nameElement = js2xml.getElement(responseDoc, deploymentElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (nameElement !== null && nameElement !== undefined) {
              var nameInstance = nameElement;
              result.name = nameInstance;
            }
            
            var deploymentSlotElement = js2xml.getElement(responseDoc, deploymentElement, 'DEPLOYMENTSLOT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (deploymentSlotElement !== null && deploymentSlotElement !== undefined && deploymentSlotElement.length !== 0) {
              var deploymentSlotInstance = deploymentSlotElement;
              result.deploymentSlot = deploymentSlotInstance;
            }
            
            var privateIDElement = js2xml.getElement(responseDoc, deploymentElement, 'PRIVATEID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (privateIDElement !== null && privateIDElement !== undefined) {
              var privateIDInstance = privateIDElement;
              result.privateId = privateIDInstance;
            }
            
            var statusElement = js2xml.getElement(responseDoc, deploymentElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (statusElement !== null && statusElement !== undefined && statusElement.length !== 0) {
              var statusInstance = statusElement;
              result.status = statusInstance;
            }
            
            var labelElement = js2xml.getElement(responseDoc, deploymentElement, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (labelElement !== null && labelElement !== undefined) {
              var labelInstance = new Buffer(labelElement, 'base64').toString('utf8');
              result.label = labelInstance;
            }
            
            var urlElement = js2xml.getElement(responseDoc, deploymentElement, 'URL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (urlElement !== null && urlElement !== undefined) {
              var urlInstance = urlElement;
              result.uri = urlInstance;
            }
            
            var configurationElement = js2xml.getElement(responseDoc, deploymentElement, 'CONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (configurationElement !== null && configurationElement !== undefined) {
              var configurationInstance = new Buffer(configurationElement, 'base64').toString('utf8');
              result.configuration = configurationInstance;
            }
            
            var roleInstanceListSequenceElement = js2xml.getElement(responseDoc, deploymentElement, 'ROLEINSTANCELIST', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (roleInstanceListSequenceElement !== null && roleInstanceListSequenceElement !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, roleInstanceListSequenceElement, 'ROLEINSTANCE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
                var roleInstanceListElement = js2xml.getElements(responseDoc, roleInstanceListSequenceElement, 'ROLEINSTANCE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
                var roleInstanceInstance = { instanceEndpoints: [], networkInterfaces: [], publicIPs: [], resourceExtensionStatusList: [] };
                result.roleInstances.push(roleInstanceInstance);
                
                var roleNameElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'ROLENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (roleNameElement !== null && roleNameElement !== undefined) {
                  var roleNameInstance = roleNameElement;
                  roleInstanceInstance.roleName = roleNameInstance;
                }
                
                var instanceNameElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'INSTANCENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (instanceNameElement !== null && instanceNameElement !== undefined) {
                  var instanceNameInstance = instanceNameElement;
                  roleInstanceInstance.instanceName = instanceNameInstance;
                }
                
                var instanceStatusElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'INSTANCESTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (instanceStatusElement !== null && instanceStatusElement !== undefined) {
                  var instanceStatusInstance = instanceStatusElement;
                  roleInstanceInstance.instanceStatus = instanceStatusInstance;
                }
                
                var instanceUpgradeDomainElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'INSTANCEUPGRADEDOMAIN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (instanceUpgradeDomainElement !== null && instanceUpgradeDomainElement !== undefined && instanceUpgradeDomainElement.length !== 0) {
                  var instanceUpgradeDomainInstance = parseInt(instanceUpgradeDomainElement, 10);
                  roleInstanceInstance.instanceUpgradeDomain = instanceUpgradeDomainInstance;
                }
                
                var instanceFaultDomainElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'INSTANCEFAULTDOMAIN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (instanceFaultDomainElement !== null && instanceFaultDomainElement !== undefined && instanceFaultDomainElement.length !== 0) {
                  var instanceFaultDomainInstance = parseInt(instanceFaultDomainElement, 10);
                  roleInstanceInstance.instanceFaultDomain = instanceFaultDomainInstance;
                }
                
                var instanceSizeElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'INSTANCESIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (instanceSizeElement !== null && instanceSizeElement !== undefined) {
                  var instanceSizeInstance = instanceSizeElement;
                  roleInstanceInstance.instanceSize = instanceSizeInstance;
                }
                
                var instanceStateDetailsElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'INSTANCESTATEDETAILS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (instanceStateDetailsElement !== null && instanceStateDetailsElement !== undefined) {
                  var instanceStateDetailsInstance = instanceStateDetailsElement;
                  roleInstanceInstance.instanceStateDetails = instanceStateDetailsInstance;
                }
                
                var instanceErrorCodeElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'INSTANCEERRORCODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (instanceErrorCodeElement !== null && instanceErrorCodeElement !== undefined) {
                  var instanceErrorCodeInstance = instanceErrorCodeElement;
                  roleInstanceInstance.instanceErrorCode = instanceErrorCodeInstance;
                }
                
                var ipAddressElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'IPADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (ipAddressElement !== null && ipAddressElement !== undefined) {
                  var ipAddressInstance = ipAddressElement;
                  roleInstanceInstance.iPAddress = ipAddressInstance;
                }
                
                var instanceEndpointsSequenceElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'INSTANCEENDPOINTS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (instanceEndpointsSequenceElement !== null && instanceEndpointsSequenceElement !== undefined) {
                  for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, instanceEndpointsSequenceElement, 'INSTANCEENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex2 = loweredIndex2 + 1) {
                    var instanceEndpointsElement = js2xml.getElements(responseDoc, instanceEndpointsSequenceElement, 'INSTANCEENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex2];
                    var instanceEndpointInstance = {};
                    roleInstanceInstance.instanceEndpoints.push(instanceEndpointInstance);
                    
                    var localPortElement = js2xml.getElement(responseDoc, instanceEndpointsElement, 'LOCALPORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (localPortElement !== null && localPortElement !== undefined && localPortElement.length !== 0) {
                      var localPortInstance = parseInt(localPortElement, 10);
                      instanceEndpointInstance.localPort = localPortInstance;
                    }
                    
                    var nameElement2 = js2xml.getElement(responseDoc, instanceEndpointsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (nameElement2 !== null && nameElement2 !== undefined) {
                      var nameInstance2 = nameElement2;
                      instanceEndpointInstance.name = nameInstance2;
                    }
                    
                    var publicPortElement = js2xml.getElement(responseDoc, instanceEndpointsElement, 'PUBLICPORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (publicPortElement !== null && publicPortElement !== undefined && publicPortElement.length !== 0) {
                      var publicPortInstance = parseInt(publicPortElement, 10);
                      instanceEndpointInstance.port = publicPortInstance;
                    }
                    
                    var protocolElement = js2xml.getElement(responseDoc, instanceEndpointsElement, 'PROTOCOL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (protocolElement !== null && protocolElement !== undefined) {
                      var protocolInstance = protocolElement;
                      instanceEndpointInstance.protocol = protocolInstance;
                    }
                    
                    var vipElement = js2xml.getElement(responseDoc, instanceEndpointsElement, 'VIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (vipElement !== null && vipElement !== undefined) {
                      var vipInstance = vipElement;
                      instanceEndpointInstance.virtualIPAddress = vipInstance;
                    }
                    
                    var idleTimeoutInMinutesElement = js2xml.getElement(responseDoc, instanceEndpointsElement, 'IDLETIMEOUTINMINUTES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (idleTimeoutInMinutesElement !== null && idleTimeoutInMinutesElement !== undefined && idleTimeoutInMinutesElement.length !== 0) {
                      var idleTimeoutInMinutesInstance = parseInt(idleTimeoutInMinutesElement, 10);
                      instanceEndpointInstance.idleTimeoutInMinutes = idleTimeoutInMinutesInstance;
                    }
                  }
                }
                
                var guestAgentStatusElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'GUESTAGENTSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (guestAgentStatusElement !== null && guestAgentStatusElement !== undefined) {
                  var guestAgentStatusInstance = {};
                  roleInstanceInstance.guestAgentStatus = guestAgentStatusInstance;
                  
                  var protocolVersionElement = js2xml.getElement(responseDoc, guestAgentStatusElement, 'PROTOCOLVERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (protocolVersionElement !== null && protocolVersionElement !== undefined) {
                    var protocolVersionInstance = protocolVersionElement;
                    guestAgentStatusInstance.protocolVersion = protocolVersionInstance;
                  }
                  
                  var timestampElement = js2xml.getElement(responseDoc, guestAgentStatusElement, 'TIMESTAMP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (timestampElement !== null && timestampElement !== undefined && timestampElement.length !== 0) {
                    var timestampInstance = new Date(timestampElement);
                    guestAgentStatusInstance.timestamp = timestampInstance;
                  }
                  
                  var guestAgentVersionElement = js2xml.getElement(responseDoc, guestAgentStatusElement, 'GUESTAGENTVERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (guestAgentVersionElement !== null && guestAgentVersionElement !== undefined) {
                    var guestAgentVersionInstance = guestAgentVersionElement;
                    guestAgentStatusInstance.guestAgentVersion = guestAgentVersionInstance;
                  }
                  
                  var statusElement2 = js2xml.getElement(responseDoc, guestAgentStatusElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (statusElement2 !== null && statusElement2 !== undefined) {
                    var statusInstance2 = statusElement2;
                    guestAgentStatusInstance.status = statusInstance2;
                  }
                  
                  var codeElement = js2xml.getElement(responseDoc, guestAgentStatusElement, 'CODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (codeElement !== null && codeElement !== undefined && codeElement.length !== 0) {
                    var codeInstance = parseInt(codeElement, 10);
                    guestAgentStatusInstance.code = codeInstance;
                  }
                  
                  var messageElement = js2xml.getElement(responseDoc, guestAgentStatusElement, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (messageElement !== null && messageElement !== undefined) {
                    var messageInstance = { paramList: [] };
                    guestAgentStatusInstance.message = messageInstance;
                    
                    var messageResourceIdElement = js2xml.getElement(responseDoc, messageElement, 'MESSAGERESOURCEID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (messageResourceIdElement !== null && messageResourceIdElement !== undefined) {
                      var messageResourceIdInstance = messageResourceIdElement;
                      messageInstance.messageResourceId = messageResourceIdInstance;
                    }
                    
                    var paramListSequenceElement = js2xml.getElement(responseDoc, messageElement, 'PARAMLIST', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (paramListSequenceElement !== null && paramListSequenceElement !== undefined) {
                      for (var loweredIndex3 = 0; loweredIndex3 < js2xml.getElements(responseDoc, paramListSequenceElement, 'PARAM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex3 = loweredIndex3 + 1) {
                        var paramListElement = js2xml.getElements(responseDoc, paramListSequenceElement, 'PARAM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex3];
                        messageInstance.paramList.push(paramListElement);
                      }
                    }
                  }
                  
                  var formattedMessageElement = js2xml.getElement(responseDoc, guestAgentStatusElement, 'FORMATTEDMESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (formattedMessageElement !== null && formattedMessageElement !== undefined) {
                    var formattedMessageInstance = {};
                    guestAgentStatusInstance.formattedMessage = formattedMessageInstance;
                    
                    var languageElement = js2xml.getElement(responseDoc, formattedMessageElement, 'LANGUAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (languageElement !== null && languageElement !== undefined) {
                      var languageInstance = languageElement;
                      formattedMessageInstance.language = languageInstance;
                    }
                    
                    var messageElement2 = js2xml.getElement(responseDoc, formattedMessageElement, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (messageElement2 !== null && messageElement2 !== undefined) {
                      var messageInstance2 = messageElement2;
                      formattedMessageInstance.message = messageInstance2;
                    }
                  }
                }
                
                var resourceExtensionStatusListSequenceElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'RESOURCEEXTENSIONSTATUSLIST', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (resourceExtensionStatusListSequenceElement !== null && resourceExtensionStatusListSequenceElement !== undefined) {
                  for (var loweredIndex4 = 0; loweredIndex4 < js2xml.getElements(responseDoc, resourceExtensionStatusListSequenceElement, 'RESOURCEEXTENSIONSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex4 = loweredIndex4 + 1) {
                    var resourceExtensionStatusListElement = js2xml.getElements(responseDoc, resourceExtensionStatusListSequenceElement, 'RESOURCEEXTENSIONSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex4];
                    var resourceExtensionStatusInstance = {};
                    roleInstanceInstance.resourceExtensionStatusList.push(resourceExtensionStatusInstance);
                    
                    var handlerNameElement = js2xml.getElement(responseDoc, resourceExtensionStatusListElement, 'HANDLERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (handlerNameElement !== null && handlerNameElement !== undefined) {
                      var handlerNameInstance = handlerNameElement;
                      resourceExtensionStatusInstance.handlerName = handlerNameInstance;
                    }
                    
                    var versionElement = js2xml.getElement(responseDoc, resourceExtensionStatusListElement, 'VERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (versionElement !== null && versionElement !== undefined) {
                      var versionInstance = versionElement;
                      resourceExtensionStatusInstance.version = versionInstance;
                    }
                    
                    var statusElement3 = js2xml.getElement(responseDoc, resourceExtensionStatusListElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (statusElement3 !== null && statusElement3 !== undefined) {
                      var statusInstance3 = statusElement3;
                      resourceExtensionStatusInstance.status = statusInstance3;
                    }
                    
                    var codeElement2 = js2xml.getElement(responseDoc, resourceExtensionStatusListElement, 'CODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (codeElement2 !== null && codeElement2 !== undefined && codeElement2.length !== 0) {
                      var codeInstance2 = parseInt(codeElement2, 10);
                      resourceExtensionStatusInstance.code = codeInstance2;
                    }
                    
                    var messageElement3 = js2xml.getElement(responseDoc, resourceExtensionStatusListElement, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (messageElement3 !== null && messageElement3 !== undefined) {
                      var messageInstance3 = { paramList: [] };
                      resourceExtensionStatusInstance.message = messageInstance3;
                      
                      var messageResourceIdElement2 = js2xml.getElement(responseDoc, messageElement3, 'MESSAGERESOURCEID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (messageResourceIdElement2 !== null && messageResourceIdElement2 !== undefined) {
                        var messageResourceIdInstance2 = messageResourceIdElement2;
                        messageInstance3.messageResourceId = messageResourceIdInstance2;
                      }
                      
                      var paramListSequenceElement2 = js2xml.getElement(responseDoc, messageElement3, 'PARAMLIST', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (paramListSequenceElement2 !== null && paramListSequenceElement2 !== undefined) {
                        for (var loweredIndex5 = 0; loweredIndex5 < js2xml.getElements(responseDoc, paramListSequenceElement2, 'PARAM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex5 = loweredIndex5 + 1) {
                          var paramListElement2 = js2xml.getElements(responseDoc, paramListSequenceElement2, 'PARAM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex5];
                          messageInstance3.paramList.push(paramListElement2);
                        }
                      }
                    }
                    
                    var formattedMessageElement2 = js2xml.getElement(responseDoc, resourceExtensionStatusListElement, 'FORMATTEDMESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (formattedMessageElement2 !== null && formattedMessageElement2 !== undefined) {
                      var formattedMessageInstance2 = {};
                      resourceExtensionStatusInstance.formattedMessage = formattedMessageInstance2;
                      
                      var languageElement2 = js2xml.getElement(responseDoc, formattedMessageElement2, 'LANGUAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (languageElement2 !== null && languageElement2 !== undefined) {
                        var languageInstance2 = languageElement2;
                        formattedMessageInstance2.language = languageInstance2;
                      }
                      
                      var messageElement4 = js2xml.getElement(responseDoc, formattedMessageElement2, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (messageElement4 !== null && messageElement4 !== undefined) {
                        var messageInstance4 = messageElement4;
                        formattedMessageInstance2.message = messageInstance4;
                      }
                    }
                    
                    var extensionSettingStatusElement = js2xml.getElement(responseDoc, resourceExtensionStatusListElement, 'EXTENSIONSETTINGSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (extensionSettingStatusElement !== null && extensionSettingStatusElement !== undefined) {
                      var extensionSettingStatusInstance = { subStatusList: [] };
                      resourceExtensionStatusInstance.extensionSettingStatus = extensionSettingStatusInstance;
                      
                      var timestampElement2 = js2xml.getElement(responseDoc, extensionSettingStatusElement, 'TIMESTAMP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (timestampElement2 !== null && timestampElement2 !== undefined && timestampElement2.length !== 0) {
                        var timestampInstance2 = new Date(timestampElement2);
                        extensionSettingStatusInstance.timestamp = timestampInstance2;
                      }
                      
                      var configurationAppliedTimeElement = js2xml.getElement(responseDoc, extensionSettingStatusElement, 'CONFIGURATIONAPPLIEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (configurationAppliedTimeElement !== null && configurationAppliedTimeElement !== undefined && configurationAppliedTimeElement.length !== 0) {
                        var configurationAppliedTimeInstance = new Date(configurationAppliedTimeElement);
                        extensionSettingStatusInstance.configurationAppliedTime = configurationAppliedTimeInstance;
                      }
                      
                      var nameElement3 = js2xml.getElement(responseDoc, extensionSettingStatusElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (nameElement3 !== null && nameElement3 !== undefined) {
                        var nameInstance3 = nameElement3;
                        extensionSettingStatusInstance.name = nameInstance3;
                      }
                      
                      var operationElement = js2xml.getElement(responseDoc, extensionSettingStatusElement, 'OPERATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (operationElement !== null && operationElement !== undefined) {
                        var operationInstance = operationElement;
                        extensionSettingStatusInstance.operation = operationInstance;
                      }
                      
                      var statusElement4 = js2xml.getElement(responseDoc, extensionSettingStatusElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (statusElement4 !== null && statusElement4 !== undefined) {
                        var statusInstance4 = statusElement4;
                        extensionSettingStatusInstance.status = statusInstance4;
                      }
                      
                      var codeElement3 = js2xml.getElement(responseDoc, extensionSettingStatusElement, 'CODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (codeElement3 !== null && codeElement3 !== undefined && codeElement3.length !== 0) {
                        var codeInstance3 = parseInt(codeElement3, 10);
                        extensionSettingStatusInstance.code = codeInstance3;
                      }
                      
                      var messageElement5 = js2xml.getElement(responseDoc, extensionSettingStatusElement, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (messageElement5 !== null && messageElement5 !== undefined) {
                        var messageInstance5 = { paramList: [] };
                        extensionSettingStatusInstance.message = messageInstance5;
                        
                        var messageResourceIdElement3 = js2xml.getElement(responseDoc, messageElement5, 'MESSAGERESOURCEID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (messageResourceIdElement3 !== null && messageResourceIdElement3 !== undefined) {
                          var messageResourceIdInstance3 = messageResourceIdElement3;
                          messageInstance5.messageResourceId = messageResourceIdInstance3;
                        }
                        
                        var paramListSequenceElement3 = js2xml.getElement(responseDoc, messageElement5, 'PARAMLIST', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (paramListSequenceElement3 !== null && paramListSequenceElement3 !== undefined) {
                          for (var loweredIndex6 = 0; loweredIndex6 < js2xml.getElements(responseDoc, paramListSequenceElement3, 'PARAM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex6 = loweredIndex6 + 1) {
                            var paramListElement3 = js2xml.getElements(responseDoc, paramListSequenceElement3, 'PARAM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex6];
                            messageInstance5.paramList.push(paramListElement3);
                          }
                        }
                      }
                      
                      var formattedMessageElement3 = js2xml.getElement(responseDoc, extensionSettingStatusElement, 'FORMATTEDMESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (formattedMessageElement3 !== null && formattedMessageElement3 !== undefined) {
                        var formattedMessageInstance3 = {};
                        extensionSettingStatusInstance.formattedMessage = formattedMessageInstance3;
                        
                        var languageElement3 = js2xml.getElement(responseDoc, formattedMessageElement3, 'LANGUAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (languageElement3 !== null && languageElement3 !== undefined) {
                          var languageInstance3 = languageElement3;
                          formattedMessageInstance3.language = languageInstance3;
                        }
                        
                        var messageElement6 = js2xml.getElement(responseDoc, formattedMessageElement3, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (messageElement6 !== null && messageElement6 !== undefined) {
                          var messageInstance6 = messageElement6;
                          formattedMessageInstance3.message = messageInstance6;
                        }
                      }
                      
                      var subStatusListSequenceElement = js2xml.getElement(responseDoc, extensionSettingStatusElement, 'SUBSTATUSLIST', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (subStatusListSequenceElement !== null && subStatusListSequenceElement !== undefined) {
                        for (var loweredIndex7 = 0; loweredIndex7 < js2xml.getElements(responseDoc, subStatusListSequenceElement, 'SUBSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex7 = loweredIndex7 + 1) {
                          var subStatusListElement = js2xml.getElements(responseDoc, subStatusListSequenceElement, 'SUBSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex7];
                          var subStatusInstance = {};
                          extensionSettingStatusInstance.subStatusList.push(subStatusInstance);
                          
                          var nameElement4 = js2xml.getElement(responseDoc, subStatusListElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (nameElement4 !== null && nameElement4 !== undefined) {
                            var nameInstance4 = nameElement4;
                            subStatusInstance.name = nameInstance4;
                          }
                          
                          var statusElement5 = js2xml.getElement(responseDoc, subStatusListElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (statusElement5 !== null && statusElement5 !== undefined) {
                            var statusInstance5 = statusElement5;
                            subStatusInstance.status = statusInstance5;
                          }
                          
                          var codeElement4 = js2xml.getElement(responseDoc, subStatusListElement, 'CODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (codeElement4 !== null && codeElement4 !== undefined && codeElement4.length !== 0) {
                            var codeInstance4 = parseInt(codeElement4, 10);
                            subStatusInstance.code = codeInstance4;
                          }
                          
                          var messageElement7 = js2xml.getElement(responseDoc, subStatusListElement, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (messageElement7 !== null && messageElement7 !== undefined) {
                            var messageInstance7 = { paramList: [] };
                            subStatusInstance.message = messageInstance7;
                            
                            var messageResourceIdElement4 = js2xml.getElement(responseDoc, messageElement7, 'MESSAGERESOURCEID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (messageResourceIdElement4 !== null && messageResourceIdElement4 !== undefined) {
                              var messageResourceIdInstance4 = messageResourceIdElement4;
                              messageInstance7.messageResourceId = messageResourceIdInstance4;
                            }
                            
                            var paramListSequenceElement4 = js2xml.getElement(responseDoc, messageElement7, 'PARAMLIST', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (paramListSequenceElement4 !== null && paramListSequenceElement4 !== undefined) {
                              for (var loweredIndex8 = 0; loweredIndex8 < js2xml.getElements(responseDoc, paramListSequenceElement4, 'PARAM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex8 = loweredIndex8 + 1) {
                                var paramListElement4 = js2xml.getElements(responseDoc, paramListSequenceElement4, 'PARAM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex8];
                                messageInstance7.paramList.push(paramListElement4);
                              }
                            }
                          }
                          
                          var formattedMessageElement4 = js2xml.getElement(responseDoc, subStatusListElement, 'FORMATTEDMESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (formattedMessageElement4 !== null && formattedMessageElement4 !== undefined) {
                            var formattedMessageInstance4 = {};
                            subStatusInstance.formattedMessage = formattedMessageInstance4;
                            
                            var languageElement4 = js2xml.getElement(responseDoc, formattedMessageElement4, 'LANGUAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (languageElement4 !== null && languageElement4 !== undefined) {
                              var languageInstance4 = languageElement4;
                              formattedMessageInstance4.language = languageInstance4;
                            }
                            
                            var messageElement8 = js2xml.getElement(responseDoc, formattedMessageElement4, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (messageElement8 !== null && messageElement8 !== undefined) {
                              var messageInstance8 = messageElement8;
                              formattedMessageInstance4.message = messageInstance8;
                            }
                          }
                        }
                      }
                    }
                  }
                }
                
                var powerStateElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'POWERSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (powerStateElement !== null && powerStateElement !== undefined && powerStateElement.length !== 0) {
                  var powerStateInstance = powerStateElement;
                  roleInstanceInstance.powerState = powerStateInstance;
                }
                
                var hostNameElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'HOSTNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (hostNameElement !== null && hostNameElement !== undefined) {
                  var hostNameInstance = hostNameElement;
                  roleInstanceInstance.hostName = hostNameInstance;
                }
                
                var remoteAccessCertificateThumbprintElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'REMOTEACCESSCERTIFICATETHUMBPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (remoteAccessCertificateThumbprintElement !== null && remoteAccessCertificateThumbprintElement !== undefined) {
                  var remoteAccessCertificateThumbprintInstance = remoteAccessCertificateThumbprintElement;
                  roleInstanceInstance.remoteAccessCertificateThumbprint = remoteAccessCertificateThumbprintInstance;
                }
                
                var publicIPsSequenceElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'PUBLICIPS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (publicIPsSequenceElement !== null && publicIPsSequenceElement !== undefined) {
                  for (var loweredIndex9 = 0; loweredIndex9 < js2xml.getElements(responseDoc, publicIPsSequenceElement, 'PUBLICIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex9 = loweredIndex9 + 1) {
                    var publicIPsElement = js2xml.getElements(responseDoc, publicIPsSequenceElement, 'PUBLICIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex9];
                    var publicIPInstance = { fqdns: [] };
                    roleInstanceInstance.publicIPs.push(publicIPInstance);
                    
                    var nameElement5 = js2xml.getElement(responseDoc, publicIPsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (nameElement5 !== null && nameElement5 !== undefined) {
                      var nameInstance5 = nameElement5;
                      publicIPInstance.name = nameInstance5;
                    }
                    
                    var addressElement = js2xml.getElement(responseDoc, publicIPsElement, 'ADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (addressElement !== null && addressElement !== undefined) {
                      var addressInstance = addressElement;
                      publicIPInstance.address = addressInstance;
                    }
                    
                    var idleTimeoutInMinutesElement2 = js2xml.getElement(responseDoc, publicIPsElement, 'IDLETIMEOUTINMINUTES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (idleTimeoutInMinutesElement2 !== null && idleTimeoutInMinutesElement2 !== undefined && idleTimeoutInMinutesElement2.length !== 0) {
                      var idleTimeoutInMinutesInstance2 = parseInt(idleTimeoutInMinutesElement2, 10);
                      publicIPInstance.idleTimeoutInMinutes = idleTimeoutInMinutesInstance2;
                    }
                    
                    var domainNameLabelElement = js2xml.getElement(responseDoc, publicIPsElement, 'DOMAINNAMELABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (domainNameLabelElement !== null && domainNameLabelElement !== undefined) {
                      var domainNameLabelInstance = domainNameLabelElement;
                      publicIPInstance.domainNameLabel = domainNameLabelInstance;
                    }
                    
                    var fqdnsSequenceElement = js2xml.getElement(responseDoc, publicIPsElement, 'FQDNS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (fqdnsSequenceElement !== null && fqdnsSequenceElement !== undefined) {
                      for (var loweredIndex10 = 0; loweredIndex10 < js2xml.getElements(responseDoc, fqdnsSequenceElement, 'FQDN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex10 = loweredIndex10 + 1) {
                        var fqdnsElement = js2xml.getElements(responseDoc, fqdnsSequenceElement, 'FQDN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex10];
                        publicIPInstance.fqdns.push(fqdnsElement);
                      }
                    }
                  }
                }
                
                var networkInterfacesSequenceElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'NETWORKINTERFACES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (networkInterfacesSequenceElement !== null && networkInterfacesSequenceElement !== undefined) {
                  for (var loweredIndex11 = 0; loweredIndex11 < js2xml.getElements(responseDoc, networkInterfacesSequenceElement, 'NETWORKINTERFACE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex11 = loweredIndex11 + 1) {
                    var networkInterfacesElement = js2xml.getElements(responseDoc, networkInterfacesSequenceElement, 'NETWORKINTERFACE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex11];
                    var networkInterfaceInstance = { iPConfigurations: [] };
                    roleInstanceInstance.networkInterfaces.push(networkInterfaceInstance);
                    
                    var nameElement6 = js2xml.getElement(responseDoc, networkInterfacesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (nameElement6 !== null && nameElement6 !== undefined) {
                      var nameInstance6 = nameElement6;
                      networkInterfaceInstance.name = nameInstance6;
                    }
                    
                    var macAddressElement = js2xml.getElement(responseDoc, networkInterfacesElement, 'MACADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (macAddressElement !== null && macAddressElement !== undefined) {
                      var macAddressInstance = macAddressElement;
                      networkInterfaceInstance.macAddress = macAddressInstance;
                    }
                    
                    var iPConfigurationsSequenceElement = js2xml.getElement(responseDoc, networkInterfacesElement, 'IPCONFIGURATIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (iPConfigurationsSequenceElement !== null && iPConfigurationsSequenceElement !== undefined) {
                      for (var loweredIndex12 = 0; loweredIndex12 < js2xml.getElements(responseDoc, iPConfigurationsSequenceElement, 'IPCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex12 = loweredIndex12 + 1) {
                        var iPConfigurationsElement = js2xml.getElements(responseDoc, iPConfigurationsSequenceElement, 'IPCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex12];
                        var iPConfigurationInstance = {};
                        networkInterfaceInstance.iPConfigurations.push(iPConfigurationInstance);
                        
                        var subnetNameElement = js2xml.getElement(responseDoc, iPConfigurationsElement, 'SUBNETNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (subnetNameElement !== null && subnetNameElement !== undefined) {
                          var subnetNameInstance = subnetNameElement;
                          iPConfigurationInstance.subnetName = subnetNameInstance;
                        }
                        
                        var addressElement2 = js2xml.getElement(responseDoc, iPConfigurationsElement, 'ADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (addressElement2 !== null && addressElement2 !== undefined) {
                          var addressInstance2 = addressElement2;
                          iPConfigurationInstance.address = addressInstance2;
                        }
                      }
                    }
                  }
                }
              }
            }
            
            var upgradeStatusElement = js2xml.getElement(responseDoc, deploymentElement, 'UPGRADESTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (upgradeStatusElement !== null && upgradeStatusElement !== undefined) {
              var upgradeStatusInstance = {};
              result.upgradeStatus = upgradeStatusInstance;
              
              var upgradeTypeElement = js2xml.getElement(responseDoc, upgradeStatusElement, 'UPGRADETYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (upgradeTypeElement !== null && upgradeTypeElement !== undefined && upgradeTypeElement.length !== 0) {
                var upgradeTypeInstance = upgradeTypeElement;
                upgradeStatusInstance.upgradeType = upgradeTypeInstance;
              }
              
              var currentUpgradeDomainStateElement = js2xml.getElement(responseDoc, upgradeStatusElement, 'CURRENTUPGRADEDOMAINSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (currentUpgradeDomainStateElement !== null && currentUpgradeDomainStateElement !== undefined && currentUpgradeDomainStateElement.length !== 0) {
                var currentUpgradeDomainStateInstance = currentUpgradeDomainStateElement;
                upgradeStatusInstance.currentUpgradeDomainState = currentUpgradeDomainStateInstance;
              }
              
              var currentUpgradeDomainElement = js2xml.getElement(responseDoc, upgradeStatusElement, 'CURRENTUPGRADEDOMAIN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (currentUpgradeDomainElement !== null && currentUpgradeDomainElement !== undefined && currentUpgradeDomainElement.length !== 0) {
                var currentUpgradeDomainInstance = parseInt(currentUpgradeDomainElement, 10);
                upgradeStatusInstance.currentUpgradeDomain = currentUpgradeDomainInstance;
              }
            }
            
            var upgradeDomainCountElement = js2xml.getElement(responseDoc, deploymentElement, 'UPGRADEDOMAINCOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (upgradeDomainCountElement !== null && upgradeDomainCountElement !== undefined && upgradeDomainCountElement.length !== 0) {
              var upgradeDomainCountInstance = parseInt(upgradeDomainCountElement, 10);
              result.upgradeDomainCount = upgradeDomainCountInstance;
            }
            
            var roleListSequenceElement = js2xml.getElement(responseDoc, deploymentElement, 'ROLELIST', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (roleListSequenceElement !== null && roleListSequenceElement !== undefined) {
              for (var loweredIndex13 = 0; loweredIndex13 < js2xml.getElements(responseDoc, roleListSequenceElement, 'ROLE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex13 = loweredIndex13 + 1) {
                var roleListElement = js2xml.getElements(responseDoc, roleListSequenceElement, 'ROLE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex13];
                var roleInstance = { configurationSets: [], dataVirtualHardDisks: [], resourceExtensionReferences: [] };
                result.roles.push(roleInstance);
                
                var roleNameElement2 = js2xml.getElement(responseDoc, roleListElement, 'ROLENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (roleNameElement2 !== null && roleNameElement2 !== undefined) {
                  var roleNameInstance2 = roleNameElement2;
                  roleInstance.roleName = roleNameInstance2;
                }
                
                var osVersionElement = js2xml.getElement(responseDoc, roleListElement, 'OSVERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (osVersionElement !== null && osVersionElement !== undefined) {
                  var osVersionInstance = osVersionElement;
                  roleInstance.oSVersion = osVersionInstance;
                }
                
                var roleTypeElement = js2xml.getElement(responseDoc, roleListElement, 'ROLETYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (roleTypeElement !== null && roleTypeElement !== undefined) {
                  var roleTypeInstance = roleTypeElement;
                  roleInstance.roleType = roleTypeInstance;
                }
                
                var configurationSetsSequenceElement = js2xml.getElement(responseDoc, roleListElement, 'CONFIGURATIONSETS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (configurationSetsSequenceElement !== null && configurationSetsSequenceElement !== undefined) {
                  for (var loweredIndex14 = 0; loweredIndex14 < js2xml.getElements(responseDoc, configurationSetsSequenceElement, 'CONFIGURATIONSET', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex14 = loweredIndex14 + 1) {
                    var configurationSetsElement = js2xml.getElements(responseDoc, configurationSetsSequenceElement, 'CONFIGURATIONSET', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex14];
                    var configurationSetInstance = { inputEndpoints: [], networkInterfaces: [], publicIPs: [], storedCertificateSettings: [], subnetNames: [] };
                    roleInstance.configurationSets.push(configurationSetInstance);
                    
                    var configurationSetTypeElement = js2xml.getElement(responseDoc, configurationSetsElement, 'CONFIGURATIONSETTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (configurationSetTypeElement !== null && configurationSetTypeElement !== undefined) {
                      var configurationSetTypeInstance = configurationSetTypeElement;
                      configurationSetInstance.configurationSetType = configurationSetTypeInstance;
                    }
                    
                    var inputEndpointsSequenceElement = js2xml.getElement(responseDoc, configurationSetsElement, 'INPUTENDPOINTS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (inputEndpointsSequenceElement !== null && inputEndpointsSequenceElement !== undefined) {
                      for (var loweredIndex15 = 0; loweredIndex15 < js2xml.getElements(responseDoc, inputEndpointsSequenceElement, 'INPUTENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex15 = loweredIndex15 + 1) {
                        var inputEndpointsElement = js2xml.getElements(responseDoc, inputEndpointsSequenceElement, 'INPUTENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex15];
                        var inputEndpointInstance = {};
                        configurationSetInstance.inputEndpoints.push(inputEndpointInstance);
                        
                        var loadBalancedEndpointSetNameElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'LOADBALANCEDENDPOINTSETNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (loadBalancedEndpointSetNameElement !== null && loadBalancedEndpointSetNameElement !== undefined) {
                          var loadBalancedEndpointSetNameInstance = loadBalancedEndpointSetNameElement;
                          inputEndpointInstance.loadBalancedEndpointSetName = loadBalancedEndpointSetNameInstance;
                        }
                        
                        var localPortElement2 = js2xml.getElement(responseDoc, inputEndpointsElement, 'LOCALPORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (localPortElement2 !== null && localPortElement2 !== undefined && localPortElement2.length !== 0) {
                          var localPortInstance2 = parseInt(localPortElement2, 10);
                          inputEndpointInstance.localPort = localPortInstance2;
                        }
                        
                        var nameElement7 = js2xml.getElement(responseDoc, inputEndpointsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (nameElement7 !== null && nameElement7 !== undefined) {
                          var nameInstance7 = nameElement7;
                          inputEndpointInstance.name = nameInstance7;
                        }
                        
                        var portElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'PORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (portElement !== null && portElement !== undefined && portElement.length !== 0) {
                          var portInstance = parseInt(portElement, 10);
                          inputEndpointInstance.port = portInstance;
                        }
                        
                        var loadBalancerProbeElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'LOADBALANCERPROBE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (loadBalancerProbeElement !== null && loadBalancerProbeElement !== undefined) {
                          var loadBalancerProbeInstance = {};
                          inputEndpointInstance.loadBalancerProbe = loadBalancerProbeInstance;
                          
                          var pathElement = js2xml.getElement(responseDoc, loadBalancerProbeElement, 'PATH', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (pathElement !== null && pathElement !== undefined) {
                            var pathInstance = pathElement;
                            loadBalancerProbeInstance.path = pathInstance;
                          }
                          
                          var portElement2 = js2xml.getElement(responseDoc, loadBalancerProbeElement, 'PORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (portElement2 !== null && portElement2 !== undefined && portElement2.length !== 0) {
                            var portInstance2 = parseInt(portElement2, 10);
                            loadBalancerProbeInstance.port = portInstance2;
                          }
                          
                          var protocolElement2 = js2xml.getElement(responseDoc, loadBalancerProbeElement, 'PROTOCOL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (protocolElement2 !== null && protocolElement2 !== undefined && protocolElement2.length !== 0) {
                            var protocolInstance2 = protocolElement2;
                            loadBalancerProbeInstance.protocol = protocolInstance2;
                          }
                          
                          var intervalInSecondsElement = js2xml.getElement(responseDoc, loadBalancerProbeElement, 'INTERVALINSECONDS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (intervalInSecondsElement !== null && intervalInSecondsElement !== undefined && intervalInSecondsElement.length !== 0) {
                            var intervalInSecondsInstance = parseInt(intervalInSecondsElement, 10);
                            loadBalancerProbeInstance.intervalInSeconds = intervalInSecondsInstance;
                          }
                          
                          var timeoutInSecondsElement = js2xml.getElement(responseDoc, loadBalancerProbeElement, 'TIMEOUTINSECONDS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (timeoutInSecondsElement !== null && timeoutInSecondsElement !== undefined && timeoutInSecondsElement.length !== 0) {
                            var timeoutInSecondsInstance = parseInt(timeoutInSecondsElement, 10);
                            loadBalancerProbeInstance.timeoutInSeconds = timeoutInSecondsInstance;
                          }
                        }
                        
                        var protocolElement3 = js2xml.getElement(responseDoc, inputEndpointsElement, 'PROTOCOL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (protocolElement3 !== null && protocolElement3 !== undefined) {
                          var protocolInstance3 = protocolElement3;
                          inputEndpointInstance.protocol = protocolInstance3;
                        }
                        
                        var vipElement2 = js2xml.getElement(responseDoc, inputEndpointsElement, 'VIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (vipElement2 !== null && vipElement2 !== undefined) {
                          var vipInstance2 = vipElement2;
                          inputEndpointInstance.virtualIPAddress = vipInstance2;
                        }
                        
                        var enableDirectServerReturnElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'ENABLEDIRECTSERVERRETURN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (enableDirectServerReturnElement !== null && enableDirectServerReturnElement !== undefined && enableDirectServerReturnElement.length !== 0) {
                          var enableDirectServerReturnInstance = enableDirectServerReturnElement === 'true';
                          inputEndpointInstance.enableDirectServerReturn = enableDirectServerReturnInstance;
                        }
                        
                        var loadBalancerNameElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'LOADBALANCERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (loadBalancerNameElement !== null && loadBalancerNameElement !== undefined) {
                          var loadBalancerNameInstance = loadBalancerNameElement;
                          inputEndpointInstance.loadBalancerName = loadBalancerNameInstance;
                        }
                        
                        var endpointAclElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'ENDPOINTACL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (endpointAclElement !== null && endpointAclElement !== undefined) {
                          var endpointAclInstance = { rules: [] };
                          inputEndpointInstance.endpointAcl = endpointAclInstance;
                          
                          var rulesSequenceElement = js2xml.getElement(responseDoc, endpointAclElement, 'RULES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (rulesSequenceElement !== null && rulesSequenceElement !== undefined) {
                            for (var loweredIndex16 = 0; loweredIndex16 < js2xml.getElements(responseDoc, rulesSequenceElement, 'RULE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex16 = loweredIndex16 + 1) {
                              var rulesElement = js2xml.getElements(responseDoc, rulesSequenceElement, 'RULE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex16];
                              var ruleInstance = {};
                              endpointAclInstance.rules.push(ruleInstance);
                              
                              var orderElement = js2xml.getElement(responseDoc, rulesElement, 'ORDER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (orderElement !== null && orderElement !== undefined && orderElement.length !== 0) {
                                var orderInstance = parseInt(orderElement, 10);
                                ruleInstance.order = orderInstance;
                              }
                              
                              var actionElement = js2xml.getElement(responseDoc, rulesElement, 'ACTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (actionElement !== null && actionElement !== undefined) {
                                var actionInstance = actionElement;
                                ruleInstance.action = actionInstance;
                              }
                              
                              var remoteSubnetElement = js2xml.getElement(responseDoc, rulesElement, 'REMOTESUBNET', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (remoteSubnetElement !== null && remoteSubnetElement !== undefined) {
                                var remoteSubnetInstance = remoteSubnetElement;
                                ruleInstance.remoteSubnet = remoteSubnetInstance;
                              }
                              
                              var descriptionElement = js2xml.getElement(responseDoc, rulesElement, 'DESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (descriptionElement !== null && descriptionElement !== undefined) {
                                var descriptionInstance = descriptionElement;
                                ruleInstance.description = descriptionInstance;
                              }
                            }
                          }
                        }
                        
                        var idleTimeoutInMinutesElement3 = js2xml.getElement(responseDoc, inputEndpointsElement, 'IDLETIMEOUTINMINUTES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (idleTimeoutInMinutesElement3 !== null && idleTimeoutInMinutesElement3 !== undefined && idleTimeoutInMinutesElement3.length !== 0) {
                          var idleTimeoutInMinutesInstance3 = parseInt(idleTimeoutInMinutesElement3, 10);
                          inputEndpointInstance.idleTimeoutInMinutes = idleTimeoutInMinutesInstance3;
                        }
                        
                        var loadBalancerDistributionElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'LOADBALANCERDISTRIBUTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (loadBalancerDistributionElement !== null && loadBalancerDistributionElement !== undefined) {
                          var loadBalancerDistributionInstance = loadBalancerDistributionElement;
                          inputEndpointInstance.loadBalancerDistribution = loadBalancerDistributionInstance;
                        }
                        
                        var virtualIPNameElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'VIRTUALIPNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (virtualIPNameElement !== null && virtualIPNameElement !== undefined) {
                          var virtualIPNameInstance = virtualIPNameElement;
                          inputEndpointInstance.virtualIPName = virtualIPNameInstance;
                        }
                      }
                    }
                    
                    var subnetNamesSequenceElement = js2xml.getElement(responseDoc, configurationSetsElement, 'SUBNETNAMES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (subnetNamesSequenceElement !== null && subnetNamesSequenceElement !== undefined) {
                      for (var loweredIndex17 = 0; loweredIndex17 < js2xml.getElements(responseDoc, subnetNamesSequenceElement, 'SUBNETNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex17 = loweredIndex17 + 1) {
                        var subnetNamesElement = js2xml.getElements(responseDoc, subnetNamesSequenceElement, 'SUBNETNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex17];
                        configurationSetInstance.subnetNames.push(subnetNamesElement);
                      }
                    }
                    
                    var staticVirtualNetworkIPAddressElement = js2xml.getElement(responseDoc, configurationSetsElement, 'STATICVIRTUALNETWORKIPADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (staticVirtualNetworkIPAddressElement !== null && staticVirtualNetworkIPAddressElement !== undefined) {
                      var staticVirtualNetworkIPAddressInstance = staticVirtualNetworkIPAddressElement;
                      configurationSetInstance.staticVirtualNetworkIPAddress = staticVirtualNetworkIPAddressInstance;
                    }
                    
                    var publicIPsSequenceElement2 = js2xml.getElement(responseDoc, configurationSetsElement, 'PUBLICIPS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (publicIPsSequenceElement2 !== null && publicIPsSequenceElement2 !== undefined) {
                      for (var loweredIndex18 = 0; loweredIndex18 < js2xml.getElements(responseDoc, publicIPsSequenceElement2, 'PUBLICIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex18 = loweredIndex18 + 1) {
                        var publicIPsElement2 = js2xml.getElements(responseDoc, publicIPsSequenceElement2, 'PUBLICIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex18];
                        var publicIPInstance2 = {};
                        configurationSetInstance.publicIPs.push(publicIPInstance2);
                        
                        var nameElement8 = js2xml.getElement(responseDoc, publicIPsElement2, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (nameElement8 !== null && nameElement8 !== undefined) {
                          var nameInstance8 = nameElement8;
                          publicIPInstance2.name = nameInstance8;
                        }
                        
                        var idleTimeoutInMinutesElement4 = js2xml.getElement(responseDoc, publicIPsElement2, 'IDLETIMEOUTINMINUTES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (idleTimeoutInMinutesElement4 !== null && idleTimeoutInMinutesElement4 !== undefined && idleTimeoutInMinutesElement4.length !== 0) {
                          var idleTimeoutInMinutesInstance4 = parseInt(idleTimeoutInMinutesElement4, 10);
                          publicIPInstance2.idleTimeoutInMinutes = idleTimeoutInMinutesInstance4;
                        }
                        
                        var domainNameLabelElement2 = js2xml.getElement(responseDoc, publicIPsElement2, 'DOMAINNAMELABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (domainNameLabelElement2 !== null && domainNameLabelElement2 !== undefined) {
                          var domainNameLabelInstance2 = domainNameLabelElement2;
                          publicIPInstance2.domainNameLabel = domainNameLabelInstance2;
                        }
                      }
                    }
                    
                    var networkInterfacesSequenceElement2 = js2xml.getElement(responseDoc, configurationSetsElement, 'NETWORKINTERFACES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (networkInterfacesSequenceElement2 !== null && networkInterfacesSequenceElement2 !== undefined) {
                      for (var loweredIndex19 = 0; loweredIndex19 < js2xml.getElements(responseDoc, networkInterfacesSequenceElement2, 'NETWORKINTERFACE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex19 = loweredIndex19 + 1) {
                        var networkInterfacesElement2 = js2xml.getElements(responseDoc, networkInterfacesSequenceElement2, 'NETWORKINTERFACE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex19];
                        var networkInterfaceInstance2 = { iPConfigurations: [] };
                        configurationSetInstance.networkInterfaces.push(networkInterfaceInstance2);
                        
                        var nameElement9 = js2xml.getElement(responseDoc, networkInterfacesElement2, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (nameElement9 !== null && nameElement9 !== undefined) {
                          var nameInstance9 = nameElement9;
                          networkInterfaceInstance2.name = nameInstance9;
                        }
                        
                        var iPConfigurationsSequenceElement2 = js2xml.getElement(responseDoc, networkInterfacesElement2, 'IPCONFIGURATIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (iPConfigurationsSequenceElement2 !== null && iPConfigurationsSequenceElement2 !== undefined) {
                          for (var loweredIndex20 = 0; loweredIndex20 < js2xml.getElements(responseDoc, iPConfigurationsSequenceElement2, 'IPCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex20 = loweredIndex20 + 1) {
                            var iPConfigurationsElement2 = js2xml.getElements(responseDoc, iPConfigurationsSequenceElement2, 'IPCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex20];
                            var iPConfigurationInstance2 = {};
                            networkInterfaceInstance2.iPConfigurations.push(iPConfigurationInstance2);
                            
                            var subnetNameElement2 = js2xml.getElement(responseDoc, iPConfigurationsElement2, 'SUBNETNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (subnetNameElement2 !== null && subnetNameElement2 !== undefined) {
                              var subnetNameInstance2 = subnetNameElement2;
                              iPConfigurationInstance2.subnetName = subnetNameInstance2;
                            }
                            
                            var staticVirtualNetworkIPAddressElement2 = js2xml.getElement(responseDoc, iPConfigurationsElement2, 'STATICVIRTUALNETWORKIPADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (staticVirtualNetworkIPAddressElement2 !== null && staticVirtualNetworkIPAddressElement2 !== undefined) {
                              var staticVirtualNetworkIPAddressInstance2 = staticVirtualNetworkIPAddressElement2;
                              iPConfigurationInstance2.staticVirtualNetworkIPAddress = staticVirtualNetworkIPAddressInstance2;
                            }
                          }
                        }
                        
                        var networkSecurityGroupElement = js2xml.getElement(responseDoc, networkInterfacesElement2, 'NETWORKSECURITYGROUP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (networkSecurityGroupElement !== null && networkSecurityGroupElement !== undefined) {
                          var networkSecurityGroupInstance = networkSecurityGroupElement;
                          networkInterfaceInstance2.networkSecurityGroup = networkSecurityGroupInstance;
                        }
                        
                        var iPForwardingElement = js2xml.getElement(responseDoc, networkInterfacesElement2, 'IPFORWARDING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (iPForwardingElement !== null && iPForwardingElement !== undefined) {
                          var iPForwardingInstance = iPForwardingElement;
                          networkInterfaceInstance2.iPForwarding = iPForwardingInstance;
                        }
                      }
                    }
                    
                    var networkSecurityGroupElement2 = js2xml.getElement(responseDoc, configurationSetsElement, 'NETWORKSECURITYGROUP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (networkSecurityGroupElement2 !== null && networkSecurityGroupElement2 !== undefined) {
                      var networkSecurityGroupInstance2 = networkSecurityGroupElement2;
                      configurationSetInstance.networkSecurityGroup = networkSecurityGroupInstance2;
                    }
                    
                    var iPForwardingElement2 = js2xml.getElement(responseDoc, configurationSetsElement, 'IPFORWARDING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (iPForwardingElement2 !== null && iPForwardingElement2 !== undefined) {
                      var iPForwardingInstance2 = iPForwardingElement2;
                      configurationSetInstance.iPForwarding = iPForwardingInstance2;
                    }
                    
                    var computerNameElement = js2xml.getElement(responseDoc, configurationSetsElement, 'COMPUTERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (computerNameElement !== null && computerNameElement !== undefined) {
                      var computerNameInstance = computerNameElement;
                      configurationSetInstance.computerName = computerNameInstance;
                    }
                    
                    var adminPasswordElement = js2xml.getElement(responseDoc, configurationSetsElement, 'ADMINPASSWORD', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (adminPasswordElement !== null && adminPasswordElement !== undefined) {
                      var adminPasswordInstance = adminPasswordElement;
                      configurationSetInstance.adminPassword = adminPasswordInstance;
                    }
                    
                    var resetPasswordOnFirstLogonElement = js2xml.getElement(responseDoc, configurationSetsElement, 'RESETPASSWORDONFIRSTLOGON', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (resetPasswordOnFirstLogonElement !== null && resetPasswordOnFirstLogonElement !== undefined && resetPasswordOnFirstLogonElement.length !== 0) {
                      var resetPasswordOnFirstLogonInstance = resetPasswordOnFirstLogonElement === 'true';
                      configurationSetInstance.resetPasswordOnFirstLogon = resetPasswordOnFirstLogonInstance;
                    }
                    
                    var enableAutomaticUpdatesElement = js2xml.getElement(responseDoc, configurationSetsElement, 'ENABLEAUTOMATICUPDATES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (enableAutomaticUpdatesElement !== null && enableAutomaticUpdatesElement !== undefined && enableAutomaticUpdatesElement.length !== 0) {
                      var enableAutomaticUpdatesInstance = enableAutomaticUpdatesElement === 'true';
                      configurationSetInstance.enableAutomaticUpdates = enableAutomaticUpdatesInstance;
                    }
                    
                    var timeZoneElement = js2xml.getElement(responseDoc, configurationSetsElement, 'TIMEZONE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (timeZoneElement !== null && timeZoneElement !== undefined) {
                      var timeZoneInstance = timeZoneElement;
                      configurationSetInstance.timeZone = timeZoneInstance;
                    }
                    
                    var domainJoinElement = js2xml.getElement(responseDoc, configurationSetsElement, 'DOMAINJOIN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (domainJoinElement !== null && domainJoinElement !== undefined) {
                      var domainJoinInstance = {};
                      configurationSetInstance.domainJoin = domainJoinInstance;
                      
                      var credentialsElement = js2xml.getElement(responseDoc, domainJoinElement, 'CREDENTIALS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (credentialsElement !== null && credentialsElement !== undefined) {
                        var credentialsInstance = {};
                        domainJoinInstance.credentials = credentialsInstance;
                        
                        var domainElement = js2xml.getElement(responseDoc, credentialsElement, 'DOMAIN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (domainElement !== null && domainElement !== undefined) {
                          var domainInstance = domainElement;
                          credentialsInstance.domain = domainInstance;
                        }
                        
                        var usernameElement = js2xml.getElement(responseDoc, credentialsElement, 'USERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (usernameElement !== null && usernameElement !== undefined) {
                          var usernameInstance = usernameElement;
                          credentialsInstance.userName = usernameInstance;
                        }
                        
                        var passwordElement = js2xml.getElement(responseDoc, credentialsElement, 'PASSWORD', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (passwordElement !== null && passwordElement !== undefined) {
                          var passwordInstance = passwordElement;
                          credentialsInstance.password = passwordInstance;
                        }
                      }
                      
                      var joinDomainElement = js2xml.getElement(responseDoc, domainJoinElement, 'JOINDOMAIN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (joinDomainElement !== null && joinDomainElement !== undefined) {
                        var joinDomainInstance = joinDomainElement;
                        domainJoinInstance.domainToJoin = joinDomainInstance;
                      }
                      
                      var machineObjectOUElement = js2xml.getElement(responseDoc, domainJoinElement, 'MACHINEOBJECTOU', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (machineObjectOUElement !== null && machineObjectOUElement !== undefined) {
                        var machineObjectOUInstance = machineObjectOUElement;
                        domainJoinInstance.ldapMachineObjectOU = machineObjectOUInstance;
                      }
                      
                      var provisioningElement = js2xml.getElement(responseDoc, domainJoinElement, 'PROVISIONING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (provisioningElement !== null && provisioningElement !== undefined) {
                        var provisioningInstance = {};
                        domainJoinInstance.provisioning = provisioningInstance;
                        
                        var accountDataElement = js2xml.getElement(responseDoc, provisioningElement, 'ACCOUNTDATA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (accountDataElement !== null && accountDataElement !== undefined) {
                          var accountDataInstance = accountDataElement;
                          provisioningInstance.accountData = accountDataInstance;
                        }
                      }
                    }
                    
                    var storedCertificateSettingsSequenceElement = js2xml.getElement(responseDoc, configurationSetsElement, 'STOREDCERTIFICATESETTINGS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (storedCertificateSettingsSequenceElement !== null && storedCertificateSettingsSequenceElement !== undefined) {
                      for (var loweredIndex21 = 0; loweredIndex21 < js2xml.getElements(responseDoc, storedCertificateSettingsSequenceElement, 'CERTIFICATESETTING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex21 = loweredIndex21 + 1) {
                        var storedCertificateSettingsElement = js2xml.getElements(responseDoc, storedCertificateSettingsSequenceElement, 'CERTIFICATESETTING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex21];
                        var certificateSettingInstance = {};
                        configurationSetInstance.storedCertificateSettings.push(certificateSettingInstance);
                        
                        var storeLocationElement = js2xml.getElement(responseDoc, storedCertificateSettingsElement, 'STORELOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (storeLocationElement !== null && storeLocationElement !== undefined) {
                        }
                        
                        var storeNameElement = js2xml.getElement(responseDoc, storedCertificateSettingsElement, 'STORENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (storeNameElement !== null && storeNameElement !== undefined) {
                          var storeNameInstance = storeNameElement;
                          certificateSettingInstance.storeName = storeNameInstance;
                        }
                        
                        var thumbprintElement = js2xml.getElement(responseDoc, storedCertificateSettingsElement, 'THUMBPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (thumbprintElement !== null && thumbprintElement !== undefined) {
                          var thumbprintInstance = thumbprintElement;
                          certificateSettingInstance.thumbprint = thumbprintInstance;
                        }
                      }
                    }
                    
                    var winRMElement = js2xml.getElement(responseDoc, configurationSetsElement, 'WINRM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (winRMElement !== null && winRMElement !== undefined) {
                      var winRMInstance = { listeners: [] };
                      configurationSetInstance.windowsRemoteManagement = winRMInstance;
                      
                      var listenersSequenceElement = js2xml.getElement(responseDoc, winRMElement, 'LISTENERS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (listenersSequenceElement !== null && listenersSequenceElement !== undefined) {
                        for (var loweredIndex22 = 0; loweredIndex22 < js2xml.getElements(responseDoc, listenersSequenceElement, 'LISTENER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex22 = loweredIndex22 + 1) {
                          var listenersElement = js2xml.getElements(responseDoc, listenersSequenceElement, 'LISTENER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex22];
                          var listenerInstance = {};
                          winRMInstance.listeners.push(listenerInstance);
                          
                          var protocolElement4 = js2xml.getElement(responseDoc, listenersElement, 'PROTOCOL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (protocolElement4 !== null && protocolElement4 !== undefined && protocolElement4.length !== 0) {
                            var protocolInstance4 = protocolElement4;
                            listenerInstance.listenerType = protocolInstance4;
                          }
                          
                          var certificateThumbprintElement = js2xml.getElement(responseDoc, listenersElement, 'CERTIFICATETHUMBPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (certificateThumbprintElement !== null && certificateThumbprintElement !== undefined) {
                            var certificateThumbprintInstance = certificateThumbprintElement;
                            listenerInstance.certificateThumbprint = certificateThumbprintInstance;
                          }
                        }
                      }
                    }
                    
                    var adminUsernameElement = js2xml.getElement(responseDoc, configurationSetsElement, 'ADMINUSERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (adminUsernameElement !== null && adminUsernameElement !== undefined) {
                      var adminUsernameInstance = adminUsernameElement;
                      configurationSetInstance.adminUserName = adminUsernameInstance;
                    }
                    
                    var additionalUnattendContentElement = js2xml.getElement(responseDoc, configurationSetsElement, 'ADDITIONALUNATTENDCONTENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (additionalUnattendContentElement !== null && additionalUnattendContentElement !== undefined) {
                      var additionalUnattendContentInstance = { unattendPasses: [] };
                      configurationSetInstance.additionalUnattendContent = additionalUnattendContentInstance;
                      
                      var passesSequenceElement = js2xml.getElement(responseDoc, additionalUnattendContentElement, 'PASSES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (passesSequenceElement !== null && passesSequenceElement !== undefined) {
                        for (var loweredIndex23 = 0; loweredIndex23 < js2xml.getElements(responseDoc, passesSequenceElement, 'UNATTENDPASS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex23 = loweredIndex23 + 1) {
                          var passesElement = js2xml.getElements(responseDoc, passesSequenceElement, 'UNATTENDPASS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex23];
                          var unattendPassInstance = { unattendComponents: [] };
                          additionalUnattendContentInstance.unattendPasses.push(unattendPassInstance);
                          
                          var passNameElement = js2xml.getElement(responseDoc, passesElement, 'PASSNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (passNameElement !== null && passNameElement !== undefined) {
                            var passNameInstance = passNameElement;
                            unattendPassInstance.passName = passNameInstance;
                          }
                          
                          var componentsSequenceElement = js2xml.getElement(responseDoc, passesElement, 'COMPONENTS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (componentsSequenceElement !== null && componentsSequenceElement !== undefined) {
                            for (var loweredIndex24 = 0; loweredIndex24 < js2xml.getElements(responseDoc, componentsSequenceElement, 'UNATTENDCOMPONENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex24 = loweredIndex24 + 1) {
                              var componentsElement = js2xml.getElements(responseDoc, componentsSequenceElement, 'UNATTENDCOMPONENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex24];
                              var unattendComponentInstance = { unattendComponentSettings: [] };
                              unattendPassInstance.unattendComponents.push(unattendComponentInstance);
                              
                              var componentNameElement = js2xml.getElement(responseDoc, componentsElement, 'COMPONENTNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (componentNameElement !== null && componentNameElement !== undefined) {
                                var componentNameInstance = componentNameElement;
                                unattendComponentInstance.componentName = componentNameInstance;
                              }
                              
                              var componentSettingsSequenceElement = js2xml.getElement(responseDoc, componentsElement, 'COMPONENTSETTINGS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (componentSettingsSequenceElement !== null && componentSettingsSequenceElement !== undefined) {
                                for (var loweredIndex25 = 0; loweredIndex25 < js2xml.getElements(responseDoc, componentSettingsSequenceElement, 'COMPONENTSETTING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex25 = loweredIndex25 + 1) {
                                  var componentSettingsElement = js2xml.getElements(responseDoc, componentSettingsSequenceElement, 'COMPONENTSETTING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex25];
                                  var componentSettingInstance = {};
                                  unattendComponentInstance.unattendComponentSettings.push(componentSettingInstance);
                                  
                                  var settingNameElement = js2xml.getElement(responseDoc, componentSettingsElement, 'SETTINGNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                                  if (settingNameElement !== null && settingNameElement !== undefined) {
                                    var settingNameInstance = settingNameElement;
                                    componentSettingInstance.settingName = settingNameInstance;
                                  }
                                  
                                  var contentElement = js2xml.getElement(responseDoc, componentSettingsElement, 'CONTENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                                  if (contentElement !== null && contentElement !== undefined) {
                                    var contentInstance = new Buffer(contentElement, 'base64').toString('utf8');
                                    componentSettingInstance.content = contentInstance;
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                    
                    var hostNameElement2 = js2xml.getElement(responseDoc, configurationSetsElement, 'HOSTNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (hostNameElement2 !== null && hostNameElement2 !== undefined) {
                      var hostNameInstance2 = hostNameElement2;
                      configurationSetInstance.hostName = hostNameInstance2;
                    }
                    
                    var userNameElement = js2xml.getElement(responseDoc, configurationSetsElement, 'USERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (userNameElement !== null && userNameElement !== undefined) {
                      var userNameInstance = userNameElement;
                      configurationSetInstance.userName = userNameInstance;
                    }
                    
                    var userPasswordElement = js2xml.getElement(responseDoc, configurationSetsElement, 'USERPASSWORD', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (userPasswordElement !== null && userPasswordElement !== undefined) {
                      var userPasswordInstance = userPasswordElement;
                      configurationSetInstance.userPassword = userPasswordInstance;
                    }
                    
                    var disableSshPasswordAuthenticationElement = js2xml.getElement(responseDoc, configurationSetsElement, 'DISABLESSHPASSWORDAUTHENTICATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (disableSshPasswordAuthenticationElement !== null && disableSshPasswordAuthenticationElement !== undefined && disableSshPasswordAuthenticationElement.length !== 0) {
                      var disableSshPasswordAuthenticationInstance = disableSshPasswordAuthenticationElement === 'true';
                      configurationSetInstance.disableSshPasswordAuthentication = disableSshPasswordAuthenticationInstance;
                    }
                    
                    var sSHElement = js2xml.getElement(responseDoc, configurationSetsElement, 'SSH', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (sSHElement !== null && sSHElement !== undefined) {
                      var sSHInstance = { keyPairs: [], publicKeys: [] };
                      configurationSetInstance.sshSettings = sSHInstance;
                      
                      var publicKeysSequenceElement = js2xml.getElement(responseDoc, sSHElement, 'PUBLICKEYS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (publicKeysSequenceElement !== null && publicKeysSequenceElement !== undefined) {
                        for (var loweredIndex26 = 0; loweredIndex26 < js2xml.getElements(responseDoc, publicKeysSequenceElement, 'PUBLICKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex26 = loweredIndex26 + 1) {
                          var publicKeysElement = js2xml.getElements(responseDoc, publicKeysSequenceElement, 'PUBLICKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex26];
                          var publicKeyInstance = {};
                          sSHInstance.publicKeys.push(publicKeyInstance);
                          
                          var fingerprintElement = js2xml.getElement(responseDoc, publicKeysElement, 'FINGERPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (fingerprintElement !== null && fingerprintElement !== undefined) {
                            var fingerprintInstance = fingerprintElement;
                            publicKeyInstance.fingerprint = fingerprintInstance;
                          }
                          
                          var pathElement2 = js2xml.getElement(responseDoc, publicKeysElement, 'PATH', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (pathElement2 !== null && pathElement2 !== undefined) {
                            var pathInstance2 = pathElement2;
                            publicKeyInstance.path = pathInstance2;
                          }
                        }
                      }
                      
                      var keyPairsSequenceElement = js2xml.getElement(responseDoc, sSHElement, 'KEYPAIRS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (keyPairsSequenceElement !== null && keyPairsSequenceElement !== undefined) {
                        for (var loweredIndex27 = 0; loweredIndex27 < js2xml.getElements(responseDoc, keyPairsSequenceElement, 'KEYPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex27 = loweredIndex27 + 1) {
                          var keyPairsElement = js2xml.getElements(responseDoc, keyPairsSequenceElement, 'KEYPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex27];
                          var keyPairInstance = {};
                          sSHInstance.keyPairs.push(keyPairInstance);
                          
                          var fingerprintElement2 = js2xml.getElement(responseDoc, keyPairsElement, 'FINGERPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (fingerprintElement2 !== null && fingerprintElement2 !== undefined) {
                            var fingerprintInstance2 = fingerprintElement2;
                            keyPairInstance.fingerprint = fingerprintInstance2;
                          }
                          
                          var pathElement3 = js2xml.getElement(responseDoc, keyPairsElement, 'PATH', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (pathElement3 !== null && pathElement3 !== undefined) {
                            var pathInstance3 = pathElement3;
                            keyPairInstance.path = pathInstance3;
                          }
                        }
                      }
                    }
                    
                    var customDataElement = js2xml.getElement(responseDoc, configurationSetsElement, 'CUSTOMDATA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (customDataElement !== null && customDataElement !== undefined) {
                      var customDataInstance = customDataElement;
                      configurationSetInstance.customData = customDataInstance;
                    }
                  }
                }
                
                var resourceExtensionReferencesSequenceElement = js2xml.getElement(responseDoc, roleListElement, 'RESOURCEEXTENSIONREFERENCES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (resourceExtensionReferencesSequenceElement !== null && resourceExtensionReferencesSequenceElement !== undefined) {
                  for (var loweredIndex28 = 0; loweredIndex28 < js2xml.getElements(responseDoc, resourceExtensionReferencesSequenceElement, 'RESOURCEEXTENSIONREFERENCE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex28 = loweredIndex28 + 1) {
                    var resourceExtensionReferencesElement = js2xml.getElements(responseDoc, resourceExtensionReferencesSequenceElement, 'RESOURCEEXTENSIONREFERENCE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex28];
                    var resourceExtensionReferenceInstance = { resourceExtensionParameterValues: [] };
                    roleInstance.resourceExtensionReferences.push(resourceExtensionReferenceInstance);
                    
                    var referenceNameElement = js2xml.getElement(responseDoc, resourceExtensionReferencesElement, 'REFERENCENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (referenceNameElement !== null && referenceNameElement !== undefined) {
                      var referenceNameInstance = referenceNameElement;
                      resourceExtensionReferenceInstance.referenceName = referenceNameInstance;
                    }
                    
                    var publisherElement = js2xml.getElement(responseDoc, resourceExtensionReferencesElement, 'PUBLISHER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (publisherElement !== null && publisherElement !== undefined) {
                      var publisherInstance = publisherElement;
                      resourceExtensionReferenceInstance.publisher = publisherInstance;
                    }
                    
                    var nameElement10 = js2xml.getElement(responseDoc, resourceExtensionReferencesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (nameElement10 !== null && nameElement10 !== undefined) {
                      var nameInstance10 = nameElement10;
                      resourceExtensionReferenceInstance.name = nameInstance10;
                    }
                    
                    var versionElement2 = js2xml.getElement(responseDoc, resourceExtensionReferencesElement, 'VERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (versionElement2 !== null && versionElement2 !== undefined) {
                      var versionInstance2 = versionElement2;
                      resourceExtensionReferenceInstance.version = versionInstance2;
                    }
                    
                    var resourceExtensionParameterValuesSequenceElement = js2xml.getElement(responseDoc, resourceExtensionReferencesElement, 'RESOURCEEXTENSIONPARAMETERVALUES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (resourceExtensionParameterValuesSequenceElement !== null && resourceExtensionParameterValuesSequenceElement !== undefined) {
                      for (var loweredIndex29 = 0; loweredIndex29 < js2xml.getElements(responseDoc, resourceExtensionParameterValuesSequenceElement, 'RESOURCEEXTENSIONPARAMETERVALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex29 = loweredIndex29 + 1) {
                        var resourceExtensionParameterValuesElement = js2xml.getElements(responseDoc, resourceExtensionParameterValuesSequenceElement, 'RESOURCEEXTENSIONPARAMETERVALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex29];
                        var resourceExtensionParameterValueInstance = {};
                        resourceExtensionReferenceInstance.resourceExtensionParameterValues.push(resourceExtensionParameterValueInstance);
                        
                        var keyElement = js2xml.getElement(responseDoc, resourceExtensionParameterValuesElement, 'KEY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (keyElement !== null && keyElement !== undefined) {
                          var keyInstance = keyElement;
                          resourceExtensionParameterValueInstance.key = keyInstance;
                        }
                        
                        var valueElement = js2xml.getElement(responseDoc, resourceExtensionParameterValuesElement, 'VALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (valueElement !== null && valueElement !== undefined) {
                          var valueInstance = new Buffer(valueElement, 'base64').toString('utf8');
                          resourceExtensionParameterValueInstance.value = valueInstance;
                        }
                        
                        var typeElement = js2xml.getElement(responseDoc, resourceExtensionParameterValuesElement, 'TYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (typeElement !== null && typeElement !== undefined) {
                          var typeInstance = typeElement;
                          resourceExtensionParameterValueInstance.type = typeInstance;
                        }
                      }
                    }
                    
                    var stateElement = js2xml.getElement(responseDoc, resourceExtensionReferencesElement, 'STATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (stateElement !== null && stateElement !== undefined) {
                      var stateInstance = stateElement;
                      resourceExtensionReferenceInstance.state = stateInstance;
                    }
                    
                    var forceUpdateElement = js2xml.getElement(responseDoc, resourceExtensionReferencesElement, 'FORCEUPDATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (forceUpdateElement !== null && forceUpdateElement !== undefined && forceUpdateElement.length !== 0) {
                      var forceUpdateInstance = forceUpdateElement === 'true';
                      resourceExtensionReferenceInstance.forceUpdate = forceUpdateInstance;
                    }
                  }
                }
                
                var vMImageNameElement = js2xml.getElement(responseDoc, roleListElement, 'VMIMAGENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (vMImageNameElement !== null && vMImageNameElement !== undefined) {
                  var vMImageNameInstance = vMImageNameElement;
                  roleInstance.vMImageName = vMImageNameInstance;
                }
                
                var mediaLocationElement = js2xml.getElement(responseDoc, roleListElement, 'MEDIALOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (mediaLocationElement !== null && mediaLocationElement !== undefined) {
                  var mediaLocationInstance = mediaLocationElement;
                  roleInstance.mediaLocation = mediaLocationInstance;
                }
                
                var availabilitySetNameElement = js2xml.getElement(responseDoc, roleListElement, 'AVAILABILITYSETNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (availabilitySetNameElement !== null && availabilitySetNameElement !== undefined) {
                  var availabilitySetNameInstance = availabilitySetNameElement;
                  roleInstance.availabilitySetName = availabilitySetNameInstance;
                }
                
                var dataVirtualHardDisksSequenceElement = js2xml.getElement(responseDoc, roleListElement, 'DATAVIRTUALHARDDISKS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (dataVirtualHardDisksSequenceElement !== null && dataVirtualHardDisksSequenceElement !== undefined) {
                  for (var loweredIndex30 = 0; loweredIndex30 < js2xml.getElements(responseDoc, dataVirtualHardDisksSequenceElement, 'DATAVIRTUALHARDDISK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex30 = loweredIndex30 + 1) {
                    var dataVirtualHardDisksElement = js2xml.getElements(responseDoc, dataVirtualHardDisksSequenceElement, 'DATAVIRTUALHARDDISK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex30];
                    var dataVirtualHardDiskInstance = {};
                    roleInstance.dataVirtualHardDisks.push(dataVirtualHardDiskInstance);
                    
                    var hostCachingElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'HOSTCACHING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (hostCachingElement !== null && hostCachingElement !== undefined) {
                      var hostCachingInstance = hostCachingElement;
                      dataVirtualHardDiskInstance.hostCaching = hostCachingInstance;
                    }
                    
                    var diskLabelElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'DISKLABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (diskLabelElement !== null && diskLabelElement !== undefined) {
                      var diskLabelInstance = diskLabelElement;
                      dataVirtualHardDiskInstance.label = diskLabelInstance;
                    }
                    
                    var diskNameElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'DISKNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (diskNameElement !== null && diskNameElement !== undefined) {
                      var diskNameInstance = diskNameElement;
                      dataVirtualHardDiskInstance.name = diskNameInstance;
                    }
                    
                    var lunElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'LUN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (lunElement !== null && lunElement !== undefined && lunElement.length !== 0) {
                      var lunInstance = parseInt(lunElement, 10);
                      dataVirtualHardDiskInstance.logicalUnitNumber = lunInstance;
                    }
                    
                    var logicalDiskSizeInGBElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'LOGICALDISKSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (logicalDiskSizeInGBElement !== null && logicalDiskSizeInGBElement !== undefined && logicalDiskSizeInGBElement.length !== 0) {
                      var logicalDiskSizeInGBInstance = parseInt(logicalDiskSizeInGBElement, 10);
                      dataVirtualHardDiskInstance.logicalDiskSizeInGB = logicalDiskSizeInGBInstance;
                    }
                    
                    var mediaLinkElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'MEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (mediaLinkElement !== null && mediaLinkElement !== undefined) {
                      var mediaLinkInstance = mediaLinkElement;
                      dataVirtualHardDiskInstance.mediaLink = mediaLinkInstance;
                    }
                    
                    var sourceMediaLinkElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'SOURCEMEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (sourceMediaLinkElement !== null && sourceMediaLinkElement !== undefined) {
                      var sourceMediaLinkInstance = sourceMediaLinkElement;
                      dataVirtualHardDiskInstance.sourceMediaLink = sourceMediaLinkInstance;
                    }
                    
                    var iOTypeElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'IOTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (iOTypeElement !== null && iOTypeElement !== undefined) {
                      var iOTypeInstance = iOTypeElement;
                      dataVirtualHardDiskInstance.iOType = iOTypeInstance;
                    }
                  }
                }
                
                var labelElement2 = js2xml.getElement(responseDoc, roleListElement, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (labelElement2 !== null && labelElement2 !== undefined) {
                  var labelInstance2 = labelElement2;
                  roleInstance.label = labelInstance2;
                }
                
                var oSVirtualHardDiskElement = js2xml.getElement(responseDoc, roleListElement, 'OSVIRTUALHARDDISK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (oSVirtualHardDiskElement !== null && oSVirtualHardDiskElement !== undefined) {
                  var oSVirtualHardDiskInstance = {};
                  roleInstance.oSVirtualHardDisk = oSVirtualHardDiskInstance;
                  
                  var hostCachingElement2 = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'HOSTCACHING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (hostCachingElement2 !== null && hostCachingElement2 !== undefined) {
                    var hostCachingInstance2 = hostCachingElement2;
                    oSVirtualHardDiskInstance.hostCaching = hostCachingInstance2;
                  }
                  
                  var diskLabelElement2 = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'DISKLABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (diskLabelElement2 !== null && diskLabelElement2 !== undefined) {
                    var diskLabelInstance2 = diskLabelElement2;
                    oSVirtualHardDiskInstance.label = diskLabelInstance2;
                  }
                  
                  var diskNameElement2 = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'DISKNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (diskNameElement2 !== null && diskNameElement2 !== undefined) {
                    var diskNameInstance2 = diskNameElement2;
                    oSVirtualHardDiskInstance.name = diskNameInstance2;
                  }
                  
                  var mediaLinkElement2 = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'MEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (mediaLinkElement2 !== null && mediaLinkElement2 !== undefined) {
                    var mediaLinkInstance2 = mediaLinkElement2;
                    oSVirtualHardDiskInstance.mediaLink = mediaLinkInstance2;
                  }
                  
                  var sourceImageNameElement = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'SOURCEIMAGENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (sourceImageNameElement !== null && sourceImageNameElement !== undefined) {
                    var sourceImageNameInstance = sourceImageNameElement;
                    oSVirtualHardDiskInstance.sourceImageName = sourceImageNameInstance;
                  }
                  
                  var osElement = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'OS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (osElement !== null && osElement !== undefined) {
                    var osInstance = osElement;
                    oSVirtualHardDiskInstance.operatingSystem = osInstance;
                  }
                  
                  var remoteSourceImageLinkElement = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'REMOTESOURCEIMAGELINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (remoteSourceImageLinkElement !== null && remoteSourceImageLinkElement !== undefined) {
                    var remoteSourceImageLinkInstance = remoteSourceImageLinkElement;
                    oSVirtualHardDiskInstance.remoteSourceImageLink = remoteSourceImageLinkInstance;
                  }
                  
                  var iOTypeElement2 = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'IOTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (iOTypeElement2 !== null && iOTypeElement2 !== undefined) {
                    var iOTypeInstance2 = iOTypeElement2;
                    oSVirtualHardDiskInstance.iOType = iOTypeInstance2;
                  }
                  
                  var resizedSizeInGBElement = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'RESIZEDSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (resizedSizeInGBElement !== null && resizedSizeInGBElement !== undefined && resizedSizeInGBElement.length !== 0) {
                    var resizedSizeInGBInstance = parseInt(resizedSizeInGBElement, 10);
                    oSVirtualHardDiskInstance.resizedSizeInGB = resizedSizeInGBInstance;
                  }
                }
                
                var roleSizeElement = js2xml.getElement(responseDoc, roleListElement, 'ROLESIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (roleSizeElement !== null && roleSizeElement !== undefined) {
                  var roleSizeInstance = roleSizeElement;
                  roleInstance.roleSize = roleSizeInstance;
                }
                
                var defaultWinRmCertificateThumbprintElement = js2xml.getElement(responseDoc, roleListElement, 'DEFAULTWINRMCERTIFICATETHUMBPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (defaultWinRmCertificateThumbprintElement !== null && defaultWinRmCertificateThumbprintElement !== undefined) {
                  var defaultWinRmCertificateThumbprintInstance = defaultWinRmCertificateThumbprintElement;
                  roleInstance.defaultWinRmCertificateThumbprint = defaultWinRmCertificateThumbprintInstance;
                }
                
                var provisionGuestAgentElement = js2xml.getElement(responseDoc, roleListElement, 'PROVISIONGUESTAGENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (provisionGuestAgentElement !== null && provisionGuestAgentElement !== undefined && provisionGuestAgentElement.length !== 0) {
                  var provisionGuestAgentInstance = provisionGuestAgentElement === 'true';
                  roleInstance.provisionGuestAgent = provisionGuestAgentInstance;
                }
                
                var vMImageInputElement = js2xml.getElement(responseDoc, roleListElement, 'VMIMAGEINPUT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (vMImageInputElement !== null && vMImageInputElement !== undefined) {
                  var vMImageInputInstance = { dataDiskConfigurations: [] };
                  roleInstance.vMImageInput = vMImageInputInstance;
                  
                  var oSDiskConfigurationElement = js2xml.getElement(responseDoc, vMImageInputElement, 'OSDISKCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (oSDiskConfigurationElement !== null && oSDiskConfigurationElement !== undefined) {
                    var oSDiskConfigurationInstance = {};
                    vMImageInputInstance.oSDiskConfiguration = oSDiskConfigurationInstance;
                    
                    var resizedSizeInGBElement2 = js2xml.getElement(responseDoc, oSDiskConfigurationElement, 'RESIZEDSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (resizedSizeInGBElement2 !== null && resizedSizeInGBElement2 !== undefined && resizedSizeInGBElement2.length !== 0) {
                      var resizedSizeInGBInstance2 = parseInt(resizedSizeInGBElement2, 10);
                      oSDiskConfigurationInstance.resizedSizeInGB = resizedSizeInGBInstance2;
                    }
                  }
                  
                  var dataDiskConfigurationsSequenceElement = js2xml.getElement(responseDoc, vMImageInputElement, 'DATADISKCONFIGURATIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (dataDiskConfigurationsSequenceElement !== null && dataDiskConfigurationsSequenceElement !== undefined) {
                    for (var loweredIndex31 = 0; loweredIndex31 < js2xml.getElements(responseDoc, dataDiskConfigurationsSequenceElement, 'DATADISKCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex31 = loweredIndex31 + 1) {
                      var dataDiskConfigurationsElement = js2xml.getElements(responseDoc, dataDiskConfigurationsSequenceElement, 'DATADISKCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex31];
                      var dataDiskConfigurationInstance = {};
                      vMImageInputInstance.dataDiskConfigurations.push(dataDiskConfigurationInstance);
                      
                      var nameElement11 = js2xml.getElement(responseDoc, dataDiskConfigurationsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (nameElement11 !== null && nameElement11 !== undefined) {
                        var nameInstance11 = nameElement11;
                        dataDiskConfigurationInstance.diskName = nameInstance11;
                      }
                      
                      var resizedSizeInGBElement3 = js2xml.getElement(responseDoc, dataDiskConfigurationsElement, 'RESIZEDSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (resizedSizeInGBElement3 !== null && resizedSizeInGBElement3 !== undefined && resizedSizeInGBElement3.length !== 0) {
                        var resizedSizeInGBInstance3 = parseInt(resizedSizeInGBElement3, 10);
                        dataDiskConfigurationInstance.resizedSizeInGB = resizedSizeInGBInstance3;
                      }
                    }
                  }
                }
                
                var debugSettingsElement = js2xml.getElement(responseDoc, roleListElement, 'DEBUGSETTINGS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (debugSettingsElement !== null && debugSettingsElement !== undefined) {
                  var debugSettingsInstance = {};
                  roleInstance.debugSettings = debugSettingsInstance;
                  
                  var bootDiagnosticsEnabledElement = js2xml.getElement(responseDoc, debugSettingsElement, 'BOOTDIAGNOSTICSENABLED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (bootDiagnosticsEnabledElement !== null && bootDiagnosticsEnabledElement !== undefined && bootDiagnosticsEnabledElement.length !== 0) {
                    var bootDiagnosticsEnabledInstance = bootDiagnosticsEnabledElement === 'true';
                    debugSettingsInstance.bootDiagnosticsEnabled = bootDiagnosticsEnabledInstance;
                  }
                  
                  var consoleScreenshotBlobUriElement = js2xml.getElement(responseDoc, debugSettingsElement, 'CONSOLESCREENSHOTBLOBURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (consoleScreenshotBlobUriElement !== null && consoleScreenshotBlobUriElement !== undefined) {
                    var consoleScreenshotBlobUriInstance = consoleScreenshotBlobUriElement;
                    debugSettingsInstance.consoleScreenshotBlobUri = consoleScreenshotBlobUriInstance;
                  }
                  
                  var serialOutputBlobUriElement = js2xml.getElement(responseDoc, debugSettingsElement, 'SERIALOUTPUTBLOBURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (serialOutputBlobUriElement !== null && serialOutputBlobUriElement !== undefined) {
                    var serialOutputBlobUriInstance = serialOutputBlobUriElement;
                    debugSettingsInstance.serialOutputBlobUri = serialOutputBlobUriInstance;
                  }
                }
                
                var licenseTypeElement = js2xml.getElement(responseDoc, roleListElement, 'LICENSETYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (licenseTypeElement !== null && licenseTypeElement !== undefined) {
                  var licenseTypeInstance = licenseTypeElement;
                  roleInstance.licenseType = licenseTypeInstance;
                }
                
                var migrationStateElement = js2xml.getElement(responseDoc, roleListElement, 'MIGRATIONSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (migrationStateElement !== null && migrationStateElement !== undefined) {
                  var migrationStateInstance = migrationStateElement;
                  roleInstance.migrationState = migrationStateInstance;
                }
              }
            }
            
            var sdkVersionElement = js2xml.getElement(responseDoc, deploymentElement, 'SDKVERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (sdkVersionElement !== null && sdkVersionElement !== undefined) {
              var sdkVersionInstance = sdkVersionElement;
              result.sdkVersion = sdkVersionInstance;
            }
            
            var lockedElement = js2xml.getElement(responseDoc, deploymentElement, 'LOCKED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (lockedElement !== null && lockedElement !== undefined && lockedElement.length !== 0) {
              var lockedInstance = lockedElement === 'true';
              result.locked = lockedInstance;
            }
            
            var rollbackAllowedElement = js2xml.getElement(responseDoc, deploymentElement, 'ROLLBACKALLOWED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (rollbackAllowedElement !== null && rollbackAllowedElement !== undefined && rollbackAllowedElement.length !== 0) {
              var rollbackAllowedInstance = rollbackAllowedElement === 'true';
              result.rollbackAllowed = rollbackAllowedInstance;
            }
            
            var virtualNetworkNameElement = js2xml.getElement(responseDoc, deploymentElement, 'VIRTUALNETWORKNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (virtualNetworkNameElement !== null && virtualNetworkNameElement !== undefined) {
              var virtualNetworkNameInstance = virtualNetworkNameElement;
              result.virtualNetworkName = virtualNetworkNameInstance;
            }
            
            var createdTimeElement = js2xml.getElement(responseDoc, deploymentElement, 'CREATEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (createdTimeElement !== null && createdTimeElement !== undefined && createdTimeElement.length !== 0) {
              var createdTimeInstance = new Date(createdTimeElement);
              result.createdTime = createdTimeInstance;
            }
            
            var lastModifiedTimeElement = js2xml.getElement(responseDoc, deploymentElement, 'LASTMODIFIEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (lastModifiedTimeElement !== null && lastModifiedTimeElement !== undefined && lastModifiedTimeElement.length !== 0) {
              var lastModifiedTimeInstance = new Date(lastModifiedTimeElement);
              result.lastModifiedTime = lastModifiedTimeInstance;
            }
            
            var extendedPropertiesSequenceElement = js2xml.getElement(responseDoc, deploymentElement, 'EXTENDEDPROPERTIES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (extendedPropertiesSequenceElement !== null && extendedPropertiesSequenceElement !== undefined) {
              for (var loweredIndex32 = 0; loweredIndex32 < js2xml.getElements(responseDoc, extendedPropertiesSequenceElement, 'EXTENDEDPROPERTY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex32 = loweredIndex32 + 1) {
                var extendedPropertiesElement = js2xml.getElements(responseDoc, extendedPropertiesSequenceElement, 'EXTENDEDPROPERTY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex32];
                var extendedPropertiesKey = js2xml.getElement(responseDoc, extendedPropertiesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                var extendedPropertiesValue = js2xml.getElement(responseDoc, extendedPropertiesElement, 'VALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                result.extendedProperties[extendedPropertiesKey] = extendedPropertiesValue;
              }
            }
            
            var dnsElement = js2xml.getElement(responseDoc, deploymentElement, 'DNS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (dnsElement !== null && dnsElement !== undefined) {
              var dnsInstance = { dnsServers: [] };
              result.dnsSettings = dnsInstance;
              
              var dnsServersSequenceElement = js2xml.getElement(responseDoc, dnsElement, 'DNSSERVERS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (dnsServersSequenceElement !== null && dnsServersSequenceElement !== undefined) {
                for (var loweredIndex33 = 0; loweredIndex33 < js2xml.getElements(responseDoc, dnsServersSequenceElement, 'DNSSERVER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex33 = loweredIndex33 + 1) {
                  var dnsServersElement = js2xml.getElements(responseDoc, dnsServersSequenceElement, 'DNSSERVER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex33];
                  var dnsServerInstance = {};
                  dnsInstance.dnsServers.push(dnsServerInstance);
                  
                  var nameElement12 = js2xml.getElement(responseDoc, dnsServersElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (nameElement12 !== null && nameElement12 !== undefined) {
                    var nameInstance12 = nameElement12;
                    dnsServerInstance.name = nameInstance12;
                  }
                  
                  var addressElement3 = js2xml.getElement(responseDoc, dnsServersElement, 'ADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (addressElement3 !== null && addressElement3 !== undefined) {
                    var addressInstance3 = addressElement3;
                    dnsServerInstance.address = addressInstance3;
                  }
                }
              }
            }
            
            var persistentVMDowntimeElement = js2xml.getElement(responseDoc, deploymentElement, 'PERSISTENTVMDOWNTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (persistentVMDowntimeElement !== null && persistentVMDowntimeElement !== undefined) {
              var persistentVMDowntimeInstance = {};
              result.persistentVMDowntime = persistentVMDowntimeInstance;
              
              var startTimeElement = js2xml.getElement(responseDoc, persistentVMDowntimeElement, 'STARTTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (startTimeElement !== null && startTimeElement !== undefined && startTimeElement.length !== 0) {
                var startTimeInstance = new Date(startTimeElement);
                persistentVMDowntimeInstance.startTime = startTimeInstance;
              }
              
              var endTimeElement = js2xml.getElement(responseDoc, persistentVMDowntimeElement, 'ENDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (endTimeElement !== null && endTimeElement !== undefined && endTimeElement.length !== 0) {
                var endTimeInstance = new Date(endTimeElement);
                persistentVMDowntimeInstance.endTime = endTimeInstance;
              }
              
              var statusElement6 = js2xml.getElement(responseDoc, persistentVMDowntimeElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (statusElement6 !== null && statusElement6 !== undefined) {
                var statusInstance6 = statusElement6;
                persistentVMDowntimeInstance.status = statusInstance6;
              }
            }
            
            var virtualIPsSequenceElement = js2xml.getElement(responseDoc, deploymentElement, 'VIRTUALIPS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (virtualIPsSequenceElement !== null && virtualIPsSequenceElement !== undefined) {
              for (var loweredIndex34 = 0; loweredIndex34 < js2xml.getElements(responseDoc, virtualIPsSequenceElement, 'VIRTUALIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex34 = loweredIndex34 + 1) {
                var virtualIPsElement = js2xml.getElements(responseDoc, virtualIPsSequenceElement, 'VIRTUALIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex34];
                var virtualIPInstance = {};
                result.virtualIPAddresses.push(virtualIPInstance);
                
                var addressElement4 = js2xml.getElement(responseDoc, virtualIPsElement, 'ADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (addressElement4 !== null && addressElement4 !== undefined) {
                  var addressInstance4 = addressElement4;
                  virtualIPInstance.address = addressInstance4;
                }
                
                var isDnsProgrammedElement = js2xml.getElement(responseDoc, virtualIPsElement, 'ISDNSPROGRAMMED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (isDnsProgrammedElement !== null && isDnsProgrammedElement !== undefined && isDnsProgrammedElement.length !== 0) {
                  var isDnsProgrammedInstance = isDnsProgrammedElement === 'true';
                  virtualIPInstance.isDnsProgrammed = isDnsProgrammedInstance;
                }
                
                var nameElement13 = js2xml.getElement(responseDoc, virtualIPsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (nameElement13 !== null && nameElement13 !== undefined) {
                  var nameInstance13 = nameElement13;
                  virtualIPInstance.name = nameInstance13;
                }
                
                var reservedIPNameElement = js2xml.getElement(responseDoc, virtualIPsElement, 'RESERVEDIPNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (reservedIPNameElement !== null && reservedIPNameElement !== undefined) {
                  var reservedIPNameInstance = reservedIPNameElement;
                  virtualIPInstance.reservedIPName = reservedIPNameInstance;
                }
              }
            }
            
            var extensionConfigurationElement = js2xml.getElement(responseDoc, deploymentElement, 'EXTENSIONCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (extensionConfigurationElement !== null && extensionConfigurationElement !== undefined) {
              var extensionConfigurationInstance = { allRoles: [], namedRoles: [] };
              result.extensionConfiguration = extensionConfigurationInstance;
              
              var allRolesSequenceElement = js2xml.getElement(responseDoc, extensionConfigurationElement, 'ALLROLES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (allRolesSequenceElement !== null && allRolesSequenceElement !== undefined) {
                for (var loweredIndex35 = 0; loweredIndex35 < js2xml.getElements(responseDoc, allRolesSequenceElement, 'EXTENSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex35 = loweredIndex35 + 1) {
                  var allRolesElement = js2xml.getElements(responseDoc, allRolesSequenceElement, 'EXTENSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex35];
                  var extensionInstance = {};
                  extensionConfigurationInstance.allRoles.push(extensionInstance);
                  
                  var idElement = js2xml.getElement(responseDoc, allRolesElement, 'ID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (idElement !== null && idElement !== undefined) {
                    var idInstance = idElement;
                    extensionInstance.id = idInstance;
                  }
                  
                  var stateElement2 = js2xml.getElement(responseDoc, allRolesElement, 'STATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (stateElement2 !== null && stateElement2 !== undefined) {
                    var stateInstance2 = stateElement2;
                    extensionInstance.state = stateInstance2;
                  }
                }
              }
              
              var namedRolesSequenceElement = js2xml.getElement(responseDoc, extensionConfigurationElement, 'NAMEDROLES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (namedRolesSequenceElement !== null && namedRolesSequenceElement !== undefined) {
                for (var loweredIndex36 = 0; loweredIndex36 < js2xml.getElements(responseDoc, namedRolesSequenceElement, 'ROLE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex36 = loweredIndex36 + 1) {
                  var namedRolesElement = js2xml.getElements(responseDoc, namedRolesSequenceElement, 'ROLE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex36];
                  var roleInstance2 = { extensions: [] };
                  extensionConfigurationInstance.namedRoles.push(roleInstance2);
                  
                  var roleNameElement3 = js2xml.getElement(responseDoc, namedRolesElement, 'ROLENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (roleNameElement3 !== null && roleNameElement3 !== undefined) {
                    var roleNameInstance3 = roleNameElement3;
                    roleInstance2.roleName = roleNameInstance3;
                  }
                  
                  var extensionsSequenceElement = js2xml.getElement(responseDoc, namedRolesElement, 'EXTENSIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (extensionsSequenceElement !== null && extensionsSequenceElement !== undefined) {
                    for (var loweredIndex37 = 0; loweredIndex37 < js2xml.getElements(responseDoc, extensionsSequenceElement, 'EXTENSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex37 = loweredIndex37 + 1) {
                      var extensionsElement = js2xml.getElements(responseDoc, extensionsSequenceElement, 'EXTENSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex37];
                      var extensionInstance2 = {};
                      roleInstance2.extensions.push(extensionInstance2);
                      
                      var idElement2 = js2xml.getElement(responseDoc, extensionsElement, 'ID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (idElement2 !== null && idElement2 !== undefined) {
                        var idInstance2 = idElement2;
                        extensionInstance2.id = idInstance2;
                      }
                      
                      var stateElement3 = js2xml.getElement(responseDoc, extensionsElement, 'STATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (stateElement3 !== null && stateElement3 !== undefined) {
                        var stateInstance3 = stateElement3;
                        extensionInstance2.state = stateInstance3;
                      }
                    }
                  }
                }
              }
            }
            
            var reservedIPNameElement2 = js2xml.getElement(responseDoc, deploymentElement, 'RESERVEDIPNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (reservedIPNameElement2 !== null && reservedIPNameElement2 !== undefined) {
              var reservedIPNameInstance2 = reservedIPNameElement2;
              result.reservedIPName = reservedIPNameInstance2;
            }
            
            var loadBalancersSequenceElement = js2xml.getElement(responseDoc, deploymentElement, 'LOADBALANCERS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (loadBalancersSequenceElement !== null && loadBalancersSequenceElement !== undefined) {
              for (var loweredIndex38 = 0; loweredIndex38 < js2xml.getElements(responseDoc, loadBalancersSequenceElement, 'LOADBALANCER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex38 = loweredIndex38 + 1) {
                var loadBalancersElement = js2xml.getElements(responseDoc, loadBalancersSequenceElement, 'LOADBALANCER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex38];
                var loadBalancerInstance = {};
                result.loadBalancers.push(loadBalancerInstance);
                
                var nameElement14 = js2xml.getElement(responseDoc, loadBalancersElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (nameElement14 !== null && nameElement14 !== undefined) {
                  var nameInstance14 = nameElement14;
                  loadBalancerInstance.name = nameInstance14;
                }
                
                var frontendIpConfigurationElement = js2xml.getElement(responseDoc, loadBalancersElement, 'FRONTENDIPCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (frontendIpConfigurationElement !== null && frontendIpConfigurationElement !== undefined) {
                  var frontendIpConfigurationInstance = {};
                  loadBalancerInstance.frontendIPConfiguration = frontendIpConfigurationInstance;
                  
                  var typeElement2 = js2xml.getElement(responseDoc, frontendIpConfigurationElement, 'TYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (typeElement2 !== null && typeElement2 !== undefined) {
                    var typeInstance2 = typeElement2;
                    frontendIpConfigurationInstance.type = typeInstance2;
                  }
                  
                  var subnetNameElement3 = js2xml.getElement(responseDoc, frontendIpConfigurationElement, 'SUBNETNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (subnetNameElement3 !== null && subnetNameElement3 !== undefined) {
                    var subnetNameInstance3 = subnetNameElement3;
                    frontendIpConfigurationInstance.subnetName = subnetNameInstance3;
                  }
                  
                  var staticVirtualNetworkIPAddressElement3 = js2xml.getElement(responseDoc, frontendIpConfigurationElement, 'STATICVIRTUALNETWORKIPADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (staticVirtualNetworkIPAddressElement3 !== null && staticVirtualNetworkIPAddressElement3 !== undefined) {
                    var staticVirtualNetworkIPAddressInstance3 = staticVirtualNetworkIPAddressElement3;
                    frontendIpConfigurationInstance.staticVirtualNetworkIPAddress = staticVirtualNetworkIPAddressInstance3;
                  }
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Get Package By Name operation retrieves a cloud service package for a
   * deployment and stores the package files in Azure Blob storage. The
   * following package files are placed in storage: the cloud service
   * configuration file (.cscfg), providing configuration settings for the
   * cloud service and individual roles, including the number of role
   * instances; and the service package (.cspkg), containing the application
   * code and the service definition file.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj154121.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {DeploymentGetPackageParameters} parameters Parameters supplied to
   * the Get Package By Name operation.
   * 
   * @param {string} parameters.containerUri Specifies the URI of the container
   * to which the packages will be saved.
   * 
   * @param {boolean} [parameters.overwriteExisting] Specifies whether an
   * existing package in the storage container should be overwritten.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.getPackageByName = function(serviceName, deploymentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.deployments.beginGettingPackageByName(serviceName, deploymentName, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Get Package By Slot operation retrieves a cloud service package for a
   * deployment and stores the package files in Azure Blob storage. The
   * following package files are placed in storage: the cloud service
   * configuration file (.cscfg), providing configuration settings for the
   * cloud service and individual roles, including the number of role
   * instances; and the service package (.cspkg), containing the application
   * code and the service definition file.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj154121.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {DeploymentSlot} deploymentSlot The deployment slot.
   * 
   * @param {DeploymentGetPackageParameters} parameters Parameters supplied to
   * the Get Package By Slot operation.
   * 
   * @param {string} parameters.containerUri Specifies the URI of the container
   * to which the packages will be saved.
   * 
   * @param {boolean} [parameters.overwriteExisting] Specifies whether an
   * existing package in the storage container should be overwritten.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.getPackageBySlot = function(serviceName, deploymentSlot, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.deployments.beginGettingPackageBySlot(serviceName, deploymentSlot, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * Identifies the list of reboot events due to planned maintenance that
   * impacted a deployment in the optionally provided timeframe.
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {string} deploymentName The name of the deployment.
   * 
   * @param {Date} startTime Datetime in UTC representing the start time of the
   * query.
   * 
   * @param {Date} endTime Datetime in UTC representing the end time of the
   * query.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.listEvents = function(serviceName, deploymentName, startTime, endTime, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (startTime === null || startTime === undefined) {
      return callback(new Error('startTime cannot be null.'));
    }
    if (endTime === null || endTime === undefined) {
      return callback(new Error('endTime cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/events';
    var queryParameters = [];
    queryParameters.push('starttime=' + encodeURIComponent(startTime.toISOString()));
    queryParameters.push('endtime=' + encodeURIComponent(endTime.toISOString()));
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { deploymentEvents: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var deploymentEventCollectionElement = js2xml.getElement(responseDoc, responseDoc, 'DEPLOYMENTEVENTCOLLECTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (deploymentEventCollectionElement !== null && deploymentEventCollectionElement !== undefined) {
            var rebootEventsSequenceElement = js2xml.getElement(responseDoc, deploymentEventCollectionElement, 'REBOOTEVENTS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (rebootEventsSequenceElement !== null && rebootEventsSequenceElement !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, rebootEventsSequenceElement, 'REBOOTEVENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
                var rebootEventsElement = js2xml.getElements(responseDoc, rebootEventsSequenceElement, 'REBOOTEVENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
                var rebootEventInstance = {};
                result.deploymentEvents.push(rebootEventInstance);
                
                var roleNameElement = js2xml.getElement(responseDoc, rebootEventsElement, 'ROLENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (roleNameElement !== null && roleNameElement !== undefined) {
                  var roleNameInstance = roleNameElement;
                  rebootEventInstance.roleName = roleNameInstance;
                }
                
                var instanceNameElement = js2xml.getElement(responseDoc, rebootEventsElement, 'INSTANCENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (instanceNameElement !== null && instanceNameElement !== undefined) {
                  var instanceNameInstance = instanceNameElement;
                  rebootEventInstance.instanceName = instanceNameInstance;
                }
                
                var rebootReasonElement = js2xml.getElement(responseDoc, rebootEventsElement, 'REBOOTREASON', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (rebootReasonElement !== null && rebootReasonElement !== undefined) {
                  var rebootReasonInstance = rebootReasonElement;
                  rebootEventInstance.rebootReason = rebootReasonInstance;
                }
                
                var rebootStartTimeElement = js2xml.getElement(responseDoc, rebootEventsElement, 'REBOOTSTARTTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (rebootStartTimeElement !== null && rebootStartTimeElement !== undefined && rebootStartTimeElement.length !== 0) {
                  var rebootStartTimeInstance = new Date(rebootStartTimeElement);
                  rebootEventInstance.rebootStartTime = rebootStartTimeInstance;
                }
              }
            }
            
            var continuationTokenElement = js2xml.getElement(responseDoc, deploymentEventCollectionElement, 'CONTINUATIONTOKEN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (continuationTokenElement !== null && continuationTokenElement !== undefined) {
              var continuationTokenInstance = continuationTokenElement;
              result.continuationToken = continuationTokenInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Identifies the list of reboot events due to planned maintenance that
   * impacted a deployment in the optionally provided timeframe.
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {DeploymentSlot} deploymentSlot The deployment slot.
   * 
   * @param {Date} startTime Datetime in UTC representing the start time of the
   * query.
   * 
   * @param {Date} endTime Datetime in UTC representing the end time of the
   * query.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.listEventsBySlot = function(serviceName, deploymentSlot, startTime, endTime, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentSlot === null || deploymentSlot === undefined) {
      return callback(new Error('deploymentSlot cannot be null.'));
    }
    if (startTime === null || startTime === undefined) {
      return callback(new Error('startTime cannot be null.'));
    }
    if (endTime === null || endTime === undefined) {
      return callback(new Error('endTime cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deploymentslots/';
    url2 = url2 + encodeURIComponent(deploymentSlot !== null && deploymentSlot !== undefined ? deploymentSlot.toString() : 'Staging');
    url2 = url2 + '/events';
    var queryParameters = [];
    queryParameters.push('starttime=' + encodeURIComponent(startTime.toISOString()));
    queryParameters.push('endtime=' + encodeURIComponent(endTime.toISOString()));
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { deploymentEvents: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var deploymentEventCollectionElement = js2xml.getElement(responseDoc, responseDoc, 'DEPLOYMENTEVENTCOLLECTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (deploymentEventCollectionElement !== null && deploymentEventCollectionElement !== undefined) {
            var rebootEventsSequenceElement = js2xml.getElement(responseDoc, deploymentEventCollectionElement, 'REBOOTEVENTS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (rebootEventsSequenceElement !== null && rebootEventsSequenceElement !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, rebootEventsSequenceElement, 'REBOOTEVENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
                var rebootEventsElement = js2xml.getElements(responseDoc, rebootEventsSequenceElement, 'REBOOTEVENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
                var rebootEventInstance = {};
                result.deploymentEvents.push(rebootEventInstance);
                
                var roleNameElement = js2xml.getElement(responseDoc, rebootEventsElement, 'ROLENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (roleNameElement !== null && roleNameElement !== undefined) {
                  var roleNameInstance = roleNameElement;
                  rebootEventInstance.roleName = roleNameInstance;
                }
                
                var instanceNameElement = js2xml.getElement(responseDoc, rebootEventsElement, 'INSTANCENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (instanceNameElement !== null && instanceNameElement !== undefined) {
                  var instanceNameInstance = instanceNameElement;
                  rebootEventInstance.instanceName = instanceNameInstance;
                }
                
                var rebootReasonElement = js2xml.getElement(responseDoc, rebootEventsElement, 'REBOOTREASON', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (rebootReasonElement !== null && rebootReasonElement !== undefined) {
                  var rebootReasonInstance = rebootReasonElement;
                  rebootEventInstance.rebootReason = rebootReasonInstance;
                }
                
                var rebootStartTimeElement = js2xml.getElement(responseDoc, rebootEventsElement, 'REBOOTSTARTTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (rebootStartTimeElement !== null && rebootStartTimeElement !== undefined && rebootStartTimeElement.length !== 0) {
                  var rebootStartTimeInstance = new Date(rebootStartTimeElement);
                  rebootEventInstance.rebootStartTime = rebootStartTimeInstance;
                }
              }
            }
            
            var continuationTokenElement = js2xml.getElement(responseDoc, deploymentEventCollectionElement, 'CONTINUATIONTOKEN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (continuationTokenElement !== null && continuationTokenElement !== undefined) {
              var continuationTokenInstance = continuationTokenElement;
              result.continuationToken = continuationTokenInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Prepare Deployment Operation validates and prepares your deployment
   * for IaaS Classic to ARM migration.
   * 
   * @param {string} serviceName Name of the cloud service.
   * 
   * @param {string} deploymentName Name of the deployment to be migrated.
   * 
   * @param {PrepareDeploymentMigrationParameters} parameters Deployment
   * Network resource parameters for migration.
   * 
   * @param {string} parameters.resourceGroupName Name of the resource group
   * for migration.
   * 
   * @param {string} parameters.virtualNetworkName Name of the Virtual Network
   * for migration.
   * 
   * @param {string} parameters.subNetName Subnet name for migration.
   * 
   * @param {string} parameters.destinationVirtualNetwork Destination Virtual
   * Network type for migration.Accepted values are Default, New, Existing.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.prepareMigration = function(serviceName, deploymentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.deployments.beginPrepareMigration(serviceName, deploymentName, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Reboot Role Instance By Deployment Name operation requests a reboot of
   * a role instance that is running in a deployment. This operation is an
   * asynchronous operation. To determine whether the Management service has
   * finished processing the request, call Get Operation Status. For more
   * information on asynchronous operations, see Tracking Asynchronous Service
   * Management Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/gg441298.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {string} roleInstanceName The name of your role instance.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.rebootRoleInstanceByDeploymentName = function(serviceName, deploymentName, roleInstanceName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.deployments.beginRebootingRoleInstanceByDeploymentName(serviceName, deploymentName, roleInstanceName, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Reboot Role Instance By Deployment Slot operation requests a reboot of
   * a role instance that is running in a deployment. This operation is an
   * asynchronous operation. To determine whether the Management service has
   * finished processing the request, call Get Operation Status. For more
   * information on asynchronous operations, see Tracking Asynchronous Service
   * Management Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/gg441298.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {DeploymentSlot} deploymentSlot The deployment slot.
   * 
   * @param {string} roleInstanceName The name of your role instance.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.rebootRoleInstanceByDeploymentSlot = function(serviceName, deploymentSlot, roleInstanceName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.deployments.beginRebootingRoleInstanceByDeploymentSlot(serviceName, deploymentSlot, roleInstanceName, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Rebuild Role Instance asynchronous operation reinstalls the operating
   * system on instances of web roles or worker roles and initializes the
   * storage resources that are used by them. If you do not want to initialize
   * storage resources, you can use Reimage Role Instance
   * athttp://msdn.microsoft.com/en-us/library/azure/gg441292.aspx.For more
   * information on asynchronous operations, see Tracking Asynchronous Service
   * Management Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx.  (see
   * http://msdn.microsoft.com/en-us/library/azure/dn627518.aspx for more
   * information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {string} roleInstanceName The name of your role instance.
   * 
   * @param {string} resources Specifies the resources that must be rebuilt.
   * Currently, the only supported value is 'allLocalDrives'.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.rebuildRoleInstanceByDeploymentName = function(serviceName, deploymentName, roleInstanceName, resources, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.deployments.beginRebuildingRoleInstanceByDeploymentName(serviceName, deploymentName, roleInstanceName, resources, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Rebuild Role Instance asynchronous operation reinstalls the operating
   * system on instances of web roles or worker roles and initializes the
   * storage resources that are used by them. If you do not want to initialize
   * storage resources, you can use Reimage Role Instance
   * athttp://msdn.microsoft.com/en-us/library/azure/gg441292.aspx.For more
   * information on asynchronous operations, see Tracking Asynchronous Service
   * Management Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx.  (see
   * http://msdn.microsoft.com/en-us/library/azure/dn627518.aspx for more
   * information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {string} deploymentSlot The deployment slot.
   * 
   * @param {string} roleInstanceName The name of your role instance.
   * 
   * @param {string} resources Specifies the resources that must be rebuilt.
   * Currently, the only supported value is 'allLocalDrives'.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.rebuildRoleInstanceByDeploymentSlot = function(serviceName, deploymentSlot, roleInstanceName, resources, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.deployments.beginRebuildingRoleInstanceByDeploymentSlot(serviceName, deploymentSlot, roleInstanceName, resources, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Reimage Role Instance By Deployment Name operation requests a reimage
   * of a role instance that is running in a deployment.This operation is an
   * asynchronous operation. To determine whether the Management service has
   * finished processing the request, call Get Operation Status. For more
   * information on asynchronous operations, see Tracking Asynchronous Service
   * Management Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/gg441292.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {string} roleInstanceName The name of your role instance.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.reimageRoleInstanceByDeploymentName = function(serviceName, deploymentName, roleInstanceName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.deployments.beginReimagingRoleInstanceByDeploymentName(serviceName, deploymentName, roleInstanceName, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Reimage Role Instance By Deployment Slot operation requests a reimage
   * of a role instance that is running in a deployment. This operation is an
   * asynchronous operation. To determine whether the Management service has
   * finished processing the request, call Get Operation Status. For more
   * information on asynchronous operations, see Tracking Asynchronous Service
   * Management Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/gg441292.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {DeploymentSlot} deploymentSlot The deployment slot.
   * 
   * @param {string} roleInstanceName The name of your role instance.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.reimageRoleInstanceByDeploymentSlot = function(serviceName, deploymentSlot, roleInstanceName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.deployments.beginReimagingRoleInstanceByDeploymentSlot(serviceName, deploymentSlot, roleInstanceName, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Rollback Update Or Upgrade By Deployment Name operation cancels an
   * in-progress configuration update and returns the deployment to its state
   * before the update was started. This operation can only be called when an
   * update is in progress on the deployment. The deployment status can be
   * detected by calling the Get Deployment operation or Get Hosted Service
   * Properties operation and inspecting the RollbackAllowed element. If the
   * value returned is true a rollback can be performed.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/hh403977.aspx for
   * more information)
   * 
   * @param {string} serviceName The cloud service to swap deployments for.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {DeploymentRollbackUpdateOrUpgradeParameters} parameters Parameters
   * supplied to the Rollback Update Or Upgrade By Deployment Name operation.
   * 
   * @param {RollbackUpdateOrUpgradeMode} parameters.mode Specifies whether the
   * rollback should proceed automatically.
   * 
   * @param {boolean} [parameters.force] Specifies whether the rollback should
   * proceed even when it will cause local data to be lost from some role
   * instances. True if the rollback should proceed; otherwise false.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.rollbackUpdateOrUpgradeByDeploymentName = function(serviceName, deploymentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    // TODO: Validate serviceName is a valid DNS name.
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.mode === null || parameters.mode === undefined) {
      return callback(new Error('parameters.mode cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/';
    var queryParameters = [];
    queryParameters.push('comp=rollback');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var rollbackUpdateOrUpgradeElement = js2xml.createElement('RollbackUpdateOrUpgrade', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, rollbackUpdateOrUpgradeElement);
    
    var modeElement = js2xml.createElement('Mode', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(modeElement, parameters.mode !== null && parameters.mode !== undefined ? parameters.mode.toString() : 'Auto');
    js2xml.addChildElement(rollbackUpdateOrUpgradeElement, modeElement);
    
    if (parameters.force !== null && parameters.force !== undefined) {
      var forceElement = js2xml.createElement('Force', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(forceElement, parameters.force.toString());
      js2xml.addChildElement(rollbackUpdateOrUpgradeElement, forceElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Rollback Update Or Upgrade By Deployment Slot operation cancels an
   * in-progress configuration update and returns the deployment to its state
   * before the update was started. This operation can only be called when an
   * update is in progress on the deployment. The deployment status can be
   * detected by calling the Get Deployment operation or Get Hosted Service
   * Properties operation and inspecting the RollbackAllowed element. If the
   * value returned is true a rollback can be performed.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/hh403977.aspx for
   * more information)
   * 
   * @param {string} serviceName The cloud service to swap deployments for.
   * 
   * @param {DeploymentSlot} deploymentSlot The deployment slot.
   * 
   * @param {DeploymentRollbackUpdateOrUpgradeParameters} parameters Parameters
   * supplied to the Rollback Update Or Upgrade By Deployment Slot operation.
   * 
   * @param {RollbackUpdateOrUpgradeMode} parameters.mode Specifies whether the
   * rollback should proceed automatically.
   * 
   * @param {boolean} [parameters.force] Specifies whether the rollback should
   * proceed even when it will cause local data to be lost from some role
   * instances. True if the rollback should proceed; otherwise false.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.rollbackUpdateOrUpgradeByDeploymentSlot = function(serviceName, deploymentSlot, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    // TODO: Validate serviceName is a valid DNS name.
    if (deploymentSlot === null || deploymentSlot === undefined) {
      return callback(new Error('deploymentSlot cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.mode === null || parameters.mode === undefined) {
      return callback(new Error('parameters.mode cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deploymentslots/';
    url2 = url2 + encodeURIComponent(deploymentSlot !== null && deploymentSlot !== undefined ? deploymentSlot.toString() : 'Staging');
    url2 = url2 + '/';
    var queryParameters = [];
    queryParameters.push('comp=rollback');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var rollbackUpdateOrUpgradeElement = js2xml.createElement('RollbackUpdateOrUpgrade', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, rollbackUpdateOrUpgradeElement);
    
    var modeElement = js2xml.createElement('Mode', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(modeElement, parameters.mode !== null && parameters.mode !== undefined ? parameters.mode.toString() : 'Auto');
    js2xml.addChildElement(rollbackUpdateOrUpgradeElement, modeElement);
    
    if (parameters.force !== null && parameters.force !== undefined) {
      var forceElement = js2xml.createElement('Force', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(forceElement, parameters.force.toString());
      js2xml.addChildElement(rollbackUpdateOrUpgradeElement, forceElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Swap Deployment operation initiates a virtual IP address swap between
   * the staging and production deployment environments for a service. If the
   * service is currently running in the staging environment, it will be
   * swapped to the production environment. If it is running in the production
   * environment, it will be swapped to staging. For more information on this
   * type of upgrade, see Performing Virtual IP Swap Upgrades at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee517253.aspx.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460814.aspx for
   * more information)
   * 
   * @param {string} serviceName The cloud service to swap deployments for.
   * 
   * @param {DeploymentSwapParameters} parameters Parameters supplied to the
   * Swap Deployment operation.
   * 
   * @param {string} [parameters.productionDeployment] The optional name of the
   * production deployment.
   * 
   * @param {string} parameters.sourceDeployment The name of the source
   * deployment.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.swap = function(serviceName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.deployments.beginSwapping(serviceName, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Update Deployment Status By Deployment Name operation initiates a
   * change in the running status of a deployment. The status of a deployment
   * can be running or suspended. This operation is an asynchronous operation.
   * To determine whether the Management service has finished processing the
   * request, call Get Operation Status. For more information on asynchronous
   * operations, see Tracking Asynchronous Service Management Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460808.aspx for
   * more information)
   * 
   * @param {string} serviceName The cloud service to swap deployments for.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {DeploymentUpdateStatusParameters} parameters Parameters supplied
   * to the Update Deployment Status By Deployment Name operation.
   * 
   * @param {UpdatedDeploymentStatus} parameters.status The new status of the
   * deployment.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.updateStatusByDeploymentName = function(serviceName, deploymentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.deployments.beginUpdatingStatusByDeploymentName(serviceName, deploymentName, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Update Deployment Status By Deployment Slot operation initiates a
   * change in the running status of a deployment. The status of a deployment
   * can be running or suspended. This operation is an asynchronous operation.
   * To determine whether the Management service has finished processing the
   * request, call Get Operation Status. For more information on asynchronous
   * operations, see Tracking Asynchronous Service Management Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460808.aspx for
   * more information)
   * 
   * @param {string} serviceName The cloud service to swap deployments for.
   * 
   * @param {DeploymentSlot} deploymentSlot The deployment slot.
   * 
   * @param {DeploymentUpdateStatusParameters} parameters Parameters supplied
   * to the Update Deployment Status By Deployment Slot operation.
   * 
   * @param {UpdatedDeploymentStatus} parameters.status The new status of the
   * deployment.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.updateStatusByDeploymentSlot = function(serviceName, deploymentSlot, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.deployments.beginUpdatingStatusByDeploymentSlot(serviceName, deploymentSlot, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Upgrade Deployment By Name operation initiates an update of role
   * instances in a deployment using the package and configuration that you
   * specify. For more information about updating role instances, see Update
   * an Azure Service at
   * http://msdn.microsoft.com/en-us/library/windowsazure/hh472157.aspx. This
   * operation is an asynchronous operation. To determine whether the request
   * has been processed, call Get Operation Status. For more information on
   * asynchronous operations, see Tracking Asynchronous Service Management
   * Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx. To
   * perform an automatic update of a deployment, call Upgrade Deployment or
   * Change Deployment Configuration with the Mode element set to automatic.
   * The update proceeds from that point without a need for further input. You
   * can call Get Operation Status to determine when the update is complete.
   * To perform a manual update, first call Upgrade Deployment with the Mode
   * element set to manual. Next, call Walk Upgrade Domain to update each
   * domain within the deployment. You should make sure that the operation is
   * complete by calling Get Operation Status before updating the next domain.
   * Important: An update that adds or removes role instances will result in a
   * configuration update to all roles that are deployed in the cloud service.
   * Existing role instances need to be notified of new role instances so that
   * all role instances can communicate together in the cloud service. By
   * default, a cloud service is deployed with five update domains, which are
   * updated one at a time during an in-place update. For information on
   * modifying the number of update domains in the service definition file,
   * see the Azure Service Definition Schema (.csdef File). To determine the
   * update domain in which a particular instance is running in Windows Azure,
   * use the UpdateDomain property of the RoleInstance class. See the Azure
   * Managed Library Reference at
   * http://msdn.microsoft.com/en-us/library/windowsazure/dd179380.aspx for
   * more information.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460793.aspx for
   * more information)
   * 
   * @param {string} serviceName The cloud service to upgrade.
   * 
   * @param {string} deploymentName The deployment to upgrade.
   * 
   * @param {DeploymentUpgradeParameters} parameters Parameters supplied to the
   * Upgrade Deployment By Name operation.
   * 
   * @param {DeploymentUpgradeMode} parameters.mode The type of update to
   * initiate. Role instances are allocated to update domains when the service
   * is deployed. Updates can be initiated manually in each update domain or
   * initiated automatically in all update domains. Possible values are Auto
   * or Manual. If not specified, the default value is Auto. If set to Manual,
   * WalkUpgradeDomain must be called to apply the update. If set to Auto, the
   * update is automatically applied to each update domain in sequence.
   * 
   * @param {string} parameters.packageUri A URL that refers to the location of
   * the service package in the Blob service. The service package can be
   * located either in a storage account beneath the same subscription or a
   * Shared Access Signature (SAS) URI from any storage account. For more
   * information about Shared Access Signatures, see Delegating Access with a
   * Shared Access Signature (REST API) at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee395415.aspx.
   * 
   * @param {string} parameters.configuration The service configuration file
   * for the deployment. The client library does the base-64 encoding from the
   * plain text input.
   * 
   * @param {string} parameters.label A name for the hosted service. The name
   * can be up to 100 characters in length. It is recommended that the label
   * be unique within the subscription. The name can be used identify the
   * hosted service for your tracking purposes.
   * 
   * @param {string} [parameters.roleToUpgrade] The name of the specific role
   * instance to update.
   * 
   * @param {boolean} parameters.force Specifies whether the rollback should
   * proceed even when it will cause local data to be lost from some role
   * instances.
   * 
   * @param {object} [parameters.extendedProperties] Represents the name of an
   * extended deployment property. Each extended property must have a defined
   * name and a value. You can have a maximum of 25 extended property
   * name/value pairs. The maximum length of the name element is 64
   * characters, only alphanumeric characters and underscores are valid in the
   * name, and the name must start with a letter. Attempting to use other
   * characters, starting the name with a non-letter character, or entering a
   * name that is identical to that of another extended property owned by the
   * same hosted service will result in a status code 400 (Bad Request) error.
   * 
   * @param {ExtensionConfiguration} [parameters.extensionConfiguration]
   * Represents an extension that is added to the cloud service. In Azure, a
   * process can run as an extension of a cloud service. For example, Remote
   * Desktop Access or the Azure Diagnostics Agent can run as extensions to
   * the cloud service. You must add an extension to the cloud service by
   * using Add Extension before it can be added to the deployment.
   * 
   * @param {array} [parameters.extensionConfiguration.allRoles] Specifies a
   * list of extensions that are applied to all roles in a deployment.
   * 
   * @param {array} [parameters.extensionConfiguration.namedRoles] Specifies a
   * list of extensions that are applied to specific roles in a deployment.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.upgradeByName = function(serviceName, deploymentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.deployments.beginUpgradingByName(serviceName, deploymentName, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Upgrade Deployment By Slot operation initiates an update of role
   * instances in a deployment using the package and configuration that you
   * specify. For more information about updating role instances, see Update
   * an Azure Service at
   * http://msdn.microsoft.com/en-us/library/windowsazure/hh472157.aspx. This
   * operation is an asynchronous operation. To determine whether the request
   * has been processed, call Get Operation Status. For more information on
   * asynchronous operations, see Tracking Asynchronous Service Management
   * Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx. To
   * perform an automatic update of a deployment, call Upgrade Deployment or
   * Change Deployment Configuration with the Mode element set to automatic.
   * The update proceeds from that point without a need for further input. You
   * can call Get Operation Status to determine when the update is complete.
   * To perform a manual update, first call Upgrade Deployment with the Mode
   * element set to manual. Next, call Walk Upgrade Domain to update each
   * domain within the deployment. You should make sure that the operation is
   * complete by calling Get Operation Status before updating the next domain.
   * Important: An update that adds or removes role instances will result in a
   * configuration update to all roles that are deployed in the cloud service.
   * Existing role instances need to be notified of new role instances so that
   * all role instances can communicate together in the cloud service. By
   * default, a cloud service is deployed with five update domains, which are
   * updated one at a time during an in-place update. For information on
   * modifying the number of update domains in the service definition file,
   * see the Azure Service Definition Schema (.csdef File). To determine the
   * update domain in which a particular instance is running in Windows Azure,
   * use the UpdateDomain property of the RoleInstance class. See the Azure
   * Managed Library Reference at
   * http://msdn.microsoft.com/en-us/library/windowsazure/dd179380.aspx for
   * more information.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460793.aspx for
   * more information)
   * 
   * @param {string} serviceName The cloud service to upgrade.
   * 
   * @param {DeploymentSlot} deploymentSlot The slot to upgrade.
   * 
   * @param {DeploymentUpgradeParameters} parameters Parameters supplied to the
   * Upgrade Deployment By Slot operation.
   * 
   * @param {DeploymentUpgradeMode} parameters.mode The type of update to
   * initiate. Role instances are allocated to update domains when the service
   * is deployed. Updates can be initiated manually in each update domain or
   * initiated automatically in all update domains. Possible values are Auto
   * or Manual. If not specified, the default value is Auto. If set to Manual,
   * WalkUpgradeDomain must be called to apply the update. If set to Auto, the
   * update is automatically applied to each update domain in sequence.
   * 
   * @param {string} parameters.packageUri A URL that refers to the location of
   * the service package in the Blob service. The service package can be
   * located either in a storage account beneath the same subscription or a
   * Shared Access Signature (SAS) URI from any storage account. For more
   * information about Shared Access Signatures, see Delegating Access with a
   * Shared Access Signature (REST API) at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee395415.aspx.
   * 
   * @param {string} parameters.configuration The service configuration file
   * for the deployment. The client library does the base-64 encoding from the
   * plain text input.
   * 
   * @param {string} parameters.label A name for the hosted service. The name
   * can be up to 100 characters in length. It is recommended that the label
   * be unique within the subscription. The name can be used identify the
   * hosted service for your tracking purposes.
   * 
   * @param {string} [parameters.roleToUpgrade] The name of the specific role
   * instance to update.
   * 
   * @param {boolean} parameters.force Specifies whether the rollback should
   * proceed even when it will cause local data to be lost from some role
   * instances.
   * 
   * @param {object} [parameters.extendedProperties] Represents the name of an
   * extended deployment property. Each extended property must have a defined
   * name and a value. You can have a maximum of 25 extended property
   * name/value pairs. The maximum length of the name element is 64
   * characters, only alphanumeric characters and underscores are valid in the
   * name, and the name must start with a letter. Attempting to use other
   * characters, starting the name with a non-letter character, or entering a
   * name that is identical to that of another extended property owned by the
   * same hosted service will result in a status code 400 (Bad Request) error.
   * 
   * @param {ExtensionConfiguration} [parameters.extensionConfiguration]
   * Represents an extension that is added to the cloud service. In Azure, a
   * process can run as an extension of a cloud service. For example, Remote
   * Desktop Access or the Azure Diagnostics Agent can run as extensions to
   * the cloud service. You must add an extension to the cloud service by
   * using Add Extension before it can be added to the deployment.
   * 
   * @param {array} [parameters.extensionConfiguration.allRoles] Specifies a
   * list of extensions that are applied to all roles in a deployment.
   * 
   * @param {array} [parameters.extensionConfiguration.namedRoles] Specifies a
   * list of extensions that are applied to specific roles in a deployment.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.upgradeBySlot = function(serviceName, deploymentSlot, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.deployments.beginUpgradingBySlot(serviceName, deploymentSlot, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Validate Deployment Operation validates your deployment for IaaS
   * Classic to ARM migration.
   * 
   * @param {string} serviceName Name of the cloud service.
   * 
   * @param {string} deploymentName Name of the deployment to be migrated.
   * 
   * @param {PrepareDeploymentMigrationParameters} parameters Deployment
   * Network resource parameters for migration.
   * 
   * @param {string} parameters.resourceGroupName Name of the resource group
   * for migration.
   * 
   * @param {string} parameters.virtualNetworkName Name of the Virtual Network
   * for migration.
   * 
   * @param {string} parameters.subNetName Subnet name for migration.
   * 
   * @param {string} parameters.destinationVirtualNetwork Destination Virtual
   * Network type for migration.Accepted values are Default, New, Existing.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.validateMigration = function(serviceName, deploymentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.destinationVirtualNetwork === null || parameters.destinationVirtualNetwork === undefined) {
      return callback(new Error('parameters.destinationVirtualNetwork cannot be null.'));
    }
    if (parameters.resourceGroupName === null || parameters.resourceGroupName === undefined) {
      return callback(new Error('parameters.resourceGroupName cannot be null.'));
    }
    if (parameters.subNetName === null || parameters.subNetName === undefined) {
      return callback(new Error('parameters.subNetName cannot be null.'));
    }
    if (parameters.virtualNetworkName === null || parameters.virtualNetworkName === undefined) {
      return callback(new Error('parameters.virtualNetworkName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/migration';
    var queryParameters = [];
    queryParameters.push('comp=validate');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var deploymentNetworkResourceElement = js2xml.createElement('DeploymentNetworkResource', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, deploymentNetworkResourceElement);
    
    var resourceGroupNameElement = js2xml.createElement('ResourceGroupName', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(resourceGroupNameElement, parameters.resourceGroupName);
    js2xml.addChildElement(deploymentNetworkResourceElement, resourceGroupNameElement);
    
    var virtualNetworkNameElement = js2xml.createElement('VirtualNetworkName', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(virtualNetworkNameElement, parameters.virtualNetworkName);
    js2xml.addChildElement(deploymentNetworkResourceElement, virtualNetworkNameElement);
    
    var subNetNameElement = js2xml.createElement('SubNetName', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(subNetNameElement, parameters.subNetName);
    js2xml.addChildElement(deploymentNetworkResourceElement, subNetNameElement);
    
    var destinationVirtualNetworkElement = js2xml.createElement('DestinationVirtualNetwork', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(destinationVirtualNetworkElement, parameters.destinationVirtualNetwork);
    js2xml.addChildElement(deploymentNetworkResourceElement, destinationVirtualNetworkElement);
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { validateDeploymentMessages: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var validationMessagesSequenceElement = js2xml.getElement(responseDoc, responseDoc, 'VALIDATIONMESSAGES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (validationMessagesSequenceElement !== null && validationMessagesSequenceElement !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, validationMessagesSequenceElement, 'VALIDATIONMESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
              var validationMessagesElement = js2xml.getElements(responseDoc, validationMessagesSequenceElement, 'VALIDATIONMESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
              var validationMessageInstance = {};
              result.validateDeploymentMessages.push(validationMessageInstance);
              
              var resourceTypeElement = js2xml.getElement(responseDoc, validationMessagesElement, 'RESOURCETYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (resourceTypeElement !== null && resourceTypeElement !== undefined) {
                var resourceTypeInstance = resourceTypeElement;
                validationMessageInstance.resourceType = resourceTypeInstance;
              }
              
              var resourceNameElement = js2xml.getElement(responseDoc, validationMessagesElement, 'RESOURCENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (resourceNameElement !== null && resourceNameElement !== undefined) {
                var resourceNameInstance = resourceNameElement;
                validationMessageInstance.resourceName = resourceNameInstance;
              }
              
              var categoryElement = js2xml.getElement(responseDoc, validationMessagesElement, 'CATEGORY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (categoryElement !== null && categoryElement !== undefined) {
                var categoryInstance = categoryElement;
                validationMessageInstance.category = categoryInstance;
              }
              
              var messageElement = js2xml.getElement(responseDoc, validationMessagesElement, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (messageElement !== null && messageElement !== undefined) {
                var messageInstance = messageElement;
                validationMessageInstance.message = messageInstance;
              }
              
              var virtualMachineElement = js2xml.getElement(responseDoc, validationMessagesElement, 'VIRTUALMACHINE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (virtualMachineElement !== null && virtualMachineElement !== undefined) {
                var virtualMachineInstance = virtualMachineElement;
                validationMessageInstance.virtualMachineName = virtualMachineInstance;
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Walk Upgrade Domain By Deployment Name operation specifies an update
   * domain in which a role instance must be updated. For more information
   * about updating role instances, see Update an Azure Service at
   * http://msdn.microsoft.com/en-us/library/windowsazure/hh472157.aspx. This
   * operation is an asynchronous operation. To determine whether the
   * Management service has finished processing the request, call Get
   * Operation Status. For more information on asynchronous operations, see
   * Tracking Asynchronous Service Management Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx. Prior
   * to calling the Walk Upgrade Domain operation you must have called Upgrade
   * Deployment, Change Deployment Configuration, or Rollback Update Or
   * Upgrade. By default, a service is deployed with five update domains,
   * which are updated one at a time during an in-place update. For
   * information on modifying the number of update domains in the service
   * definition file, see the Azure Service Definition Schema (.csdef File).
   * To perform a manual update of your deployment, proceed in this order:
   * Call Upgrade Deployment with the Mode element set to manual. Call Walk
   * Upgrade Domain to update each domain within the deployment. Update
   * domains must be updated in order. For example, begin with domain 0,
   * proceed to domain 1, and so on. Important: An update that adds or removes
   * role instances will result in a configuration update to all roles that
   * are deployed in the cloud service. Existing role instances need to be
   * notified of new role instances so that all role instances can communicate
   * together in the cloud service. While an update is in progress, call Get
   * Deployment to determine its status. If the update is in progress, Get
   * Deployment returns an UpgradeStatus element that contains information
   * about the update. If the update is complete, or if no update is in
   * progress, then the UpgradeStatus element is null.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460800.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {DeploymentWalkUpgradeDomainParameters} parameters Parameters
   * supplied to the Walk Upgrade Domain By Deployment Name operation.
   * 
   * @param {number} parameters.upgradeDomain An integer value that identifies
   * the update domain to update. Update domains are identified with a
   * zero-based index: the first update domain has an ID of 0, the second has
   * an ID of 1, and so on.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.walkUpgradeDomainByDeploymentName = function(serviceName, deploymentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.deployments.beginWalkingUpgradeDomainByDeploymentName(serviceName, deploymentName, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Walk Upgrade Domain By Deployment Slot operation specifies an update
   * domain in which a role instance must be updated. For more information
   * about updating role instances, see Update an Azure Service at
   * http://msdn.microsoft.com/en-us/library/windowsazure/hh472157.aspx. This
   * operation is an asynchronous operation. To determine whether the
   * Management service has finished processing the request, call Get
   * Operation Status. For more information on asynchronous operations, see
   * Tracking Asynchronous Service Management Requests at
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx. Prior
   * to calling the Walk Upgrade Domain operation you must have called Upgrade
   * Deployment, Change Deployment Configuration, or Rollback Update Or
   * Upgrade. By default, a service is deployed with five update domains,
   * which are updated one at a time during an in-place update. For
   * information on modifying the number of update domains in the service
   * definition file, see the Azure Service Definition Schema (.csdef File).
   * To perform a manual update of your deployment, proceed in this order:
   * Call Upgrade Deployment with the Mode element set to manual. Call Walk
   * Upgrade Domain to update each domain within the deployment. Update
   * domains must be updated in order. For example, begin with domain 0,
   * proceed to domain 1, and so on. Important: An update that adds or removes
   * role instances will result in a configuration update to all roles that
   * are deployed in the cloud service. Existing role instances need to be
   * notified of new role instances so that all role instances can communicate
   * together in the cloud service. While an update is in progress, call Get
   * Deployment to determine its status. If the update is in progress, Get
   * Deployment returns an UpgradeStatus element that contains information
   * about the update. If the update is complete, or if no update is in
   * progress, then the UpgradeStatus element is null.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460800.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {DeploymentSlot} deploymentSlot The deployment slot.
   * 
   * @param {DeploymentWalkUpgradeDomainParameters} parameters Parameters
   * supplied to the Walk Upgrade Domain By Deployment Slot operation.
   * 
   * @param {number} parameters.upgradeDomain An integer value that identifies
   * the update domain to update. Update domains are identified with a
   * zero-based index: the first update domain has an ID of 0, the second has
   * an ID of 1, and so on.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DeploymentOperations.prototype.walkUpgradeDomainByDeploymentSlot = function(serviceName, deploymentSlot, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.deployments.beginWalkingUpgradeDomainByDeploymentSlot(serviceName, deploymentSlot, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  return DeploymentOperations;
})();

var DNSServerOperations = ( /** @lends DNSServerOperations */ function() {
  /**
   * @class
   * The Compute Management API includes operations for managing the dns
   * servers for your subscription.
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [ComputeManagementClient] {@link
   * ComputeManagementClient~ComputeManagementClient}.
   * See [dnsServer] {@link
   * ComputeManagementClient~ComputeManagementClient#dnsServer}.
   * Initializes a new instance of the DNSServerOperations class.
   * @constructor
   * 
   * @param {ComputeManagementClient} client Reference to the service client.
   */
  function DNSServerOperations(client) {
    this.client = client;
  }
  
  /**
   * Add a definition for a DNS server to an existing deployment. VM's in this
   * deployment will be programmed to use this DNS server for all DNS
   * resolutions
   * 
   * @param {string} serviceName The name of the service.
   * 
   * @param {string} deploymentName The name of the deployment.
   * 
   * @param {DNSAddParameters} parameters Parameters supplied to the Add DNS
   * Server operation.
   * 
   * @param {string} [parameters.name] Name of the DNS server.
   * 
   * @param {string} [parameters.address] IP Address of the DNS server
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DNSServerOperations.prototype.addDNSServer = function(serviceName, deploymentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.dnsServer.beginAddingDNSServer(serviceName, deploymentName, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      if (result.status === 'Succeeded') {
        return callback(null, result);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * Add a definition for a DNS server to an existing deployment. VM's in this
   * deployment will be programmed to use this DNS server for all DNS
   * resolutions
   * 
   * @param {string} serviceName The name of the service.
   * 
   * @param {string} deploymentName The name of the deployment.
   * 
   * @param {DNSAddParameters} parameters Parameters supplied to the Add DNS
   * Server operation.
   * 
   * @param {string} [parameters.name] Name of the DNS server.
   * 
   * @param {string} [parameters.address] IP Address of the DNS server
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DNSServerOperations.prototype.beginAddingDNSServer = function(serviceName, deploymentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/dnsservers';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var dnsServerElement = js2xml.createElement('DnsServer', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, dnsServerElement);
    
    if (parameters.name !== null && parameters.name !== undefined) {
      var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(nameElement, parameters.name);
      js2xml.addChildElement(dnsServerElement, nameElement);
    }
    
    if (parameters.address !== null && parameters.address !== undefined) {
      var addressElement = js2xml.createElement('Address', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(addressElement, parameters.address);
      js2xml.addChildElement(dnsServerElement, addressElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Deletes a definition for an existing DNS server from the deployment
   * 
   * @param {string} serviceName The name of the service.
   * 
   * @param {string} deploymentName The name of the deployment.
   * 
   * @param {string} dnsServerName The name of the dns server.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DNSServerOperations.prototype.beginDeletingDNSServer = function(serviceName, deploymentName, dnsServerName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (dnsServerName === null || dnsServerName === undefined) {
      return callback(new Error('dnsServerName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/dnsservers/';
    url2 = url2 + encodeURIComponent(dnsServerName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Updates a definition for an existing DNS server. Updates to address is the
   * only change allowed. DNS server name cannot be changed
   * 
   * @param {string} serviceName The name of the service.
   * 
   * @param {string} deploymentName The name of the deployment.
   * 
   * @param {string} dnsServerName The name of the dns server.
   * 
   * @param {DNSUpdateParameters} parameters Parameters supplied to the Update
   * DNS Server operation.
   * 
   * @param {string} [parameters.name] Name of the DNS server.
   * 
   * @param {string} [parameters.address] IP Address of the DNS server
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DNSServerOperations.prototype.beginUpdatingDNSServer = function(serviceName, deploymentName, dnsServerName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (dnsServerName === null || dnsServerName === undefined) {
      return callback(new Error('dnsServerName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/dnsservers/';
    url2 = url2 + encodeURIComponent(dnsServerName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var dnsServerElement = js2xml.createElement('DnsServer', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, dnsServerElement);
    
    if (parameters.name !== null && parameters.name !== undefined) {
      var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(nameElement, parameters.name);
      js2xml.addChildElement(dnsServerElement, nameElement);
    }
    
    if (parameters.address !== null && parameters.address !== undefined) {
      var addressElement = js2xml.createElement('Address', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(addressElement, parameters.address);
      js2xml.addChildElement(dnsServerElement, addressElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Deletes a definition for an existing DNS server from the deployment
   * 
   * @param {string} serviceName The name of the service.
   * 
   * @param {string} deploymentName The name of the deployment.
   * 
   * @param {string} dnsServerName The name of the dns server.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DNSServerOperations.prototype.deleteDNSServer = function(serviceName, deploymentName, dnsServerName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.dnsServer.beginDeletingDNSServer(serviceName, deploymentName, dnsServerName, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      if (result.status === 'Succeeded') {
        return callback(null, result);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * Updates a definition for an existing DNS server. Updates to address is the
   * only change allowed. DNS server name cannot be changed
   * 
   * @param {string} serviceName The name of the service.
   * 
   * @param {string} deploymentName The name of the deployment.
   * 
   * @param {string} dnsServerName The name of the dns server.
   * 
   * @param {DNSUpdateParameters} parameters Parameters supplied to the Update
   * DNS Server operation.
   * 
   * @param {string} [parameters.name] Name of the DNS server.
   * 
   * @param {string} [parameters.address] IP Address of the DNS server
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  DNSServerOperations.prototype.updateDNSServer = function(serviceName, deploymentName, dnsServerName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.dnsServer.beginUpdatingDNSServer(serviceName, deploymentName, dnsServerName, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      if (result.status === 'Succeeded') {
        return callback(null, result);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  return DNSServerOperations;
})();

var ExtensionImageOperations = ( /** @lends ExtensionImageOperations */ function() {
  /**
   * @class
   * The Service Management API includes operations for managing the service
   * and virtual machine extension images in your publisher subscription.
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [ComputeManagementClient] {@link
   * ComputeManagementClient~ComputeManagementClient}.
   * See [extensionImages] {@link
   * ComputeManagementClient~ComputeManagementClient#extensionImages}.
   * Initializes a new instance of the ExtensionImageOperations class.
   * @constructor
   * 
   * @param {ComputeManagementClient} client Reference to the service client.
   */
  function ExtensionImageOperations(client) {
    this.client = client;
  }
  
  /**
   * Register a new extension. An extension is identified by the combination of
   * its ProviderNamespace and Type (case-sensitive string). It is not allowed
   * to register an extension with the same identity (i.e. combination of
   * ProviderNamespace and Type) of an already-registered extension. To
   * register new version of an existing extension, the Update Extension API
   * should be used.
   * 
   * @param {ExtensionImageRegisterParameters} parameters Parameters supplied
   * to the Register Virtual Machine Extension Image operation.
   * 
   * @param {string} parameters.providerNameSpace Required. The provider
   * namespace of the extension.
   * 
   * @param {string} parameters.type Required. The type of the extension.
   * 
   * @param {string} parameters.version Required. The version of the extension.
   * 
   * @param {string} [parameters.label] Required. A one line label of the
   * extension.
   * 
   * @param {string} [parameters.hostingResources] Required. The supported
   * hosting resources. It must contain 'WebRole' and/or 'WorkerRole'. E.g.
   * 'WebRole|WorkerRole' or 'WebRole|WorkerRole|VmRole'.
   * 
   * @param {string} [parameters.mediaLink] Required. URI string pointing to
   * the ZIP package of the extension. The ZIP package has to include the
   * extension executable and other supporting files, and the
   * PluginManifest.xml manifest. MediaLink value must point to a URL (either
   * Http or Https) in a Azure blob storage and is downloadable. Windows Azure
   * will copy the extension package from this source location and replicate
   * it to all regions. The typical time for replication to complete is 20
   * minutes.
   * 
   * @param {ExtensionCertificateConfiguration} [parameters.certificate]
   * Optional. Parameters of the the certificate for encrypting the private
   * configuration data. Supported on WebRole or WorkerRole, but ignored on
   * VmRole.
   * 
   * @param {string} [parameters.certificate.storeLocation] Required for
   * certificate declaration. The Windows certificate store location to
   * install the certificate for encryption, if required. Its value has to be
   * 'LocalMachine' if present.
   * 
   * @param {string} [parameters.certificate.storeName] Optional. The Windows
   * certificate store name to install the certificate for encryption, if
   * required. Its value has to be 'My' if present.
   * 
   * @param {boolean} [parameters.certificate.thumbprintRequired] Optional.
   * Whether thumbprint is required for the certificate for encryption or not.
   * Its value has to be 'true' or 'false' (case-sensitive) if present.
   * 
   * @param {string} [parameters.certificate.thumbprintAlgorithm] Optional. The
   * thumbprint algorithm of the certificate for encryption, if required. Its
   * value has to be 'sha1' if present.
   * 
   * @param {ExtensionEndpointConfiguration} [parameters.extensionEndpoints]
   * Optional. Declared endpoints to automatically add to each deployment with
   * this extension added.
   * 
   * @param {array} [parameters.extensionEndpoints.inputEndpoints] Optional. A
   * list of input endpoints required by this extension. Supported on WebRole
   * or WorkerRole, but ignored on VmRole. Each input endpoint will be
   * automatically added to the service definition of the deployment utilizing
   * this extension.
   * 
   * @param {array} [parameters.extensionEndpoints.internalEndpoints] Optional.
   * A list of internal endpoints required by this extension. Supported on
   * WebRole or WorkerRole, but ignored on VmRole. Each internal endpoint will
   * be automatically added to the service definition of the deployment
   * utilizing this extension.
   * 
   * @param {array} [parameters.extensionEndpoints.instanceInputEndpoints]
   * Optional. A list of instance input endpoints required by this extension.
   * Supported on WebRole or WorkerRole, but ignored on VmRole. Each instance
   * input endpoint will be automatically added to the service definition of
   * the deployment utilizing this extension.
   * 
   * @param {string} [parameters.publicConfigurationSchema] Optional. The XSD
   * schema of public configuration data.
   * 
   * @param {string} [parameters.privateConfigurationSchema] Optional. The XSD
   * schema of private configuration data.
   * 
   * @param {string} [parameters.description] Required. Detailed description of
   * the extension.
   * 
   * @param {string} [parameters.publisherName] Optional. Publisher name text.
   * 
   * @param {date} [parameters.publishedDate] Publisher can set it to any
   * arbitrary date, and this is only for display purpose. If not specified by
   * publisher, Azure will automatically assign the UTC time when the
   * extension request was received.
   * 
   * @param {array} [parameters.localResources] Declared local resources used
   * inside guest VM by the extension. Optional.
   * 
   * @param {boolean} [parameters.blockRoleUponFailure] Optional. Its value has
   * to be 'true' or 'false' (case-sensitive) When set to 'true', the role
   * startup will be blocked till the extension installation completes. This
   * flag should be set to 'true' when the role cannot start without the
   * extension being installed. If set to 'false' (default value), the role
   * will be started without waiting for the extension installation to
   * complete. Supported on WebRole or WorkerRole, but ignored on VmRole.
   * 
   * @param {boolean} [parameters.isInternalExtension] Optional. If this is set
   * to 'true' the extension is not visible for public use, i.e. being
   * returned from list API's. It can be still accessed by referring to the
   * ProviderNamespace, Type & Version combo. Therefore an internal extension
   * is intended only for testing purpose. Its value has to be 'true' or
   * 'false' (case-sensitive) if present.
   * 
   * @param {string} [parameters.sampleConfig] Optional. A sample configuration
   * for the extension. It can be downloaded by users, and the user can
   * replace with customized input parameters. The sample configuration should
   * be sufficiently commented. If configuration data are in XML format, then
   * the XML document-level element must be 'Configuration', and the optional
   * public configuration data corresponds to a child element of
   * 'PublicConfig', and the optional private configuration data corresponds
   * to a child element of 'PrivateConfig'. The sample configuration data
   * should be validated against public and private configuration schema by
   * the publisher.
   * 
   * @param {boolean} [parameters.replicationCompleted] Indicates whether this
   * version of extension has been replicated to all regions or not. If true,
   * then the given extension version can be used in creating or updating
   * deployments. Otherwise, the given extension version might cause failure
   * in creating or updating deployments. The typical time is 20 minutes for a
   * newly-registered or newly-updated extension to replicate completely by
   * Azure.
   * 
   * @param {string} [parameters.eula] Optional. URL string pointing to the
   * EULA (End User License Agreement) of this version of extension. This is
   * optionally specified by the third-party publishing the extension instead
   * of Windows Azure. If the software requires any additional EULAs, a link
   * to the EULA should be provided.
   * 
   * @param {string} [parameters.privacyUri] Optional. URL string pointing to
   * privacy document of this version of extension. This is optionally
   * specified by the third-party publishing the extension instead of Azure.
   * If the software collects any data and transfers out the guest VM, then an
   * additional privacy document might be needed.
   * 
   * @param {string} [parameters.homepageUri] Optional. URL string pointing to
   * homepage of this version of extension. This is optionally specified by
   * the third-party publishing the extension instead of Azure. The homepage
   * should have usage information and contact information for customer
   * support.
   * 
   * @param {boolean} [parameters.isJsonExtension] Optional. If this is set to
   * 'true' the extension is expected to receive JSON based configuration. If
   * this is set to 'false' the extension is expected to receive XML based
   * configuration. Its value has to be 'true' or 'false' (case-sensitive) if
   * present.
   * 
   * @param {boolean} [parameters.disallowMajorVersionUpgrade] Optional. If
   * this is set to 'true' the extension version cannot be upgraded to from
   * other major versions in active deployments. If the value is 'false' or
   * nor present, the extension version can be upgraded to from any other
   * version. Downgrade is not supported. The value has to be 'true' or
   * 'false' (case-sensitive) if present.
   * 
   * @param {string} [parameters.supportedOS] String property indicating the OS
   * which the extension supports. Current values are 'Windows' or 'Linux'.
   * 
   * @param {string} [parameters.companyName] String property containing the
   * name of the company/organization who publishes the extension.
   * 
   * @param {string} [parameters.regions] String property containing the name
   * of the regions required for the slice.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ExtensionImageOperations.prototype.beginRegistering = function(parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.certificate !== null && parameters.certificate !== undefined) {
      if (parameters.certificate.storeLocation === null || parameters.certificate.storeLocation === undefined) {
        return callback(new Error('parameters.certificate.storeLocation cannot be null.'));
      }
    }
    if (parameters.extensionEndpoints !== null && parameters.extensionEndpoints !== undefined) {
      if (parameters.extensionEndpoints.inputEndpoints !== null && parameters.extensionEndpoints.inputEndpoints !== undefined) {
        for (var loweredIndex1 = 0; loweredIndex1 < parameters.extensionEndpoints.inputEndpoints.length; loweredIndex1 = loweredIndex1 + 1) {
          var inputEndpointsParameterItem = parameters.extensionEndpoints.inputEndpoints[loweredIndex1];
          if (inputEndpointsParameterItem.localPort === null || inputEndpointsParameterItem.localPort === undefined) {
            return callback(new Error('parameters.extensionEndpoints.inputEndpoints. cannot be null.'));
          }
          if (inputEndpointsParameterItem.name === null || inputEndpointsParameterItem.name === undefined) {
            return callback(new Error('parameters.extensionEndpoints.inputEndpoints. cannot be null.'));
          }
          if (inputEndpointsParameterItem.port === null || inputEndpointsParameterItem.port === undefined) {
            return callback(new Error('parameters.extensionEndpoints.inputEndpoints. cannot be null.'));
          }
          if (inputEndpointsParameterItem.protocol === null || inputEndpointsParameterItem.protocol === undefined) {
            return callback(new Error('parameters.extensionEndpoints.inputEndpoints. cannot be null.'));
          }
        }
      }
      if (parameters.extensionEndpoints.instanceInputEndpoints !== null && parameters.extensionEndpoints.instanceInputEndpoints !== undefined) {
        for (var loweredIndex2 = 0; loweredIndex2 < parameters.extensionEndpoints.instanceInputEndpoints.length; loweredIndex2 = loweredIndex2 + 1) {
          var instanceInputEndpointsParameterItem = parameters.extensionEndpoints.instanceInputEndpoints[loweredIndex2];
          if (instanceInputEndpointsParameterItem.fixedPortMax === null || instanceInputEndpointsParameterItem.fixedPortMax === undefined) {
            return callback(new Error('parameters.extensionEndpoints.instanceInputEndpoints. cannot be null.'));
          }
          if (instanceInputEndpointsParameterItem.fixedPortMin === null || instanceInputEndpointsParameterItem.fixedPortMin === undefined) {
            return callback(new Error('parameters.extensionEndpoints.instanceInputEndpoints. cannot be null.'));
          }
          if (instanceInputEndpointsParameterItem.localPort === null || instanceInputEndpointsParameterItem.localPort === undefined) {
            return callback(new Error('parameters.extensionEndpoints.instanceInputEndpoints. cannot be null.'));
          }
          if (instanceInputEndpointsParameterItem.name === null || instanceInputEndpointsParameterItem.name === undefined) {
            return callback(new Error('parameters.extensionEndpoints.instanceInputEndpoints. cannot be null.'));
          }
          if (instanceInputEndpointsParameterItem.protocol === null || instanceInputEndpointsParameterItem.protocol === undefined) {
            return callback(new Error('parameters.extensionEndpoints.instanceInputEndpoints. cannot be null.'));
          }
        }
      }
      if (parameters.extensionEndpoints.internalEndpoints !== null && parameters.extensionEndpoints.internalEndpoints !== undefined) {
        for (var loweredIndex3 = 0; loweredIndex3 < parameters.extensionEndpoints.internalEndpoints.length; loweredIndex3 = loweredIndex3 + 1) {
          var internalEndpointsParameterItem = parameters.extensionEndpoints.internalEndpoints[loweredIndex3];
          if (internalEndpointsParameterItem.name === null || internalEndpointsParameterItem.name === undefined) {
            return callback(new Error('parameters.extensionEndpoints.internalEndpoints. cannot be null.'));
          }
          if (internalEndpointsParameterItem.port === null || internalEndpointsParameterItem.port === undefined) {
            return callback(new Error('parameters.extensionEndpoints.internalEndpoints. cannot be null.'));
          }
          if (internalEndpointsParameterItem.protocol === null || internalEndpointsParameterItem.protocol === undefined) {
            return callback(new Error('parameters.extensionEndpoints.internalEndpoints. cannot be null.'));
          }
        }
      }
    }
    if (parameters.localResources !== null && parameters.localResources !== undefined) {
      for (var loweredIndex4 = 0; loweredIndex4 < parameters.localResources.length; loweredIndex4 = loweredIndex4 + 1) {
        var localResourcesParameterItem = parameters.localResources[loweredIndex4];
        if (localResourcesParameterItem.name === null || localResourcesParameterItem.name === undefined) {
          return callback(new Error('parameters.localResources.name cannot be null.'));
        }
      }
    }
    if (parameters.providerNameSpace === null || parameters.providerNameSpace === undefined) {
      return callback(new Error('parameters.providerNameSpace cannot be null.'));
    }
    if (parameters.type === null || parameters.type === undefined) {
      return callback(new Error('parameters.type cannot be null.'));
    }
    if (parameters.version === null || parameters.version === undefined) {
      return callback(new Error('parameters.version cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/extensions';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var extensionImageElement = js2xml.createElement('ExtensionImage', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, extensionImageElement);
    
    var providerNameSpaceElement = js2xml.createElement('ProviderNameSpace', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(providerNameSpaceElement, parameters.providerNameSpace);
    js2xml.addChildElement(extensionImageElement, providerNameSpaceElement);
    
    var typeElement = js2xml.createElement('Type', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(typeElement, parameters.type);
    js2xml.addChildElement(extensionImageElement, typeElement);
    
    var versionElement = js2xml.createElement('Version', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(versionElement, parameters.version);
    js2xml.addChildElement(extensionImageElement, versionElement);
    
    if (parameters.label !== null && parameters.label !== undefined) {
      var labelElement = js2xml.createElement('Label', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(labelElement, parameters.label);
      js2xml.addChildElement(extensionImageElement, labelElement);
    }
    
    if (parameters.hostingResources !== null && parameters.hostingResources !== undefined) {
      var hostingResourcesElement = js2xml.createElement('HostingResources', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(hostingResourcesElement, parameters.hostingResources);
      js2xml.addChildElement(extensionImageElement, hostingResourcesElement);
    }
    
    if (parameters.mediaLink !== null && parameters.mediaLink !== undefined) {
      var mediaLinkElement = js2xml.createElement('MediaLink', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(mediaLinkElement, parameters.mediaLink);
      js2xml.addChildElement(extensionImageElement, mediaLinkElement);
    }
    
    if (parameters.certificate !== null && parameters.certificate !== undefined) {
      var certificateElement = js2xml.createElement('Certificate', 'http://schemas.microsoft.com/windowsazure');
      js2xml.addChildElement(extensionImageElement, certificateElement);
      
      var storeLocationElement = js2xml.createElement('StoreLocation', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(storeLocationElement, parameters.certificate.storeLocation);
      js2xml.addChildElement(certificateElement, storeLocationElement);
      
      if (parameters.certificate.storeName !== null && parameters.certificate.storeName !== undefined) {
        var storeNameElement = js2xml.createElement('StoreName', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(storeNameElement, parameters.certificate.storeName);
        js2xml.addChildElement(certificateElement, storeNameElement);
      }
      
      if (parameters.certificate.thumbprintRequired !== null && parameters.certificate.thumbprintRequired !== undefined) {
        var thumbprintRequiredElement = js2xml.createElement('ThumbprintRequired', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(thumbprintRequiredElement, parameters.certificate.thumbprintRequired.toString());
        js2xml.addChildElement(certificateElement, thumbprintRequiredElement);
      }
      
      if (parameters.certificate.thumbprintAlgorithm !== null && parameters.certificate.thumbprintAlgorithm !== undefined) {
        var thumbprintAlgorithmElement = js2xml.createElement('ThumbprintAlgorithm', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(thumbprintAlgorithmElement, parameters.certificate.thumbprintAlgorithm);
        js2xml.addChildElement(certificateElement, thumbprintAlgorithmElement);
      }
    }
    
    if (parameters.extensionEndpoints !== null && parameters.extensionEndpoints !== undefined) {
      var endpointsElement = js2xml.createElement('Endpoints', 'http://schemas.microsoft.com/windowsazure');
      js2xml.addChildElement(extensionImageElement, endpointsElement);
      
      if (parameters.extensionEndpoints.inputEndpoints !== null && parameters.extensionEndpoints.inputEndpoints !== undefined) {
        var inputEndpointsSequenceElement = js2xml.createElement('InputEndpoints', 'http://schemas.microsoft.com/windowsazure');
        for (var loweredIndex5 = 0; loweredIndex5 < parameters.extensionEndpoints.inputEndpoints.length; loweredIndex5 = loweredIndex5 + 1) {
          var inputEndpointsItem = parameters.extensionEndpoints.inputEndpoints[loweredIndex5];
          var inputEndpointElement = js2xml.createElement('InputEndpoint', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(inputEndpointsSequenceElement, inputEndpointElement);
          
          var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(nameElement, inputEndpointsItem.name);
          js2xml.addChildElement(inputEndpointElement, nameElement);
          
          var protocolElement = js2xml.createElement('Protocol', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(protocolElement, inputEndpointsItem.protocol);
          js2xml.addChildElement(inputEndpointElement, protocolElement);
          
          var portElement = js2xml.createElement('Port', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(portElement, inputEndpointsItem.port.toString());
          js2xml.addChildElement(inputEndpointElement, portElement);
          
          var localPortElement = js2xml.createElement('LocalPort', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(localPortElement, inputEndpointsItem.localPort);
          js2xml.addChildElement(inputEndpointElement, localPortElement);
        }
        js2xml.addChildElement(endpointsElement, inputEndpointsSequenceElement);
      }
      
      if (parameters.extensionEndpoints.internalEndpoints !== null && parameters.extensionEndpoints.internalEndpoints !== undefined) {
        var internalEndpointsSequenceElement = js2xml.createElement('InternalEndpoints', 'http://schemas.microsoft.com/windowsazure');
        for (var loweredIndex6 = 0; loweredIndex6 < parameters.extensionEndpoints.internalEndpoints.length; loweredIndex6 = loweredIndex6 + 1) {
          var internalEndpointsItem = parameters.extensionEndpoints.internalEndpoints[loweredIndex6];
          var internalEndpointElement = js2xml.createElement('InternalEndpoint', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(internalEndpointsSequenceElement, internalEndpointElement);
          
          var nameElement2 = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(nameElement2, internalEndpointsItem.name);
          js2xml.addChildElement(internalEndpointElement, nameElement2);
          
          var protocolElement2 = js2xml.createElement('Protocol', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(protocolElement2, internalEndpointsItem.protocol);
          js2xml.addChildElement(internalEndpointElement, protocolElement2);
          
          var portElement2 = js2xml.createElement('Port', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(portElement2, internalEndpointsItem.port.toString());
          js2xml.addChildElement(internalEndpointElement, portElement2);
        }
        js2xml.addChildElement(endpointsElement, internalEndpointsSequenceElement);
      }
      
      if (parameters.extensionEndpoints.instanceInputEndpoints !== null && parameters.extensionEndpoints.instanceInputEndpoints !== undefined) {
        var instanceInputEndpointsSequenceElement = js2xml.createElement('InstanceInputEndpoints', 'http://schemas.microsoft.com/windowsazure');
        for (var loweredIndex7 = 0; loweredIndex7 < parameters.extensionEndpoints.instanceInputEndpoints.length; loweredIndex7 = loweredIndex7 + 1) {
          var instanceInputEndpointsItem = parameters.extensionEndpoints.instanceInputEndpoints[loweredIndex7];
          var instanceInputEndpointElement = js2xml.createElement('InstanceInputEndpoint', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(instanceInputEndpointsSequenceElement, instanceInputEndpointElement);
          
          var nameElement3 = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(nameElement3, instanceInputEndpointsItem.name);
          js2xml.addChildElement(instanceInputEndpointElement, nameElement3);
          
          var protocolElement3 = js2xml.createElement('Protocol', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(protocolElement3, instanceInputEndpointsItem.protocol);
          js2xml.addChildElement(instanceInputEndpointElement, protocolElement3);
          
          var localPortElement2 = js2xml.createElement('LocalPort', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(localPortElement2, instanceInputEndpointsItem.localPort);
          js2xml.addChildElement(instanceInputEndpointElement, localPortElement2);
          
          var fixedPortMinElement = js2xml.createElement('FixedPortMin', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(fixedPortMinElement, instanceInputEndpointsItem.fixedPortMin.toString());
          js2xml.addChildElement(instanceInputEndpointElement, fixedPortMinElement);
          
          var fixedPortMaxElement = js2xml.createElement('FixedPortMax', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(fixedPortMaxElement, instanceInputEndpointsItem.fixedPortMax.toString());
          js2xml.addChildElement(instanceInputEndpointElement, fixedPortMaxElement);
        }
        js2xml.addChildElement(endpointsElement, instanceInputEndpointsSequenceElement);
      }
    }
    
    if (parameters.publicConfigurationSchema !== null && parameters.publicConfigurationSchema !== undefined) {
      var publicConfigurationSchemaElement = js2xml.createElement('PublicConfigurationSchema', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(publicConfigurationSchemaElement, new Buffer(parameters.publicConfigurationSchema).toString('base64'));
      js2xml.addChildElement(extensionImageElement, publicConfigurationSchemaElement);
    }
    
    if (parameters.privateConfigurationSchema !== null && parameters.privateConfigurationSchema !== undefined) {
      var privateConfigurationSchemaElement = js2xml.createElement('PrivateConfigurationSchema', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(privateConfigurationSchemaElement, new Buffer(parameters.privateConfigurationSchema).toString('base64'));
      js2xml.addChildElement(extensionImageElement, privateConfigurationSchemaElement);
    }
    
    if (parameters.description !== null && parameters.description !== undefined) {
      var descriptionElement = js2xml.createElement('Description', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(descriptionElement, parameters.description);
      js2xml.addChildElement(extensionImageElement, descriptionElement);
    }
    
    if (parameters.publisherName !== null && parameters.publisherName !== undefined) {
      var publisherNameElement = js2xml.createElement('PublisherName', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(publisherNameElement, parameters.publisherName);
      js2xml.addChildElement(extensionImageElement, publisherNameElement);
    }
    
    if (parameters.publishedDate !== null && parameters.publishedDate !== undefined) {
      var publishedDateElement = js2xml.createElement('PublishedDate', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(publishedDateElement, parameters.publishedDate.toISOString());
      js2xml.addChildElement(extensionImageElement, publishedDateElement);
    }
    
    if (parameters.localResources !== null && parameters.localResources !== undefined) {
      var localResourcesSequenceElement = js2xml.createElement('LocalResources', 'http://schemas.microsoft.com/windowsazure');
      for (var loweredIndex8 = 0; loweredIndex8 < parameters.localResources.length; loweredIndex8 = loweredIndex8 + 1) {
        var localResourcesItem = parameters.localResources[loweredIndex8];
        var localResourceElement = js2xml.createElement('LocalResource', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(localResourcesSequenceElement, localResourceElement);
        
        var nameElement4 = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(nameElement4, localResourcesItem.name);
        js2xml.addChildElement(localResourceElement, nameElement4);
        
        if (localResourcesItem.sizeInMB !== null && localResourcesItem.sizeInMB !== undefined) {
          var sizeInMBElement = js2xml.createElement('SizeInMB', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(sizeInMBElement, localResourcesItem.sizeInMB.toString());
          js2xml.addChildElement(localResourceElement, sizeInMBElement);
        }
      }
      js2xml.addChildElement(extensionImageElement, localResourcesSequenceElement);
    }
    
    if (parameters.blockRoleUponFailure !== null && parameters.blockRoleUponFailure !== undefined) {
      var blockRoleUponFailureElement = js2xml.createElement('BlockRoleUponFailure', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(blockRoleUponFailureElement, parameters.blockRoleUponFailure.toString());
      js2xml.addChildElement(extensionImageElement, blockRoleUponFailureElement);
    }
    
    if (parameters.isInternalExtension !== null && parameters.isInternalExtension !== undefined) {
      var isInternalExtensionElement = js2xml.createElement('IsInternalExtension', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(isInternalExtensionElement, parameters.isInternalExtension.toString());
      js2xml.addChildElement(extensionImageElement, isInternalExtensionElement);
    }
    
    if (parameters.sampleConfig !== null && parameters.sampleConfig !== undefined) {
      var sampleConfigElement = js2xml.createElement('SampleConfig', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(sampleConfigElement, new Buffer(parameters.sampleConfig).toString('base64'));
      js2xml.addChildElement(extensionImageElement, sampleConfigElement);
    }
    
    if (parameters.replicationCompleted !== null && parameters.replicationCompleted !== undefined) {
      var replicationCompletedElement = js2xml.createElement('ReplicationCompleted', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(replicationCompletedElement, parameters.replicationCompleted.toString());
      js2xml.addChildElement(extensionImageElement, replicationCompletedElement);
    }
    
    if (parameters.eula !== null && parameters.eula !== undefined) {
      var eulaElement = js2xml.createElement('Eula', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(eulaElement, parameters.eula);
      js2xml.addChildElement(extensionImageElement, eulaElement);
    }
    
    if (parameters.privacyUri !== null && parameters.privacyUri !== undefined) {
      var privacyUriElement = js2xml.createElement('PrivacyUri', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(privacyUriElement, parameters.privacyUri);
      js2xml.addChildElement(extensionImageElement, privacyUriElement);
    }
    
    if (parameters.homepageUri !== null && parameters.homepageUri !== undefined) {
      var homepageUriElement = js2xml.createElement('HomepageUri', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(homepageUriElement, parameters.homepageUri);
      js2xml.addChildElement(extensionImageElement, homepageUriElement);
    }
    
    if (parameters.isJsonExtension !== null && parameters.isJsonExtension !== undefined) {
      var isJsonExtensionElement = js2xml.createElement('IsJsonExtension', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(isJsonExtensionElement, parameters.isJsonExtension.toString());
      js2xml.addChildElement(extensionImageElement, isJsonExtensionElement);
    }
    
    if (parameters.disallowMajorVersionUpgrade !== null && parameters.disallowMajorVersionUpgrade !== undefined) {
      var disallowMajorVersionUpgradeElement = js2xml.createElement('DisallowMajorVersionUpgrade', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(disallowMajorVersionUpgradeElement, parameters.disallowMajorVersionUpgrade.toString());
      js2xml.addChildElement(extensionImageElement, disallowMajorVersionUpgradeElement);
    }
    
    if (parameters.supportedOS !== null && parameters.supportedOS !== undefined) {
      var supportedOSElement = js2xml.createElement('SupportedOS', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(supportedOSElement, parameters.supportedOS);
      js2xml.addChildElement(extensionImageElement, supportedOSElement);
    }
    
    if (parameters.companyName !== null && parameters.companyName !== undefined) {
      var companyNameElement = js2xml.createElement('CompanyName', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(companyNameElement, parameters.companyName);
      js2xml.addChildElement(extensionImageElement, companyNameElement);
    }
    
    if (parameters.regions !== null && parameters.regions !== undefined) {
      var regionsElement = js2xml.createElement('Regions', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(regionsElement, parameters.regions);
      js2xml.addChildElement(extensionImageElement, regionsElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Unregister a version of an extension that was previously registered using
   * either the Register Extension or Update Extension APIs. An extension
   * version is identified by the combination of its ProviderNamespace, Type
   * and Version which are specified when registering the extension.
   * Unregistering is only allowed for internal extensions, that is, the
   * extensions for which the IsInternalExtension field is set to 'true'
   * during registration or during an update. There is a quota (15) on the
   * number of extensions that can be registered per subscription. If your
   * subscription runs out of quota, you will wither need to unregister some
   * of the internal extensions or contact Azure (same email used to become a
   * publisher)  to increase the quota.
   * 
   * @param {string} providerNamespace The provider namespace of the extension
   * image to unregister.
   * 
   * @param {string} type The type of the extension image to unregister.
   * 
   * @param {string} version The version of the extension image to unregister.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ExtensionImageOperations.prototype.beginUnregistering = function(providerNamespace, type, version, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (providerNamespace === null || providerNamespace === undefined) {
      return callback(new Error('providerNamespace cannot be null.'));
    }
    if (type === null || type === undefined) {
      return callback(new Error('type cannot be null.'));
    }
    if (version === null || version === undefined) {
      return callback(new Error('version cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/extensions/';
    url2 = url2 + encodeURIComponent(providerNamespace);
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(type);
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(version);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Update a new extension. It is allowed to update an extension which had
   * already been registered with the same identity (i.e. combination of
   * ProviderNamespace and Type) but with different version. It will fail if
   * the extension to update has an identity that has not been registered
   * before, or there is already an extension with the same identity and same
   * version.
   * 
   * @param {ExtensionImageUpdateParameters} parameters Parameters supplied to
   * the Update Virtual Machine Extension Image operation.
   * 
   * @param {string} parameters.providerNameSpace Required. The provider
   * namespace of the extension.
   * 
   * @param {string} parameters.type Required. The type of the extension.
   * 
   * @param {string} parameters.version Required. The version of the extension.
   * 
   * @param {string} [parameters.label] Required. A one line label of the
   * extension.
   * 
   * @param {string} [parameters.hostingResources] Required. The supported
   * hosting resources. It must contain 'WebRole' and/or 'WorkerRole'. E.g.
   * 'WebRole|WorkerRole' or 'WebRole|WorkerRole|VmRole'.
   * 
   * @param {string} [parameters.mediaLink] Required. URI string pointing to
   * the ZIP package of the extension. The ZIP package has to include the
   * extension executable and other supporting files, and the
   * PluginManifest.xml manifest. MediaLink value must point to a URL (either
   * Http or Https) in a Azure blob storage and is downloadable. Windows Azure
   * will copy the extension package from this source location and replicate
   * it to all regions. The typical time for replication to complete is 20
   * minutes.
   * 
   * @param {ExtensionCertificateConfiguration} [parameters.certificate]
   * Optional. Parameters of the the certificate for encrypting the private
   * configuration data. Supported on WebRole or WorkerRole, but ignored on
   * VmRole.
   * 
   * @param {string} [parameters.certificate.storeLocation] Required for
   * certificate declaration. The Windows certificate store location to
   * install the certificate for encryption, if required. Its value has to be
   * 'LocalMachine' if present.
   * 
   * @param {string} [parameters.certificate.storeName] Optional. The Windows
   * certificate store name to install the certificate for encryption, if
   * required. Its value has to be 'My' if present.
   * 
   * @param {boolean} [parameters.certificate.thumbprintRequired] Optional.
   * Whether thumbprint is required for the certificate for encryption or not.
   * Its value has to be 'true' or 'false' (case-sensitive) if present.
   * 
   * @param {string} [parameters.certificate.thumbprintAlgorithm] Optional. The
   * thumbprint algorithm of the certificate for encryption, if required. Its
   * value has to be 'sha1' if present.
   * 
   * @param {ExtensionEndpointConfiguration} [parameters.extensionEndpoints]
   * Optional. Declared endpoints to automatically add to each deployment with
   * this extension added.
   * 
   * @param {array} [parameters.extensionEndpoints.inputEndpoints] Optional. A
   * list of input endpoints required by this extension. Supported on WebRole
   * or WorkerRole, but ignored on VmRole. Each input endpoint will be
   * automatically added to the service definition of the deployment utilizing
   * this extension.
   * 
   * @param {array} [parameters.extensionEndpoints.internalEndpoints] Optional.
   * A list of internal endpoints required by this extension. Supported on
   * WebRole or WorkerRole, but ignored on VmRole. Each internal endpoint will
   * be automatically added to the service definition of the deployment
   * utilizing this extension.
   * 
   * @param {array} [parameters.extensionEndpoints.instanceInputEndpoints]
   * Optional. A list of instance input endpoints required by this extension.
   * Supported on WebRole or WorkerRole, but ignored on VmRole. Each instance
   * input endpoint will be automatically added to the service definition of
   * the deployment utilizing this extension.
   * 
   * @param {string} [parameters.publicConfigurationSchema] Optional. The XSD
   * schema of public configuration data.
   * 
   * @param {string} [parameters.privateConfigurationSchema] Optional. The XSD
   * schema of private configuration data.
   * 
   * @param {string} [parameters.description] Required. Detailed description of
   * the extension.
   * 
   * @param {string} [parameters.publisherName] Optional. Publisher name text.
   * 
   * @param {date} [parameters.publishedDate] Publisher can set it to any
   * arbitrary date, and this is only for display purpose. If not specified by
   * publisher, Azure will automatically assign the UTC time when the
   * extension request was received.
   * 
   * @param {array} [parameters.localResources] Declared local resources used
   * inside guest VM by the extension. Optional.
   * 
   * @param {boolean} [parameters.blockRoleUponFailure] Optional. Its value has
   * to be 'true' or 'false' (case-sensitive) When set to 'true', the role
   * startup will be blocked till the extension installation completes. This
   * flag should be set to 'true' when the role cannot start without the
   * extension being installed. If set to 'false' (default value), the role
   * will be started without waiting for the extension installation to
   * complete. Supported on WebRole or WorkerRole, but ignored on VmRole.
   * 
   * @param {boolean} [parameters.isInternalExtension] Optional. If this is set
   * to 'true' the extension is not visible for public use, i.e. being
   * returned from list API's. It can be still accessed by referring to the
   * ProviderNamespace, Type & Version combo. Therefore an internal extension
   * is intended only for testing purpose. Its value has to be 'true' or
   * 'false' (case-sensitive) if present.
   * 
   * @param {string} [parameters.sampleConfig] Optional. A sample configuration
   * for the extension. It can be downloaded by users, and the user can
   * replace with customized input parameters. The sample configuration should
   * be sufficiently commented. If configuration data are in XML format, then
   * the XML document-level element must be 'Configuration', and the optional
   * public configuration data corresponds to a child element of
   * 'PublicConfig', and the optional private configuration data corresponds
   * to a child element of 'PrivateConfig'. The sample configuration data
   * should be validated against public and private configuration schema by
   * the publisher.
   * 
   * @param {boolean} [parameters.replicationCompleted] Indicates whether this
   * version of extension has been replicated to all regions or not. If true,
   * then the given extension version can be used in creating or updating
   * deployments. Otherwise, the given extension version might cause failure
   * in creating or updating deployments. The typical time is 20 minutes for a
   * newly-registered or newly-updated extension to replicate completely by
   * Azure.
   * 
   * @param {string} [parameters.eula] Optional. URL string pointing to the
   * EULA (End User License Agreement) of this version of extension. This is
   * optionally specified by the third-party publishing the extension instead
   * of Windows Azure. If the software requires any additional EULAs, a link
   * to the EULA should be provided.
   * 
   * @param {string} [parameters.privacyUri] Optional. URL string pointing to
   * privacy document of this version of extension. This is optionally
   * specified by the third-party publishing the extension instead of Azure.
   * If the software collects any data and transfers out the guest VM, then an
   * additional privacy document might be needed.
   * 
   * @param {string} [parameters.homepageUri] Optional. URL string pointing to
   * homepage of this version of extension. This is optionally specified by
   * the third-party publishing the extension instead of Azure. The homepage
   * should have usage information and contact information for customer
   * support.
   * 
   * @param {boolean} [parameters.isJsonExtension] Optional. If this is set to
   * 'true' the extension is expected to receive JSON based configuration. If
   * this is set to 'false' the extension is expected to receive XML based
   * configuration. Its value has to be 'true' or 'false' (case-sensitive) if
   * present.
   * 
   * @param {boolean} [parameters.disallowMajorVersionUpgrade] Optional. If
   * this is set to 'true' the extension version cannot be upgraded to from
   * other major versions in active deployments. If the value is 'false' or
   * nor present, the extension version can be upgraded to from any other
   * version. Downgrade is not supported. The value has to be 'true' or
   * 'false' (case-sensitive) if present.
   * 
   * @param {string} [parameters.supportedOS] String property indicating the OS
   * which the extension supports. Current values are 'Windows' or 'Linux'.
   * 
   * @param {string} [parameters.companyName] String property containing the
   * name of the company/organization who publishes the extension.
   * 
   * @param {string} [parameters.regions] String property containing the name
   * of the regions required for the slice.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ExtensionImageOperations.prototype.beginUpdating = function(parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.certificate !== null && parameters.certificate !== undefined) {
      if (parameters.certificate.storeLocation === null || parameters.certificate.storeLocation === undefined) {
        return callback(new Error('parameters.certificate.storeLocation cannot be null.'));
      }
    }
    if (parameters.extensionEndpoints !== null && parameters.extensionEndpoints !== undefined) {
      if (parameters.extensionEndpoints.inputEndpoints !== null && parameters.extensionEndpoints.inputEndpoints !== undefined) {
        for (var loweredIndex1 = 0; loweredIndex1 < parameters.extensionEndpoints.inputEndpoints.length; loweredIndex1 = loweredIndex1 + 1) {
          var inputEndpointsParameterItem = parameters.extensionEndpoints.inputEndpoints[loweredIndex1];
          if (inputEndpointsParameterItem.localPort === null || inputEndpointsParameterItem.localPort === undefined) {
            return callback(new Error('parameters.extensionEndpoints.inputEndpoints. cannot be null.'));
          }
          if (inputEndpointsParameterItem.name === null || inputEndpointsParameterItem.name === undefined) {
            return callback(new Error('parameters.extensionEndpoints.inputEndpoints. cannot be null.'));
          }
          if (inputEndpointsParameterItem.port === null || inputEndpointsParameterItem.port === undefined) {
            return callback(new Error('parameters.extensionEndpoints.inputEndpoints. cannot be null.'));
          }
          if (inputEndpointsParameterItem.protocol === null || inputEndpointsParameterItem.protocol === undefined) {
            return callback(new Error('parameters.extensionEndpoints.inputEndpoints. cannot be null.'));
          }
        }
      }
      if (parameters.extensionEndpoints.instanceInputEndpoints !== null && parameters.extensionEndpoints.instanceInputEndpoints !== undefined) {
        for (var loweredIndex2 = 0; loweredIndex2 < parameters.extensionEndpoints.instanceInputEndpoints.length; loweredIndex2 = loweredIndex2 + 1) {
          var instanceInputEndpointsParameterItem = parameters.extensionEndpoints.instanceInputEndpoints[loweredIndex2];
          if (instanceInputEndpointsParameterItem.fixedPortMax === null || instanceInputEndpointsParameterItem.fixedPortMax === undefined) {
            return callback(new Error('parameters.extensionEndpoints.instanceInputEndpoints. cannot be null.'));
          }
          if (instanceInputEndpointsParameterItem.fixedPortMin === null || instanceInputEndpointsParameterItem.fixedPortMin === undefined) {
            return callback(new Error('parameters.extensionEndpoints.instanceInputEndpoints. cannot be null.'));
          }
          if (instanceInputEndpointsParameterItem.localPort === null || instanceInputEndpointsParameterItem.localPort === undefined) {
            return callback(new Error('parameters.extensionEndpoints.instanceInputEndpoints. cannot be null.'));
          }
          if (instanceInputEndpointsParameterItem.name === null || instanceInputEndpointsParameterItem.name === undefined) {
            return callback(new Error('parameters.extensionEndpoints.instanceInputEndpoints. cannot be null.'));
          }
          if (instanceInputEndpointsParameterItem.protocol === null || instanceInputEndpointsParameterItem.protocol === undefined) {
            return callback(new Error('parameters.extensionEndpoints.instanceInputEndpoints. cannot be null.'));
          }
        }
      }
      if (parameters.extensionEndpoints.internalEndpoints !== null && parameters.extensionEndpoints.internalEndpoints !== undefined) {
        for (var loweredIndex3 = 0; loweredIndex3 < parameters.extensionEndpoints.internalEndpoints.length; loweredIndex3 = loweredIndex3 + 1) {
          var internalEndpointsParameterItem = parameters.extensionEndpoints.internalEndpoints[loweredIndex3];
          if (internalEndpointsParameterItem.name === null || internalEndpointsParameterItem.name === undefined) {
            return callback(new Error('parameters.extensionEndpoints.internalEndpoints. cannot be null.'));
          }
          if (internalEndpointsParameterItem.port === null || internalEndpointsParameterItem.port === undefined) {
            return callback(new Error('parameters.extensionEndpoints.internalEndpoints. cannot be null.'));
          }
          if (internalEndpointsParameterItem.protocol === null || internalEndpointsParameterItem.protocol === undefined) {
            return callback(new Error('parameters.extensionEndpoints.internalEndpoints. cannot be null.'));
          }
        }
      }
    }
    if (parameters.localResources !== null && parameters.localResources !== undefined) {
      for (var loweredIndex4 = 0; loweredIndex4 < parameters.localResources.length; loweredIndex4 = loweredIndex4 + 1) {
        var localResourcesParameterItem = parameters.localResources[loweredIndex4];
        if (localResourcesParameterItem.name === null || localResourcesParameterItem.name === undefined) {
          return callback(new Error('parameters.localResources.name cannot be null.'));
        }
      }
    }
    if (parameters.providerNameSpace === null || parameters.providerNameSpace === undefined) {
      return callback(new Error('parameters.providerNameSpace cannot be null.'));
    }
    if (parameters.type === null || parameters.type === undefined) {
      return callback(new Error('parameters.type cannot be null.'));
    }
    if (parameters.version === null || parameters.version === undefined) {
      return callback(new Error('parameters.version cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/extensions';
    var queryParameters = [];
    queryParameters.push('action=update');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var extensionImageElement = js2xml.createElement('ExtensionImage', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, extensionImageElement);
    
    var providerNameSpaceElement = js2xml.createElement('ProviderNameSpace', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(providerNameSpaceElement, parameters.providerNameSpace);
    js2xml.addChildElement(extensionImageElement, providerNameSpaceElement);
    
    var typeElement = js2xml.createElement('Type', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(typeElement, parameters.type);
    js2xml.addChildElement(extensionImageElement, typeElement);
    
    var versionElement = js2xml.createElement('Version', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(versionElement, parameters.version);
    js2xml.addChildElement(extensionImageElement, versionElement);
    
    if (parameters.label !== null && parameters.label !== undefined) {
      var labelElement = js2xml.createElement('Label', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(labelElement, parameters.label);
      js2xml.addChildElement(extensionImageElement, labelElement);
    }
    
    if (parameters.hostingResources !== null && parameters.hostingResources !== undefined) {
      var hostingResourcesElement = js2xml.createElement('HostingResources', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(hostingResourcesElement, parameters.hostingResources);
      js2xml.addChildElement(extensionImageElement, hostingResourcesElement);
    }
    
    if (parameters.mediaLink !== null && parameters.mediaLink !== undefined) {
      var mediaLinkElement = js2xml.createElement('MediaLink', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(mediaLinkElement, parameters.mediaLink);
      js2xml.addChildElement(extensionImageElement, mediaLinkElement);
    }
    
    if (parameters.certificate !== null && parameters.certificate !== undefined) {
      var certificateElement = js2xml.createElement('Certificate', 'http://schemas.microsoft.com/windowsazure');
      js2xml.addChildElement(extensionImageElement, certificateElement);
      
      var storeLocationElement = js2xml.createElement('StoreLocation', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(storeLocationElement, parameters.certificate.storeLocation);
      js2xml.addChildElement(certificateElement, storeLocationElement);
      
      if (parameters.certificate.storeName !== null && parameters.certificate.storeName !== undefined) {
        var storeNameElement = js2xml.createElement('StoreName', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(storeNameElement, parameters.certificate.storeName);
        js2xml.addChildElement(certificateElement, storeNameElement);
      }
      
      if (parameters.certificate.thumbprintRequired !== null && parameters.certificate.thumbprintRequired !== undefined) {
        var thumbprintRequiredElement = js2xml.createElement('ThumbprintRequired', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(thumbprintRequiredElement, parameters.certificate.thumbprintRequired.toString());
        js2xml.addChildElement(certificateElement, thumbprintRequiredElement);
      }
      
      if (parameters.certificate.thumbprintAlgorithm !== null && parameters.certificate.thumbprintAlgorithm !== undefined) {
        var thumbprintAlgorithmElement = js2xml.createElement('ThumbprintAlgorithm', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(thumbprintAlgorithmElement, parameters.certificate.thumbprintAlgorithm);
        js2xml.addChildElement(certificateElement, thumbprintAlgorithmElement);
      }
    }
    
    if (parameters.extensionEndpoints !== null && parameters.extensionEndpoints !== undefined) {
      var endpointsElement = js2xml.createElement('Endpoints', 'http://schemas.microsoft.com/windowsazure');
      js2xml.addChildElement(extensionImageElement, endpointsElement);
      
      if (parameters.extensionEndpoints.inputEndpoints !== null && parameters.extensionEndpoints.inputEndpoints !== undefined) {
        var inputEndpointsSequenceElement = js2xml.createElement('InputEndpoints', 'http://schemas.microsoft.com/windowsazure');
        for (var loweredIndex5 = 0; loweredIndex5 < parameters.extensionEndpoints.inputEndpoints.length; loweredIndex5 = loweredIndex5 + 1) {
          var inputEndpointsItem = parameters.extensionEndpoints.inputEndpoints[loweredIndex5];
          var inputEndpointElement = js2xml.createElement('InputEndpoint', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(inputEndpointsSequenceElement, inputEndpointElement);
          
          var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(nameElement, inputEndpointsItem.name);
          js2xml.addChildElement(inputEndpointElement, nameElement);
          
          var protocolElement = js2xml.createElement('Protocol', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(protocolElement, inputEndpointsItem.protocol);
          js2xml.addChildElement(inputEndpointElement, protocolElement);
          
          var portElement = js2xml.createElement('Port', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(portElement, inputEndpointsItem.port.toString());
          js2xml.addChildElement(inputEndpointElement, portElement);
          
          var localPortElement = js2xml.createElement('LocalPort', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(localPortElement, inputEndpointsItem.localPort);
          js2xml.addChildElement(inputEndpointElement, localPortElement);
        }
        js2xml.addChildElement(endpointsElement, inputEndpointsSequenceElement);
      }
      
      if (parameters.extensionEndpoints.internalEndpoints !== null && parameters.extensionEndpoints.internalEndpoints !== undefined) {
        var internalEndpointsSequenceElement = js2xml.createElement('InternalEndpoints', 'http://schemas.microsoft.com/windowsazure');
        for (var loweredIndex6 = 0; loweredIndex6 < parameters.extensionEndpoints.internalEndpoints.length; loweredIndex6 = loweredIndex6 + 1) {
          var internalEndpointsItem = parameters.extensionEndpoints.internalEndpoints[loweredIndex6];
          var internalEndpointElement = js2xml.createElement('InternalEndpoint', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(internalEndpointsSequenceElement, internalEndpointElement);
          
          var nameElement2 = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(nameElement2, internalEndpointsItem.name);
          js2xml.addChildElement(internalEndpointElement, nameElement2);
          
          var protocolElement2 = js2xml.createElement('Protocol', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(protocolElement2, internalEndpointsItem.protocol);
          js2xml.addChildElement(internalEndpointElement, protocolElement2);
          
          var portElement2 = js2xml.createElement('Port', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(portElement2, internalEndpointsItem.port.toString());
          js2xml.addChildElement(internalEndpointElement, portElement2);
        }
        js2xml.addChildElement(endpointsElement, internalEndpointsSequenceElement);
      }
      
      if (parameters.extensionEndpoints.instanceInputEndpoints !== null && parameters.extensionEndpoints.instanceInputEndpoints !== undefined) {
        var instanceInputEndpointsSequenceElement = js2xml.createElement('InstanceInputEndpoints', 'http://schemas.microsoft.com/windowsazure');
        for (var loweredIndex7 = 0; loweredIndex7 < parameters.extensionEndpoints.instanceInputEndpoints.length; loweredIndex7 = loweredIndex7 + 1) {
          var instanceInputEndpointsItem = parameters.extensionEndpoints.instanceInputEndpoints[loweredIndex7];
          var instanceInputEndpointElement = js2xml.createElement('InstanceInputEndpoint', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(instanceInputEndpointsSequenceElement, instanceInputEndpointElement);
          
          var nameElement3 = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(nameElement3, instanceInputEndpointsItem.name);
          js2xml.addChildElement(instanceInputEndpointElement, nameElement3);
          
          var protocolElement3 = js2xml.createElement('Protocol', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(protocolElement3, instanceInputEndpointsItem.protocol);
          js2xml.addChildElement(instanceInputEndpointElement, protocolElement3);
          
          var localPortElement2 = js2xml.createElement('LocalPort', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(localPortElement2, instanceInputEndpointsItem.localPort);
          js2xml.addChildElement(instanceInputEndpointElement, localPortElement2);
          
          var fixedPortMinElement = js2xml.createElement('FixedPortMin', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(fixedPortMinElement, instanceInputEndpointsItem.fixedPortMin.toString());
          js2xml.addChildElement(instanceInputEndpointElement, fixedPortMinElement);
          
          var fixedPortMaxElement = js2xml.createElement('FixedPortMax', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(fixedPortMaxElement, instanceInputEndpointsItem.fixedPortMax.toString());
          js2xml.addChildElement(instanceInputEndpointElement, fixedPortMaxElement);
        }
        js2xml.addChildElement(endpointsElement, instanceInputEndpointsSequenceElement);
      }
    }
    
    if (parameters.publicConfigurationSchema !== null && parameters.publicConfigurationSchema !== undefined) {
      var publicConfigurationSchemaElement = js2xml.createElement('PublicConfigurationSchema', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(publicConfigurationSchemaElement, new Buffer(parameters.publicConfigurationSchema).toString('base64'));
      js2xml.addChildElement(extensionImageElement, publicConfigurationSchemaElement);
    }
    
    if (parameters.privateConfigurationSchema !== null && parameters.privateConfigurationSchema !== undefined) {
      var privateConfigurationSchemaElement = js2xml.createElement('PrivateConfigurationSchema', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(privateConfigurationSchemaElement, new Buffer(parameters.privateConfigurationSchema).toString('base64'));
      js2xml.addChildElement(extensionImageElement, privateConfigurationSchemaElement);
    }
    
    if (parameters.description !== null && parameters.description !== undefined) {
      var descriptionElement = js2xml.createElement('Description', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(descriptionElement, parameters.description);
      js2xml.addChildElement(extensionImageElement, descriptionElement);
    }
    
    if (parameters.publisherName !== null && parameters.publisherName !== undefined) {
      var publisherNameElement = js2xml.createElement('PublisherName', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(publisherNameElement, parameters.publisherName);
      js2xml.addChildElement(extensionImageElement, publisherNameElement);
    }
    
    if (parameters.publishedDate !== null && parameters.publishedDate !== undefined) {
      var publishedDateElement = js2xml.createElement('PublishedDate', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(publishedDateElement, parameters.publishedDate.toISOString());
      js2xml.addChildElement(extensionImageElement, publishedDateElement);
    }
    
    if (parameters.localResources !== null && parameters.localResources !== undefined) {
      var localResourcesSequenceElement = js2xml.createElement('LocalResources', 'http://schemas.microsoft.com/windowsazure');
      for (var loweredIndex8 = 0; loweredIndex8 < parameters.localResources.length; loweredIndex8 = loweredIndex8 + 1) {
        var localResourcesItem = parameters.localResources[loweredIndex8];
        var localResourceElement = js2xml.createElement('LocalResource', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(localResourcesSequenceElement, localResourceElement);
        
        var nameElement4 = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(nameElement4, localResourcesItem.name);
        js2xml.addChildElement(localResourceElement, nameElement4);
        
        if (localResourcesItem.sizeInMB !== null && localResourcesItem.sizeInMB !== undefined) {
          var sizeInMBElement = js2xml.createElement('SizeInMB', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(sizeInMBElement, localResourcesItem.sizeInMB.toString());
          js2xml.addChildElement(localResourceElement, sizeInMBElement);
        }
      }
      js2xml.addChildElement(extensionImageElement, localResourcesSequenceElement);
    }
    
    if (parameters.blockRoleUponFailure !== null && parameters.blockRoleUponFailure !== undefined) {
      var blockRoleUponFailureElement = js2xml.createElement('BlockRoleUponFailure', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(blockRoleUponFailureElement, parameters.blockRoleUponFailure.toString());
      js2xml.addChildElement(extensionImageElement, blockRoleUponFailureElement);
    }
    
    if (parameters.isInternalExtension !== null && parameters.isInternalExtension !== undefined) {
      var isInternalExtensionElement = js2xml.createElement('IsInternalExtension', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(isInternalExtensionElement, parameters.isInternalExtension.toString());
      js2xml.addChildElement(extensionImageElement, isInternalExtensionElement);
    }
    
    if (parameters.sampleConfig !== null && parameters.sampleConfig !== undefined) {
      var sampleConfigElement = js2xml.createElement('SampleConfig', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(sampleConfigElement, new Buffer(parameters.sampleConfig).toString('base64'));
      js2xml.addChildElement(extensionImageElement, sampleConfigElement);
    }
    
    if (parameters.replicationCompleted !== null && parameters.replicationCompleted !== undefined) {
      var replicationCompletedElement = js2xml.createElement('ReplicationCompleted', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(replicationCompletedElement, parameters.replicationCompleted.toString());
      js2xml.addChildElement(extensionImageElement, replicationCompletedElement);
    }
    
    if (parameters.eula !== null && parameters.eula !== undefined) {
      var eulaElement = js2xml.createElement('Eula', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(eulaElement, parameters.eula);
      js2xml.addChildElement(extensionImageElement, eulaElement);
    }
    
    if (parameters.privacyUri !== null && parameters.privacyUri !== undefined) {
      var privacyUriElement = js2xml.createElement('PrivacyUri', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(privacyUriElement, parameters.privacyUri);
      js2xml.addChildElement(extensionImageElement, privacyUriElement);
    }
    
    if (parameters.homepageUri !== null && parameters.homepageUri !== undefined) {
      var homepageUriElement = js2xml.createElement('HomepageUri', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(homepageUriElement, parameters.homepageUri);
      js2xml.addChildElement(extensionImageElement, homepageUriElement);
    }
    
    if (parameters.isJsonExtension !== null && parameters.isJsonExtension !== undefined) {
      var isJsonExtensionElement = js2xml.createElement('IsJsonExtension', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(isJsonExtensionElement, parameters.isJsonExtension.toString());
      js2xml.addChildElement(extensionImageElement, isJsonExtensionElement);
    }
    
    if (parameters.disallowMajorVersionUpgrade !== null && parameters.disallowMajorVersionUpgrade !== undefined) {
      var disallowMajorVersionUpgradeElement = js2xml.createElement('DisallowMajorVersionUpgrade', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(disallowMajorVersionUpgradeElement, parameters.disallowMajorVersionUpgrade.toString());
      js2xml.addChildElement(extensionImageElement, disallowMajorVersionUpgradeElement);
    }
    
    if (parameters.supportedOS !== null && parameters.supportedOS !== undefined) {
      var supportedOSElement = js2xml.createElement('SupportedOS', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(supportedOSElement, parameters.supportedOS);
      js2xml.addChildElement(extensionImageElement, supportedOSElement);
    }
    
    if (parameters.companyName !== null && parameters.companyName !== undefined) {
      var companyNameElement = js2xml.createElement('CompanyName', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(companyNameElement, parameters.companyName);
      js2xml.addChildElement(extensionImageElement, companyNameElement);
    }
    
    if (parameters.regions !== null && parameters.regions !== undefined) {
      var regionsElement = js2xml.createElement('Regions', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(regionsElement, parameters.regions);
      js2xml.addChildElement(extensionImageElement, regionsElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Register a new extension. An extension is identified by the combination of
   * its ProviderNamespace and Type (case-sensitive string). It is not allowed
   * to register an extension with the same identity (i.e. combination of
   * ProviderNamespace and Type) of an already-registered extension. To
   * register new version of an existing extension, the Update Extension API
   * should be used.
   * 
   * @param {ExtensionImageRegisterParameters} parameters Parameters supplied
   * to the Register Virtual Machine Extension Image operation.
   * 
   * @param {string} parameters.providerNameSpace Required. The provider
   * namespace of the extension.
   * 
   * @param {string} parameters.type Required. The type of the extension.
   * 
   * @param {string} parameters.version Required. The version of the extension.
   * 
   * @param {string} [parameters.label] Required. A one line label of the
   * extension.
   * 
   * @param {string} [parameters.hostingResources] Required. The supported
   * hosting resources. It must contain 'WebRole' and/or 'WorkerRole'. E.g.
   * 'WebRole|WorkerRole' or 'WebRole|WorkerRole|VmRole'.
   * 
   * @param {string} [parameters.mediaLink] Required. URI string pointing to
   * the ZIP package of the extension. The ZIP package has to include the
   * extension executable and other supporting files, and the
   * PluginManifest.xml manifest. MediaLink value must point to a URL (either
   * Http or Https) in a Azure blob storage and is downloadable. Windows Azure
   * will copy the extension package from this source location and replicate
   * it to all regions. The typical time for replication to complete is 20
   * minutes.
   * 
   * @param {ExtensionCertificateConfiguration} [parameters.certificate]
   * Optional. Parameters of the the certificate for encrypting the private
   * configuration data. Supported on WebRole or WorkerRole, but ignored on
   * VmRole.
   * 
   * @param {string} [parameters.certificate.storeLocation] Required for
   * certificate declaration. The Windows certificate store location to
   * install the certificate for encryption, if required. Its value has to be
   * 'LocalMachine' if present.
   * 
   * @param {string} [parameters.certificate.storeName] Optional. The Windows
   * certificate store name to install the certificate for encryption, if
   * required. Its value has to be 'My' if present.
   * 
   * @param {boolean} [parameters.certificate.thumbprintRequired] Optional.
   * Whether thumbprint is required for the certificate for encryption or not.
   * Its value has to be 'true' or 'false' (case-sensitive) if present.
   * 
   * @param {string} [parameters.certificate.thumbprintAlgorithm] Optional. The
   * thumbprint algorithm of the certificate for encryption, if required. Its
   * value has to be 'sha1' if present.
   * 
   * @param {ExtensionEndpointConfiguration} [parameters.extensionEndpoints]
   * Optional. Declared endpoints to automatically add to each deployment with
   * this extension added.
   * 
   * @param {array} [parameters.extensionEndpoints.inputEndpoints] Optional. A
   * list of input endpoints required by this extension. Supported on WebRole
   * or WorkerRole, but ignored on VmRole. Each input endpoint will be
   * automatically added to the service definition of the deployment utilizing
   * this extension.
   * 
   * @param {array} [parameters.extensionEndpoints.internalEndpoints] Optional.
   * A list of internal endpoints required by this extension. Supported on
   * WebRole or WorkerRole, but ignored on VmRole. Each internal endpoint will
   * be automatically added to the service definition of the deployment
   * utilizing this extension.
   * 
   * @param {array} [parameters.extensionEndpoints.instanceInputEndpoints]
   * Optional. A list of instance input endpoints required by this extension.
   * Supported on WebRole or WorkerRole, but ignored on VmRole. Each instance
   * input endpoint will be automatically added to the service definition of
   * the deployment utilizing this extension.
   * 
   * @param {string} [parameters.publicConfigurationSchema] Optional. The XSD
   * schema of public configuration data.
   * 
   * @param {string} [parameters.privateConfigurationSchema] Optional. The XSD
   * schema of private configuration data.
   * 
   * @param {string} [parameters.description] Required. Detailed description of
   * the extension.
   * 
   * @param {string} [parameters.publisherName] Optional. Publisher name text.
   * 
   * @param {date} [parameters.publishedDate] Publisher can set it to any
   * arbitrary date, and this is only for display purpose. If not specified by
   * publisher, Azure will automatically assign the UTC time when the
   * extension request was received.
   * 
   * @param {array} [parameters.localResources] Declared local resources used
   * inside guest VM by the extension. Optional.
   * 
   * @param {boolean} [parameters.blockRoleUponFailure] Optional. Its value has
   * to be 'true' or 'false' (case-sensitive) When set to 'true', the role
   * startup will be blocked till the extension installation completes. This
   * flag should be set to 'true' when the role cannot start without the
   * extension being installed. If set to 'false' (default value), the role
   * will be started without waiting for the extension installation to
   * complete. Supported on WebRole or WorkerRole, but ignored on VmRole.
   * 
   * @param {boolean} [parameters.isInternalExtension] Optional. If this is set
   * to 'true' the extension is not visible for public use, i.e. being
   * returned from list API's. It can be still accessed by referring to the
   * ProviderNamespace, Type & Version combo. Therefore an internal extension
   * is intended only for testing purpose. Its value has to be 'true' or
   * 'false' (case-sensitive) if present.
   * 
   * @param {string} [parameters.sampleConfig] Optional. A sample configuration
   * for the extension. It can be downloaded by users, and the user can
   * replace with customized input parameters. The sample configuration should
   * be sufficiently commented. If configuration data are in XML format, then
   * the XML document-level element must be 'Configuration', and the optional
   * public configuration data corresponds to a child element of
   * 'PublicConfig', and the optional private configuration data corresponds
   * to a child element of 'PrivateConfig'. The sample configuration data
   * should be validated against public and private configuration schema by
   * the publisher.
   * 
   * @param {boolean} [parameters.replicationCompleted] Indicates whether this
   * version of extension has been replicated to all regions or not. If true,
   * then the given extension version can be used in creating or updating
   * deployments. Otherwise, the given extension version might cause failure
   * in creating or updating deployments. The typical time is 20 minutes for a
   * newly-registered or newly-updated extension to replicate completely by
   * Azure.
   * 
   * @param {string} [parameters.eula] Optional. URL string pointing to the
   * EULA (End User License Agreement) of this version of extension. This is
   * optionally specified by the third-party publishing the extension instead
   * of Windows Azure. If the software requires any additional EULAs, a link
   * to the EULA should be provided.
   * 
   * @param {string} [parameters.privacyUri] Optional. URL string pointing to
   * privacy document of this version of extension. This is optionally
   * specified by the third-party publishing the extension instead of Azure.
   * If the software collects any data and transfers out the guest VM, then an
   * additional privacy document might be needed.
   * 
   * @param {string} [parameters.homepageUri] Optional. URL string pointing to
   * homepage of this version of extension. This is optionally specified by
   * the third-party publishing the extension instead of Azure. The homepage
   * should have usage information and contact information for customer
   * support.
   * 
   * @param {boolean} [parameters.isJsonExtension] Optional. If this is set to
   * 'true' the extension is expected to receive JSON based configuration. If
   * this is set to 'false' the extension is expected to receive XML based
   * configuration. Its value has to be 'true' or 'false' (case-sensitive) if
   * present.
   * 
   * @param {boolean} [parameters.disallowMajorVersionUpgrade] Optional. If
   * this is set to 'true' the extension version cannot be upgraded to from
   * other major versions in active deployments. If the value is 'false' or
   * nor present, the extension version can be upgraded to from any other
   * version. Downgrade is not supported. The value has to be 'true' or
   * 'false' (case-sensitive) if present.
   * 
   * @param {string} [parameters.supportedOS] String property indicating the OS
   * which the extension supports. Current values are 'Windows' or 'Linux'.
   * 
   * @param {string} [parameters.companyName] String property containing the
   * name of the company/organization who publishes the extension.
   * 
   * @param {string} [parameters.regions] String property containing the name
   * of the regions required for the slice.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ExtensionImageOperations.prototype.register = function(parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.extensionImages.beginRegistering(parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * Unregister a version of an extension that was previously registered using
   * either the Register Extension or Update Extension APIs. An extension
   * version is identified by the combination of its ProviderNamespace, Type
   * and Version which are specified when registering the extension.
   * Unregistering is only allowed for internal extensions, that is, the
   * extensions for which the IsInternalExtension field is set to 'true'
   * during registration or during an update. There is a quota (15) on the
   * number of extensions that can be registered per subscription. If your
   * subscription runs out of quota, you will wither need to unregister some
   * of the internal extensions or contact Azure (same email used to become a
   * publisher)  to increase the quota.
   * 
   * @param {string} providerNamespace The provider namespace of the extension
   * image to unregister.
   * 
   * @param {string} type The type of the extension image to unregister.
   * 
   * @param {string} version The version of the extension image to unregister.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ExtensionImageOperations.prototype.unregister = function(providerNamespace, type, version, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.extensionImages.beginUnregistering(providerNamespace, type, version, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * Update a new extension. It is allowed to update an extension which had
   * already been registered with the same identity (i.e. combination of
   * ProviderNamespace and Type) but with different version. It will fail if
   * the extension to update has an identity that has not been registered
   * before, or there is already an extension with the same identity and same
   * version.
   * 
   * @param {ExtensionImageUpdateParameters} parameters Parameters supplied to
   * the Update Virtual Machine Extension Image operation.
   * 
   * @param {string} parameters.providerNameSpace Required. The provider
   * namespace of the extension.
   * 
   * @param {string} parameters.type Required. The type of the extension.
   * 
   * @param {string} parameters.version Required. The version of the extension.
   * 
   * @param {string} [parameters.label] Required. A one line label of the
   * extension.
   * 
   * @param {string} [parameters.hostingResources] Required. The supported
   * hosting resources. It must contain 'WebRole' and/or 'WorkerRole'. E.g.
   * 'WebRole|WorkerRole' or 'WebRole|WorkerRole|VmRole'.
   * 
   * @param {string} [parameters.mediaLink] Required. URI string pointing to
   * the ZIP package of the extension. The ZIP package has to include the
   * extension executable and other supporting files, and the
   * PluginManifest.xml manifest. MediaLink value must point to a URL (either
   * Http or Https) in a Azure blob storage and is downloadable. Windows Azure
   * will copy the extension package from this source location and replicate
   * it to all regions. The typical time for replication to complete is 20
   * minutes.
   * 
   * @param {ExtensionCertificateConfiguration} [parameters.certificate]
   * Optional. Parameters of the the certificate for encrypting the private
   * configuration data. Supported on WebRole or WorkerRole, but ignored on
   * VmRole.
   * 
   * @param {string} [parameters.certificate.storeLocation] Required for
   * certificate declaration. The Windows certificate store location to
   * install the certificate for encryption, if required. Its value has to be
   * 'LocalMachine' if present.
   * 
   * @param {string} [parameters.certificate.storeName] Optional. The Windows
   * certificate store name to install the certificate for encryption, if
   * required. Its value has to be 'My' if present.
   * 
   * @param {boolean} [parameters.certificate.thumbprintRequired] Optional.
   * Whether thumbprint is required for the certificate for encryption or not.
   * Its value has to be 'true' or 'false' (case-sensitive) if present.
   * 
   * @param {string} [parameters.certificate.thumbprintAlgorithm] Optional. The
   * thumbprint algorithm of the certificate for encryption, if required. Its
   * value has to be 'sha1' if present.
   * 
   * @param {ExtensionEndpointConfiguration} [parameters.extensionEndpoints]
   * Optional. Declared endpoints to automatically add to each deployment with
   * this extension added.
   * 
   * @param {array} [parameters.extensionEndpoints.inputEndpoints] Optional. A
   * list of input endpoints required by this extension. Supported on WebRole
   * or WorkerRole, but ignored on VmRole. Each input endpoint will be
   * automatically added to the service definition of the deployment utilizing
   * this extension.
   * 
   * @param {array} [parameters.extensionEndpoints.internalEndpoints] Optional.
   * A list of internal endpoints required by this extension. Supported on
   * WebRole or WorkerRole, but ignored on VmRole. Each internal endpoint will
   * be automatically added to the service definition of the deployment
   * utilizing this extension.
   * 
   * @param {array} [parameters.extensionEndpoints.instanceInputEndpoints]
   * Optional. A list of instance input endpoints required by this extension.
   * Supported on WebRole or WorkerRole, but ignored on VmRole. Each instance
   * input endpoint will be automatically added to the service definition of
   * the deployment utilizing this extension.
   * 
   * @param {string} [parameters.publicConfigurationSchema] Optional. The XSD
   * schema of public configuration data.
   * 
   * @param {string} [parameters.privateConfigurationSchema] Optional. The XSD
   * schema of private configuration data.
   * 
   * @param {string} [parameters.description] Required. Detailed description of
   * the extension.
   * 
   * @param {string} [parameters.publisherName] Optional. Publisher name text.
   * 
   * @param {date} [parameters.publishedDate] Publisher can set it to any
   * arbitrary date, and this is only for display purpose. If not specified by
   * publisher, Azure will automatically assign the UTC time when the
   * extension request was received.
   * 
   * @param {array} [parameters.localResources] Declared local resources used
   * inside guest VM by the extension. Optional.
   * 
   * @param {boolean} [parameters.blockRoleUponFailure] Optional. Its value has
   * to be 'true' or 'false' (case-sensitive) When set to 'true', the role
   * startup will be blocked till the extension installation completes. This
   * flag should be set to 'true' when the role cannot start without the
   * extension being installed. If set to 'false' (default value), the role
   * will be started without waiting for the extension installation to
   * complete. Supported on WebRole or WorkerRole, but ignored on VmRole.
   * 
   * @param {boolean} [parameters.isInternalExtension] Optional. If this is set
   * to 'true' the extension is not visible for public use, i.e. being
   * returned from list API's. It can be still accessed by referring to the
   * ProviderNamespace, Type & Version combo. Therefore an internal extension
   * is intended only for testing purpose. Its value has to be 'true' or
   * 'false' (case-sensitive) if present.
   * 
   * @param {string} [parameters.sampleConfig] Optional. A sample configuration
   * for the extension. It can be downloaded by users, and the user can
   * replace with customized input parameters. The sample configuration should
   * be sufficiently commented. If configuration data are in XML format, then
   * the XML document-level element must be 'Configuration', and the optional
   * public configuration data corresponds to a child element of
   * 'PublicConfig', and the optional private configuration data corresponds
   * to a child element of 'PrivateConfig'. The sample configuration data
   * should be validated against public and private configuration schema by
   * the publisher.
   * 
   * @param {boolean} [parameters.replicationCompleted] Indicates whether this
   * version of extension has been replicated to all regions or not. If true,
   * then the given extension version can be used in creating or updating
   * deployments. Otherwise, the given extension version might cause failure
   * in creating or updating deployments. The typical time is 20 minutes for a
   * newly-registered or newly-updated extension to replicate completely by
   * Azure.
   * 
   * @param {string} [parameters.eula] Optional. URL string pointing to the
   * EULA (End User License Agreement) of this version of extension. This is
   * optionally specified by the third-party publishing the extension instead
   * of Windows Azure. If the software requires any additional EULAs, a link
   * to the EULA should be provided.
   * 
   * @param {string} [parameters.privacyUri] Optional. URL string pointing to
   * privacy document of this version of extension. This is optionally
   * specified by the third-party publishing the extension instead of Azure.
   * If the software collects any data and transfers out the guest VM, then an
   * additional privacy document might be needed.
   * 
   * @param {string} [parameters.homepageUri] Optional. URL string pointing to
   * homepage of this version of extension. This is optionally specified by
   * the third-party publishing the extension instead of Azure. The homepage
   * should have usage information and contact information for customer
   * support.
   * 
   * @param {boolean} [parameters.isJsonExtension] Optional. If this is set to
   * 'true' the extension is expected to receive JSON based configuration. If
   * this is set to 'false' the extension is expected to receive XML based
   * configuration. Its value has to be 'true' or 'false' (case-sensitive) if
   * present.
   * 
   * @param {boolean} [parameters.disallowMajorVersionUpgrade] Optional. If
   * this is set to 'true' the extension version cannot be upgraded to from
   * other major versions in active deployments. If the value is 'false' or
   * nor present, the extension version can be upgraded to from any other
   * version. Downgrade is not supported. The value has to be 'true' or
   * 'false' (case-sensitive) if present.
   * 
   * @param {string} [parameters.supportedOS] String property indicating the OS
   * which the extension supports. Current values are 'Windows' or 'Linux'.
   * 
   * @param {string} [parameters.companyName] String property containing the
   * name of the company/organization who publishes the extension.
   * 
   * @param {string} [parameters.regions] String property containing the name
   * of the regions required for the slice.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ExtensionImageOperations.prototype.update = function(parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.extensionImages.beginUpdating(parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  return ExtensionImageOperations;
})();

var HostedServiceOperations = ( /** @lends HostedServiceOperations */ function() {
  /**
   * @class
   * The Service Management API includes operations for managing the hosted
   * services beneath your subscription.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460812.aspx for
   * more information)
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [ComputeManagementClient] {@link
   * ComputeManagementClient~ComputeManagementClient}.
   * See [hostedServices] {@link
   * ComputeManagementClient~ComputeManagementClient#hostedServices}.
   * Initializes a new instance of the HostedServiceOperations class.
   * @constructor
   * 
   * @param {ComputeManagementClient} client Reference to the service client.
   */
  function HostedServiceOperations(client) {
    this.client = client;
  }
  
  /**
   * The Add Extension operation adds an available extension to your cloud
   * service. In Azure, a process can run as an extension of a cloud service.
   * For example, Remote Desktop Access or the Azure Diagnostics Agent can run
   * as extensions to the cloud service. You can find the available extension
   * by using the List Available Extensions operation.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn169558.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {HostedServiceAddExtensionParameters} parameters Parameters
   * supplied to the Add Extension operation.
   * 
   * @param {string} [parameters.providerNamespace] The provider namespace of
   * the extension. The provider namespace for Azure extensions is
   * Microsoft.Windows.Azure.Extensions.
   * 
   * @param {string} parameters.type The type of the extension.
   * 
   * @param {string} parameters.id The identifier of the extension.
   * 
   * @param {string} [parameters.thumbprint] The thumbprint of the certificate
   * that is used to encrypt the configuration specified in
   * PrivateConfiguration. If this element is not specified, a certificate may
   * be automatically generated and added to the cloud service.
   * 
   * @param {string} [parameters.thumbprintAlgorithm] The thumbprint algorithm
   * of the certificate that is used to encrypt the configuration specified in
   * PrivateConfiguration.
   * 
   * @param {string} [parameters.publicConfiguration] The public configuration
   * that is defined using the schema returned by the List Available
   * Extensions operation.
   * 
   * @param {string} [parameters.privateConfiguration] The private
   * configuration that is defined using the schema returned by the List
   * Available Extensions operation.
   * 
   * @param {string} [parameters.version] Specifies the version of the
   * extension. If this element is not specified or an asterisk (*) is used as
   * the value, the latest version of the extension is used. If the value is
   * specified with a major version number and an asterisk as the minor
   * version number (X.*), the latest minor version of the specified major
   * version is selected. If a major version number and a minor version number
   * are specified (X.Y), the specific extension version is selected. If a
   * version is specified, an auto-upgrade is performed on the role instance.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  HostedServiceOperations.prototype.addExtension = function(serviceName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.hostedServices.beginAddingExtension(serviceName, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Begin Adding Extension operation adds an available extension to your
   * cloud service. In Azure, a process can run as an extension of a cloud
   * service. For example, Remote Desktop Access or the Azure Diagnostics
   * Agent can run as extensions to the cloud service. You can find the
   * available extension by using the List Available Extensions operation.
   * (see http://msdn.microsoft.com/en-us/library/windowsazure/dn169558.aspx
   * for more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {HostedServiceAddExtensionParameters} parameters Parameters
   * supplied to the Begin Adding Extension operation.
   * 
   * @param {string} [parameters.providerNamespace] The provider namespace of
   * the extension. The provider namespace for Azure extensions is
   * Microsoft.Windows.Azure.Extensions.
   * 
   * @param {string} parameters.type The type of the extension.
   * 
   * @param {string} parameters.id The identifier of the extension.
   * 
   * @param {string} [parameters.thumbprint] The thumbprint of the certificate
   * that is used to encrypt the configuration specified in
   * PrivateConfiguration. If this element is not specified, a certificate may
   * be automatically generated and added to the cloud service.
   * 
   * @param {string} [parameters.thumbprintAlgorithm] The thumbprint algorithm
   * of the certificate that is used to encrypt the configuration specified in
   * PrivateConfiguration.
   * 
   * @param {string} [parameters.publicConfiguration] The public configuration
   * that is defined using the schema returned by the List Available
   * Extensions operation.
   * 
   * @param {string} [parameters.privateConfiguration] The private
   * configuration that is defined using the schema returned by the List
   * Available Extensions operation.
   * 
   * @param {string} [parameters.version] Specifies the version of the
   * extension. If this element is not specified or an asterisk (*) is used as
   * the value, the latest version of the extension is used. If the value is
   * specified with a major version number and an asterisk as the minor
   * version number (X.*), the latest minor version of the specified major
   * version is selected. If a major version number and a minor version number
   * are specified (X.Y), the specific extension version is selected. If a
   * version is specified, an auto-upgrade is performed on the role instance.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  HostedServiceOperations.prototype.beginAddingExtension = function(serviceName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    // TODO: Validate serviceName is a valid DNS name.
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.id === null || parameters.id === undefined) {
      return callback(new Error('parameters.id cannot be null.'));
    }
    if (parameters.type === null || parameters.type === undefined) {
      return callback(new Error('parameters.type cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/extensions';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var extensionElement = js2xml.createElement('Extension', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, extensionElement);
    
    if (parameters.providerNamespace !== null && parameters.providerNamespace !== undefined) {
      var providerNameSpaceElement = js2xml.createElement('ProviderNameSpace', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(providerNameSpaceElement, parameters.providerNamespace);
      js2xml.addChildElement(extensionElement, providerNameSpaceElement);
    }
    
    var typeElement = js2xml.createElement('Type', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(typeElement, parameters.type);
    js2xml.addChildElement(extensionElement, typeElement);
    
    var idElement = js2xml.createElement('Id', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(idElement, parameters.id);
    js2xml.addChildElement(extensionElement, idElement);
    
    if (parameters.thumbprint !== null && parameters.thumbprint !== undefined) {
      var thumbprintElement = js2xml.createElement('Thumbprint', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(thumbprintElement, parameters.thumbprint);
      js2xml.addChildElement(extensionElement, thumbprintElement);
    }
    
    if (parameters.thumbprintAlgorithm !== null && parameters.thumbprintAlgorithm !== undefined) {
      var thumbprintAlgorithmElement = js2xml.createElement('ThumbprintAlgorithm', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(thumbprintAlgorithmElement, parameters.thumbprintAlgorithm);
      js2xml.addChildElement(extensionElement, thumbprintAlgorithmElement);
    }
    
    if (parameters.publicConfiguration !== null && parameters.publicConfiguration !== undefined) {
      var publicConfigurationElement = js2xml.createElement('PublicConfiguration', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(publicConfigurationElement, new Buffer(parameters.publicConfiguration).toString('base64'));
      js2xml.addChildElement(extensionElement, publicConfigurationElement);
    }
    
    if (parameters.privateConfiguration !== null && parameters.privateConfiguration !== undefined) {
      var privateConfigurationElement = js2xml.createElement('PrivateConfiguration', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(privateConfigurationElement, new Buffer(parameters.privateConfiguration).toString('base64'));
      js2xml.addChildElement(extensionElement, privateConfigurationElement);
    }
    
    if (parameters.version !== null && parameters.version !== undefined) {
      var versionElement = js2xml.createElement('Version', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(versionElement, parameters.version);
      js2xml.addChildElement(extensionElement, versionElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The DeleteAll Hosted Service operation deletes the specified cloud service
   * as well as operating system disk, attached data disks, and the source
   * blobs for the disks from storage from Microsoft Azure. (see
   * 'http://msdn.microsoft.com/en-us/library/windowsazure/gg441305.aspx' for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  HostedServiceOperations.prototype.beginDeletingAll = function(serviceName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    var queryParameters = [];
    queryParameters.push('comp=media');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Deleting Extension operation deletes the specified extension
   * from a cloud service.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn169560.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {string} extensionId The identifier that was assigned to the
   * extension when it was added to the cloud service
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  HostedServiceOperations.prototype.beginDeletingExtension = function(serviceName, extensionId, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    // TODO: Validate serviceName is a valid DNS name.
    if (extensionId === null || extensionId === undefined) {
      return callback(new Error('extensionId cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/extensions/';
    url2 = url2 + encodeURIComponent(extensionId);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200 && statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Check Hosted Service Name Availability operation checks for the
   * availability of the specified cloud service name.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj154116.aspx for
   * more information)
   * 
   * @param {string} serviceName The cloud service name that you would like to
   * use.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  HostedServiceOperations.prototype.checkNameAvailability = function(serviceName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    // TODO: Validate serviceName is a valid DNS name.
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/operations/isavailable/';
    url2 = url2 + encodeURIComponent(serviceName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var availabilityResponseElement = js2xml.getElement(responseDoc, responseDoc, 'AVAILABILITYRESPONSE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (availabilityResponseElement !== null && availabilityResponseElement !== undefined) {
            var resultElement = js2xml.getElement(responseDoc, availabilityResponseElement, 'RESULT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (resultElement !== null && resultElement !== undefined && resultElement.length !== 0) {
              var resultInstance = resultElement === 'true';
              result.isAvailable = resultInstance;
            }
            
            var reasonElement = js2xml.getElement(responseDoc, availabilityResponseElement, 'REASON', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (reasonElement !== null && reasonElement !== undefined) {
              var reasonInstance = reasonElement;
              result.reason = reasonInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Create Hosted Service operation creates a new cloud service in Azure.
   * (see http://msdn.microsoft.com/en-us/library/windowsazure/gg441304.aspx
   * for more information)
   * 
   * @param {HostedServiceCreateParameters} parameters Parameters supplied to
   * the Create Hosted Service operation.
   * 
   * @param {string} parameters.serviceName A name for the cloud service that
   * is unique within Azure. This name is the DNS prefix name and can be used
   * to access the service.
   * 
   * @param {string} parameters.label A name for the cloud service. The name
   * can be up to 100 characters in length. The name can be used to identify
   * the storage account for your tracking purposes.
   * 
   * @param {string} [parameters.description] A description for the cloud
   * service. The description can be up to 1024 characters in length.
   * 
   * @param {string} [parameters.location] The location where the cloud service
   * will be created. Required if AffinityGroup is not specified. Specify
   * either Location or AffinityGroup, but not both. To list available
   * locations, use the List Locations operation.
   * 
   * @param {string} [parameters.affinityGroup] The name of an existing
   * affinity group associated with this subscription. Required if Location is
   * not specified. This name is a GUID and can be retrieved by examining the
   * name element of the response body returned by the List Affinity Groups
   * operation. Specify either Location or AffinityGroup, but not both. To
   * list available affinity groups, use the List Affinity Groups operation.
   * 
   * @param {object} [parameters.extendedProperties] Represents the name of an
   * extended cloud service property. Each extended property must have a
   * defined name and a value. You can have a maximum of 50 extended property
   * name and value pairs. The maximum length of the name element is 64
   * characters, only alphanumeric characters and underscores are valid in the
   * name, and it must start with a letter. Attempting to use other
   * characters, starting with a non-letter character, or entering a name that
   * is identical to that of another extended property owned by the same
   * service will result in a status code 400 (Bad Request) error. Each
   * extended property value has a maximum length of 255 characters.
   * 
   * @param {string} [parameters.reverseDnsFqdn] Dns address to which the cloud
   * service's IP address resolves when queried using a reverse Dns query.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  HostedServiceOperations.prototype.create = function(parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.description !== null && parameters.description !== undefined && parameters.description.length > 1024) {
      return callback(new Error('parameters.description is outside the valid range.'));
    }
    if (parameters.label === null || parameters.label === undefined) {
      return callback(new Error('parameters.label cannot be null.'));
    }
    if (parameters.serviceName === null || parameters.serviceName === undefined) {
      return callback(new Error('parameters.serviceName cannot be null.'));
    }
    // TODO: Validate parameters.serviceName is a valid DNS name.
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var createHostedServiceElement = js2xml.createElement('CreateHostedService', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, createHostedServiceElement);
    
    var serviceNameElement = js2xml.createElement('ServiceName', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(serviceNameElement, parameters.serviceName);
    js2xml.addChildElement(createHostedServiceElement, serviceNameElement);
    
    var labelElement = js2xml.createElement('Label', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(labelElement, new Buffer(parameters.label).toString('base64'));
    js2xml.addChildElement(createHostedServiceElement, labelElement);
    
    if (parameters.description !== null && parameters.description !== undefined) {
      var descriptionElement = js2xml.createElement('Description', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(descriptionElement, parameters.description);
      js2xml.addChildElement(createHostedServiceElement, descriptionElement);
    }
    
    if (parameters.location !== null && parameters.location !== undefined) {
      var locationElement = js2xml.createElement('Location', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(locationElement, parameters.location);
      js2xml.addChildElement(createHostedServiceElement, locationElement);
    }
    
    if (parameters.affinityGroup !== null && parameters.affinityGroup !== undefined) {
      var affinityGroupElement = js2xml.createElement('AffinityGroup', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(affinityGroupElement, parameters.affinityGroup);
      js2xml.addChildElement(createHostedServiceElement, affinityGroupElement);
    }
    
    if (parameters.extendedProperties !== null && parameters.extendedProperties !== undefined) {
      var extendedPropertiesDictionaryElement = js2xml.createElement('ExtendedProperties', 'http://schemas.microsoft.com/windowsazure');
      for (var extendedPropertiesKey in parameters.extendedProperties) {
        var extendedPropertiesValue = parameters.extendedProperties[extendedPropertiesKey];
        var extendedPropertiesElement = js2xml.createElement('ExtendedProperty', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(extendedPropertiesDictionaryElement, extendedPropertiesElement);
        
        var extendedPropertiesKeyElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(extendedPropertiesKeyElement, extendedPropertiesKey);
        js2xml.addChildElement(extendedPropertiesElement, extendedPropertiesKeyElement);
        
        var extendedPropertiesValueElement = js2xml.createElement('Value', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(extendedPropertiesValueElement, extendedPropertiesValue);
        js2xml.addChildElement(extendedPropertiesElement, extendedPropertiesValueElement);
      }
      js2xml.addChildElement(createHostedServiceElement, extendedPropertiesDictionaryElement);
    }
    
    if (parameters.reverseDnsFqdn !== null && parameters.reverseDnsFqdn !== undefined) {
      var reverseDnsFqdnElement = js2xml.createElement('ReverseDnsFqdn', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(reverseDnsFqdnElement, parameters.reverseDnsFqdn);
      js2xml.addChildElement(createHostedServiceElement, reverseDnsFqdnElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 201) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Delete Hosted Service operation deletes the specified cloud service
   * from Azure.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/gg441305.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  HostedServiceOperations.prototype.deleteMethod = function(serviceName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The DeleteAll Hosted Service operation deletes the specified cloud service
   * as well as operating system disk, attached data disks, and the source
   * blobs for the disks from storage from Microsoft Azure. (see
   * 'http://msdn.microsoft.com/en-us/library/windowsazure/gg441305.aspx' for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  HostedServiceOperations.prototype.deleteAll = function(serviceName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.hostedServices.beginDeletingAll(serviceName, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Delete Extension operation deletes the specified extension from a
   * cloud service.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn169560.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {string} extensionId The identifier that was assigned to the
   * extension when it was added to the cloud service
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  HostedServiceOperations.prototype.deleteExtension = function(serviceName, extensionId, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.hostedServices.beginDeletingExtension(serviceName, extensionId, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Get Hosted Service Properties operation retrieves system properties
   * for the specified cloud service. These properties include the service
   * name and service type; and the name of the affinity group to which the
   * service belongs, or its location if it is not part of an affinity group.
   * (see http://msdn.microsoft.com/en-us/library/windowsazure/ee460806.aspx
   * for more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  HostedServiceOperations.prototype.get = function(serviceName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var hostedServiceElement = js2xml.getElement(responseDoc, responseDoc, 'HOSTEDSERVICE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (hostedServiceElement !== null && hostedServiceElement !== undefined) {
            var urlElement = js2xml.getElement(responseDoc, hostedServiceElement, 'URL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (urlElement !== null && urlElement !== undefined) {
              var urlInstance = urlElement;
              result.uri = urlInstance;
            }
            
            var serviceNameElement = js2xml.getElement(responseDoc, hostedServiceElement, 'SERVICENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (serviceNameElement !== null && serviceNameElement !== undefined) {
              var serviceNameInstance = serviceNameElement;
              result.serviceName = serviceNameInstance;
            }
            
            var hostedServicePropertiesElement = js2xml.getElement(responseDoc, hostedServiceElement, 'HOSTEDSERVICEPROPERTIES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (hostedServicePropertiesElement !== null && hostedServicePropertiesElement !== undefined) {
              var hostedServicePropertiesInstance = { extendedProperties: {} };
              result.properties = hostedServicePropertiesInstance;
              
              var descriptionElement = js2xml.getElement(responseDoc, hostedServicePropertiesElement, 'DESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (descriptionElement !== null && descriptionElement !== undefined) {
                var descriptionInstance = descriptionElement;
                hostedServicePropertiesInstance.description = descriptionInstance;
              }
              
              var affinityGroupElement = js2xml.getElement(responseDoc, hostedServicePropertiesElement, 'AFFINITYGROUP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (affinityGroupElement !== null && affinityGroupElement !== undefined) {
                var affinityGroupInstance = affinityGroupElement;
                hostedServicePropertiesInstance.affinityGroup = affinityGroupInstance;
              }
              
              var locationElement = js2xml.getElement(responseDoc, hostedServicePropertiesElement, 'LOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (locationElement !== null && locationElement !== undefined) {
                var locationInstance = locationElement;
                hostedServicePropertiesInstance.location = locationInstance;
              }
              
              var labelElement = js2xml.getElement(responseDoc, hostedServicePropertiesElement, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (labelElement !== null && labelElement !== undefined) {
                var labelInstance = new Buffer(labelElement, 'base64').toString('utf8');
                hostedServicePropertiesInstance.label = labelInstance;
              }
              
              var statusElement = js2xml.getElement(responseDoc, hostedServicePropertiesElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (statusElement !== null && statusElement !== undefined && statusElement.length !== 0) {
                var statusInstance = statusElement;
                hostedServicePropertiesInstance.status = statusInstance;
              }
              
              var dateCreatedElement = js2xml.getElement(responseDoc, hostedServicePropertiesElement, 'DATECREATED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (dateCreatedElement !== null && dateCreatedElement !== undefined && dateCreatedElement.length !== 0) {
                var dateCreatedInstance = new Date(dateCreatedElement);
                hostedServicePropertiesInstance.dateCreated = dateCreatedInstance;
              }
              
              var dateLastModifiedElement = js2xml.getElement(responseDoc, hostedServicePropertiesElement, 'DATELASTMODIFIED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (dateLastModifiedElement !== null && dateLastModifiedElement !== undefined && dateLastModifiedElement.length !== 0) {
                var dateLastModifiedInstance = new Date(dateLastModifiedElement);
                hostedServicePropertiesInstance.dateLastModified = dateLastModifiedInstance;
              }
              
              var extendedPropertiesSequenceElement = js2xml.getElement(responseDoc, hostedServicePropertiesElement, 'EXTENDEDPROPERTIES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (extendedPropertiesSequenceElement !== null && extendedPropertiesSequenceElement !== undefined) {
                for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, extendedPropertiesSequenceElement, 'EXTENDEDPROPERTY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
                  var extendedPropertiesElement = js2xml.getElements(responseDoc, extendedPropertiesSequenceElement, 'EXTENDEDPROPERTY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
                  var extendedPropertiesKey = js2xml.getElement(responseDoc, extendedPropertiesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  var extendedPropertiesValue = js2xml.getElement(responseDoc, extendedPropertiesElement, 'VALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  hostedServicePropertiesInstance.extendedProperties[extendedPropertiesKey] = extendedPropertiesValue;
                }
              }
              
              var reverseDnsFqdnElement = js2xml.getElement(responseDoc, hostedServicePropertiesElement, 'REVERSEDNSFQDN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (reverseDnsFqdnElement !== null && reverseDnsFqdnElement !== undefined) {
                var reverseDnsFqdnInstance = reverseDnsFqdnElement;
                hostedServicePropertiesInstance.reverseDnsFqdn = reverseDnsFqdnInstance;
              }
            }
            
            var computeCapabilitiesElement = js2xml.getElement(responseDoc, hostedServiceElement, 'COMPUTECAPABILITIES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (computeCapabilitiesElement !== null && computeCapabilitiesElement !== undefined) {
              var computeCapabilitiesInstance = { virtualMachinesRoleSizes: [], webWorkerRoleSizes: [] };
              result.computeCapabilities = computeCapabilitiesInstance;
              
              var virtualMachinesRoleSizesSequenceElement = js2xml.getElement(responseDoc, computeCapabilitiesElement, 'VIRTUALMACHINESROLESIZES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (virtualMachinesRoleSizesSequenceElement !== null && virtualMachinesRoleSizesSequenceElement !== undefined) {
                for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, virtualMachinesRoleSizesSequenceElement, 'ROLESIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex2 = loweredIndex2 + 1) {
                  var virtualMachinesRoleSizesElement = js2xml.getElements(responseDoc, virtualMachinesRoleSizesSequenceElement, 'ROLESIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex2];
                  computeCapabilitiesInstance.virtualMachinesRoleSizes.push(virtualMachinesRoleSizesElement);
                }
              }
              
              var webWorkerRoleSizesSequenceElement = js2xml.getElement(responseDoc, computeCapabilitiesElement, 'WEBWORKERROLESIZES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (webWorkerRoleSizesSequenceElement !== null && webWorkerRoleSizesSequenceElement !== undefined) {
                for (var loweredIndex3 = 0; loweredIndex3 < js2xml.getElements(responseDoc, webWorkerRoleSizesSequenceElement, 'ROLESIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex3 = loweredIndex3 + 1) {
                  var webWorkerRoleSizesElement = js2xml.getElements(responseDoc, webWorkerRoleSizesSequenceElement, 'ROLESIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex3];
                  computeCapabilitiesInstance.webWorkerRoleSizes.push(webWorkerRoleSizesElement);
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Get Detailed Hosted Service Properties operation retrieves system
   * properties for the specified cloud service. These properties include the
   * service name and service type; the name of the affinity group to which
   * the service belongs, or its location if it is not part of an affinity
   * group; and information on the deployments of the service.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460806.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  HostedServiceOperations.prototype.getDetailed = function(serviceName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    var queryParameters = [];
    queryParameters.push('embed-detail=true');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { deployments: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var hostedServiceElement = js2xml.getElement(responseDoc, responseDoc, 'HOSTEDSERVICE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (hostedServiceElement !== null && hostedServiceElement !== undefined) {
            var deploymentsSequenceElement = js2xml.getElement(responseDoc, hostedServiceElement, 'DEPLOYMENTS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (deploymentsSequenceElement !== null && deploymentsSequenceElement !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, deploymentsSequenceElement, 'DEPLOYMENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
                var deploymentsElement = js2xml.getElements(responseDoc, deploymentsSequenceElement, 'DEPLOYMENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
                var deploymentInstance = { extendedProperties: {}, roleInstances: [], roles: [], virtualIPAddresses: [] };
                result.deployments.push(deploymentInstance);
                
                var nameElement = js2xml.getElement(responseDoc, deploymentsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (nameElement !== null && nameElement !== undefined) {
                  var nameInstance = nameElement;
                  deploymentInstance.name = nameInstance;
                }
                
                var deploymentSlotElement = js2xml.getElement(responseDoc, deploymentsElement, 'DEPLOYMENTSLOT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (deploymentSlotElement !== null && deploymentSlotElement !== undefined && deploymentSlotElement.length !== 0) {
                  var deploymentSlotInstance = deploymentSlotElement;
                  deploymentInstance.deploymentSlot = deploymentSlotInstance;
                }
                
                var privateIDElement = js2xml.getElement(responseDoc, deploymentsElement, 'PRIVATEID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (privateIDElement !== null && privateIDElement !== undefined) {
                  var privateIDInstance = privateIDElement;
                  deploymentInstance.privateId = privateIDInstance;
                }
                
                var statusElement = js2xml.getElement(responseDoc, deploymentsElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (statusElement !== null && statusElement !== undefined && statusElement.length !== 0) {
                  var statusInstance = statusElement;
                  deploymentInstance.status = statusInstance;
                }
                
                var labelElement = js2xml.getElement(responseDoc, deploymentsElement, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (labelElement !== null && labelElement !== undefined) {
                  var labelInstance = new Buffer(labelElement, 'base64').toString('utf8');
                  deploymentInstance.label = labelInstance;
                }
                
                var urlElement = js2xml.getElement(responseDoc, deploymentsElement, 'URL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (urlElement !== null && urlElement !== undefined) {
                  var urlInstance = urlElement;
                  deploymentInstance.uri = urlInstance;
                }
                
                var configurationElement = js2xml.getElement(responseDoc, deploymentsElement, 'CONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (configurationElement !== null && configurationElement !== undefined) {
                  var configurationInstance = new Buffer(configurationElement, 'base64').toString('utf8');
                  deploymentInstance.configuration = configurationInstance;
                }
                
                var roleInstanceListSequenceElement = js2xml.getElement(responseDoc, deploymentsElement, 'ROLEINSTANCELIST', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (roleInstanceListSequenceElement !== null && roleInstanceListSequenceElement !== undefined) {
                  for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, roleInstanceListSequenceElement, 'ROLEINSTANCE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex2 = loweredIndex2 + 1) {
                    var roleInstanceListElement = js2xml.getElements(responseDoc, roleInstanceListSequenceElement, 'ROLEINSTANCE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex2];
                    var roleInstanceInstance = { instanceEndpoints: [], networkInterfaces: [], publicIPs: [], resourceExtensionStatusList: [] };
                    deploymentInstance.roleInstances.push(roleInstanceInstance);
                    
                    var roleNameElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'ROLENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (roleNameElement !== null && roleNameElement !== undefined) {
                      var roleNameInstance = roleNameElement;
                      roleInstanceInstance.roleName = roleNameInstance;
                    }
                    
                    var instanceNameElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'INSTANCENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (instanceNameElement !== null && instanceNameElement !== undefined) {
                      var instanceNameInstance = instanceNameElement;
                      roleInstanceInstance.instanceName = instanceNameInstance;
                    }
                    
                    var instanceStatusElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'INSTANCESTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (instanceStatusElement !== null && instanceStatusElement !== undefined) {
                      var instanceStatusInstance = instanceStatusElement;
                      roleInstanceInstance.instanceStatus = instanceStatusInstance;
                    }
                    
                    var instanceUpgradeDomainElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'INSTANCEUPGRADEDOMAIN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (instanceUpgradeDomainElement !== null && instanceUpgradeDomainElement !== undefined && instanceUpgradeDomainElement.length !== 0) {
                      var instanceUpgradeDomainInstance = parseInt(instanceUpgradeDomainElement, 10);
                      roleInstanceInstance.instanceUpgradeDomain = instanceUpgradeDomainInstance;
                    }
                    
                    var instanceFaultDomainElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'INSTANCEFAULTDOMAIN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (instanceFaultDomainElement !== null && instanceFaultDomainElement !== undefined && instanceFaultDomainElement.length !== 0) {
                      var instanceFaultDomainInstance = parseInt(instanceFaultDomainElement, 10);
                      roleInstanceInstance.instanceFaultDomain = instanceFaultDomainInstance;
                    }
                    
                    var instanceSizeElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'INSTANCESIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (instanceSizeElement !== null && instanceSizeElement !== undefined) {
                      var instanceSizeInstance = instanceSizeElement;
                      roleInstanceInstance.instanceSize = instanceSizeInstance;
                    }
                    
                    var instanceStateDetailsElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'INSTANCESTATEDETAILS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (instanceStateDetailsElement !== null && instanceStateDetailsElement !== undefined) {
                      var instanceStateDetailsInstance = instanceStateDetailsElement;
                      roleInstanceInstance.instanceStateDetails = instanceStateDetailsInstance;
                    }
                    
                    var instanceErrorCodeElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'INSTANCEERRORCODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (instanceErrorCodeElement !== null && instanceErrorCodeElement !== undefined) {
                      var instanceErrorCodeInstance = instanceErrorCodeElement;
                      roleInstanceInstance.instanceErrorCode = instanceErrorCodeInstance;
                    }
                    
                    var ipAddressElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'IPADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (ipAddressElement !== null && ipAddressElement !== undefined) {
                      var ipAddressInstance = ipAddressElement;
                      roleInstanceInstance.iPAddress = ipAddressInstance;
                    }
                    
                    var instanceEndpointsSequenceElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'INSTANCEENDPOINTS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (instanceEndpointsSequenceElement !== null && instanceEndpointsSequenceElement !== undefined) {
                      for (var loweredIndex3 = 0; loweredIndex3 < js2xml.getElements(responseDoc, instanceEndpointsSequenceElement, 'INSTANCEENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex3 = loweredIndex3 + 1) {
                        var instanceEndpointsElement = js2xml.getElements(responseDoc, instanceEndpointsSequenceElement, 'INSTANCEENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex3];
                        var instanceEndpointInstance = {};
                        roleInstanceInstance.instanceEndpoints.push(instanceEndpointInstance);
                        
                        var localPortElement = js2xml.getElement(responseDoc, instanceEndpointsElement, 'LOCALPORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (localPortElement !== null && localPortElement !== undefined && localPortElement.length !== 0) {
                          var localPortInstance = parseInt(localPortElement, 10);
                          instanceEndpointInstance.localPort = localPortInstance;
                        }
                        
                        var nameElement2 = js2xml.getElement(responseDoc, instanceEndpointsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (nameElement2 !== null && nameElement2 !== undefined) {
                          var nameInstance2 = nameElement2;
                          instanceEndpointInstance.name = nameInstance2;
                        }
                        
                        var publicPortElement = js2xml.getElement(responseDoc, instanceEndpointsElement, 'PUBLICPORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (publicPortElement !== null && publicPortElement !== undefined && publicPortElement.length !== 0) {
                          var publicPortInstance = parseInt(publicPortElement, 10);
                          instanceEndpointInstance.port = publicPortInstance;
                        }
                        
                        var protocolElement = js2xml.getElement(responseDoc, instanceEndpointsElement, 'PROTOCOL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (protocolElement !== null && protocolElement !== undefined) {
                          var protocolInstance = protocolElement;
                          instanceEndpointInstance.protocol = protocolInstance;
                        }
                        
                        var vipElement = js2xml.getElement(responseDoc, instanceEndpointsElement, 'VIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (vipElement !== null && vipElement !== undefined) {
                          var vipInstance = vipElement;
                          instanceEndpointInstance.virtualIPAddress = vipInstance;
                        }
                        
                        var idleTimeoutInMinutesElement = js2xml.getElement(responseDoc, instanceEndpointsElement, 'IDLETIMEOUTINMINUTES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (idleTimeoutInMinutesElement !== null && idleTimeoutInMinutesElement !== undefined && idleTimeoutInMinutesElement.length !== 0) {
                          var idleTimeoutInMinutesInstance = parseInt(idleTimeoutInMinutesElement, 10);
                          instanceEndpointInstance.idleTimeoutInMinutes = idleTimeoutInMinutesInstance;
                        }
                      }
                    }
                    
                    var guestAgentStatusElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'GUESTAGENTSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (guestAgentStatusElement !== null && guestAgentStatusElement !== undefined) {
                      var guestAgentStatusInstance = {};
                      roleInstanceInstance.guestAgentStatus = guestAgentStatusInstance;
                      
                      var protocolVersionElement = js2xml.getElement(responseDoc, guestAgentStatusElement, 'PROTOCOLVERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (protocolVersionElement !== null && protocolVersionElement !== undefined) {
                        var protocolVersionInstance = protocolVersionElement;
                        guestAgentStatusInstance.protocolVersion = protocolVersionInstance;
                      }
                      
                      var timestampElement = js2xml.getElement(responseDoc, guestAgentStatusElement, 'TIMESTAMP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (timestampElement !== null && timestampElement !== undefined && timestampElement.length !== 0) {
                        var timestampInstance = new Date(timestampElement);
                        guestAgentStatusInstance.timestamp = timestampInstance;
                      }
                      
                      var guestAgentVersionElement = js2xml.getElement(responseDoc, guestAgentStatusElement, 'GUESTAGENTVERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (guestAgentVersionElement !== null && guestAgentVersionElement !== undefined) {
                        var guestAgentVersionInstance = guestAgentVersionElement;
                        guestAgentStatusInstance.guestAgentVersion = guestAgentVersionInstance;
                      }
                      
                      var statusElement2 = js2xml.getElement(responseDoc, guestAgentStatusElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (statusElement2 !== null && statusElement2 !== undefined) {
                        var statusInstance2 = statusElement2;
                        guestAgentStatusInstance.status = statusInstance2;
                      }
                      
                      var codeElement = js2xml.getElement(responseDoc, guestAgentStatusElement, 'CODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (codeElement !== null && codeElement !== undefined && codeElement.length !== 0) {
                        var codeInstance = parseInt(codeElement, 10);
                        guestAgentStatusInstance.code = codeInstance;
                      }
                      
                      var messageElement = js2xml.getElement(responseDoc, guestAgentStatusElement, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (messageElement !== null && messageElement !== undefined) {
                        var messageInstance = { paramList: [] };
                        guestAgentStatusInstance.message = messageInstance;
                        
                        var messageResourceIdElement = js2xml.getElement(responseDoc, messageElement, 'MESSAGERESOURCEID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (messageResourceIdElement !== null && messageResourceIdElement !== undefined) {
                          var messageResourceIdInstance = messageResourceIdElement;
                          messageInstance.messageResourceId = messageResourceIdInstance;
                        }
                        
                        var paramListSequenceElement = js2xml.getElement(responseDoc, messageElement, 'PARAMLIST', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (paramListSequenceElement !== null && paramListSequenceElement !== undefined) {
                          for (var loweredIndex4 = 0; loweredIndex4 < js2xml.getElements(responseDoc, paramListSequenceElement, 'PARAM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex4 = loweredIndex4 + 1) {
                            var paramListElement = js2xml.getElements(responseDoc, paramListSequenceElement, 'PARAM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex4];
                            messageInstance.paramList.push(paramListElement);
                          }
                        }
                      }
                      
                      var formattedMessageElement = js2xml.getElement(responseDoc, guestAgentStatusElement, 'FORMATTEDMESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (formattedMessageElement !== null && formattedMessageElement !== undefined) {
                        var formattedMessageInstance = {};
                        guestAgentStatusInstance.formattedMessage = formattedMessageInstance;
                        
                        var languageElement = js2xml.getElement(responseDoc, formattedMessageElement, 'LANGUAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (languageElement !== null && languageElement !== undefined) {
                          var languageInstance = languageElement;
                          formattedMessageInstance.language = languageInstance;
                        }
                        
                        var messageElement2 = js2xml.getElement(responseDoc, formattedMessageElement, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (messageElement2 !== null && messageElement2 !== undefined) {
                          var messageInstance2 = messageElement2;
                          formattedMessageInstance.message = messageInstance2;
                        }
                      }
                    }
                    
                    var resourceExtensionStatusListSequenceElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'RESOURCEEXTENSIONSTATUSLIST', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (resourceExtensionStatusListSequenceElement !== null && resourceExtensionStatusListSequenceElement !== undefined) {
                      for (var loweredIndex5 = 0; loweredIndex5 < js2xml.getElements(responseDoc, resourceExtensionStatusListSequenceElement, 'RESOURCEEXTENSIONSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex5 = loweredIndex5 + 1) {
                        var resourceExtensionStatusListElement = js2xml.getElements(responseDoc, resourceExtensionStatusListSequenceElement, 'RESOURCEEXTENSIONSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex5];
                        var resourceExtensionStatusInstance = {};
                        roleInstanceInstance.resourceExtensionStatusList.push(resourceExtensionStatusInstance);
                        
                        var handlerNameElement = js2xml.getElement(responseDoc, resourceExtensionStatusListElement, 'HANDLERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (handlerNameElement !== null && handlerNameElement !== undefined) {
                          var handlerNameInstance = handlerNameElement;
                          resourceExtensionStatusInstance.handlerName = handlerNameInstance;
                        }
                        
                        var versionElement = js2xml.getElement(responseDoc, resourceExtensionStatusListElement, 'VERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (versionElement !== null && versionElement !== undefined) {
                          var versionInstance = versionElement;
                          resourceExtensionStatusInstance.version = versionInstance;
                        }
                        
                        var statusElement3 = js2xml.getElement(responseDoc, resourceExtensionStatusListElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (statusElement3 !== null && statusElement3 !== undefined) {
                          var statusInstance3 = statusElement3;
                          resourceExtensionStatusInstance.status = statusInstance3;
                        }
                        
                        var codeElement2 = js2xml.getElement(responseDoc, resourceExtensionStatusListElement, 'CODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (codeElement2 !== null && codeElement2 !== undefined && codeElement2.length !== 0) {
                          var codeInstance2 = parseInt(codeElement2, 10);
                          resourceExtensionStatusInstance.code = codeInstance2;
                        }
                        
                        var messageElement3 = js2xml.getElement(responseDoc, resourceExtensionStatusListElement, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (messageElement3 !== null && messageElement3 !== undefined) {
                          var messageInstance3 = { paramList: [] };
                          resourceExtensionStatusInstance.message = messageInstance3;
                          
                          var messageResourceIdElement2 = js2xml.getElement(responseDoc, messageElement3, 'MESSAGERESOURCEID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (messageResourceIdElement2 !== null && messageResourceIdElement2 !== undefined) {
                            var messageResourceIdInstance2 = messageResourceIdElement2;
                            messageInstance3.messageResourceId = messageResourceIdInstance2;
                          }
                          
                          var paramListSequenceElement2 = js2xml.getElement(responseDoc, messageElement3, 'PARAMLIST', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (paramListSequenceElement2 !== null && paramListSequenceElement2 !== undefined) {
                            for (var loweredIndex6 = 0; loweredIndex6 < js2xml.getElements(responseDoc, paramListSequenceElement2, 'PARAM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex6 = loweredIndex6 + 1) {
                              var paramListElement2 = js2xml.getElements(responseDoc, paramListSequenceElement2, 'PARAM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex6];
                              messageInstance3.paramList.push(paramListElement2);
                            }
                          }
                        }
                        
                        var formattedMessageElement2 = js2xml.getElement(responseDoc, resourceExtensionStatusListElement, 'FORMATTEDMESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (formattedMessageElement2 !== null && formattedMessageElement2 !== undefined) {
                          var formattedMessageInstance2 = {};
                          resourceExtensionStatusInstance.formattedMessage = formattedMessageInstance2;
                          
                          var languageElement2 = js2xml.getElement(responseDoc, formattedMessageElement2, 'LANGUAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (languageElement2 !== null && languageElement2 !== undefined) {
                            var languageInstance2 = languageElement2;
                            formattedMessageInstance2.language = languageInstance2;
                          }
                          
                          var messageElement4 = js2xml.getElement(responseDoc, formattedMessageElement2, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (messageElement4 !== null && messageElement4 !== undefined) {
                            var messageInstance4 = messageElement4;
                            formattedMessageInstance2.message = messageInstance4;
                          }
                        }
                        
                        var extensionSettingStatusElement = js2xml.getElement(responseDoc, resourceExtensionStatusListElement, 'EXTENSIONSETTINGSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (extensionSettingStatusElement !== null && extensionSettingStatusElement !== undefined) {
                          var extensionSettingStatusInstance = { subStatusList: [] };
                          resourceExtensionStatusInstance.extensionSettingStatus = extensionSettingStatusInstance;
                          
                          var timestampElement2 = js2xml.getElement(responseDoc, extensionSettingStatusElement, 'TIMESTAMP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (timestampElement2 !== null && timestampElement2 !== undefined && timestampElement2.length !== 0) {
                            var timestampInstance2 = new Date(timestampElement2);
                            extensionSettingStatusInstance.timestamp = timestampInstance2;
                          }
                          
                          var configurationAppliedTimeElement = js2xml.getElement(responseDoc, extensionSettingStatusElement, 'CONFIGURATIONAPPLIEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (configurationAppliedTimeElement !== null && configurationAppliedTimeElement !== undefined && configurationAppliedTimeElement.length !== 0) {
                            var configurationAppliedTimeInstance = new Date(configurationAppliedTimeElement);
                            extensionSettingStatusInstance.configurationAppliedTime = configurationAppliedTimeInstance;
                          }
                          
                          var nameElement3 = js2xml.getElement(responseDoc, extensionSettingStatusElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (nameElement3 !== null && nameElement3 !== undefined) {
                            var nameInstance3 = nameElement3;
                            extensionSettingStatusInstance.name = nameInstance3;
                          }
                          
                          var operationElement = js2xml.getElement(responseDoc, extensionSettingStatusElement, 'OPERATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (operationElement !== null && operationElement !== undefined) {
                            var operationInstance = operationElement;
                            extensionSettingStatusInstance.operation = operationInstance;
                          }
                          
                          var statusElement4 = js2xml.getElement(responseDoc, extensionSettingStatusElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (statusElement4 !== null && statusElement4 !== undefined) {
                            var statusInstance4 = statusElement4;
                            extensionSettingStatusInstance.status = statusInstance4;
                          }
                          
                          var codeElement3 = js2xml.getElement(responseDoc, extensionSettingStatusElement, 'CODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (codeElement3 !== null && codeElement3 !== undefined && codeElement3.length !== 0) {
                            var codeInstance3 = parseInt(codeElement3, 10);
                            extensionSettingStatusInstance.code = codeInstance3;
                          }
                          
                          var messageElement5 = js2xml.getElement(responseDoc, extensionSettingStatusElement, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (messageElement5 !== null && messageElement5 !== undefined) {
                            var messageInstance5 = { paramList: [] };
                            extensionSettingStatusInstance.message = messageInstance5;
                            
                            var messageResourceIdElement3 = js2xml.getElement(responseDoc, messageElement5, 'MESSAGERESOURCEID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (messageResourceIdElement3 !== null && messageResourceIdElement3 !== undefined) {
                              var messageResourceIdInstance3 = messageResourceIdElement3;
                              messageInstance5.messageResourceId = messageResourceIdInstance3;
                            }
                            
                            var paramListSequenceElement3 = js2xml.getElement(responseDoc, messageElement5, 'PARAMLIST', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (paramListSequenceElement3 !== null && paramListSequenceElement3 !== undefined) {
                              for (var loweredIndex7 = 0; loweredIndex7 < js2xml.getElements(responseDoc, paramListSequenceElement3, 'PARAM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex7 = loweredIndex7 + 1) {
                                var paramListElement3 = js2xml.getElements(responseDoc, paramListSequenceElement3, 'PARAM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex7];
                                messageInstance5.paramList.push(paramListElement3);
                              }
                            }
                          }
                          
                          var formattedMessageElement3 = js2xml.getElement(responseDoc, extensionSettingStatusElement, 'FORMATTEDMESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (formattedMessageElement3 !== null && formattedMessageElement3 !== undefined) {
                            var formattedMessageInstance3 = {};
                            extensionSettingStatusInstance.formattedMessage = formattedMessageInstance3;
                            
                            var languageElement3 = js2xml.getElement(responseDoc, formattedMessageElement3, 'LANGUAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (languageElement3 !== null && languageElement3 !== undefined) {
                              var languageInstance3 = languageElement3;
                              formattedMessageInstance3.language = languageInstance3;
                            }
                            
                            var messageElement6 = js2xml.getElement(responseDoc, formattedMessageElement3, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (messageElement6 !== null && messageElement6 !== undefined) {
                              var messageInstance6 = messageElement6;
                              formattedMessageInstance3.message = messageInstance6;
                            }
                          }
                          
                          var subStatusListSequenceElement = js2xml.getElement(responseDoc, extensionSettingStatusElement, 'SUBSTATUSLIST', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (subStatusListSequenceElement !== null && subStatusListSequenceElement !== undefined) {
                            for (var loweredIndex8 = 0; loweredIndex8 < js2xml.getElements(responseDoc, subStatusListSequenceElement, 'SUBSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex8 = loweredIndex8 + 1) {
                              var subStatusListElement = js2xml.getElements(responseDoc, subStatusListSequenceElement, 'SUBSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex8];
                              var subStatusInstance = {};
                              extensionSettingStatusInstance.subStatusList.push(subStatusInstance);
                              
                              var nameElement4 = js2xml.getElement(responseDoc, subStatusListElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (nameElement4 !== null && nameElement4 !== undefined) {
                                var nameInstance4 = nameElement4;
                                subStatusInstance.name = nameInstance4;
                              }
                              
                              var statusElement5 = js2xml.getElement(responseDoc, subStatusListElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (statusElement5 !== null && statusElement5 !== undefined) {
                                var statusInstance5 = statusElement5;
                                subStatusInstance.status = statusInstance5;
                              }
                              
                              var codeElement4 = js2xml.getElement(responseDoc, subStatusListElement, 'CODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (codeElement4 !== null && codeElement4 !== undefined && codeElement4.length !== 0) {
                                var codeInstance4 = parseInt(codeElement4, 10);
                                subStatusInstance.code = codeInstance4;
                              }
                              
                              var messageElement7 = js2xml.getElement(responseDoc, subStatusListElement, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (messageElement7 !== null && messageElement7 !== undefined) {
                                var messageInstance7 = { paramList: [] };
                                subStatusInstance.message = messageInstance7;
                                
                                var messageResourceIdElement4 = js2xml.getElement(responseDoc, messageElement7, 'MESSAGERESOURCEID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                                if (messageResourceIdElement4 !== null && messageResourceIdElement4 !== undefined) {
                                  var messageResourceIdInstance4 = messageResourceIdElement4;
                                  messageInstance7.messageResourceId = messageResourceIdInstance4;
                                }
                                
                                var paramListSequenceElement4 = js2xml.getElement(responseDoc, messageElement7, 'PARAMLIST', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                                if (paramListSequenceElement4 !== null && paramListSequenceElement4 !== undefined) {
                                  for (var loweredIndex9 = 0; loweredIndex9 < js2xml.getElements(responseDoc, paramListSequenceElement4, 'PARAM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex9 = loweredIndex9 + 1) {
                                    var paramListElement4 = js2xml.getElements(responseDoc, paramListSequenceElement4, 'PARAM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex9];
                                    messageInstance7.paramList.push(paramListElement4);
                                  }
                                }
                              }
                              
                              var formattedMessageElement4 = js2xml.getElement(responseDoc, subStatusListElement, 'FORMATTEDMESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (formattedMessageElement4 !== null && formattedMessageElement4 !== undefined) {
                                var formattedMessageInstance4 = {};
                                subStatusInstance.formattedMessage = formattedMessageInstance4;
                                
                                var languageElement4 = js2xml.getElement(responseDoc, formattedMessageElement4, 'LANGUAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                                if (languageElement4 !== null && languageElement4 !== undefined) {
                                  var languageInstance4 = languageElement4;
                                  formattedMessageInstance4.language = languageInstance4;
                                }
                                
                                var messageElement8 = js2xml.getElement(responseDoc, formattedMessageElement4, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                                if (messageElement8 !== null && messageElement8 !== undefined) {
                                  var messageInstance8 = messageElement8;
                                  formattedMessageInstance4.message = messageInstance8;
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                    
                    var powerStateElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'POWERSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (powerStateElement !== null && powerStateElement !== undefined && powerStateElement.length !== 0) {
                      var powerStateInstance = powerStateElement;
                      roleInstanceInstance.powerState = powerStateInstance;
                    }
                    
                    var hostNameElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'HOSTNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (hostNameElement !== null && hostNameElement !== undefined) {
                      var hostNameInstance = hostNameElement;
                      roleInstanceInstance.hostName = hostNameInstance;
                    }
                    
                    var remoteAccessCertificateThumbprintElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'REMOTEACCESSCERTIFICATETHUMBPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (remoteAccessCertificateThumbprintElement !== null && remoteAccessCertificateThumbprintElement !== undefined) {
                      var remoteAccessCertificateThumbprintInstance = remoteAccessCertificateThumbprintElement;
                      roleInstanceInstance.remoteAccessCertificateThumbprint = remoteAccessCertificateThumbprintInstance;
                    }
                    
                    var publicIPsSequenceElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'PUBLICIPS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (publicIPsSequenceElement !== null && publicIPsSequenceElement !== undefined) {
                      for (var loweredIndex10 = 0; loweredIndex10 < js2xml.getElements(responseDoc, publicIPsSequenceElement, 'PUBLICIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex10 = loweredIndex10 + 1) {
                        var publicIPsElement = js2xml.getElements(responseDoc, publicIPsSequenceElement, 'PUBLICIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex10];
                        var publicIPInstance = { fqdns: [] };
                        roleInstanceInstance.publicIPs.push(publicIPInstance);
                        
                        var nameElement5 = js2xml.getElement(responseDoc, publicIPsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (nameElement5 !== null && nameElement5 !== undefined) {
                          var nameInstance5 = nameElement5;
                          publicIPInstance.name = nameInstance5;
                        }
                        
                        var addressElement = js2xml.getElement(responseDoc, publicIPsElement, 'ADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (addressElement !== null && addressElement !== undefined) {
                          var addressInstance = addressElement;
                          publicIPInstance.address = addressInstance;
                        }
                        
                        var idleTimeoutInMinutesElement2 = js2xml.getElement(responseDoc, publicIPsElement, 'IDLETIMEOUTINMINUTES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (idleTimeoutInMinutesElement2 !== null && idleTimeoutInMinutesElement2 !== undefined && idleTimeoutInMinutesElement2.length !== 0) {
                          var idleTimeoutInMinutesInstance2 = parseInt(idleTimeoutInMinutesElement2, 10);
                          publicIPInstance.idleTimeoutInMinutes = idleTimeoutInMinutesInstance2;
                        }
                        
                        var domainNameLabelElement = js2xml.getElement(responseDoc, publicIPsElement, 'DOMAINNAMELABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (domainNameLabelElement !== null && domainNameLabelElement !== undefined) {
                          var domainNameLabelInstance = domainNameLabelElement;
                          publicIPInstance.domainNameLabel = domainNameLabelInstance;
                        }
                        
                        var fqdnsSequenceElement = js2xml.getElement(responseDoc, publicIPsElement, 'FQDNS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (fqdnsSequenceElement !== null && fqdnsSequenceElement !== undefined) {
                          for (var loweredIndex11 = 0; loweredIndex11 < js2xml.getElements(responseDoc, fqdnsSequenceElement, 'FQDN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex11 = loweredIndex11 + 1) {
                            var fqdnsElement = js2xml.getElements(responseDoc, fqdnsSequenceElement, 'FQDN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex11];
                            publicIPInstance.fqdns.push(fqdnsElement);
                          }
                        }
                      }
                    }
                    
                    var networkInterfacesSequenceElement = js2xml.getElement(responseDoc, roleInstanceListElement, 'NETWORKINTERFACES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (networkInterfacesSequenceElement !== null && networkInterfacesSequenceElement !== undefined) {
                      for (var loweredIndex12 = 0; loweredIndex12 < js2xml.getElements(responseDoc, networkInterfacesSequenceElement, 'NETWORKINTERFACE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex12 = loweredIndex12 + 1) {
                        var networkInterfacesElement = js2xml.getElements(responseDoc, networkInterfacesSequenceElement, 'NETWORKINTERFACE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex12];
                        var networkInterfaceInstance = { iPConfigurations: [] };
                        roleInstanceInstance.networkInterfaces.push(networkInterfaceInstance);
                        
                        var nameElement6 = js2xml.getElement(responseDoc, networkInterfacesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (nameElement6 !== null && nameElement6 !== undefined) {
                          var nameInstance6 = nameElement6;
                          networkInterfaceInstance.name = nameInstance6;
                        }
                        
                        var macAddressElement = js2xml.getElement(responseDoc, networkInterfacesElement, 'MACADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (macAddressElement !== null && macAddressElement !== undefined) {
                          var macAddressInstance = macAddressElement;
                          networkInterfaceInstance.macAddress = macAddressInstance;
                        }
                        
                        var iPConfigurationsSequenceElement = js2xml.getElement(responseDoc, networkInterfacesElement, 'IPCONFIGURATIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (iPConfigurationsSequenceElement !== null && iPConfigurationsSequenceElement !== undefined) {
                          for (var loweredIndex13 = 0; loweredIndex13 < js2xml.getElements(responseDoc, iPConfigurationsSequenceElement, 'IPCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex13 = loweredIndex13 + 1) {
                            var iPConfigurationsElement = js2xml.getElements(responseDoc, iPConfigurationsSequenceElement, 'IPCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex13];
                            var iPConfigurationInstance = {};
                            networkInterfaceInstance.iPConfigurations.push(iPConfigurationInstance);
                            
                            var subnetNameElement = js2xml.getElement(responseDoc, iPConfigurationsElement, 'SUBNETNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (subnetNameElement !== null && subnetNameElement !== undefined) {
                              var subnetNameInstance = subnetNameElement;
                              iPConfigurationInstance.subnetName = subnetNameInstance;
                            }
                            
                            var addressElement2 = js2xml.getElement(responseDoc, iPConfigurationsElement, 'ADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (addressElement2 !== null && addressElement2 !== undefined) {
                              var addressInstance2 = addressElement2;
                              iPConfigurationInstance.address = addressInstance2;
                            }
                          }
                        }
                      }
                    }
                  }
                }
                
                var upgradeStatusElement = js2xml.getElement(responseDoc, deploymentsElement, 'UPGRADESTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (upgradeStatusElement !== null && upgradeStatusElement !== undefined) {
                  var upgradeStatusInstance = {};
                  deploymentInstance.upgradeStatus = upgradeStatusInstance;
                  
                  var upgradeTypeElement = js2xml.getElement(responseDoc, upgradeStatusElement, 'UPGRADETYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (upgradeTypeElement !== null && upgradeTypeElement !== undefined && upgradeTypeElement.length !== 0) {
                    var upgradeTypeInstance = upgradeTypeElement;
                    upgradeStatusInstance.upgradeType = upgradeTypeInstance;
                  }
                  
                  var currentUpgradeDomainStateElement = js2xml.getElement(responseDoc, upgradeStatusElement, 'CURRENTUPGRADEDOMAINSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (currentUpgradeDomainStateElement !== null && currentUpgradeDomainStateElement !== undefined && currentUpgradeDomainStateElement.length !== 0) {
                    var currentUpgradeDomainStateInstance = currentUpgradeDomainStateElement;
                    upgradeStatusInstance.currentUpgradeDomainState = currentUpgradeDomainStateInstance;
                  }
                  
                  var currentUpgradeDomainElement = js2xml.getElement(responseDoc, upgradeStatusElement, 'CURRENTUPGRADEDOMAIN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (currentUpgradeDomainElement !== null && currentUpgradeDomainElement !== undefined && currentUpgradeDomainElement.length !== 0) {
                    var currentUpgradeDomainInstance = parseInt(currentUpgradeDomainElement, 10);
                    upgradeStatusInstance.currentUpgradeDomain = currentUpgradeDomainInstance;
                  }
                }
                
                var upgradeDomainCountElement = js2xml.getElement(responseDoc, deploymentsElement, 'UPGRADEDOMAINCOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (upgradeDomainCountElement !== null && upgradeDomainCountElement !== undefined && upgradeDomainCountElement.length !== 0) {
                  var upgradeDomainCountInstance = parseInt(upgradeDomainCountElement, 10);
                  deploymentInstance.upgradeDomainCount = upgradeDomainCountInstance;
                }
                
                var roleListSequenceElement = js2xml.getElement(responseDoc, deploymentsElement, 'ROLELIST', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (roleListSequenceElement !== null && roleListSequenceElement !== undefined) {
                  for (var loweredIndex14 = 0; loweredIndex14 < js2xml.getElements(responseDoc, roleListSequenceElement, 'ROLE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex14 = loweredIndex14 + 1) {
                    var roleListElement = js2xml.getElements(responseDoc, roleListSequenceElement, 'ROLE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex14];
                    var roleInstance = { configurationSets: [], dataVirtualHardDisks: [], resourceExtensionReferences: [] };
                    deploymentInstance.roles.push(roleInstance);
                    
                    var roleNameElement2 = js2xml.getElement(responseDoc, roleListElement, 'ROLENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (roleNameElement2 !== null && roleNameElement2 !== undefined) {
                      var roleNameInstance2 = roleNameElement2;
                      roleInstance.roleName = roleNameInstance2;
                    }
                    
                    var osVersionElement = js2xml.getElement(responseDoc, roleListElement, 'OSVERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (osVersionElement !== null && osVersionElement !== undefined) {
                      var osVersionInstance = osVersionElement;
                      roleInstance.oSVersion = osVersionInstance;
                    }
                    
                    var roleTypeElement = js2xml.getElement(responseDoc, roleListElement, 'ROLETYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (roleTypeElement !== null && roleTypeElement !== undefined) {
                      var roleTypeInstance = roleTypeElement;
                      roleInstance.roleType = roleTypeInstance;
                    }
                    
                    var configurationSetsSequenceElement = js2xml.getElement(responseDoc, roleListElement, 'CONFIGURATIONSETS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (configurationSetsSequenceElement !== null && configurationSetsSequenceElement !== undefined) {
                      for (var loweredIndex15 = 0; loweredIndex15 < js2xml.getElements(responseDoc, configurationSetsSequenceElement, 'CONFIGURATIONSET', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex15 = loweredIndex15 + 1) {
                        var configurationSetsElement = js2xml.getElements(responseDoc, configurationSetsSequenceElement, 'CONFIGURATIONSET', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex15];
                        var configurationSetInstance = { inputEndpoints: [], networkInterfaces: [], publicIPs: [], storedCertificateSettings: [], subnetNames: [] };
                        roleInstance.configurationSets.push(configurationSetInstance);
                        
                        var configurationSetTypeElement = js2xml.getElement(responseDoc, configurationSetsElement, 'CONFIGURATIONSETTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (configurationSetTypeElement !== null && configurationSetTypeElement !== undefined) {
                          var configurationSetTypeInstance = configurationSetTypeElement;
                          configurationSetInstance.configurationSetType = configurationSetTypeInstance;
                        }
                        
                        var inputEndpointsSequenceElement = js2xml.getElement(responseDoc, configurationSetsElement, 'INPUTENDPOINTS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (inputEndpointsSequenceElement !== null && inputEndpointsSequenceElement !== undefined) {
                          for (var loweredIndex16 = 0; loweredIndex16 < js2xml.getElements(responseDoc, inputEndpointsSequenceElement, 'INPUTENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex16 = loweredIndex16 + 1) {
                            var inputEndpointsElement = js2xml.getElements(responseDoc, inputEndpointsSequenceElement, 'INPUTENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex16];
                            var inputEndpointInstance = {};
                            configurationSetInstance.inputEndpoints.push(inputEndpointInstance);
                            
                            var loadBalancedEndpointSetNameElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'LOADBALANCEDENDPOINTSETNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (loadBalancedEndpointSetNameElement !== null && loadBalancedEndpointSetNameElement !== undefined) {
                              var loadBalancedEndpointSetNameInstance = loadBalancedEndpointSetNameElement;
                              inputEndpointInstance.loadBalancedEndpointSetName = loadBalancedEndpointSetNameInstance;
                            }
                            
                            var localPortElement2 = js2xml.getElement(responseDoc, inputEndpointsElement, 'LOCALPORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (localPortElement2 !== null && localPortElement2 !== undefined && localPortElement2.length !== 0) {
                              var localPortInstance2 = parseInt(localPortElement2, 10);
                              inputEndpointInstance.localPort = localPortInstance2;
                            }
                            
                            var nameElement7 = js2xml.getElement(responseDoc, inputEndpointsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (nameElement7 !== null && nameElement7 !== undefined) {
                              var nameInstance7 = nameElement7;
                              inputEndpointInstance.name = nameInstance7;
                            }
                            
                            var portElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'PORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (portElement !== null && portElement !== undefined && portElement.length !== 0) {
                              var portInstance = parseInt(portElement, 10);
                              inputEndpointInstance.port = portInstance;
                            }
                            
                            var loadBalancerProbeElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'LOADBALANCERPROBE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (loadBalancerProbeElement !== null && loadBalancerProbeElement !== undefined) {
                              var loadBalancerProbeInstance = {};
                              inputEndpointInstance.loadBalancerProbe = loadBalancerProbeInstance;
                              
                              var pathElement = js2xml.getElement(responseDoc, loadBalancerProbeElement, 'PATH', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (pathElement !== null && pathElement !== undefined) {
                                var pathInstance = pathElement;
                                loadBalancerProbeInstance.path = pathInstance;
                              }
                              
                              var portElement2 = js2xml.getElement(responseDoc, loadBalancerProbeElement, 'PORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (portElement2 !== null && portElement2 !== undefined && portElement2.length !== 0) {
                                var portInstance2 = parseInt(portElement2, 10);
                                loadBalancerProbeInstance.port = portInstance2;
                              }
                              
                              var protocolElement2 = js2xml.getElement(responseDoc, loadBalancerProbeElement, 'PROTOCOL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (protocolElement2 !== null && protocolElement2 !== undefined && protocolElement2.length !== 0) {
                                var protocolInstance2 = protocolElement2;
                                loadBalancerProbeInstance.protocol = protocolInstance2;
                              }
                              
                              var intervalInSecondsElement = js2xml.getElement(responseDoc, loadBalancerProbeElement, 'INTERVALINSECONDS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (intervalInSecondsElement !== null && intervalInSecondsElement !== undefined && intervalInSecondsElement.length !== 0) {
                                var intervalInSecondsInstance = parseInt(intervalInSecondsElement, 10);
                                loadBalancerProbeInstance.intervalInSeconds = intervalInSecondsInstance;
                              }
                              
                              var timeoutInSecondsElement = js2xml.getElement(responseDoc, loadBalancerProbeElement, 'TIMEOUTINSECONDS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (timeoutInSecondsElement !== null && timeoutInSecondsElement !== undefined && timeoutInSecondsElement.length !== 0) {
                                var timeoutInSecondsInstance = parseInt(timeoutInSecondsElement, 10);
                                loadBalancerProbeInstance.timeoutInSeconds = timeoutInSecondsInstance;
                              }
                            }
                            
                            var protocolElement3 = js2xml.getElement(responseDoc, inputEndpointsElement, 'PROTOCOL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (protocolElement3 !== null && protocolElement3 !== undefined) {
                              var protocolInstance3 = protocolElement3;
                              inputEndpointInstance.protocol = protocolInstance3;
                            }
                            
                            var vipElement2 = js2xml.getElement(responseDoc, inputEndpointsElement, 'VIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (vipElement2 !== null && vipElement2 !== undefined) {
                              var vipInstance2 = vipElement2;
                              inputEndpointInstance.virtualIPAddress = vipInstance2;
                            }
                            
                            var enableDirectServerReturnElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'ENABLEDIRECTSERVERRETURN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (enableDirectServerReturnElement !== null && enableDirectServerReturnElement !== undefined && enableDirectServerReturnElement.length !== 0) {
                              var enableDirectServerReturnInstance = enableDirectServerReturnElement === 'true';
                              inputEndpointInstance.enableDirectServerReturn = enableDirectServerReturnInstance;
                            }
                            
                            var loadBalancerNameElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'LOADBALANCERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (loadBalancerNameElement !== null && loadBalancerNameElement !== undefined) {
                              var loadBalancerNameInstance = loadBalancerNameElement;
                              inputEndpointInstance.loadBalancerName = loadBalancerNameInstance;
                            }
                            
                            var endpointAclElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'ENDPOINTACL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (endpointAclElement !== null && endpointAclElement !== undefined) {
                              var endpointAclInstance = { rules: [] };
                              inputEndpointInstance.endpointAcl = endpointAclInstance;
                              
                              var rulesSequenceElement = js2xml.getElement(responseDoc, endpointAclElement, 'RULES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (rulesSequenceElement !== null && rulesSequenceElement !== undefined) {
                                for (var loweredIndex17 = 0; loweredIndex17 < js2xml.getElements(responseDoc, rulesSequenceElement, 'RULE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex17 = loweredIndex17 + 1) {
                                  var rulesElement = js2xml.getElements(responseDoc, rulesSequenceElement, 'RULE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex17];
                                  var ruleInstance = {};
                                  endpointAclInstance.rules.push(ruleInstance);
                                  
                                  var orderElement = js2xml.getElement(responseDoc, rulesElement, 'ORDER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                                  if (orderElement !== null && orderElement !== undefined && orderElement.length !== 0) {
                                    var orderInstance = parseInt(orderElement, 10);
                                    ruleInstance.order = orderInstance;
                                  }
                                  
                                  var actionElement = js2xml.getElement(responseDoc, rulesElement, 'ACTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                                  if (actionElement !== null && actionElement !== undefined) {
                                    var actionInstance = actionElement;
                                    ruleInstance.action = actionInstance;
                                  }
                                  
                                  var remoteSubnetElement = js2xml.getElement(responseDoc, rulesElement, 'REMOTESUBNET', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                                  if (remoteSubnetElement !== null && remoteSubnetElement !== undefined) {
                                    var remoteSubnetInstance = remoteSubnetElement;
                                    ruleInstance.remoteSubnet = remoteSubnetInstance;
                                  }
                                  
                                  var descriptionElement = js2xml.getElement(responseDoc, rulesElement, 'DESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                                  if (descriptionElement !== null && descriptionElement !== undefined) {
                                    var descriptionInstance = descriptionElement;
                                    ruleInstance.description = descriptionInstance;
                                  }
                                }
                              }
                            }
                            
                            var idleTimeoutInMinutesElement3 = js2xml.getElement(responseDoc, inputEndpointsElement, 'IDLETIMEOUTINMINUTES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (idleTimeoutInMinutesElement3 !== null && idleTimeoutInMinutesElement3 !== undefined && idleTimeoutInMinutesElement3.length !== 0) {
                              var idleTimeoutInMinutesInstance3 = parseInt(idleTimeoutInMinutesElement3, 10);
                              inputEndpointInstance.idleTimeoutInMinutes = idleTimeoutInMinutesInstance3;
                            }
                            
                            var loadBalancerDistributionElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'LOADBALANCERDISTRIBUTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (loadBalancerDistributionElement !== null && loadBalancerDistributionElement !== undefined) {
                              var loadBalancerDistributionInstance = loadBalancerDistributionElement;
                              inputEndpointInstance.loadBalancerDistribution = loadBalancerDistributionInstance;
                            }
                            
                            var virtualIPNameElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'VIRTUALIPNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (virtualIPNameElement !== null && virtualIPNameElement !== undefined) {
                              var virtualIPNameInstance = virtualIPNameElement;
                              inputEndpointInstance.virtualIPName = virtualIPNameInstance;
                            }
                          }
                        }
                        
                        var subnetNamesSequenceElement = js2xml.getElement(responseDoc, configurationSetsElement, 'SUBNETNAMES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (subnetNamesSequenceElement !== null && subnetNamesSequenceElement !== undefined) {
                          for (var loweredIndex18 = 0; loweredIndex18 < js2xml.getElements(responseDoc, subnetNamesSequenceElement, 'SUBNETNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex18 = loweredIndex18 + 1) {
                            var subnetNamesElement = js2xml.getElements(responseDoc, subnetNamesSequenceElement, 'SUBNETNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex18];
                            configurationSetInstance.subnetNames.push(subnetNamesElement);
                          }
                        }
                        
                        var staticVirtualNetworkIPAddressElement = js2xml.getElement(responseDoc, configurationSetsElement, 'STATICVIRTUALNETWORKIPADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (staticVirtualNetworkIPAddressElement !== null && staticVirtualNetworkIPAddressElement !== undefined) {
                          var staticVirtualNetworkIPAddressInstance = staticVirtualNetworkIPAddressElement;
                          configurationSetInstance.staticVirtualNetworkIPAddress = staticVirtualNetworkIPAddressInstance;
                        }
                        
                        var publicIPsSequenceElement2 = js2xml.getElement(responseDoc, configurationSetsElement, 'PUBLICIPS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (publicIPsSequenceElement2 !== null && publicIPsSequenceElement2 !== undefined) {
                          for (var loweredIndex19 = 0; loweredIndex19 < js2xml.getElements(responseDoc, publicIPsSequenceElement2, 'PUBLICIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex19 = loweredIndex19 + 1) {
                            var publicIPsElement2 = js2xml.getElements(responseDoc, publicIPsSequenceElement2, 'PUBLICIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex19];
                            var publicIPInstance2 = {};
                            configurationSetInstance.publicIPs.push(publicIPInstance2);
                            
                            var nameElement8 = js2xml.getElement(responseDoc, publicIPsElement2, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (nameElement8 !== null && nameElement8 !== undefined) {
                              var nameInstance8 = nameElement8;
                              publicIPInstance2.name = nameInstance8;
                            }
                            
                            var idleTimeoutInMinutesElement4 = js2xml.getElement(responseDoc, publicIPsElement2, 'IDLETIMEOUTINMINUTES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (idleTimeoutInMinutesElement4 !== null && idleTimeoutInMinutesElement4 !== undefined && idleTimeoutInMinutesElement4.length !== 0) {
                              var idleTimeoutInMinutesInstance4 = parseInt(idleTimeoutInMinutesElement4, 10);
                              publicIPInstance2.idleTimeoutInMinutes = idleTimeoutInMinutesInstance4;
                            }
                            
                            var domainNameLabelElement2 = js2xml.getElement(responseDoc, publicIPsElement2, 'DOMAINNAMELABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (domainNameLabelElement2 !== null && domainNameLabelElement2 !== undefined) {
                              var domainNameLabelInstance2 = domainNameLabelElement2;
                              publicIPInstance2.domainNameLabel = domainNameLabelInstance2;
                            }
                          }
                        }
                        
                        var networkInterfacesSequenceElement2 = js2xml.getElement(responseDoc, configurationSetsElement, 'NETWORKINTERFACES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (networkInterfacesSequenceElement2 !== null && networkInterfacesSequenceElement2 !== undefined) {
                          for (var loweredIndex20 = 0; loweredIndex20 < js2xml.getElements(responseDoc, networkInterfacesSequenceElement2, 'NETWORKINTERFACE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex20 = loweredIndex20 + 1) {
                            var networkInterfacesElement2 = js2xml.getElements(responseDoc, networkInterfacesSequenceElement2, 'NETWORKINTERFACE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex20];
                            var networkInterfaceInstance2 = { iPConfigurations: [] };
                            configurationSetInstance.networkInterfaces.push(networkInterfaceInstance2);
                            
                            var nameElement9 = js2xml.getElement(responseDoc, networkInterfacesElement2, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (nameElement9 !== null && nameElement9 !== undefined) {
                              var nameInstance9 = nameElement9;
                              networkInterfaceInstance2.name = nameInstance9;
                            }
                            
                            var iPConfigurationsSequenceElement2 = js2xml.getElement(responseDoc, networkInterfacesElement2, 'IPCONFIGURATIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (iPConfigurationsSequenceElement2 !== null && iPConfigurationsSequenceElement2 !== undefined) {
                              for (var loweredIndex21 = 0; loweredIndex21 < js2xml.getElements(responseDoc, iPConfigurationsSequenceElement2, 'IPCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex21 = loweredIndex21 + 1) {
                                var iPConfigurationsElement2 = js2xml.getElements(responseDoc, iPConfigurationsSequenceElement2, 'IPCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex21];
                                var iPConfigurationInstance2 = {};
                                networkInterfaceInstance2.iPConfigurations.push(iPConfigurationInstance2);
                                
                                var subnetNameElement2 = js2xml.getElement(responseDoc, iPConfigurationsElement2, 'SUBNETNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                                if (subnetNameElement2 !== null && subnetNameElement2 !== undefined) {
                                  var subnetNameInstance2 = subnetNameElement2;
                                  iPConfigurationInstance2.subnetName = subnetNameInstance2;
                                }
                                
                                var staticVirtualNetworkIPAddressElement2 = js2xml.getElement(responseDoc, iPConfigurationsElement2, 'STATICVIRTUALNETWORKIPADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                                if (staticVirtualNetworkIPAddressElement2 !== null && staticVirtualNetworkIPAddressElement2 !== undefined) {
                                  var staticVirtualNetworkIPAddressInstance2 = staticVirtualNetworkIPAddressElement2;
                                  iPConfigurationInstance2.staticVirtualNetworkIPAddress = staticVirtualNetworkIPAddressInstance2;
                                }
                              }
                            }
                            
                            var networkSecurityGroupElement = js2xml.getElement(responseDoc, networkInterfacesElement2, 'NETWORKSECURITYGROUP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (networkSecurityGroupElement !== null && networkSecurityGroupElement !== undefined) {
                              var networkSecurityGroupInstance = networkSecurityGroupElement;
                              networkInterfaceInstance2.networkSecurityGroup = networkSecurityGroupInstance;
                            }
                            
                            var iPForwardingElement = js2xml.getElement(responseDoc, networkInterfacesElement2, 'IPFORWARDING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (iPForwardingElement !== null && iPForwardingElement !== undefined) {
                              var iPForwardingInstance = iPForwardingElement;
                              networkInterfaceInstance2.iPForwarding = iPForwardingInstance;
                            }
                          }
                        }
                        
                        var networkSecurityGroupElement2 = js2xml.getElement(responseDoc, configurationSetsElement, 'NETWORKSECURITYGROUP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (networkSecurityGroupElement2 !== null && networkSecurityGroupElement2 !== undefined) {
                          var networkSecurityGroupInstance2 = networkSecurityGroupElement2;
                          configurationSetInstance.networkSecurityGroup = networkSecurityGroupInstance2;
                        }
                        
                        var iPForwardingElement2 = js2xml.getElement(responseDoc, configurationSetsElement, 'IPFORWARDING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (iPForwardingElement2 !== null && iPForwardingElement2 !== undefined) {
                          var iPForwardingInstance2 = iPForwardingElement2;
                          configurationSetInstance.iPForwarding = iPForwardingInstance2;
                        }
                        
                        var computerNameElement = js2xml.getElement(responseDoc, configurationSetsElement, 'COMPUTERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (computerNameElement !== null && computerNameElement !== undefined) {
                          var computerNameInstance = computerNameElement;
                          configurationSetInstance.computerName = computerNameInstance;
                        }
                        
                        var adminPasswordElement = js2xml.getElement(responseDoc, configurationSetsElement, 'ADMINPASSWORD', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (adminPasswordElement !== null && adminPasswordElement !== undefined) {
                          var adminPasswordInstance = adminPasswordElement;
                          configurationSetInstance.adminPassword = adminPasswordInstance;
                        }
                        
                        var resetPasswordOnFirstLogonElement = js2xml.getElement(responseDoc, configurationSetsElement, 'RESETPASSWORDONFIRSTLOGON', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (resetPasswordOnFirstLogonElement !== null && resetPasswordOnFirstLogonElement !== undefined && resetPasswordOnFirstLogonElement.length !== 0) {
                          var resetPasswordOnFirstLogonInstance = resetPasswordOnFirstLogonElement === 'true';
                          configurationSetInstance.resetPasswordOnFirstLogon = resetPasswordOnFirstLogonInstance;
                        }
                        
                        var enableAutomaticUpdatesElement = js2xml.getElement(responseDoc, configurationSetsElement, 'ENABLEAUTOMATICUPDATES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (enableAutomaticUpdatesElement !== null && enableAutomaticUpdatesElement !== undefined && enableAutomaticUpdatesElement.length !== 0) {
                          var enableAutomaticUpdatesInstance = enableAutomaticUpdatesElement === 'true';
                          configurationSetInstance.enableAutomaticUpdates = enableAutomaticUpdatesInstance;
                        }
                        
                        var timeZoneElement = js2xml.getElement(responseDoc, configurationSetsElement, 'TIMEZONE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (timeZoneElement !== null && timeZoneElement !== undefined) {
                          var timeZoneInstance = timeZoneElement;
                          configurationSetInstance.timeZone = timeZoneInstance;
                        }
                        
                        var domainJoinElement = js2xml.getElement(responseDoc, configurationSetsElement, 'DOMAINJOIN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (domainJoinElement !== null && domainJoinElement !== undefined) {
                          var domainJoinInstance = {};
                          configurationSetInstance.domainJoin = domainJoinInstance;
                          
                          var credentialsElement = js2xml.getElement(responseDoc, domainJoinElement, 'CREDENTIALS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (credentialsElement !== null && credentialsElement !== undefined) {
                            var credentialsInstance = {};
                            domainJoinInstance.credentials = credentialsInstance;
                            
                            var domainElement = js2xml.getElement(responseDoc, credentialsElement, 'DOMAIN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (domainElement !== null && domainElement !== undefined) {
                              var domainInstance = domainElement;
                              credentialsInstance.domain = domainInstance;
                            }
                            
                            var usernameElement = js2xml.getElement(responseDoc, credentialsElement, 'USERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (usernameElement !== null && usernameElement !== undefined) {
                              var usernameInstance = usernameElement;
                              credentialsInstance.userName = usernameInstance;
                            }
                            
                            var passwordElement = js2xml.getElement(responseDoc, credentialsElement, 'PASSWORD', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (passwordElement !== null && passwordElement !== undefined) {
                              var passwordInstance = passwordElement;
                              credentialsInstance.password = passwordInstance;
                            }
                          }
                          
                          var joinDomainElement = js2xml.getElement(responseDoc, domainJoinElement, 'JOINDOMAIN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (joinDomainElement !== null && joinDomainElement !== undefined) {
                            var joinDomainInstance = joinDomainElement;
                            domainJoinInstance.domainToJoin = joinDomainInstance;
                          }
                          
                          var machineObjectOUElement = js2xml.getElement(responseDoc, domainJoinElement, 'MACHINEOBJECTOU', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (machineObjectOUElement !== null && machineObjectOUElement !== undefined) {
                            var machineObjectOUInstance = machineObjectOUElement;
                            domainJoinInstance.ldapMachineObjectOU = machineObjectOUInstance;
                          }
                          
                          var provisioningElement = js2xml.getElement(responseDoc, domainJoinElement, 'PROVISIONING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (provisioningElement !== null && provisioningElement !== undefined) {
                            var provisioningInstance = {};
                            domainJoinInstance.provisioning = provisioningInstance;
                            
                            var accountDataElement = js2xml.getElement(responseDoc, provisioningElement, 'ACCOUNTDATA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (accountDataElement !== null && accountDataElement !== undefined) {
                              var accountDataInstance = accountDataElement;
                              provisioningInstance.accountData = accountDataInstance;
                            }
                          }
                        }
                        
                        var storedCertificateSettingsSequenceElement = js2xml.getElement(responseDoc, configurationSetsElement, 'STOREDCERTIFICATESETTINGS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (storedCertificateSettingsSequenceElement !== null && storedCertificateSettingsSequenceElement !== undefined) {
                          for (var loweredIndex22 = 0; loweredIndex22 < js2xml.getElements(responseDoc, storedCertificateSettingsSequenceElement, 'CERTIFICATESETTING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex22 = loweredIndex22 + 1) {
                            var storedCertificateSettingsElement = js2xml.getElements(responseDoc, storedCertificateSettingsSequenceElement, 'CERTIFICATESETTING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex22];
                            var certificateSettingInstance = {};
                            configurationSetInstance.storedCertificateSettings.push(certificateSettingInstance);
                            
                            var storeLocationElement = js2xml.getElement(responseDoc, storedCertificateSettingsElement, 'STORELOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (storeLocationElement !== null && storeLocationElement !== undefined) {
                            }
                            
                            var storeNameElement = js2xml.getElement(responseDoc, storedCertificateSettingsElement, 'STORENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (storeNameElement !== null && storeNameElement !== undefined) {
                              var storeNameInstance = storeNameElement;
                              certificateSettingInstance.storeName = storeNameInstance;
                            }
                            
                            var thumbprintElement = js2xml.getElement(responseDoc, storedCertificateSettingsElement, 'THUMBPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (thumbprintElement !== null && thumbprintElement !== undefined) {
                              var thumbprintInstance = thumbprintElement;
                              certificateSettingInstance.thumbprint = thumbprintInstance;
                            }
                          }
                        }
                        
                        var winRMElement = js2xml.getElement(responseDoc, configurationSetsElement, 'WINRM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (winRMElement !== null && winRMElement !== undefined) {
                          var winRMInstance = { listeners: [] };
                          configurationSetInstance.windowsRemoteManagement = winRMInstance;
                          
                          var listenersSequenceElement = js2xml.getElement(responseDoc, winRMElement, 'LISTENERS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (listenersSequenceElement !== null && listenersSequenceElement !== undefined) {
                            for (var loweredIndex23 = 0; loweredIndex23 < js2xml.getElements(responseDoc, listenersSequenceElement, 'LISTENER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex23 = loweredIndex23 + 1) {
                              var listenersElement = js2xml.getElements(responseDoc, listenersSequenceElement, 'LISTENER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex23];
                              var listenerInstance = {};
                              winRMInstance.listeners.push(listenerInstance);
                              
                              var protocolElement4 = js2xml.getElement(responseDoc, listenersElement, 'PROTOCOL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (protocolElement4 !== null && protocolElement4 !== undefined && protocolElement4.length !== 0) {
                                var protocolInstance4 = protocolElement4;
                                listenerInstance.listenerType = protocolInstance4;
                              }
                              
                              var certificateThumbprintElement = js2xml.getElement(responseDoc, listenersElement, 'CERTIFICATETHUMBPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (certificateThumbprintElement !== null && certificateThumbprintElement !== undefined) {
                                var certificateThumbprintInstance = certificateThumbprintElement;
                                listenerInstance.certificateThumbprint = certificateThumbprintInstance;
                              }
                            }
                          }
                        }
                        
                        var adminUsernameElement = js2xml.getElement(responseDoc, configurationSetsElement, 'ADMINUSERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (adminUsernameElement !== null && adminUsernameElement !== undefined) {
                          var adminUsernameInstance = adminUsernameElement;
                          configurationSetInstance.adminUserName = adminUsernameInstance;
                        }
                        
                        var additionalUnattendContentElement = js2xml.getElement(responseDoc, configurationSetsElement, 'ADDITIONALUNATTENDCONTENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (additionalUnattendContentElement !== null && additionalUnattendContentElement !== undefined) {
                          var additionalUnattendContentInstance = { unattendPasses: [] };
                          configurationSetInstance.additionalUnattendContent = additionalUnattendContentInstance;
                          
                          var passesSequenceElement = js2xml.getElement(responseDoc, additionalUnattendContentElement, 'PASSES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (passesSequenceElement !== null && passesSequenceElement !== undefined) {
                            for (var loweredIndex24 = 0; loweredIndex24 < js2xml.getElements(responseDoc, passesSequenceElement, 'UNATTENDPASS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex24 = loweredIndex24 + 1) {
                              var passesElement = js2xml.getElements(responseDoc, passesSequenceElement, 'UNATTENDPASS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex24];
                              var unattendPassInstance = { unattendComponents: [] };
                              additionalUnattendContentInstance.unattendPasses.push(unattendPassInstance);
                              
                              var passNameElement = js2xml.getElement(responseDoc, passesElement, 'PASSNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (passNameElement !== null && passNameElement !== undefined) {
                                var passNameInstance = passNameElement;
                                unattendPassInstance.passName = passNameInstance;
                              }
                              
                              var componentsSequenceElement = js2xml.getElement(responseDoc, passesElement, 'COMPONENTS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (componentsSequenceElement !== null && componentsSequenceElement !== undefined) {
                                for (var loweredIndex25 = 0; loweredIndex25 < js2xml.getElements(responseDoc, componentsSequenceElement, 'UNATTENDCOMPONENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex25 = loweredIndex25 + 1) {
                                  var componentsElement = js2xml.getElements(responseDoc, componentsSequenceElement, 'UNATTENDCOMPONENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex25];
                                  var unattendComponentInstance = { unattendComponentSettings: [] };
                                  unattendPassInstance.unattendComponents.push(unattendComponentInstance);
                                  
                                  var componentNameElement = js2xml.getElement(responseDoc, componentsElement, 'COMPONENTNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                                  if (componentNameElement !== null && componentNameElement !== undefined) {
                                    var componentNameInstance = componentNameElement;
                                    unattendComponentInstance.componentName = componentNameInstance;
                                  }
                                  
                                  var componentSettingsSequenceElement = js2xml.getElement(responseDoc, componentsElement, 'COMPONENTSETTINGS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                                  if (componentSettingsSequenceElement !== null && componentSettingsSequenceElement !== undefined) {
                                    for (var loweredIndex26 = 0; loweredIndex26 < js2xml.getElements(responseDoc, componentSettingsSequenceElement, 'COMPONENTSETTING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex26 = loweredIndex26 + 1) {
                                      var componentSettingsElement = js2xml.getElements(responseDoc, componentSettingsSequenceElement, 'COMPONENTSETTING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex26];
                                      var componentSettingInstance = {};
                                      unattendComponentInstance.unattendComponentSettings.push(componentSettingInstance);
                                      
                                      var settingNameElement = js2xml.getElement(responseDoc, componentSettingsElement, 'SETTINGNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                                      if (settingNameElement !== null && settingNameElement !== undefined) {
                                        var settingNameInstance = settingNameElement;
                                        componentSettingInstance.settingName = settingNameInstance;
                                      }
                                      
                                      var contentElement = js2xml.getElement(responseDoc, componentSettingsElement, 'CONTENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                                      if (contentElement !== null && contentElement !== undefined) {
                                        var contentInstance = new Buffer(contentElement, 'base64').toString('utf8');
                                        componentSettingInstance.content = contentInstance;
                                      }
                                    }
                                  }
                                }
                              }
                            }
                          }
                        }
                        
                        var hostNameElement2 = js2xml.getElement(responseDoc, configurationSetsElement, 'HOSTNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (hostNameElement2 !== null && hostNameElement2 !== undefined) {
                          var hostNameInstance2 = hostNameElement2;
                          configurationSetInstance.hostName = hostNameInstance2;
                        }
                        
                        var userNameElement = js2xml.getElement(responseDoc, configurationSetsElement, 'USERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (userNameElement !== null && userNameElement !== undefined) {
                          var userNameInstance = userNameElement;
                          configurationSetInstance.userName = userNameInstance;
                        }
                        
                        var userPasswordElement = js2xml.getElement(responseDoc, configurationSetsElement, 'USERPASSWORD', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (userPasswordElement !== null && userPasswordElement !== undefined) {
                          var userPasswordInstance = userPasswordElement;
                          configurationSetInstance.userPassword = userPasswordInstance;
                        }
                        
                        var disableSshPasswordAuthenticationElement = js2xml.getElement(responseDoc, configurationSetsElement, 'DISABLESSHPASSWORDAUTHENTICATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (disableSshPasswordAuthenticationElement !== null && disableSshPasswordAuthenticationElement !== undefined && disableSshPasswordAuthenticationElement.length !== 0) {
                          var disableSshPasswordAuthenticationInstance = disableSshPasswordAuthenticationElement === 'true';
                          configurationSetInstance.disableSshPasswordAuthentication = disableSshPasswordAuthenticationInstance;
                        }
                        
                        var sSHElement = js2xml.getElement(responseDoc, configurationSetsElement, 'SSH', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (sSHElement !== null && sSHElement !== undefined) {
                          var sSHInstance = { keyPairs: [], publicKeys: [] };
                          configurationSetInstance.sshSettings = sSHInstance;
                          
                          var publicKeysSequenceElement = js2xml.getElement(responseDoc, sSHElement, 'PUBLICKEYS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (publicKeysSequenceElement !== null && publicKeysSequenceElement !== undefined) {
                            for (var loweredIndex27 = 0; loweredIndex27 < js2xml.getElements(responseDoc, publicKeysSequenceElement, 'PUBLICKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex27 = loweredIndex27 + 1) {
                              var publicKeysElement = js2xml.getElements(responseDoc, publicKeysSequenceElement, 'PUBLICKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex27];
                              var publicKeyInstance = {};
                              sSHInstance.publicKeys.push(publicKeyInstance);
                              
                              var fingerprintElement = js2xml.getElement(responseDoc, publicKeysElement, 'FINGERPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (fingerprintElement !== null && fingerprintElement !== undefined) {
                                var fingerprintInstance = fingerprintElement;
                                publicKeyInstance.fingerprint = fingerprintInstance;
                              }
                              
                              var pathElement2 = js2xml.getElement(responseDoc, publicKeysElement, 'PATH', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (pathElement2 !== null && pathElement2 !== undefined) {
                                var pathInstance2 = pathElement2;
                                publicKeyInstance.path = pathInstance2;
                              }
                            }
                          }
                          
                          var keyPairsSequenceElement = js2xml.getElement(responseDoc, sSHElement, 'KEYPAIRS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (keyPairsSequenceElement !== null && keyPairsSequenceElement !== undefined) {
                            for (var loweredIndex28 = 0; loweredIndex28 < js2xml.getElements(responseDoc, keyPairsSequenceElement, 'KEYPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex28 = loweredIndex28 + 1) {
                              var keyPairsElement = js2xml.getElements(responseDoc, keyPairsSequenceElement, 'KEYPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex28];
                              var keyPairInstance = {};
                              sSHInstance.keyPairs.push(keyPairInstance);
                              
                              var fingerprintElement2 = js2xml.getElement(responseDoc, keyPairsElement, 'FINGERPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (fingerprintElement2 !== null && fingerprintElement2 !== undefined) {
                                var fingerprintInstance2 = fingerprintElement2;
                                keyPairInstance.fingerprint = fingerprintInstance2;
                              }
                              
                              var pathElement3 = js2xml.getElement(responseDoc, keyPairsElement, 'PATH', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (pathElement3 !== null && pathElement3 !== undefined) {
                                var pathInstance3 = pathElement3;
                                keyPairInstance.path = pathInstance3;
                              }
                            }
                          }
                        }
                        
                        var customDataElement = js2xml.getElement(responseDoc, configurationSetsElement, 'CUSTOMDATA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (customDataElement !== null && customDataElement !== undefined) {
                          var customDataInstance = customDataElement;
                          configurationSetInstance.customData = customDataInstance;
                        }
                      }
                    }
                    
                    var resourceExtensionReferencesSequenceElement = js2xml.getElement(responseDoc, roleListElement, 'RESOURCEEXTENSIONREFERENCES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (resourceExtensionReferencesSequenceElement !== null && resourceExtensionReferencesSequenceElement !== undefined) {
                      for (var loweredIndex29 = 0; loweredIndex29 < js2xml.getElements(responseDoc, resourceExtensionReferencesSequenceElement, 'RESOURCEEXTENSIONREFERENCE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex29 = loweredIndex29 + 1) {
                        var resourceExtensionReferencesElement = js2xml.getElements(responseDoc, resourceExtensionReferencesSequenceElement, 'RESOURCEEXTENSIONREFERENCE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex29];
                        var resourceExtensionReferenceInstance = { resourceExtensionParameterValues: [] };
                        roleInstance.resourceExtensionReferences.push(resourceExtensionReferenceInstance);
                        
                        var referenceNameElement = js2xml.getElement(responseDoc, resourceExtensionReferencesElement, 'REFERENCENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (referenceNameElement !== null && referenceNameElement !== undefined) {
                          var referenceNameInstance = referenceNameElement;
                          resourceExtensionReferenceInstance.referenceName = referenceNameInstance;
                        }
                        
                        var publisherElement = js2xml.getElement(responseDoc, resourceExtensionReferencesElement, 'PUBLISHER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (publisherElement !== null && publisherElement !== undefined) {
                          var publisherInstance = publisherElement;
                          resourceExtensionReferenceInstance.publisher = publisherInstance;
                        }
                        
                        var nameElement10 = js2xml.getElement(responseDoc, resourceExtensionReferencesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (nameElement10 !== null && nameElement10 !== undefined) {
                          var nameInstance10 = nameElement10;
                          resourceExtensionReferenceInstance.name = nameInstance10;
                        }
                        
                        var versionElement2 = js2xml.getElement(responseDoc, resourceExtensionReferencesElement, 'VERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (versionElement2 !== null && versionElement2 !== undefined) {
                          var versionInstance2 = versionElement2;
                          resourceExtensionReferenceInstance.version = versionInstance2;
                        }
                        
                        var resourceExtensionParameterValuesSequenceElement = js2xml.getElement(responseDoc, resourceExtensionReferencesElement, 'RESOURCEEXTENSIONPARAMETERVALUES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (resourceExtensionParameterValuesSequenceElement !== null && resourceExtensionParameterValuesSequenceElement !== undefined) {
                          for (var loweredIndex30 = 0; loweredIndex30 < js2xml.getElements(responseDoc, resourceExtensionParameterValuesSequenceElement, 'RESOURCEEXTENSIONPARAMETERVALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex30 = loweredIndex30 + 1) {
                            var resourceExtensionParameterValuesElement = js2xml.getElements(responseDoc, resourceExtensionParameterValuesSequenceElement, 'RESOURCEEXTENSIONPARAMETERVALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex30];
                            var resourceExtensionParameterValueInstance = {};
                            resourceExtensionReferenceInstance.resourceExtensionParameterValues.push(resourceExtensionParameterValueInstance);
                            
                            var keyElement = js2xml.getElement(responseDoc, resourceExtensionParameterValuesElement, 'KEY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (keyElement !== null && keyElement !== undefined) {
                              var keyInstance = keyElement;
                              resourceExtensionParameterValueInstance.key = keyInstance;
                            }
                            
                            var valueElement = js2xml.getElement(responseDoc, resourceExtensionParameterValuesElement, 'VALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (valueElement !== null && valueElement !== undefined) {
                              var valueInstance = new Buffer(valueElement, 'base64').toString('utf8');
                              resourceExtensionParameterValueInstance.value = valueInstance;
                            }
                            
                            var typeElement = js2xml.getElement(responseDoc, resourceExtensionParameterValuesElement, 'TYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                            if (typeElement !== null && typeElement !== undefined) {
                              var typeInstance = typeElement;
                              resourceExtensionParameterValueInstance.type = typeInstance;
                            }
                          }
                        }
                        
                        var stateElement = js2xml.getElement(responseDoc, resourceExtensionReferencesElement, 'STATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (stateElement !== null && stateElement !== undefined) {
                          var stateInstance = stateElement;
                          resourceExtensionReferenceInstance.state = stateInstance;
                        }
                        
                        var forceUpdateElement = js2xml.getElement(responseDoc, resourceExtensionReferencesElement, 'FORCEUPDATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (forceUpdateElement !== null && forceUpdateElement !== undefined && forceUpdateElement.length !== 0) {
                          var forceUpdateInstance = forceUpdateElement === 'true';
                          resourceExtensionReferenceInstance.forceUpdate = forceUpdateInstance;
                        }
                      }
                    }
                    
                    var vMImageNameElement = js2xml.getElement(responseDoc, roleListElement, 'VMIMAGENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (vMImageNameElement !== null && vMImageNameElement !== undefined) {
                      var vMImageNameInstance = vMImageNameElement;
                      roleInstance.vMImageName = vMImageNameInstance;
                    }
                    
                    var mediaLocationElement = js2xml.getElement(responseDoc, roleListElement, 'MEDIALOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (mediaLocationElement !== null && mediaLocationElement !== undefined) {
                      var mediaLocationInstance = mediaLocationElement;
                      roleInstance.mediaLocation = mediaLocationInstance;
                    }
                    
                    var availabilitySetNameElement = js2xml.getElement(responseDoc, roleListElement, 'AVAILABILITYSETNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (availabilitySetNameElement !== null && availabilitySetNameElement !== undefined) {
                      var availabilitySetNameInstance = availabilitySetNameElement;
                      roleInstance.availabilitySetName = availabilitySetNameInstance;
                    }
                    
                    var dataVirtualHardDisksSequenceElement = js2xml.getElement(responseDoc, roleListElement, 'DATAVIRTUALHARDDISKS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (dataVirtualHardDisksSequenceElement !== null && dataVirtualHardDisksSequenceElement !== undefined) {
                      for (var loweredIndex31 = 0; loweredIndex31 < js2xml.getElements(responseDoc, dataVirtualHardDisksSequenceElement, 'DATAVIRTUALHARDDISK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex31 = loweredIndex31 + 1) {
                        var dataVirtualHardDisksElement = js2xml.getElements(responseDoc, dataVirtualHardDisksSequenceElement, 'DATAVIRTUALHARDDISK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex31];
                        var dataVirtualHardDiskInstance = {};
                        roleInstance.dataVirtualHardDisks.push(dataVirtualHardDiskInstance);
                        
                        var hostCachingElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'HOSTCACHING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (hostCachingElement !== null && hostCachingElement !== undefined) {
                          var hostCachingInstance = hostCachingElement;
                          dataVirtualHardDiskInstance.hostCaching = hostCachingInstance;
                        }
                        
                        var diskLabelElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'DISKLABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (diskLabelElement !== null && diskLabelElement !== undefined) {
                          var diskLabelInstance = diskLabelElement;
                          dataVirtualHardDiskInstance.label = diskLabelInstance;
                        }
                        
                        var diskNameElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'DISKNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (diskNameElement !== null && diskNameElement !== undefined) {
                          var diskNameInstance = diskNameElement;
                          dataVirtualHardDiskInstance.name = diskNameInstance;
                        }
                        
                        var lunElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'LUN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (lunElement !== null && lunElement !== undefined && lunElement.length !== 0) {
                          var lunInstance = parseInt(lunElement, 10);
                          dataVirtualHardDiskInstance.logicalUnitNumber = lunInstance;
                        }
                        
                        var logicalDiskSizeInGBElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'LOGICALDISKSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (logicalDiskSizeInGBElement !== null && logicalDiskSizeInGBElement !== undefined && logicalDiskSizeInGBElement.length !== 0) {
                          var logicalDiskSizeInGBInstance = parseInt(logicalDiskSizeInGBElement, 10);
                          dataVirtualHardDiskInstance.logicalDiskSizeInGB = logicalDiskSizeInGBInstance;
                        }
                        
                        var mediaLinkElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'MEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (mediaLinkElement !== null && mediaLinkElement !== undefined) {
                          var mediaLinkInstance = mediaLinkElement;
                          dataVirtualHardDiskInstance.mediaLink = mediaLinkInstance;
                        }
                        
                        var sourceMediaLinkElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'SOURCEMEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (sourceMediaLinkElement !== null && sourceMediaLinkElement !== undefined) {
                          var sourceMediaLinkInstance = sourceMediaLinkElement;
                          dataVirtualHardDiskInstance.sourceMediaLink = sourceMediaLinkInstance;
                        }
                        
                        var iOTypeElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'IOTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (iOTypeElement !== null && iOTypeElement !== undefined) {
                          var iOTypeInstance = iOTypeElement;
                          dataVirtualHardDiskInstance.iOType = iOTypeInstance;
                        }
                      }
                    }
                    
                    var labelElement2 = js2xml.getElement(responseDoc, roleListElement, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (labelElement2 !== null && labelElement2 !== undefined) {
                      var labelInstance2 = labelElement2;
                      roleInstance.label = labelInstance2;
                    }
                    
                    var oSVirtualHardDiskElement = js2xml.getElement(responseDoc, roleListElement, 'OSVIRTUALHARDDISK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (oSVirtualHardDiskElement !== null && oSVirtualHardDiskElement !== undefined) {
                      var oSVirtualHardDiskInstance = {};
                      roleInstance.oSVirtualHardDisk = oSVirtualHardDiskInstance;
                      
                      var hostCachingElement2 = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'HOSTCACHING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (hostCachingElement2 !== null && hostCachingElement2 !== undefined) {
                        var hostCachingInstance2 = hostCachingElement2;
                        oSVirtualHardDiskInstance.hostCaching = hostCachingInstance2;
                      }
                      
                      var diskLabelElement2 = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'DISKLABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (diskLabelElement2 !== null && diskLabelElement2 !== undefined) {
                        var diskLabelInstance2 = diskLabelElement2;
                        oSVirtualHardDiskInstance.label = diskLabelInstance2;
                      }
                      
                      var diskNameElement2 = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'DISKNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (diskNameElement2 !== null && diskNameElement2 !== undefined) {
                        var diskNameInstance2 = diskNameElement2;
                        oSVirtualHardDiskInstance.name = diskNameInstance2;
                      }
                      
                      var mediaLinkElement2 = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'MEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (mediaLinkElement2 !== null && mediaLinkElement2 !== undefined) {
                        var mediaLinkInstance2 = mediaLinkElement2;
                        oSVirtualHardDiskInstance.mediaLink = mediaLinkInstance2;
                      }
                      
                      var sourceImageNameElement = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'SOURCEIMAGENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (sourceImageNameElement !== null && sourceImageNameElement !== undefined) {
                        var sourceImageNameInstance = sourceImageNameElement;
                        oSVirtualHardDiskInstance.sourceImageName = sourceImageNameInstance;
                      }
                      
                      var osElement = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'OS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (osElement !== null && osElement !== undefined) {
                        var osInstance = osElement;
                        oSVirtualHardDiskInstance.operatingSystem = osInstance;
                      }
                      
                      var remoteSourceImageLinkElement = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'REMOTESOURCEIMAGELINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (remoteSourceImageLinkElement !== null && remoteSourceImageLinkElement !== undefined) {
                        var remoteSourceImageLinkInstance = remoteSourceImageLinkElement;
                        oSVirtualHardDiskInstance.remoteSourceImageLink = remoteSourceImageLinkInstance;
                      }
                      
                      var iOTypeElement2 = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'IOTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (iOTypeElement2 !== null && iOTypeElement2 !== undefined) {
                        var iOTypeInstance2 = iOTypeElement2;
                        oSVirtualHardDiskInstance.iOType = iOTypeInstance2;
                      }
                      
                      var resizedSizeInGBElement = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'RESIZEDSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (resizedSizeInGBElement !== null && resizedSizeInGBElement !== undefined && resizedSizeInGBElement.length !== 0) {
                        var resizedSizeInGBInstance = parseInt(resizedSizeInGBElement, 10);
                        oSVirtualHardDiskInstance.resizedSizeInGB = resizedSizeInGBInstance;
                      }
                    }
                    
                    var roleSizeElement = js2xml.getElement(responseDoc, roleListElement, 'ROLESIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (roleSizeElement !== null && roleSizeElement !== undefined) {
                      var roleSizeInstance = roleSizeElement;
                      roleInstance.roleSize = roleSizeInstance;
                    }
                    
                    var defaultWinRmCertificateThumbprintElement = js2xml.getElement(responseDoc, roleListElement, 'DEFAULTWINRMCERTIFICATETHUMBPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (defaultWinRmCertificateThumbprintElement !== null && defaultWinRmCertificateThumbprintElement !== undefined) {
                      var defaultWinRmCertificateThumbprintInstance = defaultWinRmCertificateThumbprintElement;
                      roleInstance.defaultWinRmCertificateThumbprint = defaultWinRmCertificateThumbprintInstance;
                    }
                    
                    var provisionGuestAgentElement = js2xml.getElement(responseDoc, roleListElement, 'PROVISIONGUESTAGENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (provisionGuestAgentElement !== null && provisionGuestAgentElement !== undefined && provisionGuestAgentElement.length !== 0) {
                      var provisionGuestAgentInstance = provisionGuestAgentElement === 'true';
                      roleInstance.provisionGuestAgent = provisionGuestAgentInstance;
                    }
                    
                    var vMImageInputElement = js2xml.getElement(responseDoc, roleListElement, 'VMIMAGEINPUT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (vMImageInputElement !== null && vMImageInputElement !== undefined) {
                      var vMImageInputInstance = { dataDiskConfigurations: [] };
                      roleInstance.vMImageInput = vMImageInputInstance;
                      
                      var oSDiskConfigurationElement = js2xml.getElement(responseDoc, vMImageInputElement, 'OSDISKCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (oSDiskConfigurationElement !== null && oSDiskConfigurationElement !== undefined) {
                        var oSDiskConfigurationInstance = {};
                        vMImageInputInstance.oSDiskConfiguration = oSDiskConfigurationInstance;
                        
                        var resizedSizeInGBElement2 = js2xml.getElement(responseDoc, oSDiskConfigurationElement, 'RESIZEDSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (resizedSizeInGBElement2 !== null && resizedSizeInGBElement2 !== undefined && resizedSizeInGBElement2.length !== 0) {
                          var resizedSizeInGBInstance2 = parseInt(resizedSizeInGBElement2, 10);
                          oSDiskConfigurationInstance.resizedSizeInGB = resizedSizeInGBInstance2;
                        }
                      }
                      
                      var dataDiskConfigurationsSequenceElement = js2xml.getElement(responseDoc, vMImageInputElement, 'DATADISKCONFIGURATIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (dataDiskConfigurationsSequenceElement !== null && dataDiskConfigurationsSequenceElement !== undefined) {
                        for (var loweredIndex32 = 0; loweredIndex32 < js2xml.getElements(responseDoc, dataDiskConfigurationsSequenceElement, 'DATADISKCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex32 = loweredIndex32 + 1) {
                          var dataDiskConfigurationsElement = js2xml.getElements(responseDoc, dataDiskConfigurationsSequenceElement, 'DATADISKCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex32];
                          var dataDiskConfigurationInstance = {};
                          vMImageInputInstance.dataDiskConfigurations.push(dataDiskConfigurationInstance);
                          
                          var nameElement11 = js2xml.getElement(responseDoc, dataDiskConfigurationsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (nameElement11 !== null && nameElement11 !== undefined) {
                            var nameInstance11 = nameElement11;
                            dataDiskConfigurationInstance.diskName = nameInstance11;
                          }
                          
                          var resizedSizeInGBElement3 = js2xml.getElement(responseDoc, dataDiskConfigurationsElement, 'RESIZEDSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (resizedSizeInGBElement3 !== null && resizedSizeInGBElement3 !== undefined && resizedSizeInGBElement3.length !== 0) {
                            var resizedSizeInGBInstance3 = parseInt(resizedSizeInGBElement3, 10);
                            dataDiskConfigurationInstance.resizedSizeInGB = resizedSizeInGBInstance3;
                          }
                        }
                      }
                    }
                    
                    var debugSettingsElement = js2xml.getElement(responseDoc, roleListElement, 'DEBUGSETTINGS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (debugSettingsElement !== null && debugSettingsElement !== undefined) {
                      var debugSettingsInstance = {};
                      roleInstance.debugSettings = debugSettingsInstance;
                      
                      var bootDiagnosticsEnabledElement = js2xml.getElement(responseDoc, debugSettingsElement, 'BOOTDIAGNOSTICSENABLED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (bootDiagnosticsEnabledElement !== null && bootDiagnosticsEnabledElement !== undefined && bootDiagnosticsEnabledElement.length !== 0) {
                        var bootDiagnosticsEnabledInstance = bootDiagnosticsEnabledElement === 'true';
                        debugSettingsInstance.bootDiagnosticsEnabled = bootDiagnosticsEnabledInstance;
                      }
                      
                      var consoleScreenshotBlobUriElement = js2xml.getElement(responseDoc, debugSettingsElement, 'CONSOLESCREENSHOTBLOBURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (consoleScreenshotBlobUriElement !== null && consoleScreenshotBlobUriElement !== undefined) {
                        var consoleScreenshotBlobUriInstance = consoleScreenshotBlobUriElement;
                        debugSettingsInstance.consoleScreenshotBlobUri = consoleScreenshotBlobUriInstance;
                      }
                      
                      var serialOutputBlobUriElement = js2xml.getElement(responseDoc, debugSettingsElement, 'SERIALOUTPUTBLOBURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (serialOutputBlobUriElement !== null && serialOutputBlobUriElement !== undefined) {
                        var serialOutputBlobUriInstance = serialOutputBlobUriElement;
                        debugSettingsInstance.serialOutputBlobUri = serialOutputBlobUriInstance;
                      }
                    }
                    
                    var licenseTypeElement = js2xml.getElement(responseDoc, roleListElement, 'LICENSETYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (licenseTypeElement !== null && licenseTypeElement !== undefined) {
                      var licenseTypeInstance = licenseTypeElement;
                      roleInstance.licenseType = licenseTypeInstance;
                    }
                    
                    var migrationStateElement = js2xml.getElement(responseDoc, roleListElement, 'MIGRATIONSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (migrationStateElement !== null && migrationStateElement !== undefined) {
                      var migrationStateInstance = migrationStateElement;
                      roleInstance.migrationState = migrationStateInstance;
                    }
                  }
                }
                
                var sdkVersionElement = js2xml.getElement(responseDoc, deploymentsElement, 'SDKVERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (sdkVersionElement !== null && sdkVersionElement !== undefined) {
                  var sdkVersionInstance = sdkVersionElement;
                  deploymentInstance.sdkVersion = sdkVersionInstance;
                }
                
                var lockedElement = js2xml.getElement(responseDoc, deploymentsElement, 'LOCKED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (lockedElement !== null && lockedElement !== undefined && lockedElement.length !== 0) {
                  var lockedInstance = lockedElement === 'true';
                  deploymentInstance.locked = lockedInstance;
                }
                
                var rollbackAllowedElement = js2xml.getElement(responseDoc, deploymentsElement, 'ROLLBACKALLOWED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (rollbackAllowedElement !== null && rollbackAllowedElement !== undefined && rollbackAllowedElement.length !== 0) {
                  var rollbackAllowedInstance = rollbackAllowedElement === 'true';
                  deploymentInstance.rollbackAllowed = rollbackAllowedInstance;
                }
                
                var createdTimeElement = js2xml.getElement(responseDoc, deploymentsElement, 'CREATEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (createdTimeElement !== null && createdTimeElement !== undefined && createdTimeElement.length !== 0) {
                  var createdTimeInstance = new Date(createdTimeElement);
                  deploymentInstance.createdTime = createdTimeInstance;
                }
                
                var lastModifiedTimeElement = js2xml.getElement(responseDoc, deploymentsElement, 'LASTMODIFIEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (lastModifiedTimeElement !== null && lastModifiedTimeElement !== undefined) {
                  var lastModifiedTimeInstance = lastModifiedTimeElement;
                  deploymentInstance.lastModifiedTime = lastModifiedTimeInstance;
                }
                
                var virtualNetworkNameElement = js2xml.getElement(responseDoc, deploymentsElement, 'VIRTUALNETWORKNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (virtualNetworkNameElement !== null && virtualNetworkNameElement !== undefined) {
                  var virtualNetworkNameInstance = virtualNetworkNameElement;
                  deploymentInstance.virtualNetworkName = virtualNetworkNameInstance;
                }
                
                var extendedPropertiesSequenceElement = js2xml.getElement(responseDoc, deploymentsElement, 'EXTENDEDPROPERTIES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (extendedPropertiesSequenceElement !== null && extendedPropertiesSequenceElement !== undefined) {
                  for (var loweredIndex33 = 0; loweredIndex33 < js2xml.getElements(responseDoc, extendedPropertiesSequenceElement, 'EXTENDEDPROPERTY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex33 = loweredIndex33 + 1) {
                    var extendedPropertiesElement = js2xml.getElements(responseDoc, extendedPropertiesSequenceElement, 'EXTENDEDPROPERTY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex33];
                    var extendedPropertiesKey = js2xml.getElement(responseDoc, extendedPropertiesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    var extendedPropertiesValue = js2xml.getElement(responseDoc, extendedPropertiesElement, 'VALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    deploymentInstance.extendedProperties[extendedPropertiesKey] = extendedPropertiesValue;
                  }
                }
                
                var persistentVMDowntimeElement = js2xml.getElement(responseDoc, deploymentsElement, 'PERSISTENTVMDOWNTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (persistentVMDowntimeElement !== null && persistentVMDowntimeElement !== undefined) {
                  var persistentVMDowntimeInstance = {};
                  deploymentInstance.persistentVMDowntime = persistentVMDowntimeInstance;
                  
                  var startTimeElement = js2xml.getElement(responseDoc, persistentVMDowntimeElement, 'STARTTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (startTimeElement !== null && startTimeElement !== undefined && startTimeElement.length !== 0) {
                    var startTimeInstance = new Date(startTimeElement);
                    persistentVMDowntimeInstance.startTime = startTimeInstance;
                  }
                  
                  var endTimeElement = js2xml.getElement(responseDoc, persistentVMDowntimeElement, 'ENDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (endTimeElement !== null && endTimeElement !== undefined && endTimeElement.length !== 0) {
                    var endTimeInstance = new Date(endTimeElement);
                    persistentVMDowntimeInstance.endTime = endTimeInstance;
                  }
                  
                  var statusElement6 = js2xml.getElement(responseDoc, persistentVMDowntimeElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (statusElement6 !== null && statusElement6 !== undefined) {
                    var statusInstance6 = statusElement6;
                    persistentVMDowntimeInstance.status = statusInstance6;
                  }
                }
                
                var virtualIPsSequenceElement = js2xml.getElement(responseDoc, deploymentsElement, 'VIRTUALIPS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (virtualIPsSequenceElement !== null && virtualIPsSequenceElement !== undefined) {
                  for (var loweredIndex34 = 0; loweredIndex34 < js2xml.getElements(responseDoc, virtualIPsSequenceElement, 'VIRTUALIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex34 = loweredIndex34 + 1) {
                    var virtualIPsElement = js2xml.getElements(responseDoc, virtualIPsSequenceElement, 'VIRTUALIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex34];
                    var virtualIPInstance = {};
                    deploymentInstance.virtualIPAddresses.push(virtualIPInstance);
                    
                    var addressElement3 = js2xml.getElement(responseDoc, virtualIPsElement, 'ADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (addressElement3 !== null && addressElement3 !== undefined) {
                      var addressInstance3 = addressElement3;
                      virtualIPInstance.address = addressInstance3;
                    }
                    
                    var isDnsProgrammedElement = js2xml.getElement(responseDoc, virtualIPsElement, 'ISDNSPROGRAMMED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (isDnsProgrammedElement !== null && isDnsProgrammedElement !== undefined && isDnsProgrammedElement.length !== 0) {
                      var isDnsProgrammedInstance = isDnsProgrammedElement === 'true';
                      virtualIPInstance.isDnsProgrammed = isDnsProgrammedInstance;
                    }
                    
                    var nameElement12 = js2xml.getElement(responseDoc, virtualIPsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (nameElement12 !== null && nameElement12 !== undefined) {
                      var nameInstance12 = nameElement12;
                      virtualIPInstance.name = nameInstance12;
                    }
                    
                    var reservedIPNameElement = js2xml.getElement(responseDoc, virtualIPsElement, 'RESERVEDIPNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (reservedIPNameElement !== null && reservedIPNameElement !== undefined) {
                      var reservedIPNameInstance = reservedIPNameElement;
                      virtualIPInstance.reservedIPName = reservedIPNameInstance;
                    }
                  }
                }
                
                var dnsElement = js2xml.getElement(responseDoc, deploymentsElement, 'DNS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (dnsElement !== null && dnsElement !== undefined) {
                  var dnsInstance = { dnsServers: [] };
                  deploymentInstance.dnsSettings = dnsInstance;
                  
                  var dnsServersSequenceElement = js2xml.getElement(responseDoc, dnsElement, 'DNSSERVERS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (dnsServersSequenceElement !== null && dnsServersSequenceElement !== undefined) {
                    for (var loweredIndex35 = 0; loweredIndex35 < js2xml.getElements(responseDoc, dnsServersSequenceElement, 'DNSSERVER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex35 = loweredIndex35 + 1) {
                      var dnsServersElement = js2xml.getElements(responseDoc, dnsServersSequenceElement, 'DNSSERVER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex35];
                      var dnsServerInstance = {};
                      dnsInstance.dnsServers.push(dnsServerInstance);
                      
                      var nameElement13 = js2xml.getElement(responseDoc, dnsServersElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (nameElement13 !== null && nameElement13 !== undefined) {
                        var nameInstance13 = nameElement13;
                        dnsServerInstance.name = nameInstance13;
                      }
                      
                      var addressElement4 = js2xml.getElement(responseDoc, dnsServersElement, 'ADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (addressElement4 !== null && addressElement4 !== undefined) {
                        var addressInstance4 = addressElement4;
                        dnsServerInstance.address = addressInstance4;
                      }
                    }
                  }
                }
              }
            }
            
            var urlElement2 = js2xml.getElement(responseDoc, hostedServiceElement, 'URL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (urlElement2 !== null && urlElement2 !== undefined) {
              var urlInstance2 = urlElement2;
              result.uri = urlInstance2;
            }
            
            var serviceNameElement = js2xml.getElement(responseDoc, hostedServiceElement, 'SERVICENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (serviceNameElement !== null && serviceNameElement !== undefined) {
              var serviceNameInstance = serviceNameElement;
              result.serviceName = serviceNameInstance;
            }
            
            var hostedServicePropertiesElement = js2xml.getElement(responseDoc, hostedServiceElement, 'HOSTEDSERVICEPROPERTIES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (hostedServicePropertiesElement !== null && hostedServicePropertiesElement !== undefined) {
              var hostedServicePropertiesInstance = { extendedProperties: {} };
              result.properties = hostedServicePropertiesInstance;
              
              var descriptionElement2 = js2xml.getElement(responseDoc, hostedServicePropertiesElement, 'DESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (descriptionElement2 !== null && descriptionElement2 !== undefined) {
                var descriptionInstance2 = descriptionElement2;
                hostedServicePropertiesInstance.description = descriptionInstance2;
              }
              
              var affinityGroupElement = js2xml.getElement(responseDoc, hostedServicePropertiesElement, 'AFFINITYGROUP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (affinityGroupElement !== null && affinityGroupElement !== undefined) {
                var affinityGroupInstance = affinityGroupElement;
                hostedServicePropertiesInstance.affinityGroup = affinityGroupInstance;
              }
              
              var locationElement = js2xml.getElement(responseDoc, hostedServicePropertiesElement, 'LOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (locationElement !== null && locationElement !== undefined) {
                var locationInstance = locationElement;
                hostedServicePropertiesInstance.location = locationInstance;
              }
              
              var labelElement3 = js2xml.getElement(responseDoc, hostedServicePropertiesElement, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (labelElement3 !== null && labelElement3 !== undefined) {
                var labelInstance3 = new Buffer(labelElement3, 'base64').toString('utf8');
                hostedServicePropertiesInstance.label = labelInstance3;
              }
              
              var statusElement7 = js2xml.getElement(responseDoc, hostedServicePropertiesElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (statusElement7 !== null && statusElement7 !== undefined && statusElement7.length !== 0) {
                var statusInstance7 = statusElement7;
                hostedServicePropertiesInstance.status = statusInstance7;
              }
              
              var dateCreatedElement = js2xml.getElement(responseDoc, hostedServicePropertiesElement, 'DATECREATED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (dateCreatedElement !== null && dateCreatedElement !== undefined && dateCreatedElement.length !== 0) {
                var dateCreatedInstance = new Date(dateCreatedElement);
                hostedServicePropertiesInstance.dateCreated = dateCreatedInstance;
              }
              
              var dateLastModifiedElement = js2xml.getElement(responseDoc, hostedServicePropertiesElement, 'DATELASTMODIFIED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (dateLastModifiedElement !== null && dateLastModifiedElement !== undefined && dateLastModifiedElement.length !== 0) {
                var dateLastModifiedInstance = new Date(dateLastModifiedElement);
                hostedServicePropertiesInstance.dateLastModified = dateLastModifiedInstance;
              }
              
              var extendedPropertiesSequenceElement2 = js2xml.getElement(responseDoc, hostedServicePropertiesElement, 'EXTENDEDPROPERTIES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (extendedPropertiesSequenceElement2 !== null && extendedPropertiesSequenceElement2 !== undefined) {
                for (var loweredIndex36 = 0; loweredIndex36 < js2xml.getElements(responseDoc, extendedPropertiesSequenceElement2, 'EXTENDEDPROPERTY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex36 = loweredIndex36 + 1) {
                  var extendedPropertiesElement2 = js2xml.getElements(responseDoc, extendedPropertiesSequenceElement2, 'EXTENDEDPROPERTY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex36];
                  var extendedPropertiesKey2 = js2xml.getElement(responseDoc, extendedPropertiesElement2, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  var extendedPropertiesValue2 = js2xml.getElement(responseDoc, extendedPropertiesElement2, 'VALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  hostedServicePropertiesInstance.extendedProperties[extendedPropertiesKey2] = extendedPropertiesValue2;
                }
              }
              
              var reverseDnsFqdnElement = js2xml.getElement(responseDoc, hostedServicePropertiesElement, 'REVERSEDNSFQDN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (reverseDnsFqdnElement !== null && reverseDnsFqdnElement !== undefined) {
                var reverseDnsFqdnInstance = reverseDnsFqdnElement;
                hostedServicePropertiesInstance.reverseDnsFqdn = reverseDnsFqdnInstance;
              }
            }
            
            var computeCapabilitiesElement = js2xml.getElement(responseDoc, hostedServiceElement, 'COMPUTECAPABILITIES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (computeCapabilitiesElement !== null && computeCapabilitiesElement !== undefined) {
              var computeCapabilitiesInstance = { virtualMachinesRoleSizes: [], webWorkerRoleSizes: [] };
              result.computeCapabilities = computeCapabilitiesInstance;
              
              var virtualMachinesRoleSizesSequenceElement = js2xml.getElement(responseDoc, computeCapabilitiesElement, 'VIRTUALMACHINESROLESIZES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (virtualMachinesRoleSizesSequenceElement !== null && virtualMachinesRoleSizesSequenceElement !== undefined) {
                for (var loweredIndex37 = 0; loweredIndex37 < js2xml.getElements(responseDoc, virtualMachinesRoleSizesSequenceElement, 'ROLESIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex37 = loweredIndex37 + 1) {
                  var virtualMachinesRoleSizesElement = js2xml.getElements(responseDoc, virtualMachinesRoleSizesSequenceElement, 'ROLESIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex37];
                  computeCapabilitiesInstance.virtualMachinesRoleSizes.push(virtualMachinesRoleSizesElement);
                }
              }
              
              var webWorkerRoleSizesSequenceElement = js2xml.getElement(responseDoc, computeCapabilitiesElement, 'WEBWORKERROLESIZES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (webWorkerRoleSizesSequenceElement !== null && webWorkerRoleSizesSequenceElement !== undefined) {
                for (var loweredIndex38 = 0; loweredIndex38 < js2xml.getElements(responseDoc, webWorkerRoleSizesSequenceElement, 'ROLESIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex38 = loweredIndex38 + 1) {
                  var webWorkerRoleSizesElement = js2xml.getElements(responseDoc, webWorkerRoleSizesSequenceElement, 'ROLESIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex38];
                  computeCapabilitiesInstance.webWorkerRoleSizes.push(webWorkerRoleSizesElement);
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Get Extension operation retrieves information about a specified
   * extension that was added to a cloud service.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn169557.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {string} extensionId The identifier that was assigned to the
   * extension when it was added to the cloud service
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  HostedServiceOperations.prototype.getExtension = function(serviceName, extensionId, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    // TODO: Validate serviceName is a valid DNS name.
    if (extensionId === null || extensionId === undefined) {
      return callback(new Error('extensionId cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/extensions/';
    url2 = url2 + encodeURIComponent(extensionId);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var extensionElement = js2xml.getElement(responseDoc, responseDoc, 'EXTENSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (extensionElement !== null && extensionElement !== undefined) {
            var providerNameSpaceElement = js2xml.getElement(responseDoc, extensionElement, 'PROVIDERNAMESPACE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (providerNameSpaceElement !== null && providerNameSpaceElement !== undefined) {
              var providerNameSpaceInstance = providerNameSpaceElement;
              result.providerNamespace = providerNameSpaceInstance;
            }
            
            var typeElement = js2xml.getElement(responseDoc, extensionElement, 'TYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (typeElement !== null && typeElement !== undefined) {
              var typeInstance = typeElement;
              result.type = typeInstance;
            }
            
            var idElement = js2xml.getElement(responseDoc, extensionElement, 'ID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (idElement !== null && idElement !== undefined) {
              var idInstance = idElement;
              result.id = idInstance;
            }
            
            var versionElement = js2xml.getElement(responseDoc, extensionElement, 'VERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (versionElement !== null && versionElement !== undefined) {
              var versionInstance = versionElement;
              result.version = versionInstance;
            }
            
            var thumbprintElement = js2xml.getElement(responseDoc, extensionElement, 'THUMBPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (thumbprintElement !== null && thumbprintElement !== undefined) {
              var thumbprintInstance = thumbprintElement;
              result.thumbprint = thumbprintInstance;
            }
            
            var thumbprintAlgorithmElement = js2xml.getElement(responseDoc, extensionElement, 'THUMBPRINTALGORITHM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (thumbprintAlgorithmElement !== null && thumbprintAlgorithmElement !== undefined) {
              var thumbprintAlgorithmInstance = thumbprintAlgorithmElement;
              result.thumbprintAlgorithm = thumbprintAlgorithmInstance;
            }
            
            var publicConfigurationElement = js2xml.getElement(responseDoc, extensionElement, 'PUBLICCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (publicConfigurationElement !== null && publicConfigurationElement !== undefined) {
              var publicConfigurationInstance = new Buffer(publicConfigurationElement, 'base64').toString('utf8');
              result.publicConfiguration = publicConfigurationInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The List Hosted Services operation lists the cloud services available
   * under the current subscription.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460781.aspx for
   * more information)
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  HostedServiceOperations.prototype.list = function(callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { hostedServices: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var hostedServicesSequenceElement = js2xml.getElement(responseDoc, responseDoc, 'HOSTEDSERVICES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (hostedServicesSequenceElement !== null && hostedServicesSequenceElement !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, hostedServicesSequenceElement, 'HOSTEDSERVICE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
              var hostedServicesElement = js2xml.getElements(responseDoc, hostedServicesSequenceElement, 'HOSTEDSERVICE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
              var hostedServiceInstance = {};
              result.hostedServices.push(hostedServiceInstance);
              
              var urlElement = js2xml.getElement(responseDoc, hostedServicesElement, 'URL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (urlElement !== null && urlElement !== undefined) {
                var urlInstance = urlElement;
                hostedServiceInstance.uri = urlInstance;
              }
              
              var serviceNameElement = js2xml.getElement(responseDoc, hostedServicesElement, 'SERVICENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (serviceNameElement !== null && serviceNameElement !== undefined) {
                var serviceNameInstance = serviceNameElement;
                hostedServiceInstance.serviceName = serviceNameInstance;
              }
              
              var hostedServicePropertiesElement = js2xml.getElement(responseDoc, hostedServicesElement, 'HOSTEDSERVICEPROPERTIES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (hostedServicePropertiesElement !== null && hostedServicePropertiesElement !== undefined) {
                var hostedServicePropertiesInstance = { extendedProperties: {} };
                hostedServiceInstance.properties = hostedServicePropertiesInstance;
                
                var descriptionElement = js2xml.getElement(responseDoc, hostedServicePropertiesElement, 'DESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (descriptionElement !== null && descriptionElement !== undefined) {
                  var descriptionInstance = descriptionElement;
                  hostedServicePropertiesInstance.description = descriptionInstance;
                }
                
                var affinityGroupElement = js2xml.getElement(responseDoc, hostedServicePropertiesElement, 'AFFINITYGROUP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (affinityGroupElement !== null && affinityGroupElement !== undefined) {
                  var affinityGroupInstance = affinityGroupElement;
                  hostedServicePropertiesInstance.affinityGroup = affinityGroupInstance;
                }
                
                var locationElement = js2xml.getElement(responseDoc, hostedServicePropertiesElement, 'LOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (locationElement !== null && locationElement !== undefined) {
                  var locationInstance = locationElement;
                  hostedServicePropertiesInstance.location = locationInstance;
                }
                
                var labelElement = js2xml.getElement(responseDoc, hostedServicePropertiesElement, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (labelElement !== null && labelElement !== undefined) {
                  var labelInstance = new Buffer(labelElement, 'base64').toString('utf8');
                  hostedServicePropertiesInstance.label = labelInstance;
                }
                
                var statusElement = js2xml.getElement(responseDoc, hostedServicePropertiesElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (statusElement !== null && statusElement !== undefined && statusElement.length !== 0) {
                  var statusInstance = statusElement;
                  hostedServicePropertiesInstance.status = statusInstance;
                }
                
                var dateCreatedElement = js2xml.getElement(responseDoc, hostedServicePropertiesElement, 'DATECREATED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (dateCreatedElement !== null && dateCreatedElement !== undefined && dateCreatedElement.length !== 0) {
                  var dateCreatedInstance = new Date(dateCreatedElement);
                  hostedServicePropertiesInstance.dateCreated = dateCreatedInstance;
                }
                
                var dateLastModifiedElement = js2xml.getElement(responseDoc, hostedServicePropertiesElement, 'DATELASTMODIFIED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (dateLastModifiedElement !== null && dateLastModifiedElement !== undefined && dateLastModifiedElement.length !== 0) {
                  var dateLastModifiedInstance = new Date(dateLastModifiedElement);
                  hostedServicePropertiesInstance.dateLastModified = dateLastModifiedInstance;
                }
                
                var extendedPropertiesSequenceElement = js2xml.getElement(responseDoc, hostedServicePropertiesElement, 'EXTENDEDPROPERTIES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (extendedPropertiesSequenceElement !== null && extendedPropertiesSequenceElement !== undefined) {
                  for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, extendedPropertiesSequenceElement, 'EXTENDEDPROPERTY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex2 = loweredIndex2 + 1) {
                    var extendedPropertiesElement = js2xml.getElements(responseDoc, extendedPropertiesSequenceElement, 'EXTENDEDPROPERTY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex2];
                    var extendedPropertiesKey = js2xml.getElement(responseDoc, extendedPropertiesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    var extendedPropertiesValue = js2xml.getElement(responseDoc, extendedPropertiesElement, 'VALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    hostedServicePropertiesInstance.extendedProperties[extendedPropertiesKey] = extendedPropertiesValue;
                  }
                }
                
                var reverseDnsFqdnElement = js2xml.getElement(responseDoc, hostedServicePropertiesElement, 'REVERSEDNSFQDN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (reverseDnsFqdnElement !== null && reverseDnsFqdnElement !== undefined) {
                  var reverseDnsFqdnInstance = reverseDnsFqdnElement;
                  hostedServicePropertiesInstance.reverseDnsFqdn = reverseDnsFqdnInstance;
                }
              }
              
              var computeCapabilitiesElement = js2xml.getElement(responseDoc, hostedServicesElement, 'COMPUTECAPABILITIES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (computeCapabilitiesElement !== null && computeCapabilitiesElement !== undefined) {
                var computeCapabilitiesInstance = { virtualMachinesRoleSizes: [], webWorkerRoleSizes: [] };
                hostedServiceInstance.computeCapabilities = computeCapabilitiesInstance;
                
                var virtualMachinesRoleSizesSequenceElement = js2xml.getElement(responseDoc, computeCapabilitiesElement, 'VIRTUALMACHINESROLESIZES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (virtualMachinesRoleSizesSequenceElement !== null && virtualMachinesRoleSizesSequenceElement !== undefined) {
                  for (var loweredIndex3 = 0; loweredIndex3 < js2xml.getElements(responseDoc, virtualMachinesRoleSizesSequenceElement, 'ROLESIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex3 = loweredIndex3 + 1) {
                    var virtualMachinesRoleSizesElement = js2xml.getElements(responseDoc, virtualMachinesRoleSizesSequenceElement, 'ROLESIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex3];
                    computeCapabilitiesInstance.virtualMachinesRoleSizes.push(virtualMachinesRoleSizesElement);
                  }
                }
                
                var webWorkerRoleSizesSequenceElement = js2xml.getElement(responseDoc, computeCapabilitiesElement, 'WEBWORKERROLESIZES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (webWorkerRoleSizesSequenceElement !== null && webWorkerRoleSizesSequenceElement !== undefined) {
                  for (var loweredIndex4 = 0; loweredIndex4 < js2xml.getElements(responseDoc, webWorkerRoleSizesSequenceElement, 'ROLESIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex4 = loweredIndex4 + 1) {
                    var webWorkerRoleSizesElement = js2xml.getElements(responseDoc, webWorkerRoleSizesSequenceElement, 'ROLESIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex4];
                    computeCapabilitiesInstance.webWorkerRoleSizes.push(webWorkerRoleSizesElement);
                  }
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The List Available Extensions operation lists the extensions that are
   * available to add to your cloud service. In Windows Azure, a process can
   * run as an extension of a cloud service. For example, Remote Desktop
   * Access or the Azure Diagnostics Agent can run as extensions to the cloud
   * service.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn169559.aspx for
   * more information)
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  HostedServiceOperations.prototype.listAvailableExtensions = function(callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/extensions';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { extensionImages: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var extensionImagesSequenceElement = js2xml.getElement(responseDoc, responseDoc, 'EXTENSIONIMAGES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (extensionImagesSequenceElement !== null && extensionImagesSequenceElement !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, extensionImagesSequenceElement, 'EXTENSIONIMAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
              var extensionImagesElement = js2xml.getElements(responseDoc, extensionImagesSequenceElement, 'EXTENSIONIMAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
              var extensionImageInstance = { localResources: [] };
              result.extensionImages.push(extensionImageInstance);
              
              var providerNameSpaceElement = js2xml.getElement(responseDoc, extensionImagesElement, 'PROVIDERNAMESPACE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (providerNameSpaceElement !== null && providerNameSpaceElement !== undefined) {
                var providerNameSpaceInstance = providerNameSpaceElement;
                extensionImageInstance.providerNameSpace = providerNameSpaceInstance;
              }
              
              var typeElement = js2xml.getElement(responseDoc, extensionImagesElement, 'TYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (typeElement !== null && typeElement !== undefined) {
                var typeInstance = typeElement;
                extensionImageInstance.type = typeInstance;
              }
              
              var versionElement = js2xml.getElement(responseDoc, extensionImagesElement, 'VERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (versionElement !== null && versionElement !== undefined) {
                var versionInstance = versionElement;
                extensionImageInstance.version = versionInstance;
              }
              
              var labelElement = js2xml.getElement(responseDoc, extensionImagesElement, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (labelElement !== null && labelElement !== undefined) {
                var labelInstance = labelElement;
                extensionImageInstance.label = labelInstance;
              }
              
              var hostingResourcesElement = js2xml.getElement(responseDoc, extensionImagesElement, 'HOSTINGRESOURCES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (hostingResourcesElement !== null && hostingResourcesElement !== undefined) {
                var hostingResourcesInstance = hostingResourcesElement;
                extensionImageInstance.hostingResources = hostingResourcesInstance;
              }
              
              var mediaLinkElement = js2xml.getElement(responseDoc, extensionImagesElement, 'MEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (mediaLinkElement !== null && mediaLinkElement !== undefined) {
                var mediaLinkInstance = mediaLinkElement;
                extensionImageInstance.mediaLink = mediaLinkInstance;
              }
              
              var certificateElement = js2xml.getElement(responseDoc, extensionImagesElement, 'CERTIFICATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (certificateElement !== null && certificateElement !== undefined) {
                var certificateInstance = {};
                extensionImageInstance.certificate = certificateInstance;
                
                var storeLocationElement = js2xml.getElement(responseDoc, certificateElement, 'STORELOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (storeLocationElement !== null && storeLocationElement !== undefined) {
                  var storeLocationInstance = storeLocationElement;
                  certificateInstance.storeLocation = storeLocationInstance;
                }
                
                var storeNameElement = js2xml.getElement(responseDoc, certificateElement, 'STORENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (storeNameElement !== null && storeNameElement !== undefined) {
                  var storeNameInstance = storeNameElement;
                  certificateInstance.storeName = storeNameInstance;
                }
                
                var thumbprintRequiredElement = js2xml.getElement(responseDoc, certificateElement, 'THUMBPRINTREQUIRED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (thumbprintRequiredElement !== null && thumbprintRequiredElement !== undefined && thumbprintRequiredElement.length !== 0) {
                  var thumbprintRequiredInstance = thumbprintRequiredElement === 'true';
                  certificateInstance.thumbprintRequired = thumbprintRequiredInstance;
                }
                
                var thumbprintAlgorithmElement = js2xml.getElement(responseDoc, certificateElement, 'THUMBPRINTALGORITHM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (thumbprintAlgorithmElement !== null && thumbprintAlgorithmElement !== undefined) {
                  var thumbprintAlgorithmInstance = thumbprintAlgorithmElement;
                  certificateInstance.thumbprintAlgorithm = thumbprintAlgorithmInstance;
                }
              }
              
              var endpointsElement = js2xml.getElement(responseDoc, extensionImagesElement, 'ENDPOINTS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (endpointsElement !== null && endpointsElement !== undefined) {
                var endpointsInstance = { inputEndpoints: [], instanceInputEndpoints: [], internalEndpoints: [] };
                extensionImageInstance.extensionEndpoints = endpointsInstance;
                
                var inputEndpointsSequenceElement = js2xml.getElement(responseDoc, endpointsElement, 'INPUTENDPOINTS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (inputEndpointsSequenceElement !== null && inputEndpointsSequenceElement !== undefined) {
                  for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, inputEndpointsSequenceElement, 'INPUTENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex2 = loweredIndex2 + 1) {
                    var inputEndpointsElement = js2xml.getElements(responseDoc, inputEndpointsSequenceElement, 'INPUTENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex2];
                    var inputEndpointInstance = {};
                    endpointsInstance.inputEndpoints.push(inputEndpointInstance);
                    
                    var nameElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (nameElement !== null && nameElement !== undefined) {
                      var nameInstance = nameElement;
                      inputEndpointInstance.name = nameInstance;
                    }
                    
                    var protocolElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'PROTOCOL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (protocolElement !== null && protocolElement !== undefined) {
                      var protocolInstance = protocolElement;
                      inputEndpointInstance.protocol = protocolInstance;
                    }
                    
                    var portElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'PORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (portElement !== null && portElement !== undefined && portElement.length !== 0) {
                      var portInstance = parseInt(portElement, 10);
                      inputEndpointInstance.port = portInstance;
                    }
                    
                    var localPortElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'LOCALPORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (localPortElement !== null && localPortElement !== undefined) {
                      var localPortInstance = localPortElement;
                      inputEndpointInstance.localPort = localPortInstance;
                    }
                  }
                }
                
                var internalEndpointsSequenceElement = js2xml.getElement(responseDoc, endpointsElement, 'INTERNALENDPOINTS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (internalEndpointsSequenceElement !== null && internalEndpointsSequenceElement !== undefined) {
                  for (var loweredIndex3 = 0; loweredIndex3 < js2xml.getElements(responseDoc, internalEndpointsSequenceElement, 'INTERNALENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex3 = loweredIndex3 + 1) {
                    var internalEndpointsElement = js2xml.getElements(responseDoc, internalEndpointsSequenceElement, 'INTERNALENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex3];
                    var internalEndpointInstance = {};
                    endpointsInstance.internalEndpoints.push(internalEndpointInstance);
                    
                    var nameElement2 = js2xml.getElement(responseDoc, internalEndpointsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (nameElement2 !== null && nameElement2 !== undefined) {
                      var nameInstance2 = nameElement2;
                      internalEndpointInstance.name = nameInstance2;
                    }
                    
                    var protocolElement2 = js2xml.getElement(responseDoc, internalEndpointsElement, 'PROTOCOL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (protocolElement2 !== null && protocolElement2 !== undefined) {
                      var protocolInstance2 = protocolElement2;
                      internalEndpointInstance.protocol = protocolInstance2;
                    }
                    
                    var portElement2 = js2xml.getElement(responseDoc, internalEndpointsElement, 'PORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (portElement2 !== null && portElement2 !== undefined && portElement2.length !== 0) {
                      var portInstance2 = parseInt(portElement2, 10);
                      internalEndpointInstance.port = portInstance2;
                    }
                  }
                }
                
                var instanceInputEndpointsSequenceElement = js2xml.getElement(responseDoc, endpointsElement, 'INSTANCEINPUTENDPOINTS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (instanceInputEndpointsSequenceElement !== null && instanceInputEndpointsSequenceElement !== undefined) {
                  for (var loweredIndex4 = 0; loweredIndex4 < js2xml.getElements(responseDoc, instanceInputEndpointsSequenceElement, 'INSTANCEINPUTENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex4 = loweredIndex4 + 1) {
                    var instanceInputEndpointsElement = js2xml.getElements(responseDoc, instanceInputEndpointsSequenceElement, 'INSTANCEINPUTENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex4];
                    var instanceInputEndpointInstance = {};
                    endpointsInstance.instanceInputEndpoints.push(instanceInputEndpointInstance);
                    
                    var nameElement3 = js2xml.getElement(responseDoc, instanceInputEndpointsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (nameElement3 !== null && nameElement3 !== undefined) {
                      var nameInstance3 = nameElement3;
                      instanceInputEndpointInstance.name = nameInstance3;
                    }
                    
                    var protocolElement3 = js2xml.getElement(responseDoc, instanceInputEndpointsElement, 'PROTOCOL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (protocolElement3 !== null && protocolElement3 !== undefined) {
                      var protocolInstance3 = protocolElement3;
                      instanceInputEndpointInstance.protocol = protocolInstance3;
                    }
                    
                    var localPortElement2 = js2xml.getElement(responseDoc, instanceInputEndpointsElement, 'LOCALPORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (localPortElement2 !== null && localPortElement2 !== undefined) {
                      var localPortInstance2 = localPortElement2;
                      instanceInputEndpointInstance.localPort = localPortInstance2;
                    }
                    
                    var fixedPortMinElement = js2xml.getElement(responseDoc, instanceInputEndpointsElement, 'FIXEDPORTMIN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (fixedPortMinElement !== null && fixedPortMinElement !== undefined && fixedPortMinElement.length !== 0) {
                      var fixedPortMinInstance = parseInt(fixedPortMinElement, 10);
                      instanceInputEndpointInstance.fixedPortMin = fixedPortMinInstance;
                    }
                    
                    var fixedPortMaxElement = js2xml.getElement(responseDoc, instanceInputEndpointsElement, 'FIXEDPORTMAX', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (fixedPortMaxElement !== null && fixedPortMaxElement !== undefined && fixedPortMaxElement.length !== 0) {
                      var fixedPortMaxInstance = parseInt(fixedPortMaxElement, 10);
                      instanceInputEndpointInstance.fixedPortMax = fixedPortMaxInstance;
                    }
                  }
                }
              }
              
              var publicConfigurationSchemaElement = js2xml.getElement(responseDoc, extensionImagesElement, 'PUBLICCONFIGURATIONSCHEMA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (publicConfigurationSchemaElement !== null && publicConfigurationSchemaElement !== undefined) {
                var publicConfigurationSchemaInstance = new Buffer(publicConfigurationSchemaElement, 'base64').toString('utf8');
                extensionImageInstance.publicConfigurationSchema = publicConfigurationSchemaInstance;
              }
              
              var privateConfigurationSchemaElement = js2xml.getElement(responseDoc, extensionImagesElement, 'PRIVATECONFIGURATIONSCHEMA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (privateConfigurationSchemaElement !== null && privateConfigurationSchemaElement !== undefined) {
                var privateConfigurationSchemaInstance = new Buffer(privateConfigurationSchemaElement, 'base64').toString('utf8');
                extensionImageInstance.privateConfigurationSchema = privateConfigurationSchemaInstance;
              }
              
              var descriptionElement = js2xml.getElement(responseDoc, extensionImagesElement, 'DESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (descriptionElement !== null && descriptionElement !== undefined) {
                var descriptionInstance = descriptionElement;
                extensionImageInstance.description = descriptionInstance;
              }
              
              var publisherNameElement = js2xml.getElement(responseDoc, extensionImagesElement, 'PUBLISHERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (publisherNameElement !== null && publisherNameElement !== undefined) {
                var publisherNameInstance = publisherNameElement;
                extensionImageInstance.publisherName = publisherNameInstance;
              }
              
              var publishedDateElement = js2xml.getElement(responseDoc, extensionImagesElement, 'PUBLISHEDDATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (publishedDateElement !== null && publishedDateElement !== undefined && publishedDateElement.length !== 0) {
                var publishedDateInstance = new Date(publishedDateElement);
                extensionImageInstance.publishedDate = publishedDateInstance;
              }
              
              var localResourcesSequenceElement = js2xml.getElement(responseDoc, extensionImagesElement, 'LOCALRESOURCES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (localResourcesSequenceElement !== null && localResourcesSequenceElement !== undefined) {
                for (var loweredIndex5 = 0; loweredIndex5 < js2xml.getElements(responseDoc, localResourcesSequenceElement, 'LOCALRESOURCE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex5 = loweredIndex5 + 1) {
                  var localResourcesElement = js2xml.getElements(responseDoc, localResourcesSequenceElement, 'LOCALRESOURCE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex5];
                  var localResourceInstance = {};
                  extensionImageInstance.localResources.push(localResourceInstance);
                  
                  var nameElement4 = js2xml.getElement(responseDoc, localResourcesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (nameElement4 !== null && nameElement4 !== undefined) {
                    var nameInstance4 = nameElement4;
                    localResourceInstance.name = nameInstance4;
                  }
                  
                  var sizeInMBElement = js2xml.getElement(responseDoc, localResourcesElement, 'SIZEINMB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (sizeInMBElement !== null && sizeInMBElement !== undefined && sizeInMBElement.length !== 0) {
                    var sizeInMBInstance = parseInt(sizeInMBElement, 10);
                    localResourceInstance.sizeInMB = sizeInMBInstance;
                  }
                }
              }
              
              var blockRoleUponFailureElement = js2xml.getElement(responseDoc, extensionImagesElement, 'BLOCKROLEUPONFAILURE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (blockRoleUponFailureElement !== null && blockRoleUponFailureElement !== undefined && blockRoleUponFailureElement.length !== 0) {
                var blockRoleUponFailureInstance = blockRoleUponFailureElement === 'true';
                extensionImageInstance.blockRoleUponFailure = blockRoleUponFailureInstance;
              }
              
              var isInternalExtensionElement = js2xml.getElement(responseDoc, extensionImagesElement, 'ISINTERNALEXTENSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (isInternalExtensionElement !== null && isInternalExtensionElement !== undefined && isInternalExtensionElement.length !== 0) {
                var isInternalExtensionInstance = isInternalExtensionElement === 'true';
                extensionImageInstance.isInternalExtension = isInternalExtensionInstance;
              }
              
              var sampleConfigElement = js2xml.getElement(responseDoc, extensionImagesElement, 'SAMPLECONFIG', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (sampleConfigElement !== null && sampleConfigElement !== undefined) {
                var sampleConfigInstance = new Buffer(sampleConfigElement, 'base64').toString('utf8');
                extensionImageInstance.sampleConfig = sampleConfigInstance;
              }
              
              var replicationCompletedElement = js2xml.getElement(responseDoc, extensionImagesElement, 'REPLICATIONCOMPLETED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (replicationCompletedElement !== null && replicationCompletedElement !== undefined && replicationCompletedElement.length !== 0) {
                var replicationCompletedInstance = replicationCompletedElement === 'true';
                extensionImageInstance.replicationCompleted = replicationCompletedInstance;
              }
              
              var eulaElement = js2xml.getElement(responseDoc, extensionImagesElement, 'EULA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (eulaElement !== null && eulaElement !== undefined) {
                var eulaInstance = eulaElement;
                extensionImageInstance.eula = eulaInstance;
              }
              
              var privacyUriElement = js2xml.getElement(responseDoc, extensionImagesElement, 'PRIVACYURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (privacyUriElement !== null && privacyUriElement !== undefined) {
                var privacyUriInstance = privacyUriElement;
                extensionImageInstance.privacyUri = privacyUriInstance;
              }
              
              var homepageUriElement = js2xml.getElement(responseDoc, extensionImagesElement, 'HOMEPAGEURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (homepageUriElement !== null && homepageUriElement !== undefined) {
                var homepageUriInstance = homepageUriElement;
                extensionImageInstance.homepageUri = homepageUriInstance;
              }
              
              var isJsonExtensionElement = js2xml.getElement(responseDoc, extensionImagesElement, 'ISJSONEXTENSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (isJsonExtensionElement !== null && isJsonExtensionElement !== undefined && isJsonExtensionElement.length !== 0) {
                var isJsonExtensionInstance = isJsonExtensionElement === 'true';
                extensionImageInstance.isJsonExtension = isJsonExtensionInstance;
              }
              
              var disallowMajorVersionUpgradeElement = js2xml.getElement(responseDoc, extensionImagesElement, 'DISALLOWMAJORVERSIONUPGRADE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (disallowMajorVersionUpgradeElement !== null && disallowMajorVersionUpgradeElement !== undefined && disallowMajorVersionUpgradeElement.length !== 0) {
                var disallowMajorVersionUpgradeInstance = disallowMajorVersionUpgradeElement === 'true';
                extensionImageInstance.disallowMajorVersionUpgrade = disallowMajorVersionUpgradeInstance;
              }
              
              var supportedOSElement = js2xml.getElement(responseDoc, extensionImagesElement, 'SUPPORTEDOS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (supportedOSElement !== null && supportedOSElement !== undefined) {
                var supportedOSInstance = supportedOSElement;
                extensionImageInstance.supportedOS = supportedOSInstance;
              }
              
              var companyNameElement = js2xml.getElement(responseDoc, extensionImagesElement, 'COMPANYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (companyNameElement !== null && companyNameElement !== undefined) {
                var companyNameInstance = companyNameElement;
                extensionImageInstance.companyName = companyNameInstance;
              }
              
              var regionsElement = js2xml.getElement(responseDoc, extensionImagesElement, 'REGIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (regionsElement !== null && regionsElement !== undefined) {
                var regionsInstance = regionsElement;
                extensionImageInstance.regions = regionsInstance;
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The List Extensions operation lists all of the extensions that were added
   * to a cloud service.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn169561.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  HostedServiceOperations.prototype.listExtensions = function(serviceName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    // TODO: Validate serviceName is a valid DNS name.
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/extensions';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { extensions: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var extensionsSequenceElement = js2xml.getElement(responseDoc, responseDoc, 'EXTENSIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (extensionsSequenceElement !== null && extensionsSequenceElement !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, extensionsSequenceElement, 'EXTENSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
              var extensionsElement = js2xml.getElements(responseDoc, extensionsSequenceElement, 'EXTENSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
              var extensionInstance = {};
              result.extensions.push(extensionInstance);
              
              var providerNameSpaceElement = js2xml.getElement(responseDoc, extensionsElement, 'PROVIDERNAMESPACE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (providerNameSpaceElement !== null && providerNameSpaceElement !== undefined) {
                var providerNameSpaceInstance = providerNameSpaceElement;
                extensionInstance.providerNamespace = providerNameSpaceInstance;
              }
              
              var typeElement = js2xml.getElement(responseDoc, extensionsElement, 'TYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (typeElement !== null && typeElement !== undefined) {
                var typeInstance = typeElement;
                extensionInstance.type = typeInstance;
              }
              
              var idElement = js2xml.getElement(responseDoc, extensionsElement, 'ID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (idElement !== null && idElement !== undefined) {
                var idInstance = idElement;
                extensionInstance.id = idInstance;
              }
              
              var versionElement = js2xml.getElement(responseDoc, extensionsElement, 'VERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (versionElement !== null && versionElement !== undefined) {
                var versionInstance = versionElement;
                extensionInstance.version = versionInstance;
              }
              
              var thumbprintElement = js2xml.getElement(responseDoc, extensionsElement, 'THUMBPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (thumbprintElement !== null && thumbprintElement !== undefined) {
                var thumbprintInstance = thumbprintElement;
                extensionInstance.thumbprint = thumbprintInstance;
              }
              
              var thumbprintAlgorithmElement = js2xml.getElement(responseDoc, extensionsElement, 'THUMBPRINTALGORITHM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (thumbprintAlgorithmElement !== null && thumbprintAlgorithmElement !== undefined) {
                var thumbprintAlgorithmInstance = thumbprintAlgorithmElement;
                extensionInstance.thumbprintAlgorithm = thumbprintAlgorithmInstance;
              }
              
              var publicConfigurationElement = js2xml.getElement(responseDoc, extensionsElement, 'PUBLICCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (publicConfigurationElement !== null && publicConfigurationElement !== undefined) {
                var publicConfigurationInstance = new Buffer(publicConfigurationElement, 'base64').toString('utf8');
                extensionInstance.publicConfiguration = publicConfigurationInstance;
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The List Extension Versions operation lists the versions of an extension
   * that are available to add to a cloud service. In Azure, a process can run
   * as an extension of a cloud service. For example, Remote Desktop Access or
   * the Azure Diagnostics Agent can run as extensions to the cloud service.
   * (see http://msdn.microsoft.com/en-us/library/windowsazure/dn495437.aspx
   * for more information)
   * 
   * @param {string} providerNamespace The provider namespace.
   * 
   * @param {string} extensionType The extension type name.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  HostedServiceOperations.prototype.listExtensionVersions = function(providerNamespace, extensionType, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (providerNamespace === null || providerNamespace === undefined) {
      return callback(new Error('providerNamespace cannot be null.'));
    }
    if (extensionType === null || extensionType === undefined) {
      return callback(new Error('extensionType cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/extensions/';
    url2 = url2 + encodeURIComponent(providerNamespace);
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(extensionType);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { extensionImages: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var extensionImagesSequenceElement = js2xml.getElement(responseDoc, responseDoc, 'EXTENSIONIMAGES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (extensionImagesSequenceElement !== null && extensionImagesSequenceElement !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, extensionImagesSequenceElement, 'EXTENSIONIMAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
              var extensionImagesElement = js2xml.getElements(responseDoc, extensionImagesSequenceElement, 'EXTENSIONIMAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
              var extensionImageInstance = { localResources: [] };
              result.extensionImages.push(extensionImageInstance);
              
              var providerNameSpaceElement = js2xml.getElement(responseDoc, extensionImagesElement, 'PROVIDERNAMESPACE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (providerNameSpaceElement !== null && providerNameSpaceElement !== undefined) {
                var providerNameSpaceInstance = providerNameSpaceElement;
                extensionImageInstance.providerNameSpace = providerNameSpaceInstance;
              }
              
              var typeElement = js2xml.getElement(responseDoc, extensionImagesElement, 'TYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (typeElement !== null && typeElement !== undefined) {
                var typeInstance = typeElement;
                extensionImageInstance.type = typeInstance;
              }
              
              var versionElement = js2xml.getElement(responseDoc, extensionImagesElement, 'VERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (versionElement !== null && versionElement !== undefined) {
                var versionInstance = versionElement;
                extensionImageInstance.version = versionInstance;
              }
              
              var labelElement = js2xml.getElement(responseDoc, extensionImagesElement, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (labelElement !== null && labelElement !== undefined) {
                var labelInstance = labelElement;
                extensionImageInstance.label = labelInstance;
              }
              
              var hostingResourcesElement = js2xml.getElement(responseDoc, extensionImagesElement, 'HOSTINGRESOURCES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (hostingResourcesElement !== null && hostingResourcesElement !== undefined) {
                var hostingResourcesInstance = hostingResourcesElement;
                extensionImageInstance.hostingResources = hostingResourcesInstance;
              }
              
              var mediaLinkElement = js2xml.getElement(responseDoc, extensionImagesElement, 'MEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (mediaLinkElement !== null && mediaLinkElement !== undefined) {
                var mediaLinkInstance = mediaLinkElement;
                extensionImageInstance.mediaLink = mediaLinkInstance;
              }
              
              var certificateElement = js2xml.getElement(responseDoc, extensionImagesElement, 'CERTIFICATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (certificateElement !== null && certificateElement !== undefined) {
                var certificateInstance = {};
                extensionImageInstance.certificate = certificateInstance;
                
                var storeLocationElement = js2xml.getElement(responseDoc, certificateElement, 'STORELOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (storeLocationElement !== null && storeLocationElement !== undefined) {
                  var storeLocationInstance = storeLocationElement;
                  certificateInstance.storeLocation = storeLocationInstance;
                }
                
                var storeNameElement = js2xml.getElement(responseDoc, certificateElement, 'STORENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (storeNameElement !== null && storeNameElement !== undefined) {
                  var storeNameInstance = storeNameElement;
                  certificateInstance.storeName = storeNameInstance;
                }
                
                var thumbprintRequiredElement = js2xml.getElement(responseDoc, certificateElement, 'THUMBPRINTREQUIRED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (thumbprintRequiredElement !== null && thumbprintRequiredElement !== undefined && thumbprintRequiredElement.length !== 0) {
                  var thumbprintRequiredInstance = thumbprintRequiredElement === 'true';
                  certificateInstance.thumbprintRequired = thumbprintRequiredInstance;
                }
                
                var thumbprintAlgorithmElement = js2xml.getElement(responseDoc, certificateElement, 'THUMBPRINTALGORITHM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (thumbprintAlgorithmElement !== null && thumbprintAlgorithmElement !== undefined) {
                  var thumbprintAlgorithmInstance = thumbprintAlgorithmElement;
                  certificateInstance.thumbprintAlgorithm = thumbprintAlgorithmInstance;
                }
              }
              
              var endpointsElement = js2xml.getElement(responseDoc, extensionImagesElement, 'ENDPOINTS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (endpointsElement !== null && endpointsElement !== undefined) {
                var endpointsInstance = { inputEndpoints: [], instanceInputEndpoints: [], internalEndpoints: [] };
                extensionImageInstance.extensionEndpoints = endpointsInstance;
                
                var inputEndpointsSequenceElement = js2xml.getElement(responseDoc, endpointsElement, 'INPUTENDPOINTS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (inputEndpointsSequenceElement !== null && inputEndpointsSequenceElement !== undefined) {
                  for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, inputEndpointsSequenceElement, 'INPUTENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex2 = loweredIndex2 + 1) {
                    var inputEndpointsElement = js2xml.getElements(responseDoc, inputEndpointsSequenceElement, 'INPUTENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex2];
                    var inputEndpointInstance = {};
                    endpointsInstance.inputEndpoints.push(inputEndpointInstance);
                    
                    var nameElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (nameElement !== null && nameElement !== undefined) {
                      var nameInstance = nameElement;
                      inputEndpointInstance.name = nameInstance;
                    }
                    
                    var protocolElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'PROTOCOL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (protocolElement !== null && protocolElement !== undefined) {
                      var protocolInstance = protocolElement;
                      inputEndpointInstance.protocol = protocolInstance;
                    }
                    
                    var portElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'PORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (portElement !== null && portElement !== undefined && portElement.length !== 0) {
                      var portInstance = parseInt(portElement, 10);
                      inputEndpointInstance.port = portInstance;
                    }
                    
                    var localPortElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'LOCALPORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (localPortElement !== null && localPortElement !== undefined) {
                      var localPortInstance = localPortElement;
                      inputEndpointInstance.localPort = localPortInstance;
                    }
                  }
                }
                
                var internalEndpointsSequenceElement = js2xml.getElement(responseDoc, endpointsElement, 'INTERNALENDPOINTS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (internalEndpointsSequenceElement !== null && internalEndpointsSequenceElement !== undefined) {
                  for (var loweredIndex3 = 0; loweredIndex3 < js2xml.getElements(responseDoc, internalEndpointsSequenceElement, 'INTERNALENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex3 = loweredIndex3 + 1) {
                    var internalEndpointsElement = js2xml.getElements(responseDoc, internalEndpointsSequenceElement, 'INTERNALENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex3];
                    var internalEndpointInstance = {};
                    endpointsInstance.internalEndpoints.push(internalEndpointInstance);
                    
                    var nameElement2 = js2xml.getElement(responseDoc, internalEndpointsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (nameElement2 !== null && nameElement2 !== undefined) {
                      var nameInstance2 = nameElement2;
                      internalEndpointInstance.name = nameInstance2;
                    }
                    
                    var protocolElement2 = js2xml.getElement(responseDoc, internalEndpointsElement, 'PROTOCOL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (protocolElement2 !== null && protocolElement2 !== undefined) {
                      var protocolInstance2 = protocolElement2;
                      internalEndpointInstance.protocol = protocolInstance2;
                    }
                    
                    var portElement2 = js2xml.getElement(responseDoc, internalEndpointsElement, 'PORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (portElement2 !== null && portElement2 !== undefined && portElement2.length !== 0) {
                      var portInstance2 = parseInt(portElement2, 10);
                      internalEndpointInstance.port = portInstance2;
                    }
                  }
                }
                
                var instanceInputEndpointsSequenceElement = js2xml.getElement(responseDoc, endpointsElement, 'INSTANCEINPUTENDPOINTS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (instanceInputEndpointsSequenceElement !== null && instanceInputEndpointsSequenceElement !== undefined) {
                  for (var loweredIndex4 = 0; loweredIndex4 < js2xml.getElements(responseDoc, instanceInputEndpointsSequenceElement, 'INSTANCEINPUTENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex4 = loweredIndex4 + 1) {
                    var instanceInputEndpointsElement = js2xml.getElements(responseDoc, instanceInputEndpointsSequenceElement, 'INSTANCEINPUTENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex4];
                    var instanceInputEndpointInstance = {};
                    endpointsInstance.instanceInputEndpoints.push(instanceInputEndpointInstance);
                    
                    var nameElement3 = js2xml.getElement(responseDoc, instanceInputEndpointsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (nameElement3 !== null && nameElement3 !== undefined) {
                      var nameInstance3 = nameElement3;
                      instanceInputEndpointInstance.name = nameInstance3;
                    }
                    
                    var protocolElement3 = js2xml.getElement(responseDoc, instanceInputEndpointsElement, 'PROTOCOL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (protocolElement3 !== null && protocolElement3 !== undefined) {
                      var protocolInstance3 = protocolElement3;
                      instanceInputEndpointInstance.protocol = protocolInstance3;
                    }
                    
                    var localPortElement2 = js2xml.getElement(responseDoc, instanceInputEndpointsElement, 'LOCALPORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (localPortElement2 !== null && localPortElement2 !== undefined) {
                      var localPortInstance2 = localPortElement2;
                      instanceInputEndpointInstance.localPort = localPortInstance2;
                    }
                    
                    var fixedPortMinElement = js2xml.getElement(responseDoc, instanceInputEndpointsElement, 'FIXEDPORTMIN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (fixedPortMinElement !== null && fixedPortMinElement !== undefined && fixedPortMinElement.length !== 0) {
                      var fixedPortMinInstance = parseInt(fixedPortMinElement, 10);
                      instanceInputEndpointInstance.fixedPortMin = fixedPortMinInstance;
                    }
                    
                    var fixedPortMaxElement = js2xml.getElement(responseDoc, instanceInputEndpointsElement, 'FIXEDPORTMAX', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (fixedPortMaxElement !== null && fixedPortMaxElement !== undefined && fixedPortMaxElement.length !== 0) {
                      var fixedPortMaxInstance = parseInt(fixedPortMaxElement, 10);
                      instanceInputEndpointInstance.fixedPortMax = fixedPortMaxInstance;
                    }
                  }
                }
              }
              
              var publicConfigurationSchemaElement = js2xml.getElement(responseDoc, extensionImagesElement, 'PUBLICCONFIGURATIONSCHEMA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (publicConfigurationSchemaElement !== null && publicConfigurationSchemaElement !== undefined) {
                var publicConfigurationSchemaInstance = new Buffer(publicConfigurationSchemaElement, 'base64').toString('utf8');
                extensionImageInstance.publicConfigurationSchema = publicConfigurationSchemaInstance;
              }
              
              var privateConfigurationSchemaElement = js2xml.getElement(responseDoc, extensionImagesElement, 'PRIVATECONFIGURATIONSCHEMA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (privateConfigurationSchemaElement !== null && privateConfigurationSchemaElement !== undefined) {
                var privateConfigurationSchemaInstance = new Buffer(privateConfigurationSchemaElement, 'base64').toString('utf8');
                extensionImageInstance.privateConfigurationSchema = privateConfigurationSchemaInstance;
              }
              
              var descriptionElement = js2xml.getElement(responseDoc, extensionImagesElement, 'DESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (descriptionElement !== null && descriptionElement !== undefined) {
                var descriptionInstance = descriptionElement;
                extensionImageInstance.description = descriptionInstance;
              }
              
              var publisherNameElement = js2xml.getElement(responseDoc, extensionImagesElement, 'PUBLISHERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (publisherNameElement !== null && publisherNameElement !== undefined) {
                var publisherNameInstance = publisherNameElement;
                extensionImageInstance.publisherName = publisherNameInstance;
              }
              
              var publishedDateElement = js2xml.getElement(responseDoc, extensionImagesElement, 'PUBLISHEDDATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (publishedDateElement !== null && publishedDateElement !== undefined && publishedDateElement.length !== 0) {
                var publishedDateInstance = new Date(publishedDateElement);
                extensionImageInstance.publishedDate = publishedDateInstance;
              }
              
              var localResourcesSequenceElement = js2xml.getElement(responseDoc, extensionImagesElement, 'LOCALRESOURCES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (localResourcesSequenceElement !== null && localResourcesSequenceElement !== undefined) {
                for (var loweredIndex5 = 0; loweredIndex5 < js2xml.getElements(responseDoc, localResourcesSequenceElement, 'LOCALRESOURCE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex5 = loweredIndex5 + 1) {
                  var localResourcesElement = js2xml.getElements(responseDoc, localResourcesSequenceElement, 'LOCALRESOURCE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex5];
                  var localResourceInstance = {};
                  extensionImageInstance.localResources.push(localResourceInstance);
                  
                  var nameElement4 = js2xml.getElement(responseDoc, localResourcesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (nameElement4 !== null && nameElement4 !== undefined) {
                    var nameInstance4 = nameElement4;
                    localResourceInstance.name = nameInstance4;
                  }
                  
                  var sizeInMBElement = js2xml.getElement(responseDoc, localResourcesElement, 'SIZEINMB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (sizeInMBElement !== null && sizeInMBElement !== undefined && sizeInMBElement.length !== 0) {
                    var sizeInMBInstance = parseInt(sizeInMBElement, 10);
                    localResourceInstance.sizeInMB = sizeInMBInstance;
                  }
                }
              }
              
              var blockRoleUponFailureElement = js2xml.getElement(responseDoc, extensionImagesElement, 'BLOCKROLEUPONFAILURE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (blockRoleUponFailureElement !== null && blockRoleUponFailureElement !== undefined && blockRoleUponFailureElement.length !== 0) {
                var blockRoleUponFailureInstance = blockRoleUponFailureElement === 'true';
                extensionImageInstance.blockRoleUponFailure = blockRoleUponFailureInstance;
              }
              
              var isInternalExtensionElement = js2xml.getElement(responseDoc, extensionImagesElement, 'ISINTERNALEXTENSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (isInternalExtensionElement !== null && isInternalExtensionElement !== undefined && isInternalExtensionElement.length !== 0) {
                var isInternalExtensionInstance = isInternalExtensionElement === 'true';
                extensionImageInstance.isInternalExtension = isInternalExtensionInstance;
              }
              
              var sampleConfigElement = js2xml.getElement(responseDoc, extensionImagesElement, 'SAMPLECONFIG', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (sampleConfigElement !== null && sampleConfigElement !== undefined) {
                var sampleConfigInstance = new Buffer(sampleConfigElement, 'base64').toString('utf8');
                extensionImageInstance.sampleConfig = sampleConfigInstance;
              }
              
              var replicationCompletedElement = js2xml.getElement(responseDoc, extensionImagesElement, 'REPLICATIONCOMPLETED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (replicationCompletedElement !== null && replicationCompletedElement !== undefined && replicationCompletedElement.length !== 0) {
                var replicationCompletedInstance = replicationCompletedElement === 'true';
                extensionImageInstance.replicationCompleted = replicationCompletedInstance;
              }
              
              var eulaElement = js2xml.getElement(responseDoc, extensionImagesElement, 'EULA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (eulaElement !== null && eulaElement !== undefined) {
                var eulaInstance = eulaElement;
                extensionImageInstance.eula = eulaInstance;
              }
              
              var privacyUriElement = js2xml.getElement(responseDoc, extensionImagesElement, 'PRIVACYURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (privacyUriElement !== null && privacyUriElement !== undefined) {
                var privacyUriInstance = privacyUriElement;
                extensionImageInstance.privacyUri = privacyUriInstance;
              }
              
              var homepageUriElement = js2xml.getElement(responseDoc, extensionImagesElement, 'HOMEPAGEURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (homepageUriElement !== null && homepageUriElement !== undefined) {
                var homepageUriInstance = homepageUriElement;
                extensionImageInstance.homepageUri = homepageUriInstance;
              }
              
              var isJsonExtensionElement = js2xml.getElement(responseDoc, extensionImagesElement, 'ISJSONEXTENSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (isJsonExtensionElement !== null && isJsonExtensionElement !== undefined && isJsonExtensionElement.length !== 0) {
                var isJsonExtensionInstance = isJsonExtensionElement === 'true';
                extensionImageInstance.isJsonExtension = isJsonExtensionInstance;
              }
              
              var disallowMajorVersionUpgradeElement = js2xml.getElement(responseDoc, extensionImagesElement, 'DISALLOWMAJORVERSIONUPGRADE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (disallowMajorVersionUpgradeElement !== null && disallowMajorVersionUpgradeElement !== undefined && disallowMajorVersionUpgradeElement.length !== 0) {
                var disallowMajorVersionUpgradeInstance = disallowMajorVersionUpgradeElement === 'true';
                extensionImageInstance.disallowMajorVersionUpgrade = disallowMajorVersionUpgradeInstance;
              }
              
              var supportedOSElement = js2xml.getElement(responseDoc, extensionImagesElement, 'SUPPORTEDOS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (supportedOSElement !== null && supportedOSElement !== undefined) {
                var supportedOSInstance = supportedOSElement;
                extensionImageInstance.supportedOS = supportedOSInstance;
              }
              
              var companyNameElement = js2xml.getElement(responseDoc, extensionImagesElement, 'COMPANYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (companyNameElement !== null && companyNameElement !== undefined) {
                var companyNameInstance = companyNameElement;
                extensionImageInstance.companyName = companyNameInstance;
              }
              
              var regionsElement = js2xml.getElement(responseDoc, extensionImagesElement, 'REGIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (regionsElement !== null && regionsElement !== undefined) {
                var regionsInstance = regionsElement;
                extensionImageInstance.regions = regionsInstance;
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The List Available Extensions operation lists the extensions that are
   * available to add to your cloud service. In Windows Azure, a process can
   * run as an extension of a cloud service. For example, Remote Desktop
   * Access or the Azure Diagnostics Agent can run as extensions to the cloud
   * service.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn169559.aspx for
   * more information)
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  HostedServiceOperations.prototype.listPublisherExtensions = function(callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/publisherextensions';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { extensionImages: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var extensionImagesSequenceElement = js2xml.getElement(responseDoc, responseDoc, 'EXTENSIONIMAGES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (extensionImagesSequenceElement !== null && extensionImagesSequenceElement !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, extensionImagesSequenceElement, 'EXTENSIONIMAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
              var extensionImagesElement = js2xml.getElements(responseDoc, extensionImagesSequenceElement, 'EXTENSIONIMAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
              var extensionImageInstance = { localResources: [] };
              result.extensionImages.push(extensionImageInstance);
              
              var providerNameSpaceElement = js2xml.getElement(responseDoc, extensionImagesElement, 'PROVIDERNAMESPACE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (providerNameSpaceElement !== null && providerNameSpaceElement !== undefined) {
                var providerNameSpaceInstance = providerNameSpaceElement;
                extensionImageInstance.providerNameSpace = providerNameSpaceInstance;
              }
              
              var typeElement = js2xml.getElement(responseDoc, extensionImagesElement, 'TYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (typeElement !== null && typeElement !== undefined) {
                var typeInstance = typeElement;
                extensionImageInstance.type = typeInstance;
              }
              
              var versionElement = js2xml.getElement(responseDoc, extensionImagesElement, 'VERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (versionElement !== null && versionElement !== undefined) {
                var versionInstance = versionElement;
                extensionImageInstance.version = versionInstance;
              }
              
              var labelElement = js2xml.getElement(responseDoc, extensionImagesElement, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (labelElement !== null && labelElement !== undefined) {
                var labelInstance = labelElement;
                extensionImageInstance.label = labelInstance;
              }
              
              var hostingResourcesElement = js2xml.getElement(responseDoc, extensionImagesElement, 'HOSTINGRESOURCES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (hostingResourcesElement !== null && hostingResourcesElement !== undefined) {
                var hostingResourcesInstance = hostingResourcesElement;
                extensionImageInstance.hostingResources = hostingResourcesInstance;
              }
              
              var mediaLinkElement = js2xml.getElement(responseDoc, extensionImagesElement, 'MEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (mediaLinkElement !== null && mediaLinkElement !== undefined) {
                var mediaLinkInstance = mediaLinkElement;
                extensionImageInstance.mediaLink = mediaLinkInstance;
              }
              
              var certificateElement = js2xml.getElement(responseDoc, extensionImagesElement, 'CERTIFICATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (certificateElement !== null && certificateElement !== undefined) {
                var certificateInstance = {};
                extensionImageInstance.certificate = certificateInstance;
                
                var storeLocationElement = js2xml.getElement(responseDoc, certificateElement, 'STORELOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (storeLocationElement !== null && storeLocationElement !== undefined) {
                  var storeLocationInstance = storeLocationElement;
                  certificateInstance.storeLocation = storeLocationInstance;
                }
                
                var storeNameElement = js2xml.getElement(responseDoc, certificateElement, 'STORENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (storeNameElement !== null && storeNameElement !== undefined) {
                  var storeNameInstance = storeNameElement;
                  certificateInstance.storeName = storeNameInstance;
                }
                
                var thumbprintRequiredElement = js2xml.getElement(responseDoc, certificateElement, 'THUMBPRINTREQUIRED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (thumbprintRequiredElement !== null && thumbprintRequiredElement !== undefined && thumbprintRequiredElement.length !== 0) {
                  var thumbprintRequiredInstance = thumbprintRequiredElement === 'true';
                  certificateInstance.thumbprintRequired = thumbprintRequiredInstance;
                }
                
                var thumbprintAlgorithmElement = js2xml.getElement(responseDoc, certificateElement, 'THUMBPRINTALGORITHM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (thumbprintAlgorithmElement !== null && thumbprintAlgorithmElement !== undefined) {
                  var thumbprintAlgorithmInstance = thumbprintAlgorithmElement;
                  certificateInstance.thumbprintAlgorithm = thumbprintAlgorithmInstance;
                }
              }
              
              var endpointsElement = js2xml.getElement(responseDoc, extensionImagesElement, 'ENDPOINTS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (endpointsElement !== null && endpointsElement !== undefined) {
                var endpointsInstance = { inputEndpoints: [], instanceInputEndpoints: [], internalEndpoints: [] };
                extensionImageInstance.extensionEndpoints = endpointsInstance;
                
                var inputEndpointsSequenceElement = js2xml.getElement(responseDoc, endpointsElement, 'INPUTENDPOINTS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (inputEndpointsSequenceElement !== null && inputEndpointsSequenceElement !== undefined) {
                  for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, inputEndpointsSequenceElement, 'INPUTENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex2 = loweredIndex2 + 1) {
                    var inputEndpointsElement = js2xml.getElements(responseDoc, inputEndpointsSequenceElement, 'INPUTENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex2];
                    var inputEndpointInstance = {};
                    endpointsInstance.inputEndpoints.push(inputEndpointInstance);
                    
                    var nameElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (nameElement !== null && nameElement !== undefined) {
                      var nameInstance = nameElement;
                      inputEndpointInstance.name = nameInstance;
                    }
                    
                    var protocolElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'PROTOCOL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (protocolElement !== null && protocolElement !== undefined) {
                      var protocolInstance = protocolElement;
                      inputEndpointInstance.protocol = protocolInstance;
                    }
                    
                    var portElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'PORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (portElement !== null && portElement !== undefined && portElement.length !== 0) {
                      var portInstance = parseInt(portElement, 10);
                      inputEndpointInstance.port = portInstance;
                    }
                    
                    var localPortElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'LOCALPORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (localPortElement !== null && localPortElement !== undefined) {
                      var localPortInstance = localPortElement;
                      inputEndpointInstance.localPort = localPortInstance;
                    }
                  }
                }
                
                var internalEndpointsSequenceElement = js2xml.getElement(responseDoc, endpointsElement, 'INTERNALENDPOINTS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (internalEndpointsSequenceElement !== null && internalEndpointsSequenceElement !== undefined) {
                  for (var loweredIndex3 = 0; loweredIndex3 < js2xml.getElements(responseDoc, internalEndpointsSequenceElement, 'INTERNALENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex3 = loweredIndex3 + 1) {
                    var internalEndpointsElement = js2xml.getElements(responseDoc, internalEndpointsSequenceElement, 'INTERNALENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex3];
                    var internalEndpointInstance = {};
                    endpointsInstance.internalEndpoints.push(internalEndpointInstance);
                    
                    var nameElement2 = js2xml.getElement(responseDoc, internalEndpointsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (nameElement2 !== null && nameElement2 !== undefined) {
                      var nameInstance2 = nameElement2;
                      internalEndpointInstance.name = nameInstance2;
                    }
                    
                    var protocolElement2 = js2xml.getElement(responseDoc, internalEndpointsElement, 'PROTOCOL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (protocolElement2 !== null && protocolElement2 !== undefined) {
                      var protocolInstance2 = protocolElement2;
                      internalEndpointInstance.protocol = protocolInstance2;
                    }
                    
                    var portElement2 = js2xml.getElement(responseDoc, internalEndpointsElement, 'PORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (portElement2 !== null && portElement2 !== undefined && portElement2.length !== 0) {
                      var portInstance2 = parseInt(portElement2, 10);
                      internalEndpointInstance.port = portInstance2;
                    }
                  }
                }
                
                var instanceInputEndpointsSequenceElement = js2xml.getElement(responseDoc, endpointsElement, 'INSTANCEINPUTENDPOINTS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (instanceInputEndpointsSequenceElement !== null && instanceInputEndpointsSequenceElement !== undefined) {
                  for (var loweredIndex4 = 0; loweredIndex4 < js2xml.getElements(responseDoc, instanceInputEndpointsSequenceElement, 'INSTANCEINPUTENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex4 = loweredIndex4 + 1) {
                    var instanceInputEndpointsElement = js2xml.getElements(responseDoc, instanceInputEndpointsSequenceElement, 'INSTANCEINPUTENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex4];
                    var instanceInputEndpointInstance = {};
                    endpointsInstance.instanceInputEndpoints.push(instanceInputEndpointInstance);
                    
                    var nameElement3 = js2xml.getElement(responseDoc, instanceInputEndpointsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (nameElement3 !== null && nameElement3 !== undefined) {
                      var nameInstance3 = nameElement3;
                      instanceInputEndpointInstance.name = nameInstance3;
                    }
                    
                    var protocolElement3 = js2xml.getElement(responseDoc, instanceInputEndpointsElement, 'PROTOCOL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (protocolElement3 !== null && protocolElement3 !== undefined) {
                      var protocolInstance3 = protocolElement3;
                      instanceInputEndpointInstance.protocol = protocolInstance3;
                    }
                    
                    var localPortElement2 = js2xml.getElement(responseDoc, instanceInputEndpointsElement, 'LOCALPORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (localPortElement2 !== null && localPortElement2 !== undefined) {
                      var localPortInstance2 = localPortElement2;
                      instanceInputEndpointInstance.localPort = localPortInstance2;
                    }
                    
                    var fixedPortMinElement = js2xml.getElement(responseDoc, instanceInputEndpointsElement, 'FIXEDPORTMIN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (fixedPortMinElement !== null && fixedPortMinElement !== undefined && fixedPortMinElement.length !== 0) {
                      var fixedPortMinInstance = parseInt(fixedPortMinElement, 10);
                      instanceInputEndpointInstance.fixedPortMin = fixedPortMinInstance;
                    }
                    
                    var fixedPortMaxElement = js2xml.getElement(responseDoc, instanceInputEndpointsElement, 'FIXEDPORTMAX', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (fixedPortMaxElement !== null && fixedPortMaxElement !== undefined && fixedPortMaxElement.length !== 0) {
                      var fixedPortMaxInstance = parseInt(fixedPortMaxElement, 10);
                      instanceInputEndpointInstance.fixedPortMax = fixedPortMaxInstance;
                    }
                  }
                }
              }
              
              var publicConfigurationSchemaElement = js2xml.getElement(responseDoc, extensionImagesElement, 'PUBLICCONFIGURATIONSCHEMA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (publicConfigurationSchemaElement !== null && publicConfigurationSchemaElement !== undefined) {
                var publicConfigurationSchemaInstance = new Buffer(publicConfigurationSchemaElement, 'base64').toString('utf8');
                extensionImageInstance.publicConfigurationSchema = publicConfigurationSchemaInstance;
              }
              
              var privateConfigurationSchemaElement = js2xml.getElement(responseDoc, extensionImagesElement, 'PRIVATECONFIGURATIONSCHEMA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (privateConfigurationSchemaElement !== null && privateConfigurationSchemaElement !== undefined) {
                var privateConfigurationSchemaInstance = new Buffer(privateConfigurationSchemaElement, 'base64').toString('utf8');
                extensionImageInstance.privateConfigurationSchema = privateConfigurationSchemaInstance;
              }
              
              var descriptionElement = js2xml.getElement(responseDoc, extensionImagesElement, 'DESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (descriptionElement !== null && descriptionElement !== undefined) {
                var descriptionInstance = descriptionElement;
                extensionImageInstance.description = descriptionInstance;
              }
              
              var publisherNameElement = js2xml.getElement(responseDoc, extensionImagesElement, 'PUBLISHERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (publisherNameElement !== null && publisherNameElement !== undefined) {
                var publisherNameInstance = publisherNameElement;
                extensionImageInstance.publisherName = publisherNameInstance;
              }
              
              var publishedDateElement = js2xml.getElement(responseDoc, extensionImagesElement, 'PUBLISHEDDATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (publishedDateElement !== null && publishedDateElement !== undefined && publishedDateElement.length !== 0) {
                var publishedDateInstance = new Date(publishedDateElement);
                extensionImageInstance.publishedDate = publishedDateInstance;
              }
              
              var localResourcesSequenceElement = js2xml.getElement(responseDoc, extensionImagesElement, 'LOCALRESOURCES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (localResourcesSequenceElement !== null && localResourcesSequenceElement !== undefined) {
                for (var loweredIndex5 = 0; loweredIndex5 < js2xml.getElements(responseDoc, localResourcesSequenceElement, 'LOCALRESOURCE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex5 = loweredIndex5 + 1) {
                  var localResourcesElement = js2xml.getElements(responseDoc, localResourcesSequenceElement, 'LOCALRESOURCE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex5];
                  var localResourceInstance = {};
                  extensionImageInstance.localResources.push(localResourceInstance);
                  
                  var nameElement4 = js2xml.getElement(responseDoc, localResourcesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (nameElement4 !== null && nameElement4 !== undefined) {
                    var nameInstance4 = nameElement4;
                    localResourceInstance.name = nameInstance4;
                  }
                  
                  var sizeInMBElement = js2xml.getElement(responseDoc, localResourcesElement, 'SIZEINMB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (sizeInMBElement !== null && sizeInMBElement !== undefined && sizeInMBElement.length !== 0) {
                    var sizeInMBInstance = parseInt(sizeInMBElement, 10);
                    localResourceInstance.sizeInMB = sizeInMBInstance;
                  }
                }
              }
              
              var blockRoleUponFailureElement = js2xml.getElement(responseDoc, extensionImagesElement, 'BLOCKROLEUPONFAILURE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (blockRoleUponFailureElement !== null && blockRoleUponFailureElement !== undefined && blockRoleUponFailureElement.length !== 0) {
                var blockRoleUponFailureInstance = blockRoleUponFailureElement === 'true';
                extensionImageInstance.blockRoleUponFailure = blockRoleUponFailureInstance;
              }
              
              var isInternalExtensionElement = js2xml.getElement(responseDoc, extensionImagesElement, 'ISINTERNALEXTENSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (isInternalExtensionElement !== null && isInternalExtensionElement !== undefined && isInternalExtensionElement.length !== 0) {
                var isInternalExtensionInstance = isInternalExtensionElement === 'true';
                extensionImageInstance.isInternalExtension = isInternalExtensionInstance;
              }
              
              var sampleConfigElement = js2xml.getElement(responseDoc, extensionImagesElement, 'SAMPLECONFIG', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (sampleConfigElement !== null && sampleConfigElement !== undefined) {
                var sampleConfigInstance = new Buffer(sampleConfigElement, 'base64').toString('utf8');
                extensionImageInstance.sampleConfig = sampleConfigInstance;
              }
              
              var replicationCompletedElement = js2xml.getElement(responseDoc, extensionImagesElement, 'REPLICATIONCOMPLETED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (replicationCompletedElement !== null && replicationCompletedElement !== undefined && replicationCompletedElement.length !== 0) {
                var replicationCompletedInstance = replicationCompletedElement === 'true';
                extensionImageInstance.replicationCompleted = replicationCompletedInstance;
              }
              
              var eulaElement = js2xml.getElement(responseDoc, extensionImagesElement, 'EULA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (eulaElement !== null && eulaElement !== undefined) {
                var eulaInstance = eulaElement;
                extensionImageInstance.eula = eulaInstance;
              }
              
              var privacyUriElement = js2xml.getElement(responseDoc, extensionImagesElement, 'PRIVACYURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (privacyUriElement !== null && privacyUriElement !== undefined) {
                var privacyUriInstance = privacyUriElement;
                extensionImageInstance.privacyUri = privacyUriInstance;
              }
              
              var homepageUriElement = js2xml.getElement(responseDoc, extensionImagesElement, 'HOMEPAGEURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (homepageUriElement !== null && homepageUriElement !== undefined) {
                var homepageUriInstance = homepageUriElement;
                extensionImageInstance.homepageUri = homepageUriInstance;
              }
              
              var isJsonExtensionElement = js2xml.getElement(responseDoc, extensionImagesElement, 'ISJSONEXTENSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (isJsonExtensionElement !== null && isJsonExtensionElement !== undefined && isJsonExtensionElement.length !== 0) {
                var isJsonExtensionInstance = isJsonExtensionElement === 'true';
                extensionImageInstance.isJsonExtension = isJsonExtensionInstance;
              }
              
              var disallowMajorVersionUpgradeElement = js2xml.getElement(responseDoc, extensionImagesElement, 'DISALLOWMAJORVERSIONUPGRADE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (disallowMajorVersionUpgradeElement !== null && disallowMajorVersionUpgradeElement !== undefined && disallowMajorVersionUpgradeElement.length !== 0) {
                var disallowMajorVersionUpgradeInstance = disallowMajorVersionUpgradeElement === 'true';
                extensionImageInstance.disallowMajorVersionUpgrade = disallowMajorVersionUpgradeInstance;
              }
              
              var supportedOSElement = js2xml.getElement(responseDoc, extensionImagesElement, 'SUPPORTEDOS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (supportedOSElement !== null && supportedOSElement !== undefined) {
                var supportedOSInstance = supportedOSElement;
                extensionImageInstance.supportedOS = supportedOSInstance;
              }
              
              var companyNameElement = js2xml.getElement(responseDoc, extensionImagesElement, 'COMPANYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (companyNameElement !== null && companyNameElement !== undefined) {
                var companyNameInstance = companyNameElement;
                extensionImageInstance.companyName = companyNameInstance;
              }
              
              var regionsElement = js2xml.getElement(responseDoc, extensionImagesElement, 'REGIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (regionsElement !== null && regionsElement !== undefined) {
                var regionsInstance = regionsElement;
                extensionImageInstance.regions = regionsInstance;
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Update Hosted Service operation can update the label or description of
   * a cloud service in Azure.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/gg441303.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of the cloud service.
   * 
   * @param {HostedServiceUpdateParameters} parameters Parameters supplied to
   * the Update Hosted Service operation.
   * 
   * @param {string} [parameters.label] A name for the cloud service. The name
   * may be up to 100 characters in length. You must specify a value for at
   * least one of Label or Description. It is recommended that the label be
   * unique within the subscription. The name can be used identify the service
   * for your tracking purposes.
   * 
   * @param {string} [parameters.description] A description for the cloud
   * service. The description may be up to 1024 characters in length. You must
   * specify a value for at least one of Label or Description.
   * 
   * @param {object} [parameters.extendedProperties] Represents the name of an
   * extended cloud service property. Each extended property must have a
   * defined name and a value. You can have a maximum of 50 extended property
   * name and value pairs. The maximum length of the name element is 64
   * characters, only alphanumeric characters and underscores are valid in the
   * name, and it must start with a letter. Attempting to use other
   * characters, starting with a non-letter character, or entering a name that
   * is identical to that of another extended property owned by the same
   * service will result in a status code 400 (Bad Request) error. Each
   * extended property value has a maximum length of 255 characters.
   * 
   * @param {string} [parameters.reverseDnsFqdn] Dns address to which the cloud
   * service's IP address resolves when queried using a reverse Dns query.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  HostedServiceOperations.prototype.update = function(serviceName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    // TODO: Validate serviceName is a valid DNS name.
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.description !== null && parameters.description !== undefined && parameters.description.length > 1024) {
      return callback(new Error('parameters.description is outside the valid range.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var updateHostedServiceElement = js2xml.createElement('UpdateHostedService', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, updateHostedServiceElement);
    
    if (parameters.label !== null && parameters.label !== undefined) {
      var labelElement = js2xml.createElement('Label', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(labelElement, new Buffer(parameters.label).toString('base64'));
      js2xml.addChildElement(updateHostedServiceElement, labelElement);
    }
    
    if (parameters.description !== null && parameters.description !== undefined) {
      var descriptionElement = js2xml.createElement('Description', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(descriptionElement, parameters.description);
      js2xml.addChildElement(updateHostedServiceElement, descriptionElement);
    }
    
    if (parameters.reverseDnsFqdn !== null && parameters.reverseDnsFqdn !== undefined) {
      var reverseDnsFqdnElement = js2xml.createElement('ReverseDnsFqdn', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(reverseDnsFqdnElement, parameters.reverseDnsFqdn);
      js2xml.addChildElement(updateHostedServiceElement, reverseDnsFqdnElement);
    }
    
    if (parameters.extendedProperties !== null && parameters.extendedProperties !== undefined) {
      var extendedPropertiesDictionaryElement = js2xml.createElement('ExtendedProperties', 'http://schemas.microsoft.com/windowsazure');
      for (var extendedPropertiesKey in parameters.extendedProperties) {
        var extendedPropertiesValue = parameters.extendedProperties[extendedPropertiesKey];
        var extendedPropertiesElement = js2xml.createElement('ExtendedProperty', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(extendedPropertiesDictionaryElement, extendedPropertiesElement);
        
        var extendedPropertiesKeyElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(extendedPropertiesKeyElement, extendedPropertiesKey);
        js2xml.addChildElement(extendedPropertiesElement, extendedPropertiesKeyElement);
        
        var extendedPropertiesValueElement = js2xml.createElement('Value', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(extendedPropertiesValueElement, extendedPropertiesValue);
        js2xml.addChildElement(extendedPropertiesElement, extendedPropertiesValueElement);
      }
      js2xml.addChildElement(updateHostedServiceElement, extendedPropertiesDictionaryElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return HostedServiceOperations;
})();

var LoadBalancerOperations = ( /** @lends LoadBalancerOperations */ function() {
  /**
   * @class
   * The Compute Management API includes operations for managing the load
   * balancers for your subscription.
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [ComputeManagementClient] {@link
   * ComputeManagementClient~ComputeManagementClient}.
   * See [loadBalancers] {@link
   * ComputeManagementClient~ComputeManagementClient#loadBalancers}.
   * Initializes a new instance of the LoadBalancerOperations class.
   * @constructor
   * 
   * @param {ComputeManagementClient} client Reference to the service client.
   */
  function LoadBalancerOperations(client) {
    this.client = client;
  }
  
  /**
   * Add an internal load balancer to a an existing deployment. When used by an
   * input endpoint, the internal load balancer will provide an additional
   * private VIP that can be used for load balancing to the roles in this
   * deployment.
   * 
   * @param {string} serviceName The name of the service.
   * 
   * @param {string} deploymentName The name of the deployment.
   * 
   * @param {LoadBalancerCreateParameters} parameters Parameters supplied to
   * the Create Load Balancer operation.
   * 
   * @param {string} [parameters.name] Name of the load balancer.
   * 
   * @param {FrontendIPConfiguration} [parameters.frontendIPConfiguration] The
   * configuration for the virtual IP address (VIP) this load balancer
   * provides.
   * 
   * @param {string} [parameters.frontendIPConfiguration.type] The type of the
   * VIP provided by this load balancer. Currently, only 'Private' is
   * supported. This will create load balancing services on a private VIP.
   * 
   * @param {string} [parameters.frontendIPConfiguration.subnetName] If the
   * deployment exists inside a virtual network, a subnet of that virtual
   * network must be specified for the load balancer. The VIP managed by the
   * load balancer will then be an IP address out of this subnet. If the
   * deployment exists outside of a virtual network, no subnet can be
   * specified and the private VIP will be an IP address from the general
   * private address pool.
   * 
   * @param {string}
   * [parameters.frontendIPConfiguration.staticVirtualNetworkIPAddress] If the
   * deployment exists inside a virtual network, a specific address from the
   * load balancer subnet can be specified. The VIP for the load balancer will
   * then be this specific IP address. If a static virtual network IP address
   * is provided, the SubnetName element of the load balancer must be
   * specified as well. If the deployment exists outside of a virtual network,
   * no static virtual network IP address can be specified.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  LoadBalancerOperations.prototype.beginCreating = function(serviceName, deploymentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/loadbalancers';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var loadBalancerElement = js2xml.createElement('LoadBalancer', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, loadBalancerElement);
    
    if (parameters.name !== null && parameters.name !== undefined) {
      var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(nameElement, parameters.name);
      js2xml.addChildElement(loadBalancerElement, nameElement);
    }
    
    if (parameters.frontendIPConfiguration !== null && parameters.frontendIPConfiguration !== undefined) {
      var frontendIpConfigurationElement = js2xml.createElement('FrontendIpConfiguration', 'http://schemas.microsoft.com/windowsazure');
      js2xml.addChildElement(loadBalancerElement, frontendIpConfigurationElement);
      
      if (parameters.frontendIPConfiguration.type !== null && parameters.frontendIPConfiguration.type !== undefined) {
        var typeElement = js2xml.createElement('Type', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(typeElement, parameters.frontendIPConfiguration.type);
        js2xml.addChildElement(frontendIpConfigurationElement, typeElement);
      }
      
      if (parameters.frontendIPConfiguration.subnetName !== null && parameters.frontendIPConfiguration.subnetName !== undefined) {
        var subnetNameElement = js2xml.createElement('SubnetName', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(subnetNameElement, parameters.frontendIPConfiguration.subnetName);
        js2xml.addChildElement(frontendIpConfigurationElement, subnetNameElement);
      }
      
      if (parameters.frontendIPConfiguration.staticVirtualNetworkIPAddress !== null && parameters.frontendIPConfiguration.staticVirtualNetworkIPAddress !== undefined) {
        var staticVirtualNetworkIPAddressElement = js2xml.createElement('StaticVirtualNetworkIPAddress', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(staticVirtualNetworkIPAddressElement, parameters.frontendIPConfiguration.staticVirtualNetworkIPAddress);
        js2xml.addChildElement(frontendIpConfigurationElement, staticVirtualNetworkIPAddressElement);
      }
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Delete an internal load balancer from the deployment.
   * 
   * @param {string} serviceName The name of the service.
   * 
   * @param {string} deploymentName The name of the deployment.
   * 
   * @param {string} loadBalancerName The name of the load balancer.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  LoadBalancerOperations.prototype.beginDeleting = function(serviceName, deploymentName, loadBalancerName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (loadBalancerName === null || loadBalancerName === undefined) {
      return callback(new Error('loadBalancerName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/loadbalancers/';
    url2 = url2 + encodeURIComponent(loadBalancerName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Updates an internal load balancer associated with an existing deployment.
   * 
   * @param {string} serviceName The name of the service.
   * 
   * @param {string} deploymentName The name of the deployment.
   * 
   * @param {string} loadBalancerName The name of the loadBalancer.
   * 
   * @param {LoadBalancerUpdateParameters} parameters Parameters supplied to
   * the Update Load Balancer operation.
   * 
   * @param {string} [parameters.name] Name of the load balancer.
   * 
   * @param {FrontendIPConfiguration} [parameters.frontendIPConfiguration] The
   * configuration for the virtual IP address (VIP) this load balancer
   * provides.
   * 
   * @param {string} [parameters.frontendIPConfiguration.type] The type of the
   * VIP provided by this load balancer. Currently, only 'Private' is
   * supported. This will create load balancing services on a private VIP.
   * 
   * @param {string} [parameters.frontendIPConfiguration.subnetName] If the
   * deployment exists inside a virtual network, a subnet of that virtual
   * network must be specified for the load balancer. The VIP managed by the
   * load balancer will then be an IP address out of this subnet. If the
   * deployment exists outside of a virtual network, no subnet can be
   * specified and the private VIP will be an IP address from the general
   * private address pool.
   * 
   * @param {string}
   * [parameters.frontendIPConfiguration.staticVirtualNetworkIPAddress] If the
   * deployment exists inside a virtual network, a specific address from the
   * load balancer subnet can be specified. The VIP for the load balancer will
   * then be this specific IP address. If a static virtual network IP address
   * is provided, the SubnetName element of the load balancer must be
   * specified as well. If the deployment exists outside of a virtual network,
   * no static virtual network IP address can be specified.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  LoadBalancerOperations.prototype.beginUpdating = function(serviceName, deploymentName, loadBalancerName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (loadBalancerName === null || loadBalancerName === undefined) {
      return callback(new Error('loadBalancerName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/loadbalancers/';
    url2 = url2 + encodeURIComponent(loadBalancerName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var loadBalancerElement = js2xml.createElement('LoadBalancer', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, loadBalancerElement);
    
    if (parameters.name !== null && parameters.name !== undefined) {
      var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(nameElement, parameters.name);
      js2xml.addChildElement(loadBalancerElement, nameElement);
    }
    
    if (parameters.frontendIPConfiguration !== null && parameters.frontendIPConfiguration !== undefined) {
      var frontendIpConfigurationElement = js2xml.createElement('FrontendIpConfiguration', 'http://schemas.microsoft.com/windowsazure');
      js2xml.addChildElement(loadBalancerElement, frontendIpConfigurationElement);
      
      if (parameters.frontendIPConfiguration.type !== null && parameters.frontendIPConfiguration.type !== undefined) {
        var typeElement = js2xml.createElement('Type', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(typeElement, parameters.frontendIPConfiguration.type);
        js2xml.addChildElement(frontendIpConfigurationElement, typeElement);
      }
      
      if (parameters.frontendIPConfiguration.subnetName !== null && parameters.frontendIPConfiguration.subnetName !== undefined) {
        var subnetNameElement = js2xml.createElement('SubnetName', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(subnetNameElement, parameters.frontendIPConfiguration.subnetName);
        js2xml.addChildElement(frontendIpConfigurationElement, subnetNameElement);
      }
      
      if (parameters.frontendIPConfiguration.staticVirtualNetworkIPAddress !== null && parameters.frontendIPConfiguration.staticVirtualNetworkIPAddress !== undefined) {
        var staticVirtualNetworkIPAddressElement = js2xml.createElement('StaticVirtualNetworkIPAddress', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(staticVirtualNetworkIPAddressElement, parameters.frontendIPConfiguration.staticVirtualNetworkIPAddress);
        js2xml.addChildElement(frontendIpConfigurationElement, staticVirtualNetworkIPAddressElement);
      }
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Add an internal load balancer to a an existing deployment. When used by an
   * input endpoint, the internal load balancer will provide an additional
   * private VIP that can be used for load balancing to the roles in this
   * deployment.
   * 
   * @param {string} serviceName The name of the service.
   * 
   * @param {string} deploymentName The name of the deployment.
   * 
   * @param {LoadBalancerCreateParameters} parameters Parameters supplied to
   * the Create Load Balancer operation.
   * 
   * @param {string} [parameters.name] Name of the load balancer.
   * 
   * @param {FrontendIPConfiguration} [parameters.frontendIPConfiguration] The
   * configuration for the virtual IP address (VIP) this load balancer
   * provides.
   * 
   * @param {string} [parameters.frontendIPConfiguration.type] The type of the
   * VIP provided by this load balancer. Currently, only 'Private' is
   * supported. This will create load balancing services on a private VIP.
   * 
   * @param {string} [parameters.frontendIPConfiguration.subnetName] If the
   * deployment exists inside a virtual network, a subnet of that virtual
   * network must be specified for the load balancer. The VIP managed by the
   * load balancer will then be an IP address out of this subnet. If the
   * deployment exists outside of a virtual network, no subnet can be
   * specified and the private VIP will be an IP address from the general
   * private address pool.
   * 
   * @param {string}
   * [parameters.frontendIPConfiguration.staticVirtualNetworkIPAddress] If the
   * deployment exists inside a virtual network, a specific address from the
   * load balancer subnet can be specified. The VIP for the load balancer will
   * then be this specific IP address. If a static virtual network IP address
   * is provided, the SubnetName element of the load balancer must be
   * specified as well. If the deployment exists outside of a virtual network,
   * no static virtual network IP address can be specified.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  LoadBalancerOperations.prototype.create = function(serviceName, deploymentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.loadBalancers.beginCreating(serviceName, deploymentName, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      if (result.status === 'Succeeded') {
        return callback(null, result);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * Delete an internal load balancer from the deployment.
   * 
   * @param {string} serviceName The name of the service.
   * 
   * @param {string} deploymentName The name of the deployment.
   * 
   * @param {string} loadBalancerName The name of the load balancer.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  LoadBalancerOperations.prototype.deleteMethod = function(serviceName, deploymentName, loadBalancerName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.loadBalancers.beginDeleting(serviceName, deploymentName, loadBalancerName, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * Updates an internal load balancer associated with an existing deployment.
   * 
   * @param {string} serviceName The name of the service.
   * 
   * @param {string} deploymentName The name of the deployment.
   * 
   * @param {string} loadBalancerName The name of the loadBalancer.
   * 
   * @param {LoadBalancerUpdateParameters} parameters Parameters supplied to
   * the Update Load Balancer operation.
   * 
   * @param {string} [parameters.name] Name of the load balancer.
   * 
   * @param {FrontendIPConfiguration} [parameters.frontendIPConfiguration] The
   * configuration for the virtual IP address (VIP) this load balancer
   * provides.
   * 
   * @param {string} [parameters.frontendIPConfiguration.type] The type of the
   * VIP provided by this load balancer. Currently, only 'Private' is
   * supported. This will create load balancing services on a private VIP.
   * 
   * @param {string} [parameters.frontendIPConfiguration.subnetName] If the
   * deployment exists inside a virtual network, a subnet of that virtual
   * network must be specified for the load balancer. The VIP managed by the
   * load balancer will then be an IP address out of this subnet. If the
   * deployment exists outside of a virtual network, no subnet can be
   * specified and the private VIP will be an IP address from the general
   * private address pool.
   * 
   * @param {string}
   * [parameters.frontendIPConfiguration.staticVirtualNetworkIPAddress] If the
   * deployment exists inside a virtual network, a specific address from the
   * load balancer subnet can be specified. The VIP for the load balancer will
   * then be this specific IP address. If a static virtual network IP address
   * is provided, the SubnetName element of the load balancer must be
   * specified as well. If the deployment exists outside of a virtual network,
   * no static virtual network IP address can be specified.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  LoadBalancerOperations.prototype.update = function(serviceName, deploymentName, loadBalancerName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.loadBalancers.beginUpdating(serviceName, deploymentName, loadBalancerName, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      if (result.status === 'Succeeded') {
        return callback(null, result);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  return LoadBalancerOperations;
})();

var OperatingSystemOperations = ( /** @lends OperatingSystemOperations */ function() {
  /**
   * @class
   * Operations for determining the version of the Azure Guest Operating System
   * on which your service is running.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ff684169.aspx for
   * more information)
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [ComputeManagementClient] {@link
   * ComputeManagementClient~ComputeManagementClient}.
   * See [operatingSystems] {@link
   * ComputeManagementClient~ComputeManagementClient#operatingSystems}.
   * Initializes a new instance of the OperatingSystemOperations class.
   * @constructor
   * 
   * @param {ComputeManagementClient} client Reference to the service client.
   */
  function OperatingSystemOperations(client) {
    this.client = client;
  }
  
  /**
   * The List Operating Systems operation lists the versions of the guest
   * operating system that are currently available in Windows Azure. The
   * 2010-10-28 version of List Operating Systems also indicates what family
   * an operating system version belongs to. Currently Azure supports two
   * operating system families: the Azure guest operating system that is
   * substantially compatible with Windows Server 2008 SP2, and the Azure
   * guest operating system that is substantially compatible with Windows
   * Server 2008 R2.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ff684168.aspx for
   * more information)
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  OperatingSystemOperations.prototype.list = function(callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/operatingsystems';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { operatingSystems: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var operatingSystemsSequenceElement = js2xml.getElement(responseDoc, responseDoc, 'OPERATINGSYSTEMS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (operatingSystemsSequenceElement !== null && operatingSystemsSequenceElement !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, operatingSystemsSequenceElement, 'OPERATINGSYSTEM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
              var operatingSystemsElement = js2xml.getElements(responseDoc, operatingSystemsSequenceElement, 'OPERATINGSYSTEM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
              var operatingSystemInstance = {};
              result.operatingSystems.push(operatingSystemInstance);
              
              var versionElement = js2xml.getElement(responseDoc, operatingSystemsElement, 'VERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (versionElement !== null && versionElement !== undefined) {
                var versionInstance = versionElement;
                operatingSystemInstance.version = versionInstance;
              }
              
              var labelElement = js2xml.getElement(responseDoc, operatingSystemsElement, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (labelElement !== null && labelElement !== undefined) {
                var labelInstance = new Buffer(labelElement, 'base64').toString('utf8');
                operatingSystemInstance.label = labelInstance;
              }
              
              var isDefaultElement = js2xml.getElement(responseDoc, operatingSystemsElement, 'ISDEFAULT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (isDefaultElement !== null && isDefaultElement !== undefined && isDefaultElement.length !== 0) {
                var isDefaultInstance = isDefaultElement === 'true';
                operatingSystemInstance.isDefault = isDefaultInstance;
              }
              
              var isActiveElement = js2xml.getElement(responseDoc, operatingSystemsElement, 'ISACTIVE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (isActiveElement !== null && isActiveElement !== undefined && isActiveElement.length !== 0) {
                var isActiveInstance = isActiveElement === 'true';
                operatingSystemInstance.isActive = isActiveInstance;
              }
              
              var familyElement = js2xml.getElement(responseDoc, operatingSystemsElement, 'FAMILY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (familyElement !== null && familyElement !== undefined && familyElement.length !== 0) {
                var familyInstance = parseInt(familyElement, 10);
                operatingSystemInstance.family = familyInstance;
              }
              
              var familyLabelElement = js2xml.getElement(responseDoc, operatingSystemsElement, 'FAMILYLABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (familyLabelElement !== null && familyLabelElement !== undefined) {
                var familyLabelInstance = new Buffer(familyLabelElement, 'base64').toString('utf8');
                operatingSystemInstance.familyLabel = familyLabelInstance;
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The List OS Families operation lists the guest operating system families
   * available in Azure, and also lists the operating system versions
   * available for each family. Currently Azure supports two operating system
   * families: the Azure guest operating system that is substantially
   * compatible with Windows Server 2008 SP2, and the Azure guest operating
   * system that is substantially compatible with Windows Server 2008 R2.
   * (see http://msdn.microsoft.com/en-us/library/windowsazure/gg441291.aspx
   * for more information)
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  OperatingSystemOperations.prototype.listFamilies = function(callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/operatingsystemfamilies';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { operatingSystemFamilies: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var operatingSystemFamiliesSequenceElement = js2xml.getElement(responseDoc, responseDoc, 'OPERATINGSYSTEMFAMILIES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (operatingSystemFamiliesSequenceElement !== null && operatingSystemFamiliesSequenceElement !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, operatingSystemFamiliesSequenceElement, 'OPERATINGSYSTEMFAMILY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
              var operatingSystemFamiliesElement = js2xml.getElements(responseDoc, operatingSystemFamiliesSequenceElement, 'OPERATINGSYSTEMFAMILY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
              var operatingSystemFamilyInstance = { operatingSystems: [] };
              result.operatingSystemFamilies.push(operatingSystemFamilyInstance);
              
              var nameElement = js2xml.getElement(responseDoc, operatingSystemFamiliesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (nameElement !== null && nameElement !== undefined && nameElement.length !== 0) {
                var nameInstance = parseInt(nameElement, 10);
                operatingSystemFamilyInstance.name = nameInstance;
              }
              
              var labelElement = js2xml.getElement(responseDoc, operatingSystemFamiliesElement, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (labelElement !== null && labelElement !== undefined) {
                var labelInstance = new Buffer(labelElement, 'base64').toString('utf8');
                operatingSystemFamilyInstance.label = labelInstance;
              }
              
              var operatingSystemsSequenceElement = js2xml.getElement(responseDoc, operatingSystemFamiliesElement, 'OPERATINGSYSTEMS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (operatingSystemsSequenceElement !== null && operatingSystemsSequenceElement !== undefined) {
                for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, operatingSystemsSequenceElement, 'OPERATINGSYSTEM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex2 = loweredIndex2 + 1) {
                  var operatingSystemsElement = js2xml.getElements(responseDoc, operatingSystemsSequenceElement, 'OPERATINGSYSTEM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex2];
                  var operatingSystemInstance = {};
                  operatingSystemFamilyInstance.operatingSystems.push(operatingSystemInstance);
                  
                  var versionElement = js2xml.getElement(responseDoc, operatingSystemsElement, 'VERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (versionElement !== null && versionElement !== undefined) {
                    var versionInstance = versionElement;
                    operatingSystemInstance.version = versionInstance;
                  }
                  
                  var labelElement2 = js2xml.getElement(responseDoc, operatingSystemsElement, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (labelElement2 !== null && labelElement2 !== undefined) {
                    var labelInstance2 = new Buffer(labelElement2, 'base64').toString('utf8');
                    operatingSystemInstance.label = labelInstance2;
                  }
                  
                  var isDefaultElement = js2xml.getElement(responseDoc, operatingSystemsElement, 'ISDEFAULT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (isDefaultElement !== null && isDefaultElement !== undefined && isDefaultElement.length !== 0) {
                    var isDefaultInstance = isDefaultElement === 'true';
                    operatingSystemInstance.isDefault = isDefaultInstance;
                  }
                  
                  var isActiveElement = js2xml.getElement(responseDoc, operatingSystemsElement, 'ISACTIVE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (isActiveElement !== null && isActiveElement !== undefined && isActiveElement.length !== 0) {
                    var isActiveInstance = isActiveElement === 'true';
                    operatingSystemInstance.isActive = isActiveInstance;
                  }
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return OperatingSystemOperations;
})();

var ServiceCertificateOperations = ( /** @lends ServiceCertificateOperations */ function() {
  /**
   * @class
   * Operations for managing service certificates for your subscription.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee795178.aspx for
   * more information)
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [ComputeManagementClient] {@link
   * ComputeManagementClient~ComputeManagementClient}.
   * See [serviceCertificates] {@link
   * ComputeManagementClient~ComputeManagementClient#serviceCertificates}.
   * Initializes a new instance of the ServiceCertificateOperations class.
   * @constructor
   * 
   * @param {ComputeManagementClient} client Reference to the service client.
   */
  function ServiceCertificateOperations(client) {
    this.client = client;
  }
  
  /**
   * The Begin Creating Service Certificate operation adds a certificate to a
   * hosted service. This operation is an asynchronous operation. To determine
   * whether the management service has finished processing the request, call
   * Get Operation Status.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460817.aspx for
   * more information)
   * 
   * @param {string} serviceName The DNS prefix name of your service.
   * 
   * @param {ServiceCertificateCreateParameters} parameters Parameters supplied
   * to the Begin Creating Service Certificate operation.
   * 
   * @param {buffer} parameters.data The pfx or cer file.
   * 
   * @param {CertificateFormat} parameters.certificateFormat The service
   * certificate format. Azure supports the pfx and cer file formats.
   * 
   * @param {string} [parameters.password] The password for a pfx certificate.
   * A cer certificate does not require a password.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ServiceCertificateOperations.prototype.beginCreating = function(serviceName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    // TODO: Validate serviceName is a valid DNS name.
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.certificateFormat === null || parameters.certificateFormat === undefined) {
      return callback(new Error('parameters.certificateFormat cannot be null.'));
    }
    if (parameters.data === null || parameters.data === undefined) {
      return callback(new Error('parameters.data cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/certificates';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var certificateFileElement = js2xml.createElement('CertificateFile', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, certificateFileElement);
    
    var dataElement = js2xml.createElement('Data', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(dataElement, parameters.data.toString('base64'));
    js2xml.addChildElement(certificateFileElement, dataElement);
    
    var certificateFormatElement = js2xml.createElement('CertificateFormat', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(certificateFormatElement, parameters.certificateFormat !== null && parameters.certificateFormat !== undefined ? parameters.certificateFormat.toString() : 'Pfx');
    js2xml.addChildElement(certificateFileElement, certificateFormatElement);
    
    if (parameters.password !== null && parameters.password !== undefined) {
      var passwordElement = js2xml.createElement('Password', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(passwordElement, parameters.password);
      js2xml.addChildElement(certificateFileElement, passwordElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Deleting Service Certificate operation deletes a service
   * certificate from the certificate store of a hosted service. This
   * operation is an asynchronous operation. To determine whether the
   * management service has finished processing the request, call Get
   * Operation Status.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460803.aspx for
   * more information)
   * 
   * @param {ServiceCertificateDeleteParameters} parameters Parameters supplied
   * to the Begin Deleting Service Certificate operation.
   * 
   * @param {string} parameters.serviceName The DNS prefix name of your service.
   * 
   * @param {string} parameters.thumbprintAlgorithm The algorithm for the
   * certificate's thumbprint.
   * 
   * @param {string} parameters.thumbprint The hexadecimal representation of
   * the thumbprint.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ServiceCertificateOperations.prototype.beginDeleting = function(parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.serviceName === null || parameters.serviceName === undefined) {
      return callback(new Error('parameters.serviceName cannot be null.'));
    }
    // TODO: Validate parameters.serviceName is a valid DNS name.
    if (parameters.thumbprint === null || parameters.thumbprint === undefined) {
      return callback(new Error('parameters.thumbprint cannot be null.'));
    }
    if (parameters.thumbprintAlgorithm === null || parameters.thumbprintAlgorithm === undefined) {
      return callback(new Error('parameters.thumbprintAlgorithm cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(parameters.serviceName);
    url2 = url2 + '/certificates/';
    url2 = url2 + encodeURIComponent(parameters.thumbprintAlgorithm);
    url2 = url2 + '-';
    url2 = url2 + encodeURIComponent(parameters.thumbprint);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Create Service Certificate operation adds a certificate to a hosted
   * service. This operation is an asynchronous operation. To determine
   * whether the management service has finished processing the request, call
   * Get Operation Status.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460817.aspx for
   * more information)
   * 
   * @param {string} serviceName The DNS prefix name of your service.
   * 
   * @param {ServiceCertificateCreateParameters} parameters Parameters supplied
   * to the Create Service Certificate operation.
   * 
   * @param {buffer} parameters.data The pfx or cer file.
   * 
   * @param {CertificateFormat} parameters.certificateFormat The service
   * certificate format. Azure supports the pfx and cer file formats.
   * 
   * @param {string} [parameters.password] The password for a pfx certificate.
   * A cer certificate does not require a password.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ServiceCertificateOperations.prototype.create = function(serviceName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.serviceCertificates.beginCreating(serviceName, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Delete Service Certificate operation deletes a service certificate
   * from the certificate store of a hosted service. This operation is an
   * asynchronous operation. To determine whether the management service has
   * finished processing the request, call Get Operation Status.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460803.aspx for
   * more information)
   * 
   * @param {ServiceCertificateDeleteParameters} parameters Parameters supplied
   * to the Delete Service Certificate operation.
   * 
   * @param {string} parameters.serviceName The DNS prefix name of your service.
   * 
   * @param {string} parameters.thumbprintAlgorithm The algorithm for the
   * certificate's thumbprint.
   * 
   * @param {string} parameters.thumbprint The hexadecimal representation of
   * the thumbprint.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ServiceCertificateOperations.prototype.deleteMethod = function(parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.serviceCertificates.beginDeleting(parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Get Service Certificate operation returns the public data for the
   * specified X.509 certificate associated with a hosted service.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460792.aspx for
   * more information)
   * 
   * @param {ServiceCertificateGetParameters} parameters Parameters supplied to
   * the Get Service Certificate operation.
   * 
   * @param {string} parameters.serviceName The DNS prefix name of your service.
   * 
   * @param {string} parameters.thumbprintAlgorithm The algorithm for the
   * certificate's thumbprint.
   * 
   * @param {string} parameters.thumbprint The hexadecimal representation of
   * the thumbprint.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ServiceCertificateOperations.prototype.get = function(parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.serviceName === null || parameters.serviceName === undefined) {
      return callback(new Error('parameters.serviceName cannot be null.'));
    }
    // TODO: Validate parameters.serviceName is a valid DNS name.
    if (parameters.thumbprint === null || parameters.thumbprint === undefined) {
      return callback(new Error('parameters.thumbprint cannot be null.'));
    }
    if (parameters.thumbprintAlgorithm === null || parameters.thumbprintAlgorithm === undefined) {
      return callback(new Error('parameters.thumbprintAlgorithm cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(parameters.serviceName);
    url2 = url2 + '/certificates/';
    url2 = url2 + encodeURIComponent(parameters.thumbprintAlgorithm);
    url2 = url2 + '-';
    url2 = url2 + encodeURIComponent(parameters.thumbprint);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var certificateElement = js2xml.getElement(responseDoc, responseDoc, 'CERTIFICATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (certificateElement !== null && certificateElement !== undefined) {
            var dataElement = js2xml.getElement(responseDoc, certificateElement, 'DATA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (dataElement !== null && dataElement !== undefined) {
              var dataInstance = new Buffer(dataElement, 'base64').toString('utf8');
              result.data = dataInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The List Service Certificates operation lists all of the service
   * certificates associated with the specified hosted service.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj154105.aspx for
   * more information)
   * 
   * @param {string} serviceName The DNS prefix name of your hosted service.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ServiceCertificateOperations.prototype.list = function(serviceName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    // TODO: Validate serviceName is a valid DNS name.
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/certificates';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { certificates: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var certificatesSequenceElement = js2xml.getElement(responseDoc, responseDoc, 'CERTIFICATES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (certificatesSequenceElement !== null && certificatesSequenceElement !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, certificatesSequenceElement, 'CERTIFICATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
              var certificatesElement = js2xml.getElements(responseDoc, certificatesSequenceElement, 'CERTIFICATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
              var certificateInstance = {};
              result.certificates.push(certificateInstance);
              
              var certificateUrlElement = js2xml.getElement(responseDoc, certificatesElement, 'CERTIFICATEURL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (certificateUrlElement !== null && certificateUrlElement !== undefined) {
                var certificateUrlInstance = certificateUrlElement;
                certificateInstance.certificateUri = certificateUrlInstance;
              }
              
              var thumbprintElement = js2xml.getElement(responseDoc, certificatesElement, 'THUMBPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (thumbprintElement !== null && thumbprintElement !== undefined) {
                var thumbprintInstance = thumbprintElement;
                certificateInstance.thumbprint = thumbprintInstance;
              }
              
              var thumbprintAlgorithmElement = js2xml.getElement(responseDoc, certificatesElement, 'THUMBPRINTALGORITHM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (thumbprintAlgorithmElement !== null && thumbprintAlgorithmElement !== undefined) {
                var thumbprintAlgorithmInstance = thumbprintAlgorithmElement;
                certificateInstance.thumbprintAlgorithm = thumbprintAlgorithmInstance;
              }
              
              var dataElement = js2xml.getElement(responseDoc, certificatesElement, 'DATA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (dataElement !== null && dataElement !== undefined) {
                var dataInstance = new Buffer(dataElement, 'base64').toString('utf8');
                certificateInstance.data = dataInstance;
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return ServiceCertificateOperations;
})();

var VirtualMachineDiskOperations = ( /** @lends VirtualMachineDiskOperations */ function() {
  /**
   * @class
   * The Service Management API includes operations for managing the disks in
   * your subscription.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157188.aspx for
   * more information)
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [ComputeManagementClient] {@link
   * ComputeManagementClient~ComputeManagementClient}.
   * See [virtualMachineDisks] {@link
   * ComputeManagementClient~ComputeManagementClient#virtualMachineDisks}.
   * Initializes a new instance of the VirtualMachineDiskOperations class.
   * @constructor
   * 
   * @param {ComputeManagementClient} client Reference to the service client.
   */
  function VirtualMachineDiskOperations(client) {
    this.client = client;
  }
  
  /**
   * The Create Data Disk operation adds a data disk to a virtual machine.
   * There are three ways to create the data disk using the Add Data Disk
   * operation. Option 1 - Attach an empty data disk to the role by specifying
   * the disk label and location of the disk image. Do not include the
   * DiskName and SourceMediaLink elements in the request body. Include the
   * MediaLink element and reference a blob that is in the same geographical
   * region as the role. You can also omit the MediaLink element. In this
   * usage, Azure will create the data disk in the storage account configured
   * as default for the role. Option 2 - Attach an existing data disk that is
   * in the image repository. Do not include the DiskName and SourceMediaLink
   * elements in the request body. Specify the data disk to use by including
   * the DiskName element. Note: If included the in the response body, the
   * MediaLink and LogicalDiskSizeInGB elements are ignored. Option 3 -
   * Specify the location of a blob in your storage account that contain a
   * disk image to use. Include the SourceMediaLink element. Note: If the
   * MediaLink element isincluded, it is ignored.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157199.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of the deployment.
   * 
   * @param {string} roleName The name of the role to add the data disk to.
   * 
   * @param {VirtualMachineDataDiskCreateParameters} parameters Parameters
   * supplied to the Create Virtual Machine Data Disk operation.
   * 
   * @param {string} parameters.hostCaching Specifies the platform caching
   * behavior of data disk blob for read/write efficiency. The default vault
   * is ReadOnly. Possible values are: None, ReadOnly, or ReadWrite. Warning:
   * Setting this property impacts the consistency of the disk.
   * 
   * @param {string} [parameters.label] Specifies the description of the data
   * disk. When you attach a disk, either by directly referencing a media
   * using the MediaLink element or specifying the target disk size, you can
   * use the DiskLabel element to customize the name property of the target
   * data disk.
   * 
   * @param {string} [parameters.name] Specifies the name of the disk. Azure
   * uses the specified disk to create the data disk for the machine and
   * populates this field with the disk name.
   * 
   * @param {number} [parameters.logicalUnitNumber] Specifies the Logical Unit
   * Number (LUN) for the disk. The LUN specifies the slot in which the data
   * drive appears when mounted for usage by the virtual machine. Valid LUN
   * values are 0 through 15.
   * 
   * @param {number} [parameters.logicalDiskSizeInGB] Specifies the size, in
   * GB, of an empty disk to be attached to the role. The disk can be created
   * as part of disk attach or create VM role call by specifying the value for
   * this property. Azure creates the empty disk based on size preference and
   * attaches the newly created disk to the Role.
   * 
   * @param {string} parameters.mediaLinkUri Specifies the location of the blob
   * in Azure storage where the media for the disk is located. The blob
   * location must belong to the storage account in the subscription specified
   * by the SubscriptionId value in the operation call. Example:
   * http://example.blob.core.windows.net/disks/mydisk.vhd.
   * 
   * @param {string} [parameters.sourceMediaLinkUri] Specifies the location of
   * a blob in account storage which is mounted as a data disk when the
   * virtual machine is created.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineDiskOperations.prototype.beginCreatingDataDisk = function(serviceName, deploymentName, roleName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (roleName === null || roleName === undefined) {
      return callback(new Error('roleName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.hostCaching === null || parameters.hostCaching === undefined) {
      return callback(new Error('parameters.hostCaching cannot be null.'));
    }
    if (parameters.mediaLinkUri === null || parameters.mediaLinkUri === undefined) {
      return callback(new Error('parameters.mediaLinkUri cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/roles/';
    url2 = url2 + encodeURIComponent(roleName);
    url2 = url2 + '/DataDisks';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var dataVirtualHardDiskElement = js2xml.createElement('DataVirtualHardDisk', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, dataVirtualHardDiskElement);
    
    var hostCachingElement = js2xml.createElement('HostCaching', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(hostCachingElement, parameters.hostCaching);
    js2xml.addChildElement(dataVirtualHardDiskElement, hostCachingElement);
    
    if (parameters.label !== null && parameters.label !== undefined) {
      var diskLabelElement = js2xml.createElement('DiskLabel', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(diskLabelElement, parameters.label);
      js2xml.addChildElement(dataVirtualHardDiskElement, diskLabelElement);
    }
    
    if (parameters.name !== null && parameters.name !== undefined) {
      var diskNameElement = js2xml.createElement('DiskName', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(diskNameElement, parameters.name);
      js2xml.addChildElement(dataVirtualHardDiskElement, diskNameElement);
    }
    
    if (parameters.logicalUnitNumber !== null && parameters.logicalUnitNumber !== undefined) {
      var lunElement = js2xml.createElement('Lun', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(lunElement, parameters.logicalUnitNumber.toString());
      js2xml.addChildElement(dataVirtualHardDiskElement, lunElement);
    }
    
    if (parameters.logicalDiskSizeInGB !== null && parameters.logicalDiskSizeInGB !== undefined) {
      var logicalDiskSizeInGBElement = js2xml.createElement('LogicalDiskSizeInGB', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(logicalDiskSizeInGBElement, parameters.logicalDiskSizeInGB.toString());
      js2xml.addChildElement(dataVirtualHardDiskElement, logicalDiskSizeInGBElement);
    }
    
    var mediaLinkElement = js2xml.createElement('MediaLink', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(mediaLinkElement, parameters.mediaLinkUri);
    js2xml.addChildElement(dataVirtualHardDiskElement, mediaLinkElement);
    
    if (parameters.sourceMediaLinkUri !== null && parameters.sourceMediaLinkUri !== undefined) {
      var sourceMediaLinkElement = js2xml.createElement('SourceMediaLink', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(sourceMediaLinkElement, parameters.sourceMediaLinkUri);
      js2xml.addChildElement(dataVirtualHardDiskElement, sourceMediaLinkElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Deleting Data Disk operation removes the specified data disk
   * from a virtual machine.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157179.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of the deployment.
   * 
   * @param {string} roleName The name of the role to delete the data disk from.
   * 
   * @param {Number} logicalUnitNumber The logical unit number of the disk.
   * 
   * @param {boolean} [deleteFromStorage] Specifies that the source blob for
   * the disk should also be deleted from storage.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineDiskOperations.prototype.beginDeletingDataDisk = function(serviceName, deploymentName, roleName, logicalUnitNumber, deleteFromStorage, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (roleName === null || roleName === undefined) {
      return callback(new Error('roleName cannot be null.'));
    }
    if (logicalUnitNumber === null || logicalUnitNumber === undefined) {
      return callback(new Error('logicalUnitNumber cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/roles/';
    url2 = url2 + encodeURIComponent(roleName);
    url2 = url2 + '/DataDisks/';
    url2 = url2 + encodeURIComponent(logicalUnitNumber.toString());
    var queryParameters = [];
    if (deleteFromStorage !== null && deleteFromStorage !== undefined && deleteFromStorage === true) {
      queryParameters.push('comp=media');
    }
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Add Disk operation adds a disk to the user image repository. The disk
   * can be an operating system disk or a data disk.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157178.aspx for
   * more information)
   * 
   * @param {string} name The name of the disk being updated.
   * 
   * @param {VirtualMachineDiskUpdateParameters} parameters Parameters supplied
   * to the Update Virtual Machine Disk operation.
   * 
   * @param {boolean} [parameters.hasOperatingSystem] Specifies whether the
   * disk contains an operating system. Note: Only a disk with an operating
   * system installed can be mounted as OS Drive.
   * 
   * @param {string} [parameters.operatingSystemType] The operating system type
   * of the disk. Possible values are: Linux or Windows.
   * 
   * @param {string} parameters.label Specifies the friendly name of the disk.
   * 
   * @param {string} [parameters.mediaLinkUri] Specifies the location of the
   * blob in Azure storage. The blob location must belong to a storage account
   * in the subscription specified by the SubscriptionId value in the
   * operation call. Example:
   * http://example.blob.core.windows.net/disks/mydisk.vhd.
   * 
   * @param {string} parameters.name Specifies a name for the disk. Azure uses
   * the name to identify the disk when creating virtual machines from the
   * disk.
   * 
   * @param {number} [parameters.resizedSizeInGB] Resizes the underlying blob
   * to the indicated size in GB.To use the ResizedSizeInGB property, the
   * version header should be at least 2014-10-01.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineDiskOperations.prototype.beginUpdatingDisk = function(name, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (name === null || name === undefined) {
      return callback(new Error('name cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.label === null || parameters.label === undefined) {
      return callback(new Error('parameters.label cannot be null.'));
    }
    if (parameters.name === null || parameters.name === undefined) {
      return callback(new Error('parameters.name cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/disks/';
    url2 = url2 + encodeURIComponent(name);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var diskElement = js2xml.createElement('Disk', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, diskElement);
    
    if (parameters.hasOperatingSystem !== null && parameters.hasOperatingSystem !== undefined) {
      var hasOperatingSystemElement = js2xml.createElement('HasOperatingSystem', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(hasOperatingSystemElement, parameters.hasOperatingSystem.toString());
      js2xml.addChildElement(diskElement, hasOperatingSystemElement);
    }
    
    if (parameters.operatingSystemType !== null && parameters.operatingSystemType !== undefined) {
      var osElement = js2xml.createElement('OS', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(osElement, parameters.operatingSystemType);
      js2xml.addChildElement(diskElement, osElement);
    }
    
    var labelElement = js2xml.createElement('Label', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(labelElement, parameters.label);
    js2xml.addChildElement(diskElement, labelElement);
    
    if (parameters.mediaLinkUri !== null && parameters.mediaLinkUri !== undefined) {
      var mediaLinkElement = js2xml.createElement('MediaLink', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(mediaLinkElement, parameters.mediaLinkUri);
      js2xml.addChildElement(diskElement, mediaLinkElement);
    }
    
    var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(nameElement, parameters.name);
    js2xml.addChildElement(diskElement, nameElement);
    
    if (parameters.resizedSizeInGB !== null && parameters.resizedSizeInGB !== undefined) {
      var resizedSizeInGBElement = js2xml.createElement('ResizedSizeInGB', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(resizedSizeInGBElement, parameters.resizedSizeInGB.toString());
      js2xml.addChildElement(diskElement, resizedSizeInGBElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Create Data Disk operation adds a data disk to a virtual machine.
   * There are three ways to create the data disk using the Add Data Disk
   * operation. Option 1 - Attach an empty data disk to the role by specifying
   * the disk label and location of the disk image. Do not include the
   * DiskName and SourceMediaLink elements in the request body. Include the
   * MediaLink element and reference a blob that is in the same geographical
   * region as the role. You can also omit the MediaLink element. In this
   * usage, Azure will create the data disk in the storage account configured
   * as default for the role. Option 2 - Attach an existing data disk that is
   * in the image repository. Do not include the DiskName and SourceMediaLink
   * elements in the request body. Specify the data disk to use by including
   * the DiskName element. Note: If included the in the response body, the
   * MediaLink and LogicalDiskSizeInGB elements are ignored. Option 3 -
   * Specify the location of a blob in your storage account that contain a
   * disk image to use. Include the SourceMediaLink element. Note: If the
   * MediaLink element isincluded, it is ignored.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157199.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of the deployment.
   * 
   * @param {string} roleName The name of the role to add the data disk to.
   * 
   * @param {VirtualMachineDataDiskCreateParameters} parameters Parameters
   * supplied to the Create Virtual Machine Data Disk operation.
   * 
   * @param {string} parameters.hostCaching Specifies the platform caching
   * behavior of data disk blob for read/write efficiency. The default vault
   * is ReadOnly. Possible values are: None, ReadOnly, or ReadWrite. Warning:
   * Setting this property impacts the consistency of the disk.
   * 
   * @param {string} [parameters.label] Specifies the description of the data
   * disk. When you attach a disk, either by directly referencing a media
   * using the MediaLink element or specifying the target disk size, you can
   * use the DiskLabel element to customize the name property of the target
   * data disk.
   * 
   * @param {string} [parameters.name] Specifies the name of the disk. Azure
   * uses the specified disk to create the data disk for the machine and
   * populates this field with the disk name.
   * 
   * @param {number} [parameters.logicalUnitNumber] Specifies the Logical Unit
   * Number (LUN) for the disk. The LUN specifies the slot in which the data
   * drive appears when mounted for usage by the virtual machine. Valid LUN
   * values are 0 through 15.
   * 
   * @param {number} [parameters.logicalDiskSizeInGB] Specifies the size, in
   * GB, of an empty disk to be attached to the role. The disk can be created
   * as part of disk attach or create VM role call by specifying the value for
   * this property. Azure creates the empty disk based on size preference and
   * attaches the newly created disk to the Role.
   * 
   * @param {string} parameters.mediaLinkUri Specifies the location of the blob
   * in Azure storage where the media for the disk is located. The blob
   * location must belong to the storage account in the subscription specified
   * by the SubscriptionId value in the operation call. Example:
   * http://example.blob.core.windows.net/disks/mydisk.vhd.
   * 
   * @param {string} [parameters.sourceMediaLinkUri] Specifies the location of
   * a blob in account storage which is mounted as a data disk when the
   * virtual machine is created.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineDiskOperations.prototype.createDataDisk = function(serviceName, deploymentName, roleName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachineDisks.beginCreatingDataDisk(serviceName, deploymentName, roleName, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Create Disk operation adds a disk to the user image repository. The
   * disk can be an operating system disk or a data disk.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157178.aspx for
   * more information)
   * 
   * @param {VirtualMachineDiskCreateParameters} parameters Parameters supplied
   * to the Create Virtual Machine Disk operation.
   * 
   * @param {string} [parameters.operatingSystemType] The operating system type
   * of the disk. Possible values are: Linux or Windows.
   * 
   * @param {string} parameters.label Specifies the friendly name of the disk.
   * 
   * @param {string} parameters.mediaLinkUri Specifies the location of the blob
   * in Azure storage. The blob location must belong to a storage account in
   * the subscription specified by the SubscriptionId value in the operation
   * call. Example: http://example.blob.core.windows.net/disks/mydisk.vhd.
   * 
   * @param {string} parameters.name Specifies a name for the disk. Azure uses
   * the name to identify the disk when creating virtual machines from the
   * disk.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineDiskOperations.prototype.createDisk = function(parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.label === null || parameters.label === undefined) {
      return callback(new Error('parameters.label cannot be null.'));
    }
    if (parameters.mediaLinkUri === null || parameters.mediaLinkUri === undefined) {
      return callback(new Error('parameters.mediaLinkUri cannot be null.'));
    }
    if (parameters.name === null || parameters.name === undefined) {
      return callback(new Error('parameters.name cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/disks';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var diskElement = js2xml.createElement('Disk', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, diskElement);
    
    if (parameters.operatingSystemType !== null && parameters.operatingSystemType !== undefined) {
      var osElement = js2xml.createElement('OS', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(osElement, parameters.operatingSystemType);
      js2xml.addChildElement(diskElement, osElement);
    }
    
    var labelElement = js2xml.createElement('Label', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(labelElement, parameters.label);
    js2xml.addChildElement(diskElement, labelElement);
    
    var mediaLinkElement = js2xml.createElement('MediaLink', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(mediaLinkElement, parameters.mediaLinkUri);
    js2xml.addChildElement(diskElement, mediaLinkElement);
    
    var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(nameElement, parameters.name);
    js2xml.addChildElement(diskElement, nameElement);
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var diskElement2 = js2xml.getElement(responseDoc, responseDoc, 'DISK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (diskElement2 !== null && diskElement2 !== undefined) {
            var osElement2 = js2xml.getElement(responseDoc, diskElement2, 'OS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (osElement2 !== null && osElement2 !== undefined) {
              var osInstance = osElement2;
              result.operatingSystem = osInstance;
            }
            
            var labelElement2 = js2xml.getElement(responseDoc, diskElement2, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (labelElement2 !== null && labelElement2 !== undefined) {
              var labelInstance = labelElement2;
              result.label = labelInstance;
            }
            
            var affinityGroupElement = js2xml.getElement(responseDoc, diskElement2, 'AFFINITYGROUP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (affinityGroupElement !== null && affinityGroupElement !== undefined) {
              var affinityGroupInstance = affinityGroupElement;
              result.affinityGroup = affinityGroupInstance;
            }
            
            var locationElement = js2xml.getElement(responseDoc, diskElement2, 'LOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (locationElement !== null && locationElement !== undefined) {
              var locationInstance = locationElement;
              result.location = locationInstance;
            }
            
            var logicalDiskSizeInGBElement = js2xml.getElement(responseDoc, diskElement2, 'LOGICALDISKSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (logicalDiskSizeInGBElement !== null && logicalDiskSizeInGBElement !== undefined && logicalDiskSizeInGBElement.length !== 0) {
              var logicalDiskSizeInGBInstance = parseInt(logicalDiskSizeInGBElement, 10);
              result.logicalSizeInGB = logicalDiskSizeInGBInstance;
            }
            
            var mediaLinkElement2 = js2xml.getElement(responseDoc, diskElement2, 'MEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (mediaLinkElement2 !== null && mediaLinkElement2 !== undefined) {
              var mediaLinkInstance = mediaLinkElement2;
              result.mediaLinkUri = mediaLinkInstance;
            }
            
            var nameElement2 = js2xml.getElement(responseDoc, diskElement2, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (nameElement2 !== null && nameElement2 !== undefined) {
              var nameInstance = nameElement2;
              result.name = nameInstance;
            }
            
            var sourceImageNameElement = js2xml.getElement(responseDoc, diskElement2, 'SOURCEIMAGENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (sourceImageNameElement !== null && sourceImageNameElement !== undefined) {
              var sourceImageNameInstance = sourceImageNameElement;
              result.sourceImageName = sourceImageNameInstance;
            }
            
            var attachedToElement = js2xml.getElement(responseDoc, diskElement2, 'ATTACHEDTO', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (attachedToElement !== null && attachedToElement !== undefined) {
              var attachedToInstance = {};
              result.usageDetails = attachedToInstance;
              
              var hostedServiceNameElement = js2xml.getElement(responseDoc, attachedToElement, 'HOSTEDSERVICENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (hostedServiceNameElement !== null && hostedServiceNameElement !== undefined) {
                var hostedServiceNameInstance = hostedServiceNameElement;
                attachedToInstance.hostedServiceName = hostedServiceNameInstance;
              }
              
              var deploymentNameElement = js2xml.getElement(responseDoc, attachedToElement, 'DEPLOYMENTNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (deploymentNameElement !== null && deploymentNameElement !== undefined) {
                var deploymentNameInstance = deploymentNameElement;
                attachedToInstance.deploymentName = deploymentNameInstance;
              }
              
              var roleNameElement = js2xml.getElement(responseDoc, attachedToElement, 'ROLENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (roleNameElement !== null && roleNameElement !== undefined) {
                var roleNameInstance = roleNameElement;
                attachedToInstance.roleName = roleNameInstance;
              }
            }
            
            var isPremiumElement = js2xml.getElement(responseDoc, diskElement2, 'ISPREMIUM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (isPremiumElement !== null && isPremiumElement !== undefined && isPremiumElement.length !== 0) {
              var isPremiumInstance = isPremiumElement === 'true';
              result.isPremium = isPremiumInstance;
            }
            
            var iOTypeElement = js2xml.getElement(responseDoc, diskElement2, 'IOTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (iOTypeElement !== null && iOTypeElement !== undefined) {
              var iOTypeInstance = iOTypeElement;
              result.iOType = iOTypeInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Delete Data Disk operation removes the specified data disk from a
   * virtual machine.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157179.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of the deployment.
   * 
   * @param {string} roleName The name of the role to delete the data disk from.
   * 
   * @param {Number} logicalUnitNumber The logical unit number of the disk.
   * 
   * @param {boolean} [deleteFromStorage] Specifies that the source blob for
   * the disk should also be deleted from storage.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineDiskOperations.prototype.deleteDataDisk = function(serviceName, deploymentName, roleName, logicalUnitNumber, deleteFromStorage, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachineDisks.beginDeletingDataDisk(serviceName, deploymentName, roleName, logicalUnitNumber, deleteFromStorage, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Delete Disk operation deletes the specified data or operating system
   * disk from your image repository.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157200.aspx for
   * more information)
   * 
   * @param {string} name The name of the disk to delete.
   * 
   * @param {boolean} [deleteFromStorage] Specifies that the source blob for
   * the disk should also be deleted from storage.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineDiskOperations.prototype.deleteDisk = function(name, deleteFromStorage, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (name === null || name === undefined) {
      return callback(new Error('name cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/disks/';
    url2 = url2 + encodeURIComponent(name);
    var queryParameters = [];
    if (deleteFromStorage !== null && deleteFromStorage !== undefined && deleteFromStorage === true) {
      queryParameters.push('comp=media');
    }
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Get Data Disk operation retrieves the specified data disk from a
   * virtual machine.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157180.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of the deployment.
   * 
   * @param {string} roleName The name of the role.
   * 
   * @param {Number} logicalUnitNumber The logical unit number of the disk.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineDiskOperations.prototype.getDataDisk = function(serviceName, deploymentName, roleName, logicalUnitNumber, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (roleName === null || roleName === undefined) {
      return callback(new Error('roleName cannot be null.'));
    }
    if (logicalUnitNumber === null || logicalUnitNumber === undefined) {
      return callback(new Error('logicalUnitNumber cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/roles/';
    url2 = url2 + encodeURIComponent(roleName);
    url2 = url2 + '/DataDisks/';
    url2 = url2 + encodeURIComponent(logicalUnitNumber.toString());
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var dataVirtualHardDiskElement = js2xml.getElement(responseDoc, responseDoc, 'DATAVIRTUALHARDDISK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (dataVirtualHardDiskElement !== null && dataVirtualHardDiskElement !== undefined) {
            var hostCachingElement = js2xml.getElement(responseDoc, dataVirtualHardDiskElement, 'HOSTCACHING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (hostCachingElement !== null && hostCachingElement !== undefined) {
              var hostCachingInstance = hostCachingElement;
              result.hostCaching = hostCachingInstance;
            }
            
            var diskLabelElement = js2xml.getElement(responseDoc, dataVirtualHardDiskElement, 'DISKLABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (diskLabelElement !== null && diskLabelElement !== undefined) {
              var diskLabelInstance = diskLabelElement;
              result.label = diskLabelInstance;
            }
            
            var diskNameElement = js2xml.getElement(responseDoc, dataVirtualHardDiskElement, 'DISKNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (diskNameElement !== null && diskNameElement !== undefined) {
              var diskNameInstance = diskNameElement;
              result.name = diskNameInstance;
            }
            
            var lunElement = js2xml.getElement(responseDoc, dataVirtualHardDiskElement, 'LUN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (lunElement !== null && lunElement !== undefined && lunElement.length !== 0) {
              var lunInstance = parseInt(lunElement, 10);
              result.logicalUnitNumber = lunInstance;
            }
            
            var logicalDiskSizeInGBElement = js2xml.getElement(responseDoc, dataVirtualHardDiskElement, 'LOGICALDISKSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (logicalDiskSizeInGBElement !== null && logicalDiskSizeInGBElement !== undefined && logicalDiskSizeInGBElement.length !== 0) {
              var logicalDiskSizeInGBInstance = parseInt(logicalDiskSizeInGBElement, 10);
              result.logicalDiskSizeInGB = logicalDiskSizeInGBInstance;
            }
            
            var mediaLinkElement = js2xml.getElement(responseDoc, dataVirtualHardDiskElement, 'MEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (mediaLinkElement !== null && mediaLinkElement !== undefined) {
              var mediaLinkInstance = mediaLinkElement;
              result.mediaLinkUri = mediaLinkInstance;
            }
            
            var iOTypeElement = js2xml.getElement(responseDoc, dataVirtualHardDiskElement, 'IOTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (iOTypeElement !== null && iOTypeElement !== undefined) {
              var iOTypeInstance = iOTypeElement;
              result.iOType = iOTypeInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Get Disk operation retrieves a disk from the user image repository.
   * The disk can be an operating system disk or a data disk.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157178.aspx for
   * more information)
   * 
   * @param {string} name The name of the disk.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineDiskOperations.prototype.getDisk = function(name, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (name === null || name === undefined) {
      return callback(new Error('name cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/disks/';
    url2 = url2 + encodeURIComponent(name);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var diskElement = js2xml.getElement(responseDoc, responseDoc, 'DISK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (diskElement !== null && diskElement !== undefined) {
            var affinityGroupElement = js2xml.getElement(responseDoc, diskElement, 'AFFINITYGROUP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (affinityGroupElement !== null && affinityGroupElement !== undefined) {
              var affinityGroupInstance = affinityGroupElement;
              result.affinityGroup = affinityGroupInstance;
            }
            
            var locationElement = js2xml.getElement(responseDoc, diskElement, 'LOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (locationElement !== null && locationElement !== undefined) {
              var locationInstance = locationElement;
              result.location = locationInstance;
            }
            
            var labelElement = js2xml.getElement(responseDoc, diskElement, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (labelElement !== null && labelElement !== undefined) {
              var labelInstance = labelElement;
              result.label = labelInstance;
            }
            
            var logicalDiskSizeInGBElement = js2xml.getElement(responseDoc, diskElement, 'LOGICALDISKSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (logicalDiskSizeInGBElement !== null && logicalDiskSizeInGBElement !== undefined && logicalDiskSizeInGBElement.length !== 0) {
              var logicalDiskSizeInGBInstance = parseInt(logicalDiskSizeInGBElement, 10);
              result.logicalSizeInGB = logicalDiskSizeInGBInstance;
            }
            
            var mediaLinkElement = js2xml.getElement(responseDoc, diskElement, 'MEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (mediaLinkElement !== null && mediaLinkElement !== undefined) {
              var mediaLinkInstance = mediaLinkElement;
              result.mediaLinkUri = mediaLinkInstance;
            }
            
            var nameElement = js2xml.getElement(responseDoc, diskElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (nameElement !== null && nameElement !== undefined) {
              var nameInstance = nameElement;
              result.name = nameInstance;
            }
            
            var osElement = js2xml.getElement(responseDoc, diskElement, 'OS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (osElement !== null && osElement !== undefined) {
              var osInstance = osElement;
              result.operatingSystemType = osInstance;
            }
            
            var sourceImageNameElement = js2xml.getElement(responseDoc, diskElement, 'SOURCEIMAGENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (sourceImageNameElement !== null && sourceImageNameElement !== undefined) {
              var sourceImageNameInstance = sourceImageNameElement;
              result.sourceImageName = sourceImageNameInstance;
            }
            
            var attachedToElement = js2xml.getElement(responseDoc, diskElement, 'ATTACHEDTO', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (attachedToElement !== null && attachedToElement !== undefined) {
              var attachedToInstance = {};
              result.usageDetails = attachedToInstance;
              
              var hostedServiceNameElement = js2xml.getElement(responseDoc, attachedToElement, 'HOSTEDSERVICENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (hostedServiceNameElement !== null && hostedServiceNameElement !== undefined) {
                var hostedServiceNameInstance = hostedServiceNameElement;
                attachedToInstance.hostedServiceName = hostedServiceNameInstance;
              }
              
              var deploymentNameElement = js2xml.getElement(responseDoc, attachedToElement, 'DEPLOYMENTNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (deploymentNameElement !== null && deploymentNameElement !== undefined) {
                var deploymentNameInstance = deploymentNameElement;
                attachedToInstance.deploymentName = deploymentNameInstance;
              }
              
              var roleNameElement = js2xml.getElement(responseDoc, attachedToElement, 'ROLENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (roleNameElement !== null && roleNameElement !== undefined) {
                var roleNameInstance = roleNameElement;
                attachedToInstance.roleName = roleNameInstance;
              }
            }
            
            var isCorruptedElement = js2xml.getElement(responseDoc, diskElement, 'ISCORRUPTED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (isCorruptedElement !== null && isCorruptedElement !== undefined && isCorruptedElement.length !== 0) {
              var isCorruptedInstance = isCorruptedElement === 'true';
              result.isCorrupted = isCorruptedInstance;
            }
            
            var isPremiumElement = js2xml.getElement(responseDoc, diskElement, 'ISPREMIUM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (isPremiumElement !== null && isPremiumElement !== undefined && isPremiumElement.length !== 0) {
              var isPremiumInstance = isPremiumElement === 'true';
              result.isPremium = isPremiumInstance;
            }
            
            var iOTypeElement = js2xml.getElement(responseDoc, diskElement, 'IOTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (iOTypeElement !== null && iOTypeElement !== undefined) {
              var iOTypeInstance = iOTypeElement;
              result.iOType = iOTypeInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The List Disks operation retrieves a list of the disks in your image
   * repository.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157176.aspx for
   * more information)
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineDiskOperations.prototype.listDisks = function(callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/disks';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { disks: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var disksSequenceElement = js2xml.getElement(responseDoc, responseDoc, 'DISKS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (disksSequenceElement !== null && disksSequenceElement !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, disksSequenceElement, 'DISK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
              var disksElement = js2xml.getElements(responseDoc, disksSequenceElement, 'DISK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
              var diskInstance = {};
              result.disks.push(diskInstance);
              
              var affinityGroupElement = js2xml.getElement(responseDoc, disksElement, 'AFFINITYGROUP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (affinityGroupElement !== null && affinityGroupElement !== undefined) {
                var affinityGroupInstance = affinityGroupElement;
                diskInstance.affinityGroup = affinityGroupInstance;
              }
              
              var locationElement = js2xml.getElement(responseDoc, disksElement, 'LOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (locationElement !== null && locationElement !== undefined) {
                var locationInstance = locationElement;
                diskInstance.location = locationInstance;
              }
              
              var labelElement = js2xml.getElement(responseDoc, disksElement, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (labelElement !== null && labelElement !== undefined) {
                var labelInstance = labelElement;
                diskInstance.label = labelInstance;
              }
              
              var logicalDiskSizeInGBElement = js2xml.getElement(responseDoc, disksElement, 'LOGICALDISKSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (logicalDiskSizeInGBElement !== null && logicalDiskSizeInGBElement !== undefined && logicalDiskSizeInGBElement.length !== 0) {
                var logicalDiskSizeInGBInstance = parseInt(logicalDiskSizeInGBElement, 10);
                diskInstance.logicalSizeInGB = logicalDiskSizeInGBInstance;
              }
              
              var mediaLinkElement = js2xml.getElement(responseDoc, disksElement, 'MEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (mediaLinkElement !== null && mediaLinkElement !== undefined) {
                var mediaLinkInstance = mediaLinkElement;
                diskInstance.mediaLinkUri = mediaLinkInstance;
              }
              
              var nameElement = js2xml.getElement(responseDoc, disksElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (nameElement !== null && nameElement !== undefined) {
                var nameInstance = nameElement;
                diskInstance.name = nameInstance;
              }
              
              var osElement = js2xml.getElement(responseDoc, disksElement, 'OS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (osElement !== null && osElement !== undefined) {
                var osInstance = osElement;
                diskInstance.operatingSystemType = osInstance;
              }
              
              var sourceImageNameElement = js2xml.getElement(responseDoc, disksElement, 'SOURCEIMAGENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (sourceImageNameElement !== null && sourceImageNameElement !== undefined) {
                var sourceImageNameInstance = sourceImageNameElement;
                diskInstance.sourceImageName = sourceImageNameInstance;
              }
              
              var attachedToElement = js2xml.getElement(responseDoc, disksElement, 'ATTACHEDTO', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (attachedToElement !== null && attachedToElement !== undefined) {
                var attachedToInstance = {};
                diskInstance.usageDetails = attachedToInstance;
                
                var hostedServiceNameElement = js2xml.getElement(responseDoc, attachedToElement, 'HOSTEDSERVICENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (hostedServiceNameElement !== null && hostedServiceNameElement !== undefined) {
                  var hostedServiceNameInstance = hostedServiceNameElement;
                  attachedToInstance.hostedServiceName = hostedServiceNameInstance;
                }
                
                var deploymentNameElement = js2xml.getElement(responseDoc, attachedToElement, 'DEPLOYMENTNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (deploymentNameElement !== null && deploymentNameElement !== undefined) {
                  var deploymentNameInstance = deploymentNameElement;
                  attachedToInstance.deploymentName = deploymentNameInstance;
                }
                
                var roleNameElement = js2xml.getElement(responseDoc, attachedToElement, 'ROLENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (roleNameElement !== null && roleNameElement !== undefined) {
                  var roleNameInstance = roleNameElement;
                  attachedToInstance.roleName = roleNameInstance;
                }
              }
              
              var isCorruptedElement = js2xml.getElement(responseDoc, disksElement, 'ISCORRUPTED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (isCorruptedElement !== null && isCorruptedElement !== undefined && isCorruptedElement.length !== 0) {
                var isCorruptedInstance = isCorruptedElement === 'true';
                diskInstance.isCorrupted = isCorruptedInstance;
              }
              
              var isPremiumElement = js2xml.getElement(responseDoc, disksElement, 'ISPREMIUM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (isPremiumElement !== null && isPremiumElement !== undefined && isPremiumElement.length !== 0) {
                var isPremiumInstance = isPremiumElement === 'true';
                diskInstance.isPremium = isPremiumInstance;
              }
              
              var iOTypeElement = js2xml.getElement(responseDoc, disksElement, 'IOTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (iOTypeElement !== null && iOTypeElement !== undefined) {
                var iOTypeInstance = iOTypeElement;
                diskInstance.iOType = iOTypeInstance;
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Update Data Disk operation updates the specified data disk attached to
   * the specified virtual machine.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157190.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of the deployment.
   * 
   * @param {string} roleName The name of the role to add the data disk to.
   * 
   * @param {Number} logicalUnitNumber The logical unit number of the disk.
   * 
   * @param {VirtualMachineDataDiskUpdateParameters} parameters Parameters
   * supplied to the Update Virtual Machine Data Disk operation.
   * 
   * @param {string} parameters.hostCaching Specifies the platform caching
   * behavior of data disk blob for read/write efficiency. The default vault
   * is ReadOnly. Possible values are: None, ReadOnly, or ReadWrite. Warning:
   * Setting this property impacts the consistency of the disk.
   * 
   * @param {string} [parameters.label] Specifies the description of the data
   * disk. When you attach a disk, either by directly referencing a media
   * using the MediaLink element or specifying the target disk size, you can
   * use the DiskLabel element to customize the name property of the target
   * data disk.
   * 
   * @param {string} [parameters.name] Specifies the name of the disk. Azure
   * uses the specified disk to create the data disk for the machine and
   * populates this field with the disk name.
   * 
   * @param {number} [parameters.logicalUnitNumber] Specifies the Logical Unit
   * Number (LUN) for the disk. The LUN specifies the slot in which the data
   * drive appears when mounted for usage by the virtual machine. Valid LUN
   * values are 0 through 15.
   * 
   * @param {number} [parameters.logicalDiskSizeInGB] Specifies the size, in
   * GB, of an empty disk to be attached to the role. The disk can be created
   * as part of disk attach or create VM role call by specifying the value for
   * this property. Azure creates the empty disk based on size preference and
   * attaches the newly created disk to the Role.
   * 
   * @param {string} parameters.mediaLinkUri Specifies the location of the blob
   * in Azure blob store where the media for the disk is located. The blob
   * location must belong to the storage account in the subscription specified
   * by the SubscriptionId value in the operation call. Example:
   * http://example.blob.core.windows.net/disks/mydisk.vhd.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineDiskOperations.prototype.updateDataDisk = function(serviceName, deploymentName, roleName, logicalUnitNumber, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (roleName === null || roleName === undefined) {
      return callback(new Error('roleName cannot be null.'));
    }
    if (logicalUnitNumber === null || logicalUnitNumber === undefined) {
      return callback(new Error('logicalUnitNumber cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.hostCaching === null || parameters.hostCaching === undefined) {
      return callback(new Error('parameters.hostCaching cannot be null.'));
    }
    if (parameters.mediaLinkUri === null || parameters.mediaLinkUri === undefined) {
      return callback(new Error('parameters.mediaLinkUri cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/roles/';
    url2 = url2 + encodeURIComponent(roleName);
    url2 = url2 + '/DataDisks/';
    url2 = url2 + encodeURIComponent(logicalUnitNumber.toString());
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var dataVirtualHardDiskElement = js2xml.createElement('DataVirtualHardDisk', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, dataVirtualHardDiskElement);
    
    var hostCachingElement = js2xml.createElement('HostCaching', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(hostCachingElement, parameters.hostCaching);
    js2xml.addChildElement(dataVirtualHardDiskElement, hostCachingElement);
    
    if (parameters.label !== null && parameters.label !== undefined) {
      var diskLabelElement = js2xml.createElement('DiskLabel', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(diskLabelElement, parameters.label);
      js2xml.addChildElement(dataVirtualHardDiskElement, diskLabelElement);
    }
    
    if (parameters.name !== null && parameters.name !== undefined) {
      var diskNameElement = js2xml.createElement('DiskName', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(diskNameElement, parameters.name);
      js2xml.addChildElement(dataVirtualHardDiskElement, diskNameElement);
    }
    
    if (parameters.logicalUnitNumber !== null && parameters.logicalUnitNumber !== undefined) {
      var lunElement = js2xml.createElement('Lun', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(lunElement, parameters.logicalUnitNumber.toString());
      js2xml.addChildElement(dataVirtualHardDiskElement, lunElement);
    }
    
    if (parameters.logicalDiskSizeInGB !== null && parameters.logicalDiskSizeInGB !== undefined) {
      var logicalDiskSizeInGBElement = js2xml.createElement('LogicalDiskSizeInGB', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(logicalDiskSizeInGBElement, parameters.logicalDiskSizeInGB.toString());
      js2xml.addChildElement(dataVirtualHardDiskElement, logicalDiskSizeInGBElement);
    }
    
    var mediaLinkElement = js2xml.createElement('MediaLink', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(mediaLinkElement, parameters.mediaLinkUri);
    js2xml.addChildElement(dataVirtualHardDiskElement, mediaLinkElement);
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Add Disk operation adds a disk to the user image repository. The disk
   * can be an operating system disk or a data disk.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157178.aspx for
   * more information)
   * 
   * @param {string} name The name of the disk being updated.
   * 
   * @param {VirtualMachineDiskUpdateParameters} parameters Parameters supplied
   * to the Update Virtual Machine Disk operation.
   * 
   * @param {boolean} [parameters.hasOperatingSystem] Specifies whether the
   * disk contains an operating system. Note: Only a disk with an operating
   * system installed can be mounted as OS Drive.
   * 
   * @param {string} [parameters.operatingSystemType] The operating system type
   * of the disk. Possible values are: Linux or Windows.
   * 
   * @param {string} parameters.label Specifies the friendly name of the disk.
   * 
   * @param {string} [parameters.mediaLinkUri] Specifies the location of the
   * blob in Azure storage. The blob location must belong to a storage account
   * in the subscription specified by the SubscriptionId value in the
   * operation call. Example:
   * http://example.blob.core.windows.net/disks/mydisk.vhd.
   * 
   * @param {string} parameters.name Specifies a name for the disk. Azure uses
   * the name to identify the disk when creating virtual machines from the
   * disk.
   * 
   * @param {number} [parameters.resizedSizeInGB] Resizes the underlying blob
   * to the indicated size in GB.To use the ResizedSizeInGB property, the
   * version header should be at least 2014-10-01.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineDiskOperations.prototype.updateDisk = function(name, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (name === null || name === undefined) {
      return callback(new Error('name cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.label === null || parameters.label === undefined) {
      return callback(new Error('parameters.label cannot be null.'));
    }
    if (parameters.name === null || parameters.name === undefined) {
      return callback(new Error('parameters.name cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/disks/';
    url2 = url2 + encodeURIComponent(name);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var diskElement = js2xml.createElement('Disk', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, diskElement);
    
    if (parameters.hasOperatingSystem !== null && parameters.hasOperatingSystem !== undefined) {
      var hasOperatingSystemElement = js2xml.createElement('HasOperatingSystem', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(hasOperatingSystemElement, parameters.hasOperatingSystem.toString());
      js2xml.addChildElement(diskElement, hasOperatingSystemElement);
    }
    
    if (parameters.operatingSystemType !== null && parameters.operatingSystemType !== undefined) {
      var osElement = js2xml.createElement('OS', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(osElement, parameters.operatingSystemType);
      js2xml.addChildElement(diskElement, osElement);
    }
    
    var labelElement = js2xml.createElement('Label', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(labelElement, parameters.label);
    js2xml.addChildElement(diskElement, labelElement);
    
    if (parameters.mediaLinkUri !== null && parameters.mediaLinkUri !== undefined) {
      var mediaLinkElement = js2xml.createElement('MediaLink', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(mediaLinkElement, parameters.mediaLinkUri);
      js2xml.addChildElement(diskElement, mediaLinkElement);
    }
    
    var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(nameElement, parameters.name);
    js2xml.addChildElement(diskElement, nameElement);
    
    if (parameters.resizedSizeInGB !== null && parameters.resizedSizeInGB !== undefined) {
      var resizedSizeInGBElement = js2xml.createElement('ResizedSizeInGB', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(resizedSizeInGBElement, parameters.resizedSizeInGB.toString());
      js2xml.addChildElement(diskElement, resizedSizeInGBElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var diskElement2 = js2xml.getElement(responseDoc, responseDoc, 'DISK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (diskElement2 !== null && diskElement2 !== undefined) {
            var osElement2 = js2xml.getElement(responseDoc, diskElement2, 'OS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (osElement2 !== null && osElement2 !== undefined) {
              var osInstance = osElement2;
              result.operatingSystem = osInstance;
            }
            
            var labelElement2 = js2xml.getElement(responseDoc, diskElement2, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (labelElement2 !== null && labelElement2 !== undefined) {
              var labelInstance = labelElement2;
              result.label = labelInstance;
            }
            
            var affinityGroupElement = js2xml.getElement(responseDoc, diskElement2, 'AFFINITYGROUP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (affinityGroupElement !== null && affinityGroupElement !== undefined) {
              var affinityGroupInstance = affinityGroupElement;
              result.affinityGroup = affinityGroupInstance;
            }
            
            var locationElement = js2xml.getElement(responseDoc, diskElement2, 'LOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (locationElement !== null && locationElement !== undefined) {
              var locationInstance = locationElement;
              result.location = locationInstance;
            }
            
            var logicalDiskSizeInGBElement = js2xml.getElement(responseDoc, diskElement2, 'LOGICALDISKSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (logicalDiskSizeInGBElement !== null && logicalDiskSizeInGBElement !== undefined && logicalDiskSizeInGBElement.length !== 0) {
              var logicalDiskSizeInGBInstance = parseInt(logicalDiskSizeInGBElement, 10);
              result.logicalSizeInGB = logicalDiskSizeInGBInstance;
            }
            
            var mediaLinkElement2 = js2xml.getElement(responseDoc, diskElement2, 'MEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (mediaLinkElement2 !== null && mediaLinkElement2 !== undefined) {
              var mediaLinkInstance = mediaLinkElement2;
              result.mediaLinkUri = mediaLinkInstance;
            }
            
            var nameElement2 = js2xml.getElement(responseDoc, diskElement2, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (nameElement2 !== null && nameElement2 !== undefined) {
              var nameInstance = nameElement2;
              result.name = nameInstance;
            }
            
            var isPremiumElement = js2xml.getElement(responseDoc, diskElement2, 'ISPREMIUM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (isPremiumElement !== null && isPremiumElement !== undefined && isPremiumElement.length !== 0) {
              var isPremiumInstance = isPremiumElement === 'true';
              result.isPremium = isPremiumInstance;
            }
            
            var iOTypeElement = js2xml.getElement(responseDoc, diskElement2, 'IOTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (iOTypeElement !== null && iOTypeElement !== undefined) {
              var iOTypeInstance = iOTypeElement;
              result.iOType = iOTypeInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Add Disk operation adds a disk to the user image repository. The disk
   * can be an operating system disk or a data disk.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157178.aspx for
   * more information)
   * 
   * @param {string} name The name of the disk being updated.
   * 
   * @param {VirtualMachineDiskUpdateParameters} parameters Parameters supplied
   * to the Update Virtual Machine Disk operation.
   * 
   * @param {boolean} [parameters.hasOperatingSystem] Specifies whether the
   * disk contains an operating system. Note: Only a disk with an operating
   * system installed can be mounted as OS Drive.
   * 
   * @param {string} [parameters.operatingSystemType] The operating system type
   * of the disk. Possible values are: Linux or Windows.
   * 
   * @param {string} parameters.label Specifies the friendly name of the disk.
   * 
   * @param {string} [parameters.mediaLinkUri] Specifies the location of the
   * blob in Azure storage. The blob location must belong to a storage account
   * in the subscription specified by the SubscriptionId value in the
   * operation call. Example:
   * http://example.blob.core.windows.net/disks/mydisk.vhd.
   * 
   * @param {string} parameters.name Specifies a name for the disk. Azure uses
   * the name to identify the disk when creating virtual machines from the
   * disk.
   * 
   * @param {number} [parameters.resizedSizeInGB] Resizes the underlying blob
   * to the indicated size in GB.To use the ResizedSizeInGB property, the
   * version header should be at least 2014-10-01.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineDiskOperations.prototype.updateDiskSize = function(name, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachineDisks.beginUpdatingDisk(name, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  return VirtualMachineDiskOperations;
})();

var VirtualMachineExtensionOperations = ( /** @lends VirtualMachineExtensionOperations */ function() {
  /**
   * @class
   * The Service Management API includes operations for managing the virtual
   * machine extensions in your subscription.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157206.aspx for
   * more information)
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [ComputeManagementClient] {@link
   * ComputeManagementClient~ComputeManagementClient}.
   * See [virtualMachineExtensions] {@link
   * ComputeManagementClient~ComputeManagementClient#virtualMachineExtensions}.
   * Initializes a new instance of the VirtualMachineExtensionOperations class.
   * @constructor
   * 
   * @param {ComputeManagementClient} client Reference to the service client.
   */
  function VirtualMachineExtensionOperations(client) {
    this.client = client;
  }
  
  /**
   * The List Resource Extensions operation lists the resource extensions that
   * are available to add to a Virtual Machine. In Azure, a process can run as
   * a resource extension of a Virtual Machine. For example, Remote Desktop
   * Access or the Azure Diagnostics Agent can run as resource extensions to
   * the Virtual Machine.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn495441.aspx for
   * more information)
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineExtensionOperations.prototype.list = function(callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/resourceextensions';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { resourceExtensions: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var resourceExtensionsSequenceElement = js2xml.getElement(responseDoc, responseDoc, 'RESOURCEEXTENSIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (resourceExtensionsSequenceElement !== null && resourceExtensionsSequenceElement !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, resourceExtensionsSequenceElement, 'RESOURCEEXTENSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
              var resourceExtensionsElement = js2xml.getElements(responseDoc, resourceExtensionsSequenceElement, 'RESOURCEEXTENSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
              var resourceExtensionInstance = {};
              result.resourceExtensions.push(resourceExtensionInstance);
              
              var publisherElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'PUBLISHER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (publisherElement !== null && publisherElement !== undefined) {
                var publisherInstance = publisherElement;
                resourceExtensionInstance.publisher = publisherInstance;
              }
              
              var nameElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (nameElement !== null && nameElement !== undefined) {
                var nameInstance = nameElement;
                resourceExtensionInstance.name = nameInstance;
              }
              
              var versionElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'VERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (versionElement !== null && versionElement !== undefined) {
                var versionInstance = versionElement;
                resourceExtensionInstance.version = versionInstance;
              }
              
              var labelElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (labelElement !== null && labelElement !== undefined) {
                var labelInstance = labelElement;
                resourceExtensionInstance.label = labelInstance;
              }
              
              var descriptionElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'DESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (descriptionElement !== null && descriptionElement !== undefined) {
                var descriptionInstance = descriptionElement;
                resourceExtensionInstance.description = descriptionInstance;
              }
              
              var publicConfigurationSchemaElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'PUBLICCONFIGURATIONSCHEMA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (publicConfigurationSchemaElement !== null && publicConfigurationSchemaElement !== undefined) {
                var publicConfigurationSchemaInstance = new Buffer(publicConfigurationSchemaElement, 'base64').toString('utf8');
                resourceExtensionInstance.publicConfigurationSchema = publicConfigurationSchemaInstance;
              }
              
              var privateConfigurationSchemaElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'PRIVATECONFIGURATIONSCHEMA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (privateConfigurationSchemaElement !== null && privateConfigurationSchemaElement !== undefined) {
                var privateConfigurationSchemaInstance = new Buffer(privateConfigurationSchemaElement, 'base64').toString('utf8');
                resourceExtensionInstance.privateConfigurationSchema = privateConfigurationSchemaInstance;
              }
              
              var sampleConfigElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'SAMPLECONFIG', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (sampleConfigElement !== null && sampleConfigElement !== undefined) {
                var sampleConfigInstance = new Buffer(sampleConfigElement, 'base64').toString('utf8');
                resourceExtensionInstance.sampleConfig = sampleConfigInstance;
              }
              
              var replicationCompletedElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'REPLICATIONCOMPLETED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (replicationCompletedElement !== null && replicationCompletedElement !== undefined && replicationCompletedElement.length !== 0) {
                var replicationCompletedInstance = replicationCompletedElement === 'true';
                resourceExtensionInstance.replicationCompleted = replicationCompletedInstance;
              }
              
              var eulaElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'EULA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (eulaElement !== null && eulaElement !== undefined) {
                var eulaInstance = eulaElement;
                resourceExtensionInstance.eula = eulaInstance;
              }
              
              var privacyUriElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'PRIVACYURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (privacyUriElement !== null && privacyUriElement !== undefined) {
                var privacyUriInstance = privacyUriElement;
                resourceExtensionInstance.privacyUri = privacyUriInstance;
              }
              
              var homepageUriElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'HOMEPAGEURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (homepageUriElement !== null && homepageUriElement !== undefined) {
                var homepageUriInstance = homepageUriElement;
                resourceExtensionInstance.homepageUri = homepageUriInstance;
              }
              
              var isJsonExtensionElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'ISJSONEXTENSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (isJsonExtensionElement !== null && isJsonExtensionElement !== undefined && isJsonExtensionElement.length !== 0) {
                var isJsonExtensionInstance = isJsonExtensionElement === 'true';
                resourceExtensionInstance.isJsonExtension = isJsonExtensionInstance;
              }
              
              var isInternalExtensionElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'ISINTERNALEXTENSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (isInternalExtensionElement !== null && isInternalExtensionElement !== undefined && isInternalExtensionElement.length !== 0) {
                var isInternalExtensionInstance = isInternalExtensionElement === 'true';
                resourceExtensionInstance.isInternalExtension = isInternalExtensionInstance;
              }
              
              var disallowMajorVersionUpgradeElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'DISALLOWMAJORVERSIONUPGRADE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (disallowMajorVersionUpgradeElement !== null && disallowMajorVersionUpgradeElement !== undefined && disallowMajorVersionUpgradeElement.length !== 0) {
                var disallowMajorVersionUpgradeInstance = disallowMajorVersionUpgradeElement === 'true';
                resourceExtensionInstance.disallowMajorVersionUpgrade = disallowMajorVersionUpgradeInstance;
              }
              
              var supportedOSElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'SUPPORTEDOS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (supportedOSElement !== null && supportedOSElement !== undefined) {
                var supportedOSInstance = supportedOSElement;
                resourceExtensionInstance.supportedOS = supportedOSInstance;
              }
              
              var companyNameElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'COMPANYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (companyNameElement !== null && companyNameElement !== undefined) {
                var companyNameInstance = companyNameElement;
                resourceExtensionInstance.companyName = companyNameInstance;
              }
              
              var publishedDateElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'PUBLISHEDDATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (publishedDateElement !== null && publishedDateElement !== undefined && publishedDateElement.length !== 0) {
                var publishedDateInstance = new Date(publishedDateElement);
                resourceExtensionInstance.publishedDate = publishedDateInstance;
              }
              
              var regionsElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'REGIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (regionsElement !== null && regionsElement !== undefined) {
                var regionsInstance = regionsElement;
                resourceExtensionInstance.regions = regionsInstance;
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The List Resource Extension Versions operation lists the versions of a
   * resource extension that are available to add to a Virtual Machine. In
   * Azure, a process can run as a resource extension of a Virtual Machine.
   * For example, Remote Desktop Access or the Azure Diagnostics Agent can run
   * as resource extensions to the Virtual Machine.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn495440.aspx for
   * more information)
   * 
   * @param {string} publisherName The name of the publisher.
   * 
   * @param {string} extensionName The name of the extension.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineExtensionOperations.prototype.listVersions = function(publisherName, extensionName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (publisherName === null || publisherName === undefined) {
      return callback(new Error('publisherName cannot be null.'));
    }
    if (extensionName === null || extensionName === undefined) {
      return callback(new Error('extensionName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/resourceextensions/';
    url2 = url2 + encodeURIComponent(publisherName);
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(extensionName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { resourceExtensions: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var resourceExtensionsSequenceElement = js2xml.getElement(responseDoc, responseDoc, 'RESOURCEEXTENSIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (resourceExtensionsSequenceElement !== null && resourceExtensionsSequenceElement !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, resourceExtensionsSequenceElement, 'RESOURCEEXTENSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
              var resourceExtensionsElement = js2xml.getElements(responseDoc, resourceExtensionsSequenceElement, 'RESOURCEEXTENSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
              var resourceExtensionInstance = {};
              result.resourceExtensions.push(resourceExtensionInstance);
              
              var publisherElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'PUBLISHER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (publisherElement !== null && publisherElement !== undefined) {
                var publisherInstance = publisherElement;
                resourceExtensionInstance.publisher = publisherInstance;
              }
              
              var nameElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (nameElement !== null && nameElement !== undefined) {
                var nameInstance = nameElement;
                resourceExtensionInstance.name = nameInstance;
              }
              
              var versionElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'VERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (versionElement !== null && versionElement !== undefined) {
                var versionInstance = versionElement;
                resourceExtensionInstance.version = versionInstance;
              }
              
              var labelElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (labelElement !== null && labelElement !== undefined) {
                var labelInstance = labelElement;
                resourceExtensionInstance.label = labelInstance;
              }
              
              var descriptionElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'DESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (descriptionElement !== null && descriptionElement !== undefined) {
                var descriptionInstance = descriptionElement;
                resourceExtensionInstance.description = descriptionInstance;
              }
              
              var publicConfigurationSchemaElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'PUBLICCONFIGURATIONSCHEMA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (publicConfigurationSchemaElement !== null && publicConfigurationSchemaElement !== undefined) {
                var publicConfigurationSchemaInstance = new Buffer(publicConfigurationSchemaElement, 'base64').toString('utf8');
                resourceExtensionInstance.publicConfigurationSchema = publicConfigurationSchemaInstance;
              }
              
              var privateConfigurationSchemaElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'PRIVATECONFIGURATIONSCHEMA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (privateConfigurationSchemaElement !== null && privateConfigurationSchemaElement !== undefined) {
                var privateConfigurationSchemaInstance = new Buffer(privateConfigurationSchemaElement, 'base64').toString('utf8');
                resourceExtensionInstance.privateConfigurationSchema = privateConfigurationSchemaInstance;
              }
              
              var sampleConfigElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'SAMPLECONFIG', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (sampleConfigElement !== null && sampleConfigElement !== undefined) {
                var sampleConfigInstance = new Buffer(sampleConfigElement, 'base64').toString('utf8');
                resourceExtensionInstance.sampleConfig = sampleConfigInstance;
              }
              
              var replicationCompletedElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'REPLICATIONCOMPLETED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (replicationCompletedElement !== null && replicationCompletedElement !== undefined && replicationCompletedElement.length !== 0) {
                var replicationCompletedInstance = replicationCompletedElement === 'true';
                resourceExtensionInstance.replicationCompleted = replicationCompletedInstance;
              }
              
              var eulaElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'EULA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (eulaElement !== null && eulaElement !== undefined) {
                var eulaInstance = eulaElement;
                resourceExtensionInstance.eula = eulaInstance;
              }
              
              var privacyUriElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'PRIVACYURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (privacyUriElement !== null && privacyUriElement !== undefined) {
                var privacyUriInstance = privacyUriElement;
                resourceExtensionInstance.privacyUri = privacyUriInstance;
              }
              
              var homepageUriElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'HOMEPAGEURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (homepageUriElement !== null && homepageUriElement !== undefined) {
                var homepageUriInstance = homepageUriElement;
                resourceExtensionInstance.homepageUri = homepageUriInstance;
              }
              
              var isJsonExtensionElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'ISJSONEXTENSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (isJsonExtensionElement !== null && isJsonExtensionElement !== undefined && isJsonExtensionElement.length !== 0) {
                var isJsonExtensionInstance = isJsonExtensionElement === 'true';
                resourceExtensionInstance.isJsonExtension = isJsonExtensionInstance;
              }
              
              var isInternalExtensionElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'ISINTERNALEXTENSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (isInternalExtensionElement !== null && isInternalExtensionElement !== undefined && isInternalExtensionElement.length !== 0) {
                var isInternalExtensionInstance = isInternalExtensionElement === 'true';
                resourceExtensionInstance.isInternalExtension = isInternalExtensionInstance;
              }
              
              var disallowMajorVersionUpgradeElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'DISALLOWMAJORVERSIONUPGRADE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (disallowMajorVersionUpgradeElement !== null && disallowMajorVersionUpgradeElement !== undefined && disallowMajorVersionUpgradeElement.length !== 0) {
                var disallowMajorVersionUpgradeInstance = disallowMajorVersionUpgradeElement === 'true';
                resourceExtensionInstance.disallowMajorVersionUpgrade = disallowMajorVersionUpgradeInstance;
              }
              
              var supportedOSElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'SUPPORTEDOS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (supportedOSElement !== null && supportedOSElement !== undefined) {
                var supportedOSInstance = supportedOSElement;
                resourceExtensionInstance.supportedOS = supportedOSInstance;
              }
              
              var companyNameElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'COMPANYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (companyNameElement !== null && companyNameElement !== undefined) {
                var companyNameInstance = companyNameElement;
                resourceExtensionInstance.companyName = companyNameInstance;
              }
              
              var publishedDateElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'PUBLISHEDDATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (publishedDateElement !== null && publishedDateElement !== undefined && publishedDateElement.length !== 0) {
                var publishedDateInstance = new Date(publishedDateElement);
                resourceExtensionInstance.publishedDate = publishedDateInstance;
              }
              
              var regionsElement = js2xml.getElement(responseDoc, resourceExtensionsElement, 'REGIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (regionsElement !== null && regionsElement !== undefined) {
                var regionsInstance = regionsElement;
                resourceExtensionInstance.regions = regionsInstance;
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return VirtualMachineExtensionOperations;
})();

var VirtualMachineOperations = ( /** @lends VirtualMachineOperations */ function() {
  /**
   * @class
   * The Service Management API includes operations for managing the virtual
   * machines in your subscription.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157206.aspx for
   * more information)
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [ComputeManagementClient] {@link
   * ComputeManagementClient~ComputeManagementClient}.
   * See [virtualMachines] {@link
   * ComputeManagementClient~ComputeManagementClient#virtualMachines}.
   * Initializes a new instance of the VirtualMachineOperations class.
   * @constructor
   * 
   * @param {ComputeManagementClient} client Reference to the service client.
   */
  function VirtualMachineOperations(client) {
    this.client = client;
  }
  
  /**
   * The Begin Capturing Role operation creates a copy of the operating system
   * virtual hard disk (VHD) that is deployed in the virtual machine, saves
   * the VHD copy in the same storage location as the operating system VHD,
   * and registers the copy as an image in your image gallery. From the
   * captured image, you can create additional customized virtual machines.
   * For more information about images and disks, see Manage Disks and Images
   * at http://msdn.microsoft.com/en-us/library/windowsazure/jj672979.aspx.
   * For more information about capturing images, see How to Capture an Image
   * of a Virtual Machine Running Windows Server 2008 R2 at
   * http://www.windowsazure.com/en-us/documentation/articles/virtual-machines-capture-image-windows-server/
   * or How to Capture an Image of a Virtual Machine Running Linux at
   * http://www.windowsazure.com/en-us/documentation/articles/virtual-machines-linux-capture-image/.
   * (see http://msdn.microsoft.com/en-us/library/windowsazure/jj157201.aspx
   * for more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {string} virtualMachineName The name of the virtual machine to
   * restart.
   * 
   * @param {VirtualMachineCaptureOSImageParameters} parameters Parameters
   * supplied to the Begin Capturing Virtual Machine operation.
   * 
   * @param {PostCaptureAction} parameters.postCaptureAction Specifies the
   * action that is performed after the capture operation finishes. Possible
   * values are: Delete - this value causes the virtual machine to be deleted
   * after the image has been captured; or Reprovision - this value causes the
   * virtual machine to be redeployed after the image is captured by using the
   * specified information in ProvisioningConfiguration.
   * 
   * @param {ConfigurationSet} [parameters.provisioningConfiguration] Provides
   * information to be used to redeploy the virtual machine after the image
   * has been captured. This element is only used when the PostCaptureAction
   * is set to Reprovision.
   * 
   * @param {string}
   * [parameters.provisioningConfiguration.configurationSetType] Specifies the
   * configuration type for the configuration set.
   * 
   * @param {array} [parameters.provisioningConfiguration.inputEndpoints]
   * Contains a collection of external endpoints for the virtual machine. This
   * element is only used with the NetworkConfigurationSet type.
   * 
   * @param {array} [parameters.provisioningConfiguration.subnetNames] The list
   * of Virtual Network subnet names that the deployment belongs to. This
   * element is only used with the NetworkConfigurationSet type.
   * 
   * @param {string}
   * [parameters.provisioningConfiguration.staticVirtualNetworkIPAddress]
   * Specifies a Customer Address, i.e. an IP address assigned to a VM in a
   * VNet's SubNet. For example: 10.0.0.4.
   * 
   * @param {array} [parameters.provisioningConfiguration.publicIPs] Optional.
   * A set of public IPs. Currently, only one additional public IP per role is
   * supported in an IaaS deployment. The IP address is in addition to the
   * default VIP for the deployment.
   * 
   * @param {array} [parameters.provisioningConfiguration.networkInterfaces]
   * 
   * @param {string}
   * [parameters.provisioningConfiguration.networkSecurityGroup] Gets or sets
   * the Network Security Group associated with this role. Optional
   * 
   * @param {string} [parameters.provisioningConfiguration.iPForwarding] Gets
   * or sets the IP Forwarding status for this role. Optional
   * 
   * @param {string} [parameters.provisioningConfiguration.computerName]
   * Specifies the computer name for the virtual machine. If the computer name
   * is not specified, a name is created based on the name of the role.
   * Computer names must be 1 to 15 characters in length. This element is only
   * used with the WindowsProvisioningConfiguration set.
   * 
   * @param {string} [parameters.provisioningConfiguration.adminPassword]
   * Specifies the string representing the administrator password to use for
   * the virtual machine. If the VM will be created from a 'Specialized' VM
   * image, the password is not required.
   * 
   * @param {boolean}
   * [parameters.provisioningConfiguration.resetPasswordOnFirstLogon]
   * Specifies whether password should be reset the first time the
   * administrator logs in.
   * 
   * @param {boolean}
   * [parameters.provisioningConfiguration.enableAutomaticUpdates] Specifies
   * whether automatic updates are enabled for the virtual machine. This
   * element is only used with the WindowsProvisioningConfiguration set. The
   * default value is false.
   * 
   * @param {string} [parameters.provisioningConfiguration.timeZone] Specifies
   * the time zone for the virtual machine. This element is only used with the
   * WindowsProvisioningConfiguration set. For a complete list of supported
   * time zone entries, you can refer to the values listed in the registry
   * entry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
   * NT\CurrentVersion\Time Zones on a computer running Windows 7, Windows
   * Server 2008, and Windows Server 2008 R2 or you can use the tzutil
   * command-line tool to list the valid time. The tzutil tool is installed by
   * default on Windows 7, Windows Server 2008, and Windows Server 2008 R2.
   * 
   * @param {DomainJoinSettings}
   * [parameters.provisioningConfiguration.domainJoin] Contains properties
   * that specify a domain to which the virtual machine will be joined. This
   * element is only used with the WindowsProvisioningConfiguration set.
   * 
   * @param {DomainJoinCredentials}
   * [parameters.provisioningConfiguration.domainJoin.credentials] Specifies
   * the values to use to join the virtual machine to the domain.
   * 
   * @param {string}
   * [parameters.provisioningConfiguration.domainJoin.credentials.domain]
   * Specifies the name of the domain used to authenticate an account. The
   * value is a fully qualified DNS domain. If the domains name is not
   * specified, Username must specify the user principal name (UPN) format
   * (user@fully-qualified-DNS-domain) or the
   * fully-qualified-DNS-domain\username format. Example: example.com.
   * 
   * @param {string}
   * [parameters.provisioningConfiguration.domainJoin.credentials.userName]
   * Specifies a user name in the domain that can be used to join the domain.
   * 
   * @param {string}
   * [parameters.provisioningConfiguration.domainJoin.credentials.password]
   * Specifies the password to use to join the domain.
   * 
   * @param {string}
   * [parameters.provisioningConfiguration.domainJoin.domainToJoin] Specifies
   * the domain to join.
   * 
   * @param {string}
   * [parameters.provisioningConfiguration.domainJoin.ldapMachineObjectOU]
   * Specifies the Lightweight Directory Access Protocol (LDAP) X
   * 500-distinguished name of the organizational unit (OU) in which the
   * computer account is created. This account is in Active Directory on a
   * domain controller in the domain to which the computer is being joined.
   * Example: OU=MyOu,OU=MyParentOu,DC=example.com,DC=MyCompany,DC=com.
   * 
   * @param {DomainJoinProvisioning}
   * [parameters.provisioningConfiguration.domainJoin.provisioning] Additional
   * information for domain join provisioning.
   * 
   * @param {string}
   * [parameters.provisioningConfiguration.domainJoin.provisioning.accountData]
   * The account info for joining the domain.
   * 
   * @param {array}
   * [parameters.provisioningConfiguration.storedCertificateSettings] Contains
   * a list of service certificates with which to provision to the new role.
   * This element is only used with the WindowsProvisioningConfiguration set.
   * 
   * @param {WindowsRemoteManagementSettings}
   * [parameters.provisioningConfiguration.windowsRemoteManagement] Configures
   * the Windows Remote Management service on the virtual machine, which
   * enables remote Windows PowerShell.
   * 
   * @param {array}
   * [parameters.provisioningConfiguration.windowsRemoteManagement.listeners]
   * Contains a collection of information for enabling remote Windows
   * PowerShell.
   * 
   * @param {string} [parameters.provisioningConfiguration.adminUserName]
   * Specifies the name that is used to rename the default administrator
   * account. If the VM will be created from a 'Specialized' VM image, the
   * user name is not required.
   * 
   * @param {AdditionalUnattendContentSettings}
   * [parameters.provisioningConfiguration.additionalUnattendContent]
   * Specifies additional base-64 encoded XML formatted information that can
   * be included in the Unattend.xml file, which is used by Windows Setup.
   * 
   * @param {array}
   * [parameters.provisioningConfiguration.additionalUnattendContent.unattendPasses]
   * Specifies the unattend passes
   * 
   * @param {string} [parameters.provisioningConfiguration.hostName] Specifies
   * the host name for the VM. Host names are ASCII character strings 1 to 64
   * characters in length. This element is only used with the
   * LinuxProvisioningConfiguration set.
   * 
   * @param {string} [parameters.provisioningConfiguration.userName] Specifies
   * the name of a user to be created in the sudoer group of the virtual
   * machine. User names are ASCII character strings 1 to 32 characters in
   * length. This element is only used with the LinuxProvisioningConfiguration
   * set.
   * 
   * @param {string} [parameters.provisioningConfiguration.userPassword]
   * Specifies the password for user name. Passwords are ASCII character
   * strings 6 to 72 characters in length. This element is only used with the
   * LinuxProvisioningConfiguration set.
   * 
   * @param {boolean}
   * [parameters.provisioningConfiguration.disableSshPasswordAuthentication]
   * Specifies whether or not SSH authentication is disabled for the password.
   * This element is only used with the LinuxProvisioningConfiguration set. By
   * default this value is set to true.
   * 
   * @param {SshSettings} [parameters.provisioningConfiguration.sshSettings]
   * Specifies the SSH public keys and key pairs to populate in the image
   * during provisioning. This element is only used with the
   * LinuxProvisioningConfiguration set.
   * 
   * @param {array}
   * [parameters.provisioningConfiguration.sshSettings.publicKeys] Specifies
   * the collection of SSH public keys.
   * 
   * @param {array} [parameters.provisioningConfiguration.sshSettings.keyPairs]
   * Specifies the collection of SSH key pairs.
   * 
   * @param {string} [parameters.provisioningConfiguration.customData]
   * Optional. Provides base64 encoded custom data to be passed to VM.
   * 
   * @param {string} parameters.targetImageLabel Specifies the friendly name of
   * the captured image. This is the value that appears in the Name column for
   * the image in the Azure Management Portal.
   * 
   * @param {string} parameters.targetImageName Specifies the image name of the
   * captured image.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.beginCapturingOSImage = function(serviceName, deploymentName, virtualMachineName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (virtualMachineName === null || virtualMachineName === undefined) {
      return callback(new Error('virtualMachineName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.postCaptureAction === null || parameters.postCaptureAction === undefined) {
      return callback(new Error('parameters.postCaptureAction cannot be null.'));
    }
    if (parameters.provisioningConfiguration !== null && parameters.provisioningConfiguration !== undefined) {
      if (parameters.provisioningConfiguration.additionalUnattendContent !== null && parameters.provisioningConfiguration.additionalUnattendContent !== undefined) {
        if (parameters.provisioningConfiguration.additionalUnattendContent.unattendPasses !== null && parameters.provisioningConfiguration.additionalUnattendContent.unattendPasses !== undefined) {
          for (var loweredIndex1 = 0; loweredIndex1 < parameters.provisioningConfiguration.additionalUnattendContent.unattendPasses.length; loweredIndex1 = loweredIndex1 + 1) {
            var unattendPassesParameterItem = parameters.provisioningConfiguration.additionalUnattendContent.unattendPasses[loweredIndex1];
            if (unattendPassesParameterItem.passName === null || unattendPassesParameterItem.passName === undefined) {
              return callback(new Error('parameters.provisioningConfiguration.additionalUnattendContent.unattendPasses.passName cannot be null.'));
            }
            if (unattendPassesParameterItem.unattendComponents !== null && unattendPassesParameterItem.unattendComponents !== undefined) {
              for (var loweredIndex2 = 0; loweredIndex2 < unattendPassesParameterItem.unattendComponents.length; loweredIndex2 = loweredIndex2 + 1) {
                var unattendComponentsParameterItem = unattendPassesParameterItem.unattendComponents[loweredIndex2];
                if (unattendComponentsParameterItem.componentName === null || unattendComponentsParameterItem.componentName === undefined) {
                  return callback(new Error('parameters.provisioningConfiguration.additionalUnattendContent.unattendPasses.unattendComponents.componentName cannot be null.'));
                }
                if (unattendComponentsParameterItem.unattendComponentSettings !== null && unattendComponentsParameterItem.unattendComponentSettings !== undefined) {
                  for (var loweredIndex3 = 0; loweredIndex3 < unattendComponentsParameterItem.unattendComponentSettings.length; loweredIndex3 = loweredIndex3 + 1) {
                    var unattendComponentSettingsParameterItem = unattendComponentsParameterItem.unattendComponentSettings[loweredIndex3];
                    if (unattendComponentSettingsParameterItem.settingName === null || unattendComponentSettingsParameterItem.settingName === undefined) {
                      return callback(new Error('parameters.provisioningConfiguration.additionalUnattendContent.unattendPasses.unattendComponents.unattendComponentSettings.settingName cannot be null.'));
                    }
                  }
                }
              }
            }
          }
        }
      }
      if (parameters.provisioningConfiguration.domainJoin !== null && parameters.provisioningConfiguration.domainJoin !== undefined) {
        if (parameters.provisioningConfiguration.domainJoin.credentials !== null && parameters.provisioningConfiguration.domainJoin.credentials !== undefined) {
          if (parameters.provisioningConfiguration.domainJoin.credentials.password === null || parameters.provisioningConfiguration.domainJoin.credentials.password === undefined) {
            return callback(new Error('parameters.provisioningConfiguration.domainJoin.credentials.password cannot be null.'));
          }
          if (parameters.provisioningConfiguration.domainJoin.credentials.userName === null || parameters.provisioningConfiguration.domainJoin.credentials.userName === undefined) {
            return callback(new Error('parameters.provisioningConfiguration.domainJoin.credentials.userName cannot be null.'));
          }
        }
      }
      if (parameters.provisioningConfiguration.hostName !== null && parameters.provisioningConfiguration.hostName !== undefined && parameters.provisioningConfiguration.hostName.length < 1) {
        return callback(new Error('parameters.provisioningConfiguration.hostName is outside the valid range.'));
      }
      if (parameters.provisioningConfiguration.hostName !== null && parameters.provisioningConfiguration.hostName !== undefined && parameters.provisioningConfiguration.hostName.length > 64) {
        return callback(new Error('parameters.provisioningConfiguration.hostName is outside the valid range.'));
      }
      if (parameters.provisioningConfiguration.sshSettings !== null && parameters.provisioningConfiguration.sshSettings !== undefined) {
        if (parameters.provisioningConfiguration.sshSettings.keyPairs !== null && parameters.provisioningConfiguration.sshSettings.keyPairs !== undefined) {
          for (var loweredIndex4 = 0; loweredIndex4 < parameters.provisioningConfiguration.sshSettings.keyPairs.length; loweredIndex4 = loweredIndex4 + 1) {
            var keyPairsParameterItem = parameters.provisioningConfiguration.sshSettings.keyPairs[loweredIndex4];
            if (keyPairsParameterItem.fingerprint === null || keyPairsParameterItem.fingerprint === undefined) {
              return callback(new Error('parameters.provisioningConfiguration.sshSettings.keyPairs.fingerprint cannot be null.'));
            }
            if (keyPairsParameterItem.path === null || keyPairsParameterItem.path === undefined) {
              return callback(new Error('parameters.provisioningConfiguration.sshSettings.keyPairs.path cannot be null.'));
            }
          }
        }
        if (parameters.provisioningConfiguration.sshSettings.publicKeys !== null && parameters.provisioningConfiguration.sshSettings.publicKeys !== undefined) {
          for (var loweredIndex5 = 0; loweredIndex5 < parameters.provisioningConfiguration.sshSettings.publicKeys.length; loweredIndex5 = loweredIndex5 + 1) {
            var publicKeysParameterItem = parameters.provisioningConfiguration.sshSettings.publicKeys[loweredIndex5];
            if (publicKeysParameterItem.fingerprint === null || publicKeysParameterItem.fingerprint === undefined) {
              return callback(new Error('parameters.provisioningConfiguration.sshSettings.publicKeys.fingerprint cannot be null.'));
            }
            if (publicKeysParameterItem.path === null || publicKeysParameterItem.path === undefined) {
              return callback(new Error('parameters.provisioningConfiguration.sshSettings.publicKeys.path cannot be null.'));
            }
          }
        }
      }
      if (parameters.provisioningConfiguration.storedCertificateSettings !== null && parameters.provisioningConfiguration.storedCertificateSettings !== undefined) {
        for (var loweredIndex6 = 0; loweredIndex6 < parameters.provisioningConfiguration.storedCertificateSettings.length; loweredIndex6 = loweredIndex6 + 1) {
          var storedCertificateSettingsParameterItem = parameters.provisioningConfiguration.storedCertificateSettings[loweredIndex6];
          if (storedCertificateSettingsParameterItem.storeName === null || storedCertificateSettingsParameterItem.storeName === undefined) {
            return callback(new Error('parameters.provisioningConfiguration.storedCertificateSettings.storeName cannot be null.'));
          }
          if (storedCertificateSettingsParameterItem.thumbprint === null || storedCertificateSettingsParameterItem.thumbprint === undefined) {
            return callback(new Error('parameters.provisioningConfiguration.storedCertificateSettings.thumbprint cannot be null.'));
          }
        }
      }
      if (parameters.provisioningConfiguration.userName !== null && parameters.provisioningConfiguration.userName !== undefined && parameters.provisioningConfiguration.userName.length < 1) {
        return callback(new Error('parameters.provisioningConfiguration.userName is outside the valid range.'));
      }
      if (parameters.provisioningConfiguration.userName !== null && parameters.provisioningConfiguration.userName !== undefined && parameters.provisioningConfiguration.userName.length > 32) {
        return callback(new Error('parameters.provisioningConfiguration.userName is outside the valid range.'));
      }
      if (parameters.provisioningConfiguration.userPassword !== null && parameters.provisioningConfiguration.userPassword !== undefined && parameters.provisioningConfiguration.userPassword.length < 6) {
        return callback(new Error('parameters.provisioningConfiguration.userPassword is outside the valid range.'));
      }
      if (parameters.provisioningConfiguration.userPassword !== null && parameters.provisioningConfiguration.userPassword !== undefined && parameters.provisioningConfiguration.userPassword.length > 72) {
        return callback(new Error('parameters.provisioningConfiguration.userPassword is outside the valid range.'));
      }
      if (parameters.provisioningConfiguration.windowsRemoteManagement !== null && parameters.provisioningConfiguration.windowsRemoteManagement !== undefined) {
        if (parameters.provisioningConfiguration.windowsRemoteManagement.listeners !== null && parameters.provisioningConfiguration.windowsRemoteManagement.listeners !== undefined) {
          for (var loweredIndex7 = 0; loweredIndex7 < parameters.provisioningConfiguration.windowsRemoteManagement.listeners.length; loweredIndex7 = loweredIndex7 + 1) {
            var listenersParameterItem = parameters.provisioningConfiguration.windowsRemoteManagement.listeners[loweredIndex7];
            if (listenersParameterItem.listenerType === null || listenersParameterItem.listenerType === undefined) {
              return callback(new Error('parameters.provisioningConfiguration.windowsRemoteManagement.listeners.listenerType cannot be null.'));
            }
          }
        }
      }
    }
    if (parameters.targetImageLabel === null || parameters.targetImageLabel === undefined) {
      return callback(new Error('parameters.targetImageLabel cannot be null.'));
    }
    if (parameters.targetImageName === null || parameters.targetImageName === undefined) {
      return callback(new Error('parameters.targetImageName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/roleinstances/';
    url2 = url2 + encodeURIComponent(virtualMachineName);
    url2 = url2 + '/Operations';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var captureRoleOperationElement = js2xml.createElement('CaptureRoleOperation', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, captureRoleOperationElement);
    
    var operationTypeElement = js2xml.createElement('OperationType', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(operationTypeElement, 'CaptureRoleOperation');
    js2xml.addChildElement(captureRoleOperationElement, operationTypeElement);
    
    var postCaptureActionElement = js2xml.createElement('PostCaptureAction', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(postCaptureActionElement, parameters.postCaptureAction !== null && parameters.postCaptureAction !== undefined ? parameters.postCaptureAction.toString() : 'Delete');
    js2xml.addChildElement(captureRoleOperationElement, postCaptureActionElement);
    
    if (parameters.provisioningConfiguration !== null && parameters.provisioningConfiguration !== undefined) {
      var provisioningConfigurationElement = js2xml.createElement('ProvisioningConfiguration', 'http://schemas.microsoft.com/windowsazure');
      js2xml.addChildElement(captureRoleOperationElement, provisioningConfigurationElement);
      
      if (parameters.provisioningConfiguration.configurationSetType !== null && parameters.provisioningConfiguration.configurationSetType !== undefined) {
        var configurationSetTypeElement = js2xml.createElement('ConfigurationSetType', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(configurationSetTypeElement, parameters.provisioningConfiguration.configurationSetType);
        js2xml.addChildElement(provisioningConfigurationElement, configurationSetTypeElement);
      }
      
      if (parameters.provisioningConfiguration.inputEndpoints !== null && parameters.provisioningConfiguration.inputEndpoints !== undefined) {
        var inputEndpointsSequenceElement = js2xml.createElement('InputEndpoints', 'http://schemas.microsoft.com/windowsazure');
        for (var loweredIndex8 = 0; loweredIndex8 < parameters.provisioningConfiguration.inputEndpoints.length; loweredIndex8 = loweredIndex8 + 1) {
          var inputEndpointsItem = parameters.provisioningConfiguration.inputEndpoints[loweredIndex8];
          var inputEndpointElement = js2xml.createElement('InputEndpoint', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(inputEndpointsSequenceElement, inputEndpointElement);
          
          if (inputEndpointsItem.loadBalancedEndpointSetName !== null && inputEndpointsItem.loadBalancedEndpointSetName !== undefined) {
            var loadBalancedEndpointSetNameElement = js2xml.createElement('LoadBalancedEndpointSetName', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(loadBalancedEndpointSetNameElement, inputEndpointsItem.loadBalancedEndpointSetName);
            js2xml.addChildElement(inputEndpointElement, loadBalancedEndpointSetNameElement);
          }
          
          if (inputEndpointsItem.localPort !== null && inputEndpointsItem.localPort !== undefined) {
            var localPortElement = js2xml.createElement('LocalPort', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(localPortElement, inputEndpointsItem.localPort.toString());
            js2xml.addChildElement(inputEndpointElement, localPortElement);
          }
          
          if (inputEndpointsItem.name !== null && inputEndpointsItem.name !== undefined) {
            var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(nameElement, inputEndpointsItem.name);
            js2xml.addChildElement(inputEndpointElement, nameElement);
          }
          
          if (inputEndpointsItem.port !== null && inputEndpointsItem.port !== undefined) {
            var portElement = js2xml.createElement('Port', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(portElement, inputEndpointsItem.port.toString());
            js2xml.addChildElement(inputEndpointElement, portElement);
          }
          
          if (inputEndpointsItem.loadBalancerProbe !== null && inputEndpointsItem.loadBalancerProbe !== undefined) {
            var loadBalancerProbeElement = js2xml.createElement('LoadBalancerProbe', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(inputEndpointElement, loadBalancerProbeElement);
            
            if (inputEndpointsItem.loadBalancerProbe.path !== null && inputEndpointsItem.loadBalancerProbe.path !== undefined) {
              var pathElement = js2xml.createElement('Path', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(pathElement, inputEndpointsItem.loadBalancerProbe.path);
              js2xml.addChildElement(loadBalancerProbeElement, pathElement);
            }
            
            if (inputEndpointsItem.loadBalancerProbe.port !== null && inputEndpointsItem.loadBalancerProbe.port !== undefined) {
              var portElement2 = js2xml.createElement('Port', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(portElement2, inputEndpointsItem.loadBalancerProbe.port.toString());
              js2xml.addChildElement(loadBalancerProbeElement, portElement2);
            }
            
            if (inputEndpointsItem.loadBalancerProbe.protocol !== null && inputEndpointsItem.loadBalancerProbe.protocol !== undefined) {
              var protocolElement = js2xml.createElement('Protocol', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(protocolElement, inputEndpointsItem.loadBalancerProbe.protocol !== null && inputEndpointsItem.loadBalancerProbe.protocol !== undefined ? inputEndpointsItem.loadBalancerProbe.protocol.toString() : 'Tcp');
              js2xml.addChildElement(loadBalancerProbeElement, protocolElement);
            }
            
            if (inputEndpointsItem.loadBalancerProbe.intervalInSeconds !== null && inputEndpointsItem.loadBalancerProbe.intervalInSeconds !== undefined) {
              var intervalInSecondsElement = js2xml.createElement('IntervalInSeconds', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(intervalInSecondsElement, inputEndpointsItem.loadBalancerProbe.intervalInSeconds.toString());
              js2xml.addChildElement(loadBalancerProbeElement, intervalInSecondsElement);
            }
            
            if (inputEndpointsItem.loadBalancerProbe.timeoutInSeconds !== null && inputEndpointsItem.loadBalancerProbe.timeoutInSeconds !== undefined) {
              var timeoutInSecondsElement = js2xml.createElement('TimeoutInSeconds', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(timeoutInSecondsElement, inputEndpointsItem.loadBalancerProbe.timeoutInSeconds.toString());
              js2xml.addChildElement(loadBalancerProbeElement, timeoutInSecondsElement);
            }
          }
          
          if (inputEndpointsItem.protocol !== null && inputEndpointsItem.protocol !== undefined) {
            var protocolElement2 = js2xml.createElement('Protocol', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(protocolElement2, inputEndpointsItem.protocol);
            js2xml.addChildElement(inputEndpointElement, protocolElement2);
          }
          
          if (inputEndpointsItem.virtualIPAddress !== null && inputEndpointsItem.virtualIPAddress !== undefined) {
            var vipElement = js2xml.createElement('Vip', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(vipElement, inputEndpointsItem.virtualIPAddress);
            js2xml.addChildElement(inputEndpointElement, vipElement);
          }
          
          if (inputEndpointsItem.enableDirectServerReturn !== null && inputEndpointsItem.enableDirectServerReturn !== undefined) {
            var enableDirectServerReturnElement = js2xml.createElement('EnableDirectServerReturn', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(enableDirectServerReturnElement, inputEndpointsItem.enableDirectServerReturn.toString());
            js2xml.addChildElement(inputEndpointElement, enableDirectServerReturnElement);
          }
          
          if (inputEndpointsItem.loadBalancerName !== null && inputEndpointsItem.loadBalancerName !== undefined) {
            var loadBalancerNameElement = js2xml.createElement('LoadBalancerName', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(loadBalancerNameElement, inputEndpointsItem.loadBalancerName);
            js2xml.addChildElement(inputEndpointElement, loadBalancerNameElement);
          }
          
          if (inputEndpointsItem.endpointAcl !== null && inputEndpointsItem.endpointAcl !== undefined) {
            var endpointAclElement = js2xml.createElement('EndpointAcl', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(inputEndpointElement, endpointAclElement);
            
            if (inputEndpointsItem.endpointAcl.rules !== null && inputEndpointsItem.endpointAcl.rules !== undefined) {
              var rulesSequenceElement = js2xml.createElement('Rules', 'http://schemas.microsoft.com/windowsazure');
              for (var loweredIndex9 = 0; loweredIndex9 < inputEndpointsItem.endpointAcl.rules.length; loweredIndex9 = loweredIndex9 + 1) {
                var rulesItem = inputEndpointsItem.endpointAcl.rules[loweredIndex9];
                var ruleElement = js2xml.createElement('Rule', 'http://schemas.microsoft.com/windowsazure');
                js2xml.addChildElement(rulesSequenceElement, ruleElement);
                
                if (rulesItem.order !== null && rulesItem.order !== undefined) {
                  var orderElement = js2xml.createElement('Order', 'http://schemas.microsoft.com/windowsazure');
                  js2xml.setElementValue(orderElement, rulesItem.order.toString());
                  js2xml.addChildElement(ruleElement, orderElement);
                }
                
                if (rulesItem.action !== null && rulesItem.action !== undefined) {
                  var actionElement = js2xml.createElement('Action', 'http://schemas.microsoft.com/windowsazure');
                  js2xml.setElementValue(actionElement, rulesItem.action);
                  js2xml.addChildElement(ruleElement, actionElement);
                }
                
                if (rulesItem.remoteSubnet !== null && rulesItem.remoteSubnet !== undefined) {
                  var remoteSubnetElement = js2xml.createElement('RemoteSubnet', 'http://schemas.microsoft.com/windowsazure');
                  js2xml.setElementValue(remoteSubnetElement, rulesItem.remoteSubnet);
                  js2xml.addChildElement(ruleElement, remoteSubnetElement);
                }
                
                if (rulesItem.description !== null && rulesItem.description !== undefined) {
                  var descriptionElement = js2xml.createElement('Description', 'http://schemas.microsoft.com/windowsazure');
                  js2xml.setElementValue(descriptionElement, rulesItem.description);
                  js2xml.addChildElement(ruleElement, descriptionElement);
                }
              }
              js2xml.addChildElement(endpointAclElement, rulesSequenceElement);
            }
          }
          
          if (inputEndpointsItem.idleTimeoutInMinutes !== null && inputEndpointsItem.idleTimeoutInMinutes !== undefined) {
            var idleTimeoutInMinutesElement = js2xml.createElement('IdleTimeoutInMinutes', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(idleTimeoutInMinutesElement, inputEndpointsItem.idleTimeoutInMinutes.toString());
            js2xml.addChildElement(inputEndpointElement, idleTimeoutInMinutesElement);
          }
          
          if (inputEndpointsItem.loadBalancerDistribution !== null && inputEndpointsItem.loadBalancerDistribution !== undefined) {
            var loadBalancerDistributionElement = js2xml.createElement('LoadBalancerDistribution', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(loadBalancerDistributionElement, inputEndpointsItem.loadBalancerDistribution);
            js2xml.addChildElement(inputEndpointElement, loadBalancerDistributionElement);
          }
          
          if (inputEndpointsItem.virtualIPName !== null && inputEndpointsItem.virtualIPName !== undefined) {
            var virtualIPNameElement = js2xml.createElement('VirtualIPName', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(virtualIPNameElement, inputEndpointsItem.virtualIPName);
            js2xml.addChildElement(inputEndpointElement, virtualIPNameElement);
          }
        }
        js2xml.addChildElement(provisioningConfigurationElement, inputEndpointsSequenceElement);
      }
      
      if (parameters.provisioningConfiguration.subnetNames !== null && parameters.provisioningConfiguration.subnetNames !== undefined) {
        var subnetNamesSequenceElement = js2xml.createElement('SubnetNames', 'http://schemas.microsoft.com/windowsazure');
        for (var loweredIndex10 = 0; loweredIndex10 < parameters.provisioningConfiguration.subnetNames.length; loweredIndex10 = loweredIndex10 + 1) {
          var subnetNamesItem = parameters.provisioningConfiguration.subnetNames[loweredIndex10];
          var subnetNamesItemElement = js2xml.createElement('SubnetName', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(subnetNamesItemElement, subnetNamesItem);
          js2xml.addChildElement(subnetNamesSequenceElement, subnetNamesItemElement);
        }
        js2xml.addChildElement(provisioningConfigurationElement, subnetNamesSequenceElement);
      }
      
      if (parameters.provisioningConfiguration.staticVirtualNetworkIPAddress !== null && parameters.provisioningConfiguration.staticVirtualNetworkIPAddress !== undefined) {
        var staticVirtualNetworkIPAddressElement = js2xml.createElement('StaticVirtualNetworkIPAddress', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(staticVirtualNetworkIPAddressElement, parameters.provisioningConfiguration.staticVirtualNetworkIPAddress);
        js2xml.addChildElement(provisioningConfigurationElement, staticVirtualNetworkIPAddressElement);
      }
      
      if (parameters.provisioningConfiguration.publicIPs !== null && parameters.provisioningConfiguration.publicIPs !== undefined) {
        var publicIPsSequenceElement = js2xml.createElement('PublicIPs', 'http://schemas.microsoft.com/windowsazure');
        for (var loweredIndex11 = 0; loweredIndex11 < parameters.provisioningConfiguration.publicIPs.length; loweredIndex11 = loweredIndex11 + 1) {
          var publicIPsItem = parameters.provisioningConfiguration.publicIPs[loweredIndex11];
          var publicIPElement = js2xml.createElement('PublicIP', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(publicIPsSequenceElement, publicIPElement);
          
          if (publicIPsItem.name !== null && publicIPsItem.name !== undefined) {
            var nameElement2 = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(nameElement2, publicIPsItem.name);
            js2xml.addChildElement(publicIPElement, nameElement2);
          }
          
          if (publicIPsItem.idleTimeoutInMinutes !== null && publicIPsItem.idleTimeoutInMinutes !== undefined) {
            var idleTimeoutInMinutesElement2 = js2xml.createElement('IdleTimeoutInMinutes', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(idleTimeoutInMinutesElement2, publicIPsItem.idleTimeoutInMinutes.toString());
            js2xml.addChildElement(publicIPElement, idleTimeoutInMinutesElement2);
          }
          
          if (publicIPsItem.domainNameLabel !== null && publicIPsItem.domainNameLabel !== undefined) {
            var domainNameLabelElement = js2xml.createElement('DomainNameLabel', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(domainNameLabelElement, publicIPsItem.domainNameLabel);
            js2xml.addChildElement(publicIPElement, domainNameLabelElement);
          }
        }
        js2xml.addChildElement(provisioningConfigurationElement, publicIPsSequenceElement);
      }
      
      if (parameters.provisioningConfiguration.networkInterfaces !== null && parameters.provisioningConfiguration.networkInterfaces !== undefined) {
        var networkInterfacesSequenceElement = js2xml.createElement('NetworkInterfaces', 'http://schemas.microsoft.com/windowsazure');
        for (var loweredIndex12 = 0; loweredIndex12 < parameters.provisioningConfiguration.networkInterfaces.length; loweredIndex12 = loweredIndex12 + 1) {
          var networkInterfacesItem = parameters.provisioningConfiguration.networkInterfaces[loweredIndex12];
          var networkInterfaceElement = js2xml.createElement('NetworkInterface', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(networkInterfacesSequenceElement, networkInterfaceElement);
          
          if (networkInterfacesItem.name !== null && networkInterfacesItem.name !== undefined) {
            var nameElement3 = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(nameElement3, networkInterfacesItem.name);
            js2xml.addChildElement(networkInterfaceElement, nameElement3);
          }
          
          if (networkInterfacesItem.iPConfigurations !== null && networkInterfacesItem.iPConfigurations !== undefined) {
            var iPConfigurationsSequenceElement = js2xml.createElement('IPConfigurations', 'http://schemas.microsoft.com/windowsazure');
            for (var loweredIndex13 = 0; loweredIndex13 < networkInterfacesItem.iPConfigurations.length; loweredIndex13 = loweredIndex13 + 1) {
              var iPConfigurationsItem = networkInterfacesItem.iPConfigurations[loweredIndex13];
              var iPConfigurationElement = js2xml.createElement('IPConfiguration', 'http://schemas.microsoft.com/windowsazure');
              js2xml.addChildElement(iPConfigurationsSequenceElement, iPConfigurationElement);
              
              if (iPConfigurationsItem.subnetName !== null && iPConfigurationsItem.subnetName !== undefined) {
                var subnetNameElement = js2xml.createElement('SubnetName', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(subnetNameElement, iPConfigurationsItem.subnetName);
                js2xml.addChildElement(iPConfigurationElement, subnetNameElement);
              }
              
              if (iPConfigurationsItem.staticVirtualNetworkIPAddress !== null && iPConfigurationsItem.staticVirtualNetworkIPAddress !== undefined) {
                var staticVirtualNetworkIPAddressElement2 = js2xml.createElement('StaticVirtualNetworkIPAddress', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(staticVirtualNetworkIPAddressElement2, iPConfigurationsItem.staticVirtualNetworkIPAddress);
                js2xml.addChildElement(iPConfigurationElement, staticVirtualNetworkIPAddressElement2);
              }
            }
            js2xml.addChildElement(networkInterfaceElement, iPConfigurationsSequenceElement);
          }
          
          if (networkInterfacesItem.networkSecurityGroup !== null && networkInterfacesItem.networkSecurityGroup !== undefined) {
            var networkSecurityGroupElement = js2xml.createElement('NetworkSecurityGroup', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(networkSecurityGroupElement, networkInterfacesItem.networkSecurityGroup);
            js2xml.addChildElement(networkInterfaceElement, networkSecurityGroupElement);
          }
          
          if (networkInterfacesItem.iPForwarding !== null && networkInterfacesItem.iPForwarding !== undefined) {
            var iPForwardingElement = js2xml.createElement('IPForwarding', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(iPForwardingElement, networkInterfacesItem.iPForwarding);
            js2xml.addChildElement(networkInterfaceElement, iPForwardingElement);
          }
        }
        js2xml.addChildElement(provisioningConfigurationElement, networkInterfacesSequenceElement);
      }
      
      if (parameters.provisioningConfiguration.networkSecurityGroup !== null && parameters.provisioningConfiguration.networkSecurityGroup !== undefined) {
        var networkSecurityGroupElement2 = js2xml.createElement('NetworkSecurityGroup', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(networkSecurityGroupElement2, parameters.provisioningConfiguration.networkSecurityGroup);
        js2xml.addChildElement(provisioningConfigurationElement, networkSecurityGroupElement2);
      }
      
      if (parameters.provisioningConfiguration.iPForwarding !== null && parameters.provisioningConfiguration.iPForwarding !== undefined) {
        var iPForwardingElement2 = js2xml.createElement('IPForwarding', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(iPForwardingElement2, parameters.provisioningConfiguration.iPForwarding);
        js2xml.addChildElement(provisioningConfigurationElement, iPForwardingElement2);
      }
      
      if (parameters.provisioningConfiguration.computerName !== null && parameters.provisioningConfiguration.computerName !== undefined) {
        var computerNameElement = js2xml.createElement('ComputerName', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(computerNameElement, parameters.provisioningConfiguration.computerName);
        js2xml.addChildElement(provisioningConfigurationElement, computerNameElement);
      }
      
      if (parameters.provisioningConfiguration.adminPassword !== null && parameters.provisioningConfiguration.adminPassword !== undefined) {
        var adminPasswordElement = js2xml.createElement('AdminPassword', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(adminPasswordElement, parameters.provisioningConfiguration.adminPassword);
        js2xml.addChildElement(provisioningConfigurationElement, adminPasswordElement);
      }
      
      if (parameters.provisioningConfiguration.resetPasswordOnFirstLogon !== null && parameters.provisioningConfiguration.resetPasswordOnFirstLogon !== undefined) {
        var resetPasswordOnFirstLogonElement = js2xml.createElement('ResetPasswordOnFirstLogon', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(resetPasswordOnFirstLogonElement, parameters.provisioningConfiguration.resetPasswordOnFirstLogon.toString());
        js2xml.addChildElement(provisioningConfigurationElement, resetPasswordOnFirstLogonElement);
      }
      
      if (parameters.provisioningConfiguration.enableAutomaticUpdates !== null && parameters.provisioningConfiguration.enableAutomaticUpdates !== undefined) {
        var enableAutomaticUpdatesElement = js2xml.createElement('EnableAutomaticUpdates', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(enableAutomaticUpdatesElement, parameters.provisioningConfiguration.enableAutomaticUpdates.toString());
        js2xml.addChildElement(provisioningConfigurationElement, enableAutomaticUpdatesElement);
      }
      
      if (parameters.provisioningConfiguration.timeZone !== null && parameters.provisioningConfiguration.timeZone !== undefined) {
        var timeZoneElement = js2xml.createElement('TimeZone', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(timeZoneElement, parameters.provisioningConfiguration.timeZone);
        js2xml.addChildElement(provisioningConfigurationElement, timeZoneElement);
      }
      
      if (parameters.provisioningConfiguration.domainJoin !== null && parameters.provisioningConfiguration.domainJoin !== undefined) {
        var domainJoinElement = js2xml.createElement('DomainJoin', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(provisioningConfigurationElement, domainJoinElement);
        
        if (parameters.provisioningConfiguration.domainJoin.credentials !== null && parameters.provisioningConfiguration.domainJoin.credentials !== undefined) {
          var credentialsElement = js2xml.createElement('Credentials', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(domainJoinElement, credentialsElement);
          
          if (parameters.provisioningConfiguration.domainJoin.credentials.domain !== null && parameters.provisioningConfiguration.domainJoin.credentials.domain !== undefined) {
            var domainElement = js2xml.createElement('Domain', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(domainElement, parameters.provisioningConfiguration.domainJoin.credentials.domain);
            js2xml.addChildElement(credentialsElement, domainElement);
          }
          
          var usernameElement = js2xml.createElement('Username', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(usernameElement, parameters.provisioningConfiguration.domainJoin.credentials.userName);
          js2xml.addChildElement(credentialsElement, usernameElement);
          
          var passwordElement = js2xml.createElement('Password', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(passwordElement, parameters.provisioningConfiguration.domainJoin.credentials.password);
          js2xml.addChildElement(credentialsElement, passwordElement);
        }
        
        if (parameters.provisioningConfiguration.domainJoin.domainToJoin !== null && parameters.provisioningConfiguration.domainJoin.domainToJoin !== undefined) {
          var joinDomainElement = js2xml.createElement('JoinDomain', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(joinDomainElement, parameters.provisioningConfiguration.domainJoin.domainToJoin);
          js2xml.addChildElement(domainJoinElement, joinDomainElement);
        }
        
        if (parameters.provisioningConfiguration.domainJoin.ldapMachineObjectOU !== null && parameters.provisioningConfiguration.domainJoin.ldapMachineObjectOU !== undefined) {
          var machineObjectOUElement = js2xml.createElement('MachineObjectOU', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(machineObjectOUElement, parameters.provisioningConfiguration.domainJoin.ldapMachineObjectOU);
          js2xml.addChildElement(domainJoinElement, machineObjectOUElement);
        }
        
        if (parameters.provisioningConfiguration.domainJoin.provisioning !== null && parameters.provisioningConfiguration.domainJoin.provisioning !== undefined) {
          var provisioningElement = js2xml.createElement('Provisioning', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(domainJoinElement, provisioningElement);
          
          if (parameters.provisioningConfiguration.domainJoin.provisioning.accountData !== null && parameters.provisioningConfiguration.domainJoin.provisioning.accountData !== undefined) {
            var accountDataElement = js2xml.createElement('AccountData', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(accountDataElement, parameters.provisioningConfiguration.domainJoin.provisioning.accountData);
            js2xml.addChildElement(provisioningElement, accountDataElement);
          }
        }
      }
      
      if (parameters.provisioningConfiguration.storedCertificateSettings !== null && parameters.provisioningConfiguration.storedCertificateSettings !== undefined) {
        var storedCertificateSettingsSequenceElement = js2xml.createElement('StoredCertificateSettings', 'http://schemas.microsoft.com/windowsazure');
        for (var loweredIndex14 = 0; loweredIndex14 < parameters.provisioningConfiguration.storedCertificateSettings.length; loweredIndex14 = loweredIndex14 + 1) {
          var storedCertificateSettingsItem = parameters.provisioningConfiguration.storedCertificateSettings[loweredIndex14];
          var certificateSettingElement = js2xml.createElement('CertificateSetting', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(storedCertificateSettingsSequenceElement, certificateSettingElement);
          
          var storeLocationElement = js2xml.createElement('StoreLocation', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(storeLocationElement, 'LocalMachine');
          js2xml.addChildElement(certificateSettingElement, storeLocationElement);
          
          var storeNameElement = js2xml.createElement('StoreName', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(storeNameElement, storedCertificateSettingsItem.storeName);
          js2xml.addChildElement(certificateSettingElement, storeNameElement);
          
          var thumbprintElement = js2xml.createElement('Thumbprint', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(thumbprintElement, storedCertificateSettingsItem.thumbprint);
          js2xml.addChildElement(certificateSettingElement, thumbprintElement);
        }
        js2xml.addChildElement(provisioningConfigurationElement, storedCertificateSettingsSequenceElement);
      }
      
      if (parameters.provisioningConfiguration.windowsRemoteManagement !== null && parameters.provisioningConfiguration.windowsRemoteManagement !== undefined) {
        var winRMElement = js2xml.createElement('WinRM', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(provisioningConfigurationElement, winRMElement);
        
        if (parameters.provisioningConfiguration.windowsRemoteManagement.listeners !== null && parameters.provisioningConfiguration.windowsRemoteManagement.listeners !== undefined) {
          var listenersSequenceElement = js2xml.createElement('Listeners', 'http://schemas.microsoft.com/windowsazure');
          for (var loweredIndex15 = 0; loweredIndex15 < parameters.provisioningConfiguration.windowsRemoteManagement.listeners.length; loweredIndex15 = loweredIndex15 + 1) {
            var listenersItem = parameters.provisioningConfiguration.windowsRemoteManagement.listeners[loweredIndex15];
            var listenerElement = js2xml.createElement('Listener', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(listenersSequenceElement, listenerElement);
            
            if (listenersItem.certificateThumbprint !== null && listenersItem.certificateThumbprint !== undefined) {
              var certificateThumbprintElement = js2xml.createElement('CertificateThumbprint', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(certificateThumbprintElement, listenersItem.certificateThumbprint);
              js2xml.addChildElement(listenerElement, certificateThumbprintElement);
            }
            
            var protocolElement3 = js2xml.createElement('Protocol', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(protocolElement3, listenersItem.listenerType !== null && listenersItem.listenerType !== undefined ? listenersItem.listenerType.toString() : 'Http');
            js2xml.addChildElement(listenerElement, protocolElement3);
          }
          js2xml.addChildElement(winRMElement, listenersSequenceElement);
        }
      }
      
      if (parameters.provisioningConfiguration.adminUserName !== null && parameters.provisioningConfiguration.adminUserName !== undefined) {
        var adminUsernameElement = js2xml.createElement('AdminUsername', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(adminUsernameElement, parameters.provisioningConfiguration.adminUserName);
        js2xml.addChildElement(provisioningConfigurationElement, adminUsernameElement);
      }
      
      if (parameters.provisioningConfiguration.additionalUnattendContent !== null && parameters.provisioningConfiguration.additionalUnattendContent !== undefined) {
        var additionalUnattendContentElement = js2xml.createElement('AdditionalUnattendContent', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(provisioningConfigurationElement, additionalUnattendContentElement);
        
        if (parameters.provisioningConfiguration.additionalUnattendContent.unattendPasses !== null && parameters.provisioningConfiguration.additionalUnattendContent.unattendPasses !== undefined) {
          var passesSequenceElement = js2xml.createElement('Passes', 'http://schemas.microsoft.com/windowsazure');
          for (var loweredIndex16 = 0; loweredIndex16 < parameters.provisioningConfiguration.additionalUnattendContent.unattendPasses.length; loweredIndex16 = loweredIndex16 + 1) {
            var passesItem = parameters.provisioningConfiguration.additionalUnattendContent.unattendPasses[loweredIndex16];
            var unattendPassElement = js2xml.createElement('UnattendPass', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(passesSequenceElement, unattendPassElement);
            
            var passNameElement = js2xml.createElement('PassName', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(passNameElement, passesItem.passName);
            js2xml.addChildElement(unattendPassElement, passNameElement);
            
            if (passesItem.unattendComponents !== null && passesItem.unattendComponents !== undefined) {
              var componentsSequenceElement = js2xml.createElement('Components', 'http://schemas.microsoft.com/windowsazure');
              for (var loweredIndex17 = 0; loweredIndex17 < passesItem.unattendComponents.length; loweredIndex17 = loweredIndex17 + 1) {
                var componentsItem = passesItem.unattendComponents[loweredIndex17];
                var unattendComponentElement = js2xml.createElement('UnattendComponent', 'http://schemas.microsoft.com/windowsazure');
                js2xml.addChildElement(componentsSequenceElement, unattendComponentElement);
                
                var componentNameElement = js2xml.createElement('ComponentName', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(componentNameElement, componentsItem.componentName);
                js2xml.addChildElement(unattendComponentElement, componentNameElement);
                
                if (componentsItem.unattendComponentSettings !== null && componentsItem.unattendComponentSettings !== undefined) {
                  var componentSettingsSequenceElement = js2xml.createElement('ComponentSettings', 'http://schemas.microsoft.com/windowsazure');
                  for (var loweredIndex18 = 0; loweredIndex18 < componentsItem.unattendComponentSettings.length; loweredIndex18 = loweredIndex18 + 1) {
                    var componentSettingsItem = componentsItem.unattendComponentSettings[loweredIndex18];
                    var componentSettingElement = js2xml.createElement('ComponentSetting', 'http://schemas.microsoft.com/windowsazure');
                    js2xml.addChildElement(componentSettingsSequenceElement, componentSettingElement);
                    
                    var settingNameElement = js2xml.createElement('SettingName', 'http://schemas.microsoft.com/windowsazure');
                    js2xml.setElementValue(settingNameElement, componentSettingsItem.settingName);
                    js2xml.addChildElement(componentSettingElement, settingNameElement);
                    
                    if (componentSettingsItem.content !== null && componentSettingsItem.content !== undefined) {
                      var contentElement = js2xml.createElement('Content', 'http://schemas.microsoft.com/windowsazure');
                      js2xml.setElementValue(contentElement, new Buffer(componentSettingsItem.content).toString('base64'));
                      js2xml.addChildElement(componentSettingElement, contentElement);
                    }
                  }
                  js2xml.addChildElement(unattendComponentElement, componentSettingsSequenceElement);
                }
              }
              js2xml.addChildElement(unattendPassElement, componentsSequenceElement);
            }
          }
          js2xml.addChildElement(additionalUnattendContentElement, passesSequenceElement);
        }
      }
      
      if (parameters.provisioningConfiguration.hostName !== null && parameters.provisioningConfiguration.hostName !== undefined) {
        var hostNameElement = js2xml.createElement('HostName', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(hostNameElement, parameters.provisioningConfiguration.hostName);
        js2xml.addChildElement(provisioningConfigurationElement, hostNameElement);
      }
      
      if (parameters.provisioningConfiguration.userName !== null && parameters.provisioningConfiguration.userName !== undefined) {
        var userNameElement = js2xml.createElement('UserName', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(userNameElement, parameters.provisioningConfiguration.userName);
        js2xml.addChildElement(provisioningConfigurationElement, userNameElement);
      }
      
      if (parameters.provisioningConfiguration.userPassword !== null && parameters.provisioningConfiguration.userPassword !== undefined) {
        var userPasswordElement = js2xml.createElement('UserPassword', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(userPasswordElement, parameters.provisioningConfiguration.userPassword);
        js2xml.addChildElement(provisioningConfigurationElement, userPasswordElement);
      }
      
      if (parameters.provisioningConfiguration.disableSshPasswordAuthentication !== null && parameters.provisioningConfiguration.disableSshPasswordAuthentication !== undefined) {
        var disableSshPasswordAuthenticationElement = js2xml.createElement('DisableSshPasswordAuthentication', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(disableSshPasswordAuthenticationElement, parameters.provisioningConfiguration.disableSshPasswordAuthentication.toString());
        js2xml.addChildElement(provisioningConfigurationElement, disableSshPasswordAuthenticationElement);
      }
      
      if (parameters.provisioningConfiguration.sshSettings !== null && parameters.provisioningConfiguration.sshSettings !== undefined) {
        var sSHElement = js2xml.createElement('SSH', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(provisioningConfigurationElement, sSHElement);
        
        if (parameters.provisioningConfiguration.sshSettings.publicKeys !== null && parameters.provisioningConfiguration.sshSettings.publicKeys !== undefined) {
          var publicKeysSequenceElement = js2xml.createElement('PublicKeys', 'http://schemas.microsoft.com/windowsazure');
          for (var loweredIndex19 = 0; loweredIndex19 < parameters.provisioningConfiguration.sshSettings.publicKeys.length; loweredIndex19 = loweredIndex19 + 1) {
            var publicKeysItem = parameters.provisioningConfiguration.sshSettings.publicKeys[loweredIndex19];
            var publicKeyElement = js2xml.createElement('PublicKey', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(publicKeysSequenceElement, publicKeyElement);
            
            var fingerprintElement = js2xml.createElement('Fingerprint', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(fingerprintElement, publicKeysItem.fingerprint);
            js2xml.addChildElement(publicKeyElement, fingerprintElement);
            
            var pathElement2 = js2xml.createElement('Path', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(pathElement2, publicKeysItem.path);
            js2xml.addChildElement(publicKeyElement, pathElement2);
          }
          js2xml.addChildElement(sSHElement, publicKeysSequenceElement);
        }
        
        if (parameters.provisioningConfiguration.sshSettings.keyPairs !== null && parameters.provisioningConfiguration.sshSettings.keyPairs !== undefined) {
          var keyPairsSequenceElement = js2xml.createElement('KeyPairs', 'http://schemas.microsoft.com/windowsazure');
          for (var loweredIndex20 = 0; loweredIndex20 < parameters.provisioningConfiguration.sshSettings.keyPairs.length; loweredIndex20 = loweredIndex20 + 1) {
            var keyPairsItem = parameters.provisioningConfiguration.sshSettings.keyPairs[loweredIndex20];
            var keyPairElement = js2xml.createElement('KeyPair', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(keyPairsSequenceElement, keyPairElement);
            
            var fingerprintElement2 = js2xml.createElement('Fingerprint', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(fingerprintElement2, keyPairsItem.fingerprint);
            js2xml.addChildElement(keyPairElement, fingerprintElement2);
            
            var pathElement3 = js2xml.createElement('Path', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(pathElement3, keyPairsItem.path);
            js2xml.addChildElement(keyPairElement, pathElement3);
          }
          js2xml.addChildElement(sSHElement, keyPairsSequenceElement);
        }
      }
      
      if (parameters.provisioningConfiguration.customData !== null && parameters.provisioningConfiguration.customData !== undefined) {
        var customDataElement = js2xml.createElement('CustomData', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(customDataElement, parameters.provisioningConfiguration.customData);
        js2xml.addChildElement(provisioningConfigurationElement, customDataElement);
      }
    }
    
    var targetImageLabelElement = js2xml.createElement('TargetImageLabel', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(targetImageLabelElement, parameters.targetImageLabel);
    js2xml.addChildElement(captureRoleOperationElement, targetImageLabelElement);
    
    var targetImageNameElement = js2xml.createElement('TargetImageName', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(targetImageNameElement, parameters.targetImageName);
    js2xml.addChildElement(captureRoleOperationElement, targetImageNameElement);
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Begin capturing role as VM template.
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {string} virtualMachineName The name of the virtual machine to
   * restart.
   * 
   * @param {VirtualMachineCaptureVMImageParameters} parameters Parameters
   * supplied to the Capture Virtual Machine operation.
   * 
   * @param {string} [parameters.operationType] Required. Must be set to
   * CaptureRoleOperation.
   * 
   * @param {string} [parameters.oSState] Required. The OS state: Generalized |
   * Specialized.
   * 
   * @param {string} [parameters.vMImageName] Required. The VM Template Name.
   * 
   * @param {string} [parameters.vMImageLabel] Required. The VM Template Label.
   * 
   * @param {HttpStatusCode} [parameters.statusCode]
   * 
   * @param {string} [parameters.requestId]
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.beginCapturingVMImage = function(serviceName, deploymentName, virtualMachineName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (virtualMachineName === null || virtualMachineName === undefined) {
      return callback(new Error('virtualMachineName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/roleinstances/';
    url2 = url2 + encodeURIComponent(virtualMachineName);
    url2 = url2 + '/Operations';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var captureRoleAsVMImageOperationElement = js2xml.createElement('CaptureRoleAsVMImageOperation', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, captureRoleAsVMImageOperationElement);
    
    var operationTypeElement = js2xml.createElement('OperationType', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(operationTypeElement, 'CaptureRoleAsVMImageOperation');
    js2xml.addChildElement(captureRoleAsVMImageOperationElement, operationTypeElement);
    
    if (parameters.oSState !== null && parameters.oSState !== undefined) {
      var oSStateElement = js2xml.createElement('OSState', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(oSStateElement, parameters.oSState);
      js2xml.addChildElement(captureRoleAsVMImageOperationElement, oSStateElement);
    }
    
    if (parameters.vMImageName !== null && parameters.vMImageName !== undefined) {
      var vMImageNameElement = js2xml.createElement('VMImageName', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(vMImageNameElement, parameters.vMImageName);
      js2xml.addChildElement(captureRoleAsVMImageOperationElement, vMImageNameElement);
    }
    
    if (parameters.vMImageLabel !== null && parameters.vMImageLabel !== undefined) {
      var vMImageLabelElement = js2xml.createElement('VMImageLabel', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(vMImageLabelElement, parameters.vMImageLabel);
      js2xml.addChildElement(captureRoleAsVMImageOperationElement, vMImageLabelElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Creating Role operation adds a virtual machine to an existing
   * deployment. You can refer to the OSDisk in the Add Role operation in the
   * following ways: Platform/User Image - Set the SourceImageName to a
   * platform or user image. You can optionally specify the DiskName and
   * MediaLink values as part the operation to control the name and location
   * of target disk. When DiskName and MediaLink are specified in this mode,
   * they must not already exist in the system, otherwise a conflict fault is
   * returned; UserDisk - Set DiskName to a user supplied image in image
   * repository. SourceImageName must be set to NULL. All other properties are
   * ignored; or Blob in a Storage Account - Set MediaLink to a blob
   * containing the image. SourceImageName and DiskName are set to NULL.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157186.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {VirtualMachineCreateParameters} parameters Parameters supplied to
   * the Begin Creating Virtual Machine operation.
   * 
   * @param {string} parameters.roleName Specifies the name for the virtual
   * machine. The name must be unique within the deployment.
   * 
   * @param {string} [parameters.availabilitySetName] Specifies the name of an
   * availability set to which to add the virtual machine. This value controls
   * the virtual machine allocation in the Azure environment. Virtual machines
   * specified in the same availability set are allocated to different nodes
   * to maximize availability.
   * 
   * @param {string} [parameters.roleSize] The size of the virtual machine.
   * 
   * @param {array} [parameters.configurationSets] Contains the collection of
   * configuration sets that contain system and application configuration
   * settings.
   * 
   * @param {array} [parameters.resourceExtensionReferences] Contains a
   * collection of resource extensions that are to be installed on the Virtual
   * Machine. This element is used if ProvisionGuestAgent is set to true.
   * 
   * @param {string} [parameters.vMImageName] Name of the VMImage from which
   * this Role is to be created. If the OSDisk in the VMImage was Specialized,
   * then no WindowsProvisioningConfigurationSet or
   * LinuxProvisioningConfigurationSet should be provided. No
   * OSVirtualHardDisk or DataVirtualHardDisk should be specified when using
   * this argument.
   * 
   * @param {array} [parameters.dataVirtualHardDisks] Contains the parameters
   * Azure used to create the data disk for the virtual machine.
   * 
   * @param {OSVirtualHardDisk} [parameters.oSVirtualHardDisk] Contains the
   * parameters Azure used to create the operating system disk for the virtual
   * machine.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.hostCaching] Specifies the
   * platform caching behavior of the operating system disk blob for
   * read/write efficiency.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.label] Specifies the
   * friendly name of an operating system image in the image repository.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.name] Specifies the name of
   * an operating system image in the image repository.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.mediaLink] Specifies the
   * location of the operating system disk in Azure storage.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.sourceImageName] Specifies
   * the name of the source image that was used to provision the virtual
   * machine.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.operatingSystem] The
   * operating system running in the virtual machine.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.remoteSourceImageLink] Uri
   * of the source OS image that will be copied to the customer’s storage
   * account of VM creation.If RemoteSourceImageLink is specified, then
   * MediaLink must also be specified.If RemoteSourceImageLink is specified,
   * thenSourceIamgeName must not be specified.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.iOType] Gets or sets the IO
   * type.
   * 
   * @param {number} [parameters.oSVirtualHardDisk.resizedSizeInGB] When an OS
   * Image or a RemoteSourceImage is used to create an OSVirtualHardDisk, this
   * parameter can be used to resize the new OSVirtualHardDisk to a larger
   * size. ResizedSizeInGB must be larger than the underlying OS Image’s
   * LogicalSizeInGB.
   * 
   * @param {boolean} [parameters.provisionGuestAgent] Indicates whether the
   * WindowsAzureGuestAgent service is installed on the Virtual Machine. To
   * run a resource extension in a Virtual Machine, this service must be
   * installed.
   * 
   * @param {string} [parameters.mediaLocation] Location where VMImage VHDs
   * should be copied, for published VMImages.
   * 
   * @param {VMImageInput} [parameters.vMImageInput] When a VM Image is used to
   * create a new PersistantVMRole, the DiskConfigurations in the VM Image are
   * used to create new Disks for the new VM. This parameter can be used to
   * resize the newly created Disks to a larger size than the underlying
   * DiskConfigurations in the VM Image.This property is only returned with a
   * version header of 2014-10-01 or newer.
   * 
   * @param {OSDiskConfiguration} [parameters.vMImageInput.oSDiskConfiguration]
   * This corresponds to the OSDiskConfiguration of the VM Image used to
   * create a new role. The OSDiskConfiguration element is only available
   * using version 2014-10-01 or higher.
   * 
   * @param {number}
   * [parameters.vMImageInput.oSDiskConfiguration.resizedSizeInGB] This
   * specifies the new (larger) size of the OSVirtualHardDisk created using a
   * VM Image. The ResizedSizeInGB element is only available using version
   * 2014-10-01 or higher.
   * 
   * @param {IEnumerable} [parameters.vMImageInput.dataDiskConfigurations] This
   * corresponds to the DataDiskConfigurations of the VM Image used to create
   * a new role. The DataDiskConfigurations element is only available using
   * version 2014-10-01 or higher.
   * 
   * @param {DebugSettings} [parameters.debugSettings] Debug settings for
   * console output.
   * 
   * @param {boolean} [parameters.debugSettings.bootDiagnosticsEnabled] Enable
   * or disable boot diagnostics.
   * 
   * @param {string} [parameters.debugSettings.consoleScreenshotBlobUri] Blob
   * uri for console screen shot.
   * 
   * @param {string} [parameters.debugSettings.serialOutputBlobUri] Blob uri
   * for serial output.
   * 
   * @param {string} [parameters.licenseType] Specifies that the image or disk
   * that is being used was licensed on-premises. This element is only used
   * for images that contain the Windows Server operating system. Possible
   * values are: Windows_Client, Windows_Server
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.beginCreating = function(serviceName, deploymentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.configurationSets !== null && parameters.configurationSets !== undefined) {
      for (var loweredIndex1 = 0; loweredIndex1 < parameters.configurationSets.length; loweredIndex1 = loweredIndex1 + 1) {
        var configurationSetsParameterItem = parameters.configurationSets[loweredIndex1];
        if (configurationSetsParameterItem.additionalUnattendContent !== null && configurationSetsParameterItem.additionalUnattendContent !== undefined) {
          if (configurationSetsParameterItem.additionalUnattendContent.unattendPasses !== null && configurationSetsParameterItem.additionalUnattendContent.unattendPasses !== undefined) {
            for (var loweredIndex2 = 0; loweredIndex2 < configurationSetsParameterItem.additionalUnattendContent.unattendPasses.length; loweredIndex2 = loweredIndex2 + 1) {
              var unattendPassesParameterItem = configurationSetsParameterItem.additionalUnattendContent.unattendPasses[loweredIndex2];
              if (unattendPassesParameterItem.passName === null || unattendPassesParameterItem.passName === undefined) {
                return callback(new Error('parameters.configurationSets.additionalUnattendContent.unattendPasses.passName cannot be null.'));
              }
              if (unattendPassesParameterItem.unattendComponents !== null && unattendPassesParameterItem.unattendComponents !== undefined) {
                for (var loweredIndex3 = 0; loweredIndex3 < unattendPassesParameterItem.unattendComponents.length; loweredIndex3 = loweredIndex3 + 1) {
                  var unattendComponentsParameterItem = unattendPassesParameterItem.unattendComponents[loweredIndex3];
                  if (unattendComponentsParameterItem.componentName === null || unattendComponentsParameterItem.componentName === undefined) {
                    return callback(new Error('parameters.configurationSets.additionalUnattendContent.unattendPasses.unattendComponents.componentName cannot be null.'));
                  }
                  if (unattendComponentsParameterItem.unattendComponentSettings !== null && unattendComponentsParameterItem.unattendComponentSettings !== undefined) {
                    for (var loweredIndex4 = 0; loweredIndex4 < unattendComponentsParameterItem.unattendComponentSettings.length; loweredIndex4 = loweredIndex4 + 1) {
                      var unattendComponentSettingsParameterItem = unattendComponentsParameterItem.unattendComponentSettings[loweredIndex4];
                      if (unattendComponentSettingsParameterItem.settingName === null || unattendComponentSettingsParameterItem.settingName === undefined) {
                        return callback(new Error('parameters.configurationSets.additionalUnattendContent.unattendPasses.unattendComponents.unattendComponentSettings.settingName cannot be null.'));
                      }
                    }
                  }
                }
              }
            }
          }
        }
        if (configurationSetsParameterItem.domainJoin !== null && configurationSetsParameterItem.domainJoin !== undefined) {
          if (configurationSetsParameterItem.domainJoin.credentials !== null && configurationSetsParameterItem.domainJoin.credentials !== undefined) {
            if (configurationSetsParameterItem.domainJoin.credentials.password === null || configurationSetsParameterItem.domainJoin.credentials.password === undefined) {
              return callback(new Error('parameters.configurationSets.domainJoin.credentials.password cannot be null.'));
            }
            if (configurationSetsParameterItem.domainJoin.credentials.userName === null || configurationSetsParameterItem.domainJoin.credentials.userName === undefined) {
              return callback(new Error('parameters.configurationSets.domainJoin.credentials.userName cannot be null.'));
            }
          }
        }
        if (configurationSetsParameterItem.hostName !== null && configurationSetsParameterItem.hostName !== undefined && configurationSetsParameterItem.hostName.length < 1) {
          return callback(new Error('parameters.configurationSets.hostName is outside the valid range.'));
        }
        if (configurationSetsParameterItem.hostName !== null && configurationSetsParameterItem.hostName !== undefined && configurationSetsParameterItem.hostName.length > 64) {
          return callback(new Error('parameters.configurationSets.hostName is outside the valid range.'));
        }
        if (configurationSetsParameterItem.sshSettings !== null && configurationSetsParameterItem.sshSettings !== undefined) {
          if (configurationSetsParameterItem.sshSettings.keyPairs !== null && configurationSetsParameterItem.sshSettings.keyPairs !== undefined) {
            for (var loweredIndex5 = 0; loweredIndex5 < configurationSetsParameterItem.sshSettings.keyPairs.length; loweredIndex5 = loweredIndex5 + 1) {
              var keyPairsParameterItem = configurationSetsParameterItem.sshSettings.keyPairs[loweredIndex5];
              if (keyPairsParameterItem.fingerprint === null || keyPairsParameterItem.fingerprint === undefined) {
                return callback(new Error('parameters.configurationSets.sshSettings.keyPairs.fingerprint cannot be null.'));
              }
              if (keyPairsParameterItem.path === null || keyPairsParameterItem.path === undefined) {
                return callback(new Error('parameters.configurationSets.sshSettings.keyPairs.path cannot be null.'));
              }
            }
          }
          if (configurationSetsParameterItem.sshSettings.publicKeys !== null && configurationSetsParameterItem.sshSettings.publicKeys !== undefined) {
            for (var loweredIndex6 = 0; loweredIndex6 < configurationSetsParameterItem.sshSettings.publicKeys.length; loweredIndex6 = loweredIndex6 + 1) {
              var publicKeysParameterItem = configurationSetsParameterItem.sshSettings.publicKeys[loweredIndex6];
              if (publicKeysParameterItem.fingerprint === null || publicKeysParameterItem.fingerprint === undefined) {
                return callback(new Error('parameters.configurationSets.sshSettings.publicKeys.fingerprint cannot be null.'));
              }
              if (publicKeysParameterItem.path === null || publicKeysParameterItem.path === undefined) {
                return callback(new Error('parameters.configurationSets.sshSettings.publicKeys.path cannot be null.'));
              }
            }
          }
        }
        if (configurationSetsParameterItem.storedCertificateSettings !== null && configurationSetsParameterItem.storedCertificateSettings !== undefined) {
          for (var loweredIndex7 = 0; loweredIndex7 < configurationSetsParameterItem.storedCertificateSettings.length; loweredIndex7 = loweredIndex7 + 1) {
            var storedCertificateSettingsParameterItem = configurationSetsParameterItem.storedCertificateSettings[loweredIndex7];
            if (storedCertificateSettingsParameterItem.storeName === null || storedCertificateSettingsParameterItem.storeName === undefined) {
              return callback(new Error('parameters.configurationSets.storedCertificateSettings.storeName cannot be null.'));
            }
            if (storedCertificateSettingsParameterItem.thumbprint === null || storedCertificateSettingsParameterItem.thumbprint === undefined) {
              return callback(new Error('parameters.configurationSets.storedCertificateSettings.thumbprint cannot be null.'));
            }
          }
        }
        if (configurationSetsParameterItem.userName !== null && configurationSetsParameterItem.userName !== undefined && configurationSetsParameterItem.userName.length < 1) {
          return callback(new Error('parameters.configurationSets.userName is outside the valid range.'));
        }
        if (configurationSetsParameterItem.userName !== null && configurationSetsParameterItem.userName !== undefined && configurationSetsParameterItem.userName.length > 32) {
          return callback(new Error('parameters.configurationSets.userName is outside the valid range.'));
        }
        if (configurationSetsParameterItem.userPassword !== null && configurationSetsParameterItem.userPassword !== undefined && configurationSetsParameterItem.userPassword.length < 6) {
          return callback(new Error('parameters.configurationSets.userPassword is outside the valid range.'));
        }
        if (configurationSetsParameterItem.userPassword !== null && configurationSetsParameterItem.userPassword !== undefined && configurationSetsParameterItem.userPassword.length > 72) {
          return callback(new Error('parameters.configurationSets.userPassword is outside the valid range.'));
        }
        if (configurationSetsParameterItem.windowsRemoteManagement !== null && configurationSetsParameterItem.windowsRemoteManagement !== undefined) {
          if (configurationSetsParameterItem.windowsRemoteManagement.listeners !== null && configurationSetsParameterItem.windowsRemoteManagement.listeners !== undefined) {
            for (var loweredIndex8 = 0; loweredIndex8 < configurationSetsParameterItem.windowsRemoteManagement.listeners.length; loweredIndex8 = loweredIndex8 + 1) {
              var listenersParameterItem = configurationSetsParameterItem.windowsRemoteManagement.listeners[loweredIndex8];
              if (listenersParameterItem.listenerType === null || listenersParameterItem.listenerType === undefined) {
                return callback(new Error('parameters.configurationSets.windowsRemoteManagement.listeners.listenerType cannot be null.'));
              }
            }
          }
        }
      }
    }
    if (parameters.debugSettings !== null && parameters.debugSettings !== undefined) {
      if (parameters.debugSettings.bootDiagnosticsEnabled === null || parameters.debugSettings.bootDiagnosticsEnabled === undefined) {
        return callback(new Error('parameters.debugSettings.bootDiagnosticsEnabled cannot be null.'));
      }
    }
    if (parameters.roleName === null || parameters.roleName === undefined) {
      return callback(new Error('parameters.roleName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/roles';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var persistentVMRoleElement = js2xml.createElement('PersistentVMRole', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, persistentVMRoleElement);
    
    var roleNameElement = js2xml.createElement('RoleName', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(roleNameElement, parameters.roleName);
    js2xml.addChildElement(persistentVMRoleElement, roleNameElement);
    
    var roleTypeElement = js2xml.createElement('RoleType', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(roleTypeElement, 'PersistentVMRole');
    js2xml.addChildElement(persistentVMRoleElement, roleTypeElement);
    
    if (parameters.configurationSets !== null && parameters.configurationSets !== undefined) {
      var configurationSetsSequenceElement = js2xml.createElement('ConfigurationSets', 'http://schemas.microsoft.com/windowsazure');
      for (var loweredIndex9 = 0; loweredIndex9 < parameters.configurationSets.length; loweredIndex9 = loweredIndex9 + 1) {
        var configurationSetsItem = parameters.configurationSets[loweredIndex9];
        var configurationSetElement = js2xml.createElement('ConfigurationSet', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(configurationSetsSequenceElement, configurationSetElement);
        
        if (configurationSetsItem.configurationSetType !== null && configurationSetsItem.configurationSetType !== undefined) {
          var configurationSetTypeElement = js2xml.createElement('ConfigurationSetType', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(configurationSetTypeElement, configurationSetsItem.configurationSetType);
          js2xml.addChildElement(configurationSetElement, configurationSetTypeElement);
        }
        
        if (configurationSetsItem.inputEndpoints !== null && configurationSetsItem.inputEndpoints !== undefined) {
          var inputEndpointsSequenceElement = js2xml.createElement('InputEndpoints', 'http://schemas.microsoft.com/windowsazure');
          for (var loweredIndex10 = 0; loweredIndex10 < configurationSetsItem.inputEndpoints.length; loweredIndex10 = loweredIndex10 + 1) {
            var inputEndpointsItem = configurationSetsItem.inputEndpoints[loweredIndex10];
            var inputEndpointElement = js2xml.createElement('InputEndpoint', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(inputEndpointsSequenceElement, inputEndpointElement);
            
            if (inputEndpointsItem.loadBalancedEndpointSetName !== null && inputEndpointsItem.loadBalancedEndpointSetName !== undefined) {
              var loadBalancedEndpointSetNameElement = js2xml.createElement('LoadBalancedEndpointSetName', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(loadBalancedEndpointSetNameElement, inputEndpointsItem.loadBalancedEndpointSetName);
              js2xml.addChildElement(inputEndpointElement, loadBalancedEndpointSetNameElement);
            }
            
            if (inputEndpointsItem.localPort !== null && inputEndpointsItem.localPort !== undefined) {
              var localPortElement = js2xml.createElement('LocalPort', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(localPortElement, inputEndpointsItem.localPort.toString());
              js2xml.addChildElement(inputEndpointElement, localPortElement);
            }
            
            if (inputEndpointsItem.name !== null && inputEndpointsItem.name !== undefined) {
              var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(nameElement, inputEndpointsItem.name);
              js2xml.addChildElement(inputEndpointElement, nameElement);
            }
            
            if (inputEndpointsItem.port !== null && inputEndpointsItem.port !== undefined) {
              var portElement = js2xml.createElement('Port', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(portElement, inputEndpointsItem.port.toString());
              js2xml.addChildElement(inputEndpointElement, portElement);
            }
            
            if (inputEndpointsItem.loadBalancerProbe !== null && inputEndpointsItem.loadBalancerProbe !== undefined) {
              var loadBalancerProbeElement = js2xml.createElement('LoadBalancerProbe', 'http://schemas.microsoft.com/windowsazure');
              js2xml.addChildElement(inputEndpointElement, loadBalancerProbeElement);
              
              if (inputEndpointsItem.loadBalancerProbe.path !== null && inputEndpointsItem.loadBalancerProbe.path !== undefined) {
                var pathElement = js2xml.createElement('Path', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(pathElement, inputEndpointsItem.loadBalancerProbe.path);
                js2xml.addChildElement(loadBalancerProbeElement, pathElement);
              }
              
              if (inputEndpointsItem.loadBalancerProbe.port !== null && inputEndpointsItem.loadBalancerProbe.port !== undefined) {
                var portElement2 = js2xml.createElement('Port', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(portElement2, inputEndpointsItem.loadBalancerProbe.port.toString());
                js2xml.addChildElement(loadBalancerProbeElement, portElement2);
              }
              
              if (inputEndpointsItem.loadBalancerProbe.protocol !== null && inputEndpointsItem.loadBalancerProbe.protocol !== undefined) {
                var protocolElement = js2xml.createElement('Protocol', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(protocolElement, inputEndpointsItem.loadBalancerProbe.protocol !== null && inputEndpointsItem.loadBalancerProbe.protocol !== undefined ? inputEndpointsItem.loadBalancerProbe.protocol.toString() : 'Tcp');
                js2xml.addChildElement(loadBalancerProbeElement, protocolElement);
              }
              
              if (inputEndpointsItem.loadBalancerProbe.intervalInSeconds !== null && inputEndpointsItem.loadBalancerProbe.intervalInSeconds !== undefined) {
                var intervalInSecondsElement = js2xml.createElement('IntervalInSeconds', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(intervalInSecondsElement, inputEndpointsItem.loadBalancerProbe.intervalInSeconds.toString());
                js2xml.addChildElement(loadBalancerProbeElement, intervalInSecondsElement);
              }
              
              if (inputEndpointsItem.loadBalancerProbe.timeoutInSeconds !== null && inputEndpointsItem.loadBalancerProbe.timeoutInSeconds !== undefined) {
                var timeoutInSecondsElement = js2xml.createElement('TimeoutInSeconds', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(timeoutInSecondsElement, inputEndpointsItem.loadBalancerProbe.timeoutInSeconds.toString());
                js2xml.addChildElement(loadBalancerProbeElement, timeoutInSecondsElement);
              }
            }
            
            if (inputEndpointsItem.protocol !== null && inputEndpointsItem.protocol !== undefined) {
              var protocolElement2 = js2xml.createElement('Protocol', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(protocolElement2, inputEndpointsItem.protocol);
              js2xml.addChildElement(inputEndpointElement, protocolElement2);
            }
            
            if (inputEndpointsItem.virtualIPAddress !== null && inputEndpointsItem.virtualIPAddress !== undefined) {
              var vipElement = js2xml.createElement('Vip', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(vipElement, inputEndpointsItem.virtualIPAddress);
              js2xml.addChildElement(inputEndpointElement, vipElement);
            }
            
            if (inputEndpointsItem.enableDirectServerReturn !== null && inputEndpointsItem.enableDirectServerReturn !== undefined) {
              var enableDirectServerReturnElement = js2xml.createElement('EnableDirectServerReturn', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(enableDirectServerReturnElement, inputEndpointsItem.enableDirectServerReturn.toString());
              js2xml.addChildElement(inputEndpointElement, enableDirectServerReturnElement);
            }
            
            if (inputEndpointsItem.loadBalancerName !== null && inputEndpointsItem.loadBalancerName !== undefined) {
              var loadBalancerNameElement = js2xml.createElement('LoadBalancerName', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(loadBalancerNameElement, inputEndpointsItem.loadBalancerName);
              js2xml.addChildElement(inputEndpointElement, loadBalancerNameElement);
            }
            
            if (inputEndpointsItem.endpointAcl !== null && inputEndpointsItem.endpointAcl !== undefined) {
              var endpointAclElement = js2xml.createElement('EndpointAcl', 'http://schemas.microsoft.com/windowsazure');
              js2xml.addChildElement(inputEndpointElement, endpointAclElement);
              
              if (inputEndpointsItem.endpointAcl.rules !== null && inputEndpointsItem.endpointAcl.rules !== undefined) {
                var rulesSequenceElement = js2xml.createElement('Rules', 'http://schemas.microsoft.com/windowsazure');
                for (var loweredIndex11 = 0; loweredIndex11 < inputEndpointsItem.endpointAcl.rules.length; loweredIndex11 = loweredIndex11 + 1) {
                  var rulesItem = inputEndpointsItem.endpointAcl.rules[loweredIndex11];
                  var ruleElement = js2xml.createElement('Rule', 'http://schemas.microsoft.com/windowsazure');
                  js2xml.addChildElement(rulesSequenceElement, ruleElement);
                  
                  if (rulesItem.order !== null && rulesItem.order !== undefined) {
                    var orderElement = js2xml.createElement('Order', 'http://schemas.microsoft.com/windowsazure');
                    js2xml.setElementValue(orderElement, rulesItem.order.toString());
                    js2xml.addChildElement(ruleElement, orderElement);
                  }
                  
                  if (rulesItem.action !== null && rulesItem.action !== undefined) {
                    var actionElement = js2xml.createElement('Action', 'http://schemas.microsoft.com/windowsazure');
                    js2xml.setElementValue(actionElement, rulesItem.action);
                    js2xml.addChildElement(ruleElement, actionElement);
                  }
                  
                  if (rulesItem.remoteSubnet !== null && rulesItem.remoteSubnet !== undefined) {
                    var remoteSubnetElement = js2xml.createElement('RemoteSubnet', 'http://schemas.microsoft.com/windowsazure');
                    js2xml.setElementValue(remoteSubnetElement, rulesItem.remoteSubnet);
                    js2xml.addChildElement(ruleElement, remoteSubnetElement);
                  }
                  
                  if (rulesItem.description !== null && rulesItem.description !== undefined) {
                    var descriptionElement = js2xml.createElement('Description', 'http://schemas.microsoft.com/windowsazure');
                    js2xml.setElementValue(descriptionElement, rulesItem.description);
                    js2xml.addChildElement(ruleElement, descriptionElement);
                  }
                }
                js2xml.addChildElement(endpointAclElement, rulesSequenceElement);
              }
            }
            
            if (inputEndpointsItem.idleTimeoutInMinutes !== null && inputEndpointsItem.idleTimeoutInMinutes !== undefined) {
              var idleTimeoutInMinutesElement = js2xml.createElement('IdleTimeoutInMinutes', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(idleTimeoutInMinutesElement, inputEndpointsItem.idleTimeoutInMinutes.toString());
              js2xml.addChildElement(inputEndpointElement, idleTimeoutInMinutesElement);
            }
            
            if (inputEndpointsItem.loadBalancerDistribution !== null && inputEndpointsItem.loadBalancerDistribution !== undefined) {
              var loadBalancerDistributionElement = js2xml.createElement('LoadBalancerDistribution', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(loadBalancerDistributionElement, inputEndpointsItem.loadBalancerDistribution);
              js2xml.addChildElement(inputEndpointElement, loadBalancerDistributionElement);
            }
            
            if (inputEndpointsItem.virtualIPName !== null && inputEndpointsItem.virtualIPName !== undefined) {
              var virtualIPNameElement = js2xml.createElement('VirtualIPName', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(virtualIPNameElement, inputEndpointsItem.virtualIPName);
              js2xml.addChildElement(inputEndpointElement, virtualIPNameElement);
            }
          }
          js2xml.addChildElement(configurationSetElement, inputEndpointsSequenceElement);
        }
        
        if (configurationSetsItem.subnetNames !== null && configurationSetsItem.subnetNames !== undefined) {
          var subnetNamesSequenceElement = js2xml.createElement('SubnetNames', 'http://schemas.microsoft.com/windowsazure');
          for (var loweredIndex12 = 0; loweredIndex12 < configurationSetsItem.subnetNames.length; loweredIndex12 = loweredIndex12 + 1) {
            var subnetNamesItem = configurationSetsItem.subnetNames[loweredIndex12];
            var subnetNamesItemElement = js2xml.createElement('SubnetName', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(subnetNamesItemElement, subnetNamesItem);
            js2xml.addChildElement(subnetNamesSequenceElement, subnetNamesItemElement);
          }
          js2xml.addChildElement(configurationSetElement, subnetNamesSequenceElement);
        }
        
        if (configurationSetsItem.staticVirtualNetworkIPAddress !== null && configurationSetsItem.staticVirtualNetworkIPAddress !== undefined) {
          var staticVirtualNetworkIPAddressElement = js2xml.createElement('StaticVirtualNetworkIPAddress', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(staticVirtualNetworkIPAddressElement, configurationSetsItem.staticVirtualNetworkIPAddress);
          js2xml.addChildElement(configurationSetElement, staticVirtualNetworkIPAddressElement);
        }
        
        if (configurationSetsItem.publicIPs !== null && configurationSetsItem.publicIPs !== undefined) {
          var publicIPsSequenceElement = js2xml.createElement('PublicIPs', 'http://schemas.microsoft.com/windowsazure');
          for (var loweredIndex13 = 0; loweredIndex13 < configurationSetsItem.publicIPs.length; loweredIndex13 = loweredIndex13 + 1) {
            var publicIPsItem = configurationSetsItem.publicIPs[loweredIndex13];
            var publicIPElement = js2xml.createElement('PublicIP', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(publicIPsSequenceElement, publicIPElement);
            
            if (publicIPsItem.name !== null && publicIPsItem.name !== undefined) {
              var nameElement2 = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(nameElement2, publicIPsItem.name);
              js2xml.addChildElement(publicIPElement, nameElement2);
            }
            
            if (publicIPsItem.idleTimeoutInMinutes !== null && publicIPsItem.idleTimeoutInMinutes !== undefined) {
              var idleTimeoutInMinutesElement2 = js2xml.createElement('IdleTimeoutInMinutes', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(idleTimeoutInMinutesElement2, publicIPsItem.idleTimeoutInMinutes.toString());
              js2xml.addChildElement(publicIPElement, idleTimeoutInMinutesElement2);
            }
            
            if (publicIPsItem.domainNameLabel !== null && publicIPsItem.domainNameLabel !== undefined) {
              var domainNameLabelElement = js2xml.createElement('DomainNameLabel', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(domainNameLabelElement, publicIPsItem.domainNameLabel);
              js2xml.addChildElement(publicIPElement, domainNameLabelElement);
            }
          }
          js2xml.addChildElement(configurationSetElement, publicIPsSequenceElement);
        }
        
        if (configurationSetsItem.networkInterfaces !== null && configurationSetsItem.networkInterfaces !== undefined) {
          var networkInterfacesSequenceElement = js2xml.createElement('NetworkInterfaces', 'http://schemas.microsoft.com/windowsazure');
          for (var loweredIndex14 = 0; loweredIndex14 < configurationSetsItem.networkInterfaces.length; loweredIndex14 = loweredIndex14 + 1) {
            var networkInterfacesItem = configurationSetsItem.networkInterfaces[loweredIndex14];
            var networkInterfaceElement = js2xml.createElement('NetworkInterface', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(networkInterfacesSequenceElement, networkInterfaceElement);
            
            if (networkInterfacesItem.name !== null && networkInterfacesItem.name !== undefined) {
              var nameElement3 = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(nameElement3, networkInterfacesItem.name);
              js2xml.addChildElement(networkInterfaceElement, nameElement3);
            }
            
            if (networkInterfacesItem.iPConfigurations !== null && networkInterfacesItem.iPConfigurations !== undefined) {
              var iPConfigurationsSequenceElement = js2xml.createElement('IPConfigurations', 'http://schemas.microsoft.com/windowsazure');
              for (var loweredIndex15 = 0; loweredIndex15 < networkInterfacesItem.iPConfigurations.length; loweredIndex15 = loweredIndex15 + 1) {
                var iPConfigurationsItem = networkInterfacesItem.iPConfigurations[loweredIndex15];
                var iPConfigurationElement = js2xml.createElement('IPConfiguration', 'http://schemas.microsoft.com/windowsazure');
                js2xml.addChildElement(iPConfigurationsSequenceElement, iPConfigurationElement);
                
                if (iPConfigurationsItem.subnetName !== null && iPConfigurationsItem.subnetName !== undefined) {
                  var subnetNameElement = js2xml.createElement('SubnetName', 'http://schemas.microsoft.com/windowsazure');
                  js2xml.setElementValue(subnetNameElement, iPConfigurationsItem.subnetName);
                  js2xml.addChildElement(iPConfigurationElement, subnetNameElement);
                }
                
                if (iPConfigurationsItem.staticVirtualNetworkIPAddress !== null && iPConfigurationsItem.staticVirtualNetworkIPAddress !== undefined) {
                  var staticVirtualNetworkIPAddressElement2 = js2xml.createElement('StaticVirtualNetworkIPAddress', 'http://schemas.microsoft.com/windowsazure');
                  js2xml.setElementValue(staticVirtualNetworkIPAddressElement2, iPConfigurationsItem.staticVirtualNetworkIPAddress);
                  js2xml.addChildElement(iPConfigurationElement, staticVirtualNetworkIPAddressElement2);
                }
              }
              js2xml.addChildElement(networkInterfaceElement, iPConfigurationsSequenceElement);
            }
            
            if (networkInterfacesItem.networkSecurityGroup !== null && networkInterfacesItem.networkSecurityGroup !== undefined) {
              var networkSecurityGroupElement = js2xml.createElement('NetworkSecurityGroup', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(networkSecurityGroupElement, networkInterfacesItem.networkSecurityGroup);
              js2xml.addChildElement(networkInterfaceElement, networkSecurityGroupElement);
            }
            
            if (networkInterfacesItem.iPForwarding !== null && networkInterfacesItem.iPForwarding !== undefined) {
              var iPForwardingElement = js2xml.createElement('IPForwarding', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(iPForwardingElement, networkInterfacesItem.iPForwarding);
              js2xml.addChildElement(networkInterfaceElement, iPForwardingElement);
            }
          }
          js2xml.addChildElement(configurationSetElement, networkInterfacesSequenceElement);
        }
        
        if (configurationSetsItem.networkSecurityGroup !== null && configurationSetsItem.networkSecurityGroup !== undefined) {
          var networkSecurityGroupElement2 = js2xml.createElement('NetworkSecurityGroup', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(networkSecurityGroupElement2, configurationSetsItem.networkSecurityGroup);
          js2xml.addChildElement(configurationSetElement, networkSecurityGroupElement2);
        }
        
        if (configurationSetsItem.iPForwarding !== null && configurationSetsItem.iPForwarding !== undefined) {
          var iPForwardingElement2 = js2xml.createElement('IPForwarding', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(iPForwardingElement2, configurationSetsItem.iPForwarding);
          js2xml.addChildElement(configurationSetElement, iPForwardingElement2);
        }
        
        if (configurationSetsItem.computerName !== null && configurationSetsItem.computerName !== undefined) {
          var computerNameElement = js2xml.createElement('ComputerName', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(computerNameElement, configurationSetsItem.computerName);
          js2xml.addChildElement(configurationSetElement, computerNameElement);
        }
        
        if (configurationSetsItem.adminPassword !== null && configurationSetsItem.adminPassword !== undefined) {
          var adminPasswordElement = js2xml.createElement('AdminPassword', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(adminPasswordElement, configurationSetsItem.adminPassword);
          js2xml.addChildElement(configurationSetElement, adminPasswordElement);
        }
        
        if (configurationSetsItem.resetPasswordOnFirstLogon !== null && configurationSetsItem.resetPasswordOnFirstLogon !== undefined) {
          var resetPasswordOnFirstLogonElement = js2xml.createElement('ResetPasswordOnFirstLogon', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(resetPasswordOnFirstLogonElement, configurationSetsItem.resetPasswordOnFirstLogon.toString());
          js2xml.addChildElement(configurationSetElement, resetPasswordOnFirstLogonElement);
        }
        
        if (configurationSetsItem.enableAutomaticUpdates !== null && configurationSetsItem.enableAutomaticUpdates !== undefined) {
          var enableAutomaticUpdatesElement = js2xml.createElement('EnableAutomaticUpdates', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(enableAutomaticUpdatesElement, configurationSetsItem.enableAutomaticUpdates.toString());
          js2xml.addChildElement(configurationSetElement, enableAutomaticUpdatesElement);
        }
        
        if (configurationSetsItem.timeZone !== null && configurationSetsItem.timeZone !== undefined) {
          var timeZoneElement = js2xml.createElement('TimeZone', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(timeZoneElement, configurationSetsItem.timeZone);
          js2xml.addChildElement(configurationSetElement, timeZoneElement);
        }
        
        if (configurationSetsItem.domainJoin !== null && configurationSetsItem.domainJoin !== undefined) {
          var domainJoinElement = js2xml.createElement('DomainJoin', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(configurationSetElement, domainJoinElement);
          
          if (configurationSetsItem.domainJoin.credentials !== null && configurationSetsItem.domainJoin.credentials !== undefined) {
            var credentialsElement = js2xml.createElement('Credentials', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(domainJoinElement, credentialsElement);
            
            if (configurationSetsItem.domainJoin.credentials.domain !== null && configurationSetsItem.domainJoin.credentials.domain !== undefined) {
              var domainElement = js2xml.createElement('Domain', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(domainElement, configurationSetsItem.domainJoin.credentials.domain);
              js2xml.addChildElement(credentialsElement, domainElement);
            }
            
            var usernameElement = js2xml.createElement('Username', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(usernameElement, configurationSetsItem.domainJoin.credentials.userName);
            js2xml.addChildElement(credentialsElement, usernameElement);
            
            var passwordElement = js2xml.createElement('Password', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(passwordElement, configurationSetsItem.domainJoin.credentials.password);
            js2xml.addChildElement(credentialsElement, passwordElement);
          }
          
          if (configurationSetsItem.domainJoin.domainToJoin !== null && configurationSetsItem.domainJoin.domainToJoin !== undefined) {
            var joinDomainElement = js2xml.createElement('JoinDomain', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(joinDomainElement, configurationSetsItem.domainJoin.domainToJoin);
            js2xml.addChildElement(domainJoinElement, joinDomainElement);
          }
          
          if (configurationSetsItem.domainJoin.ldapMachineObjectOU !== null && configurationSetsItem.domainJoin.ldapMachineObjectOU !== undefined) {
            var machineObjectOUElement = js2xml.createElement('MachineObjectOU', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(machineObjectOUElement, configurationSetsItem.domainJoin.ldapMachineObjectOU);
            js2xml.addChildElement(domainJoinElement, machineObjectOUElement);
          }
          
          if (configurationSetsItem.domainJoin.provisioning !== null && configurationSetsItem.domainJoin.provisioning !== undefined) {
            var provisioningElement = js2xml.createElement('Provisioning', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(domainJoinElement, provisioningElement);
            
            if (configurationSetsItem.domainJoin.provisioning.accountData !== null && configurationSetsItem.domainJoin.provisioning.accountData !== undefined) {
              var accountDataElement = js2xml.createElement('AccountData', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(accountDataElement, configurationSetsItem.domainJoin.provisioning.accountData);
              js2xml.addChildElement(provisioningElement, accountDataElement);
            }
          }
        }
        
        if (configurationSetsItem.storedCertificateSettings !== null && configurationSetsItem.storedCertificateSettings !== undefined) {
          var storedCertificateSettingsSequenceElement = js2xml.createElement('StoredCertificateSettings', 'http://schemas.microsoft.com/windowsazure');
          for (var loweredIndex16 = 0; loweredIndex16 < configurationSetsItem.storedCertificateSettings.length; loweredIndex16 = loweredIndex16 + 1) {
            var storedCertificateSettingsItem = configurationSetsItem.storedCertificateSettings[loweredIndex16];
            var certificateSettingElement = js2xml.createElement('CertificateSetting', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(storedCertificateSettingsSequenceElement, certificateSettingElement);
            
            var storeLocationElement = js2xml.createElement('StoreLocation', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(storeLocationElement, 'LocalMachine');
            js2xml.addChildElement(certificateSettingElement, storeLocationElement);
            
            var storeNameElement = js2xml.createElement('StoreName', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(storeNameElement, storedCertificateSettingsItem.storeName);
            js2xml.addChildElement(certificateSettingElement, storeNameElement);
            
            var thumbprintElement = js2xml.createElement('Thumbprint', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(thumbprintElement, storedCertificateSettingsItem.thumbprint);
            js2xml.addChildElement(certificateSettingElement, thumbprintElement);
          }
          js2xml.addChildElement(configurationSetElement, storedCertificateSettingsSequenceElement);
        }
        
        if (configurationSetsItem.windowsRemoteManagement !== null && configurationSetsItem.windowsRemoteManagement !== undefined) {
          var winRMElement = js2xml.createElement('WinRM', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(configurationSetElement, winRMElement);
          
          if (configurationSetsItem.windowsRemoteManagement.listeners !== null && configurationSetsItem.windowsRemoteManagement.listeners !== undefined) {
            var listenersSequenceElement = js2xml.createElement('Listeners', 'http://schemas.microsoft.com/windowsazure');
            for (var loweredIndex17 = 0; loweredIndex17 < configurationSetsItem.windowsRemoteManagement.listeners.length; loweredIndex17 = loweredIndex17 + 1) {
              var listenersItem = configurationSetsItem.windowsRemoteManagement.listeners[loweredIndex17];
              var listenerElement = js2xml.createElement('Listener', 'http://schemas.microsoft.com/windowsazure');
              js2xml.addChildElement(listenersSequenceElement, listenerElement);
              
              if (listenersItem.certificateThumbprint !== null && listenersItem.certificateThumbprint !== undefined) {
                var certificateThumbprintElement = js2xml.createElement('CertificateThumbprint', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(certificateThumbprintElement, listenersItem.certificateThumbprint);
                js2xml.addChildElement(listenerElement, certificateThumbprintElement);
              }
              
              var protocolElement3 = js2xml.createElement('Protocol', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(protocolElement3, listenersItem.listenerType !== null && listenersItem.listenerType !== undefined ? listenersItem.listenerType.toString() : 'Http');
              js2xml.addChildElement(listenerElement, protocolElement3);
            }
            js2xml.addChildElement(winRMElement, listenersSequenceElement);
          }
        }
        
        if (configurationSetsItem.adminUserName !== null && configurationSetsItem.adminUserName !== undefined) {
          var adminUsernameElement = js2xml.createElement('AdminUsername', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(adminUsernameElement, configurationSetsItem.adminUserName);
          js2xml.addChildElement(configurationSetElement, adminUsernameElement);
        }
        
        if (configurationSetsItem.additionalUnattendContent !== null && configurationSetsItem.additionalUnattendContent !== undefined) {
          var additionalUnattendContentElement = js2xml.createElement('AdditionalUnattendContent', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(configurationSetElement, additionalUnattendContentElement);
          
          if (configurationSetsItem.additionalUnattendContent.unattendPasses !== null && configurationSetsItem.additionalUnattendContent.unattendPasses !== undefined) {
            var passesSequenceElement = js2xml.createElement('Passes', 'http://schemas.microsoft.com/windowsazure');
            for (var loweredIndex18 = 0; loweredIndex18 < configurationSetsItem.additionalUnattendContent.unattendPasses.length; loweredIndex18 = loweredIndex18 + 1) {
              var passesItem = configurationSetsItem.additionalUnattendContent.unattendPasses[loweredIndex18];
              var unattendPassElement = js2xml.createElement('UnattendPass', 'http://schemas.microsoft.com/windowsazure');
              js2xml.addChildElement(passesSequenceElement, unattendPassElement);
              
              var passNameElement = js2xml.createElement('PassName', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(passNameElement, passesItem.passName);
              js2xml.addChildElement(unattendPassElement, passNameElement);
              
              if (passesItem.unattendComponents !== null && passesItem.unattendComponents !== undefined) {
                var componentsSequenceElement = js2xml.createElement('Components', 'http://schemas.microsoft.com/windowsazure');
                for (var loweredIndex19 = 0; loweredIndex19 < passesItem.unattendComponents.length; loweredIndex19 = loweredIndex19 + 1) {
                  var componentsItem = passesItem.unattendComponents[loweredIndex19];
                  var unattendComponentElement = js2xml.createElement('UnattendComponent', 'http://schemas.microsoft.com/windowsazure');
                  js2xml.addChildElement(componentsSequenceElement, unattendComponentElement);
                  
                  var componentNameElement = js2xml.createElement('ComponentName', 'http://schemas.microsoft.com/windowsazure');
                  js2xml.setElementValue(componentNameElement, componentsItem.componentName);
                  js2xml.addChildElement(unattendComponentElement, componentNameElement);
                  
                  if (componentsItem.unattendComponentSettings !== null && componentsItem.unattendComponentSettings !== undefined) {
                    var componentSettingsSequenceElement = js2xml.createElement('ComponentSettings', 'http://schemas.microsoft.com/windowsazure');
                    for (var loweredIndex20 = 0; loweredIndex20 < componentsItem.unattendComponentSettings.length; loweredIndex20 = loweredIndex20 + 1) {
                      var componentSettingsItem = componentsItem.unattendComponentSettings[loweredIndex20];
                      var componentSettingElement = js2xml.createElement('ComponentSetting', 'http://schemas.microsoft.com/windowsazure');
                      js2xml.addChildElement(componentSettingsSequenceElement, componentSettingElement);
                      
                      var settingNameElement = js2xml.createElement('SettingName', 'http://schemas.microsoft.com/windowsazure');
                      js2xml.setElementValue(settingNameElement, componentSettingsItem.settingName);
                      js2xml.addChildElement(componentSettingElement, settingNameElement);
                      
                      if (componentSettingsItem.content !== null && componentSettingsItem.content !== undefined) {
                        var contentElement = js2xml.createElement('Content', 'http://schemas.microsoft.com/windowsazure');
                        js2xml.setElementValue(contentElement, new Buffer(componentSettingsItem.content).toString('base64'));
                        js2xml.addChildElement(componentSettingElement, contentElement);
                      }
                    }
                    js2xml.addChildElement(unattendComponentElement, componentSettingsSequenceElement);
                  }
                }
                js2xml.addChildElement(unattendPassElement, componentsSequenceElement);
              }
            }
            js2xml.addChildElement(additionalUnattendContentElement, passesSequenceElement);
          }
        }
        
        if (configurationSetsItem.hostName !== null && configurationSetsItem.hostName !== undefined) {
          var hostNameElement = js2xml.createElement('HostName', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(hostNameElement, configurationSetsItem.hostName);
          js2xml.addChildElement(configurationSetElement, hostNameElement);
        }
        
        if (configurationSetsItem.userName !== null && configurationSetsItem.userName !== undefined) {
          var userNameElement = js2xml.createElement('UserName', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(userNameElement, configurationSetsItem.userName);
          js2xml.addChildElement(configurationSetElement, userNameElement);
        }
        
        if (configurationSetsItem.userPassword !== null && configurationSetsItem.userPassword !== undefined) {
          var userPasswordElement = js2xml.createElement('UserPassword', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(userPasswordElement, configurationSetsItem.userPassword);
          js2xml.addChildElement(configurationSetElement, userPasswordElement);
        }
        
        if (configurationSetsItem.disableSshPasswordAuthentication !== null && configurationSetsItem.disableSshPasswordAuthentication !== undefined) {
          var disableSshPasswordAuthenticationElement = js2xml.createElement('DisableSshPasswordAuthentication', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(disableSshPasswordAuthenticationElement, configurationSetsItem.disableSshPasswordAuthentication.toString());
          js2xml.addChildElement(configurationSetElement, disableSshPasswordAuthenticationElement);
        }
        
        if (configurationSetsItem.sshSettings !== null && configurationSetsItem.sshSettings !== undefined) {
          var sSHElement = js2xml.createElement('SSH', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(configurationSetElement, sSHElement);
          
          if (configurationSetsItem.sshSettings.publicKeys !== null && configurationSetsItem.sshSettings.publicKeys !== undefined) {
            var publicKeysSequenceElement = js2xml.createElement('PublicKeys', 'http://schemas.microsoft.com/windowsazure');
            for (var loweredIndex21 = 0; loweredIndex21 < configurationSetsItem.sshSettings.publicKeys.length; loweredIndex21 = loweredIndex21 + 1) {
              var publicKeysItem = configurationSetsItem.sshSettings.publicKeys[loweredIndex21];
              var publicKeyElement = js2xml.createElement('PublicKey', 'http://schemas.microsoft.com/windowsazure');
              js2xml.addChildElement(publicKeysSequenceElement, publicKeyElement);
              
              var fingerprintElement = js2xml.createElement('Fingerprint', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(fingerprintElement, publicKeysItem.fingerprint);
              js2xml.addChildElement(publicKeyElement, fingerprintElement);
              
              var pathElement2 = js2xml.createElement('Path', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(pathElement2, publicKeysItem.path);
              js2xml.addChildElement(publicKeyElement, pathElement2);
            }
            js2xml.addChildElement(sSHElement, publicKeysSequenceElement);
          }
          
          if (configurationSetsItem.sshSettings.keyPairs !== null && configurationSetsItem.sshSettings.keyPairs !== undefined) {
            var keyPairsSequenceElement = js2xml.createElement('KeyPairs', 'http://schemas.microsoft.com/windowsazure');
            for (var loweredIndex22 = 0; loweredIndex22 < configurationSetsItem.sshSettings.keyPairs.length; loweredIndex22 = loweredIndex22 + 1) {
              var keyPairsItem = configurationSetsItem.sshSettings.keyPairs[loweredIndex22];
              var keyPairElement = js2xml.createElement('KeyPair', 'http://schemas.microsoft.com/windowsazure');
              js2xml.addChildElement(keyPairsSequenceElement, keyPairElement);
              
              var fingerprintElement2 = js2xml.createElement('Fingerprint', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(fingerprintElement2, keyPairsItem.fingerprint);
              js2xml.addChildElement(keyPairElement, fingerprintElement2);
              
              var pathElement3 = js2xml.createElement('Path', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(pathElement3, keyPairsItem.path);
              js2xml.addChildElement(keyPairElement, pathElement3);
            }
            js2xml.addChildElement(sSHElement, keyPairsSequenceElement);
          }
        }
        
        if (configurationSetsItem.customData !== null && configurationSetsItem.customData !== undefined) {
          var customDataElement = js2xml.createElement('CustomData', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(customDataElement, configurationSetsItem.customData);
          js2xml.addChildElement(configurationSetElement, customDataElement);
        }
      }
      js2xml.addChildElement(persistentVMRoleElement, configurationSetsSequenceElement);
    }
    
    if (parameters.resourceExtensionReferences !== null && parameters.resourceExtensionReferences !== undefined) {
      var resourceExtensionReferencesSequenceElement = js2xml.createElement('ResourceExtensionReferences', 'http://schemas.microsoft.com/windowsazure');
      for (var loweredIndex23 = 0; loweredIndex23 < parameters.resourceExtensionReferences.length; loweredIndex23 = loweredIndex23 + 1) {
        var resourceExtensionReferencesItem = parameters.resourceExtensionReferences[loweredIndex23];
        var resourceExtensionReferenceElement = js2xml.createElement('ResourceExtensionReference', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(resourceExtensionReferencesSequenceElement, resourceExtensionReferenceElement);
        
        if (resourceExtensionReferencesItem.referenceName !== null && resourceExtensionReferencesItem.referenceName !== undefined) {
          var referenceNameElement = js2xml.createElement('ReferenceName', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(referenceNameElement, resourceExtensionReferencesItem.referenceName);
          js2xml.addChildElement(resourceExtensionReferenceElement, referenceNameElement);
        }
        
        if (resourceExtensionReferencesItem.publisher !== null && resourceExtensionReferencesItem.publisher !== undefined) {
          var publisherElement = js2xml.createElement('Publisher', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(publisherElement, resourceExtensionReferencesItem.publisher);
          js2xml.addChildElement(resourceExtensionReferenceElement, publisherElement);
        }
        
        if (resourceExtensionReferencesItem.name !== null && resourceExtensionReferencesItem.name !== undefined) {
          var nameElement4 = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(nameElement4, resourceExtensionReferencesItem.name);
          js2xml.addChildElement(resourceExtensionReferenceElement, nameElement4);
        }
        
        if (resourceExtensionReferencesItem.version !== null && resourceExtensionReferencesItem.version !== undefined) {
          var versionElement = js2xml.createElement('Version', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(versionElement, resourceExtensionReferencesItem.version);
          js2xml.addChildElement(resourceExtensionReferenceElement, versionElement);
        }
        
        if (resourceExtensionReferencesItem.resourceExtensionParameterValues !== null && resourceExtensionReferencesItem.resourceExtensionParameterValues !== undefined) {
          var resourceExtensionParameterValuesSequenceElement = js2xml.createElement('ResourceExtensionParameterValues', 'http://schemas.microsoft.com/windowsazure');
          for (var loweredIndex24 = 0; loweredIndex24 < resourceExtensionReferencesItem.resourceExtensionParameterValues.length; loweredIndex24 = loweredIndex24 + 1) {
            var resourceExtensionParameterValuesItem = resourceExtensionReferencesItem.resourceExtensionParameterValues[loweredIndex24];
            var resourceExtensionParameterValueElement = js2xml.createElement('ResourceExtensionParameterValue', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(resourceExtensionParameterValuesSequenceElement, resourceExtensionParameterValueElement);
            
            if (resourceExtensionParameterValuesItem.key !== null && resourceExtensionParameterValuesItem.key !== undefined) {
              var keyElement = js2xml.createElement('Key', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(keyElement, resourceExtensionParameterValuesItem.key);
              js2xml.addChildElement(resourceExtensionParameterValueElement, keyElement);
            }
            
            if (resourceExtensionParameterValuesItem.value !== null && resourceExtensionParameterValuesItem.value !== undefined) {
              var valueElement = js2xml.createElement('Value', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(valueElement, new Buffer(resourceExtensionParameterValuesItem.value).toString('base64'));
              js2xml.addChildElement(resourceExtensionParameterValueElement, valueElement);
            }
            
            if (resourceExtensionParameterValuesItem.type !== null && resourceExtensionParameterValuesItem.type !== undefined) {
              var typeElement = js2xml.createElement('Type', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(typeElement, resourceExtensionParameterValuesItem.type);
              js2xml.addChildElement(resourceExtensionParameterValueElement, typeElement);
            }
          }
          js2xml.addChildElement(resourceExtensionReferenceElement, resourceExtensionParameterValuesSequenceElement);
        }
        
        if (resourceExtensionReferencesItem.state !== null && resourceExtensionReferencesItem.state !== undefined) {
          var stateElement = js2xml.createElement('State', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(stateElement, resourceExtensionReferencesItem.state);
          js2xml.addChildElement(resourceExtensionReferenceElement, stateElement);
        }
        
        if (resourceExtensionReferencesItem.forceUpdate !== null && resourceExtensionReferencesItem.forceUpdate !== undefined) {
          var forceUpdateElement = js2xml.createElement('ForceUpdate', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(forceUpdateElement, resourceExtensionReferencesItem.forceUpdate.toString());
          js2xml.addChildElement(resourceExtensionReferenceElement, forceUpdateElement);
        }
      }
      js2xml.addChildElement(persistentVMRoleElement, resourceExtensionReferencesSequenceElement);
    }
    
    if (parameters.vMImageName !== null && parameters.vMImageName !== undefined) {
      var vMImageNameElement = js2xml.createElement('VMImageName', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(vMImageNameElement, parameters.vMImageName);
      js2xml.addChildElement(persistentVMRoleElement, vMImageNameElement);
    }
    
    if (parameters.mediaLocation !== null && parameters.mediaLocation !== undefined) {
      var mediaLocationElement = js2xml.createElement('MediaLocation', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(mediaLocationElement, parameters.mediaLocation);
      js2xml.addChildElement(persistentVMRoleElement, mediaLocationElement);
    }
    
    if (parameters.availabilitySetName !== null && parameters.availabilitySetName !== undefined) {
      var availabilitySetNameElement = js2xml.createElement('AvailabilitySetName', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(availabilitySetNameElement, parameters.availabilitySetName);
      js2xml.addChildElement(persistentVMRoleElement, availabilitySetNameElement);
    }
    
    if (parameters.dataVirtualHardDisks !== null && parameters.dataVirtualHardDisks !== undefined) {
      var dataVirtualHardDisksSequenceElement = js2xml.createElement('DataVirtualHardDisks', 'http://schemas.microsoft.com/windowsazure');
      for (var loweredIndex25 = 0; loweredIndex25 < parameters.dataVirtualHardDisks.length; loweredIndex25 = loweredIndex25 + 1) {
        var dataVirtualHardDisksItem = parameters.dataVirtualHardDisks[loweredIndex25];
        var dataVirtualHardDiskElement = js2xml.createElement('DataVirtualHardDisk', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(dataVirtualHardDisksSequenceElement, dataVirtualHardDiskElement);
        
        if (dataVirtualHardDisksItem.hostCaching !== null && dataVirtualHardDisksItem.hostCaching !== undefined) {
          var hostCachingElement = js2xml.createElement('HostCaching', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(hostCachingElement, dataVirtualHardDisksItem.hostCaching);
          js2xml.addChildElement(dataVirtualHardDiskElement, hostCachingElement);
        }
        
        if (dataVirtualHardDisksItem.label !== null && dataVirtualHardDisksItem.label !== undefined) {
          var diskLabelElement = js2xml.createElement('DiskLabel', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(diskLabelElement, dataVirtualHardDisksItem.label);
          js2xml.addChildElement(dataVirtualHardDiskElement, diskLabelElement);
        }
        
        if (dataVirtualHardDisksItem.name !== null && dataVirtualHardDisksItem.name !== undefined) {
          var diskNameElement = js2xml.createElement('DiskName', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(diskNameElement, dataVirtualHardDisksItem.name);
          js2xml.addChildElement(dataVirtualHardDiskElement, diskNameElement);
        }
        
        if (dataVirtualHardDisksItem.logicalUnitNumber !== null && dataVirtualHardDisksItem.logicalUnitNumber !== undefined) {
          var lunElement = js2xml.createElement('Lun', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(lunElement, dataVirtualHardDisksItem.logicalUnitNumber.toString());
          js2xml.addChildElement(dataVirtualHardDiskElement, lunElement);
        }
        
        if (dataVirtualHardDisksItem.logicalDiskSizeInGB !== null && dataVirtualHardDisksItem.logicalDiskSizeInGB !== undefined) {
          var logicalDiskSizeInGBElement = js2xml.createElement('LogicalDiskSizeInGB', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(logicalDiskSizeInGBElement, dataVirtualHardDisksItem.logicalDiskSizeInGB.toString());
          js2xml.addChildElement(dataVirtualHardDiskElement, logicalDiskSizeInGBElement);
        }
        
        if (dataVirtualHardDisksItem.mediaLink !== null && dataVirtualHardDisksItem.mediaLink !== undefined) {
          var mediaLinkElement = js2xml.createElement('MediaLink', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(mediaLinkElement, dataVirtualHardDisksItem.mediaLink);
          js2xml.addChildElement(dataVirtualHardDiskElement, mediaLinkElement);
        }
        
        if (dataVirtualHardDisksItem.sourceMediaLink !== null && dataVirtualHardDisksItem.sourceMediaLink !== undefined) {
          var sourceMediaLinkElement = js2xml.createElement('SourceMediaLink', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(sourceMediaLinkElement, dataVirtualHardDisksItem.sourceMediaLink);
          js2xml.addChildElement(dataVirtualHardDiskElement, sourceMediaLinkElement);
        }
        
        if (dataVirtualHardDisksItem.iOType !== null && dataVirtualHardDisksItem.iOType !== undefined) {
          var iOTypeElement = js2xml.createElement('IOType', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(iOTypeElement, dataVirtualHardDisksItem.iOType);
          js2xml.addChildElement(dataVirtualHardDiskElement, iOTypeElement);
        }
      }
      js2xml.addChildElement(persistentVMRoleElement, dataVirtualHardDisksSequenceElement);
    }
    
    if (parameters.oSVirtualHardDisk !== null && parameters.oSVirtualHardDisk !== undefined) {
      var oSVirtualHardDiskElement = js2xml.createElement('OSVirtualHardDisk', 'http://schemas.microsoft.com/windowsazure');
      js2xml.addChildElement(persistentVMRoleElement, oSVirtualHardDiskElement);
      
      if (parameters.oSVirtualHardDisk.hostCaching !== null && parameters.oSVirtualHardDisk.hostCaching !== undefined) {
        var hostCachingElement2 = js2xml.createElement('HostCaching', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(hostCachingElement2, parameters.oSVirtualHardDisk.hostCaching);
        js2xml.addChildElement(oSVirtualHardDiskElement, hostCachingElement2);
      }
      
      if (parameters.oSVirtualHardDisk.label !== null && parameters.oSVirtualHardDisk.label !== undefined) {
        var diskLabelElement2 = js2xml.createElement('DiskLabel', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(diskLabelElement2, parameters.oSVirtualHardDisk.label);
        js2xml.addChildElement(oSVirtualHardDiskElement, diskLabelElement2);
      }
      
      if (parameters.oSVirtualHardDisk.name !== null && parameters.oSVirtualHardDisk.name !== undefined) {
        var diskNameElement2 = js2xml.createElement('DiskName', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(diskNameElement2, parameters.oSVirtualHardDisk.name);
        js2xml.addChildElement(oSVirtualHardDiskElement, diskNameElement2);
      }
      
      if (parameters.oSVirtualHardDisk.mediaLink !== null && parameters.oSVirtualHardDisk.mediaLink !== undefined) {
        var mediaLinkElement2 = js2xml.createElement('MediaLink', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(mediaLinkElement2, parameters.oSVirtualHardDisk.mediaLink);
        js2xml.addChildElement(oSVirtualHardDiskElement, mediaLinkElement2);
      }
      
      if (parameters.oSVirtualHardDisk.sourceImageName !== null && parameters.oSVirtualHardDisk.sourceImageName !== undefined) {
        var sourceImageNameElement = js2xml.createElement('SourceImageName', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(sourceImageNameElement, parameters.oSVirtualHardDisk.sourceImageName);
        js2xml.addChildElement(oSVirtualHardDiskElement, sourceImageNameElement);
      }
      
      if (parameters.oSVirtualHardDisk.operatingSystem !== null && parameters.oSVirtualHardDisk.operatingSystem !== undefined) {
        var osElement = js2xml.createElement('OS', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(osElement, parameters.oSVirtualHardDisk.operatingSystem);
        js2xml.addChildElement(oSVirtualHardDiskElement, osElement);
      }
      
      if (parameters.oSVirtualHardDisk.remoteSourceImageLink !== null && parameters.oSVirtualHardDisk.remoteSourceImageLink !== undefined) {
        var remoteSourceImageLinkElement = js2xml.createElement('RemoteSourceImageLink', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(remoteSourceImageLinkElement, parameters.oSVirtualHardDisk.remoteSourceImageLink);
        js2xml.addChildElement(oSVirtualHardDiskElement, remoteSourceImageLinkElement);
      }
      
      if (parameters.oSVirtualHardDisk.iOType !== null && parameters.oSVirtualHardDisk.iOType !== undefined) {
        var iOTypeElement2 = js2xml.createElement('IOType', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(iOTypeElement2, parameters.oSVirtualHardDisk.iOType);
        js2xml.addChildElement(oSVirtualHardDiskElement, iOTypeElement2);
      }
      
      if (parameters.oSVirtualHardDisk.resizedSizeInGB !== null && parameters.oSVirtualHardDisk.resizedSizeInGB !== undefined) {
        var resizedSizeInGBElement = js2xml.createElement('ResizedSizeInGB', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(resizedSizeInGBElement, parameters.oSVirtualHardDisk.resizedSizeInGB.toString());
        js2xml.addChildElement(oSVirtualHardDiskElement, resizedSizeInGBElement);
      }
    }
    
    if (parameters.roleSize !== null && parameters.roleSize !== undefined) {
      var roleSizeElement = js2xml.createElement('RoleSize', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(roleSizeElement, parameters.roleSize);
      js2xml.addChildElement(persistentVMRoleElement, roleSizeElement);
    }
    
    if (parameters.provisionGuestAgent !== null && parameters.provisionGuestAgent !== undefined) {
      var provisionGuestAgentElement = js2xml.createElement('ProvisionGuestAgent', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(provisionGuestAgentElement, parameters.provisionGuestAgent.toString());
      js2xml.addChildElement(persistentVMRoleElement, provisionGuestAgentElement);
    }
    
    if (parameters.vMImageInput !== null && parameters.vMImageInput !== undefined) {
      var vMImageInputElement = js2xml.createElement('VMImageInput', 'http://schemas.microsoft.com/windowsazure');
      js2xml.addChildElement(persistentVMRoleElement, vMImageInputElement);
    }
    
    if (parameters.debugSettings !== null && parameters.debugSettings !== undefined) {
      var debugSettingsElement = js2xml.createElement('DebugSettings', 'http://schemas.microsoft.com/windowsazure');
      js2xml.addChildElement(persistentVMRoleElement, debugSettingsElement);
      
      var bootDiagnosticsEnabledElement = js2xml.createElement('BootDiagnosticsEnabled', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(bootDiagnosticsEnabledElement, parameters.debugSettings.bootDiagnosticsEnabled.toString());
      js2xml.addChildElement(debugSettingsElement, bootDiagnosticsEnabledElement);
      
      if (parameters.debugSettings.consoleScreenshotBlobUri !== null && parameters.debugSettings.consoleScreenshotBlobUri !== undefined) {
        var consoleScreenshotBlobUriElement = js2xml.createElement('ConsoleScreenshotBlobUri', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(consoleScreenshotBlobUriElement, parameters.debugSettings.consoleScreenshotBlobUri);
        js2xml.addChildElement(debugSettingsElement, consoleScreenshotBlobUriElement);
      }
      
      if (parameters.debugSettings.serialOutputBlobUri !== null && parameters.debugSettings.serialOutputBlobUri !== undefined) {
        var serialOutputBlobUriElement = js2xml.createElement('SerialOutputBlobUri', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(serialOutputBlobUriElement, parameters.debugSettings.serialOutputBlobUri);
        js2xml.addChildElement(debugSettingsElement, serialOutputBlobUriElement);
      }
    }
    
    if (parameters.licenseType !== null && parameters.licenseType !== undefined) {
      var licenseTypeElement = js2xml.createElement('LicenseType', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(licenseTypeElement, parameters.licenseType);
      js2xml.addChildElement(persistentVMRoleElement, licenseTypeElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Creating Virtual Machine Deployment operation provisions a
   * virtual machine based on the supplied configuration. When you create a
   * deployment of a virtual machine, you should make sure that the cloud
   * service and the disk or image that you use are located in the same
   * region. For example, if the cloud service was created in the West US
   * region, the disk or image that you use should also be located in a
   * storage account in the West US region.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157194.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {VirtualMachineCreateDeploymentParameters} parameters Parameters
   * supplied to the Begin Creating Virtual Machine Deployment operation.
   * 
   * @param {string} parameters.name A name for the deployment. The deployment
   * name must be unique among other deployments for the hosted service.
   * 
   * @param {DeploymentSlot} parameters.deploymentSlot Specifies the
   * environment in which to deploy the virtual machine. Possible values are:
   * Staging or Production.
   * 
   * @param {string} parameters.label A name for the hosted service. The name
   * can be up to 100 characters in length. It is recommended that the label
   * be unique within the subscription. The name can be used identify the
   * hosted service for tracking purposes.
   * 
   * @param {array} parameters.roles Contains the provisioning details for the
   * new virtual machine deployment.
   * 
   * @param {string} [parameters.virtualNetworkName] Specifies the name of an
   * existing virtual network to which the deployment will belong. Virtual
   * networks are created by calling the Set Network Configuration operation.
   * 
   * @param {DnsSettings} [parameters.dnsSettings] Contains a list of DNS
   * servers to associate with the machine.
   * 
   * @param {array} [parameters.dnsSettings.dnsServers] Contains a collection
   * of objects that define the DNS server settings.
   * 
   * @param {string} [parameters.reservedIPName] Optional. Specifies the name
   * of an existing reserved IP to which the deployment will belong. Reserved
   * IPs are created by calling the Create Reserved IP operation.
   * 
   * @param {IEnumerable} [parameters.loadBalancers] A list of internal load
   * balancers that each provide load balancing on a private VIP.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.beginCreatingDeployment = function(serviceName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.deploymentSlot === null || parameters.deploymentSlot === undefined) {
      return callback(new Error('parameters.deploymentSlot cannot be null.'));
    }
    if (parameters.label === null || parameters.label === undefined) {
      return callback(new Error('parameters.label cannot be null.'));
    }
    if (parameters.label.length > 100) {
      return callback(new Error('parameters.label is outside the valid range.'));
    }
    if (parameters.name === null || parameters.name === undefined) {
      return callback(new Error('parameters.name cannot be null.'));
    }
    if (parameters.roles === null || parameters.roles === undefined) {
      return callback(new Error('parameters.roles cannot be null.'));
    }
    if (parameters.roles !== null && parameters.roles !== undefined) {
      for (var loweredIndex1 = 0; loweredIndex1 < parameters.roles.length; loweredIndex1 = loweredIndex1 + 1) {
        var rolesParameterItem = parameters.roles[loweredIndex1];
        if (rolesParameterItem.configurationSets !== null && rolesParameterItem.configurationSets !== undefined) {
          for (var loweredIndex2 = 0; loweredIndex2 < rolesParameterItem.configurationSets.length; loweredIndex2 = loweredIndex2 + 1) {
            var configurationSetsParameterItem = rolesParameterItem.configurationSets[loweredIndex2];
            if (configurationSetsParameterItem.additionalUnattendContent !== null && configurationSetsParameterItem.additionalUnattendContent !== undefined) {
              if (configurationSetsParameterItem.additionalUnattendContent.unattendPasses !== null && configurationSetsParameterItem.additionalUnattendContent.unattendPasses !== undefined) {
                for (var loweredIndex3 = 0; loweredIndex3 < configurationSetsParameterItem.additionalUnattendContent.unattendPasses.length; loweredIndex3 = loweredIndex3 + 1) {
                  var unattendPassesParameterItem = configurationSetsParameterItem.additionalUnattendContent.unattendPasses[loweredIndex3];
                  if (unattendPassesParameterItem.passName === null || unattendPassesParameterItem.passName === undefined) {
                    return callback(new Error('parameters.roles.configurationSets.additionalUnattendContent.unattendPasses.passName cannot be null.'));
                  }
                  if (unattendPassesParameterItem.unattendComponents !== null && unattendPassesParameterItem.unattendComponents !== undefined) {
                    for (var loweredIndex4 = 0; loweredIndex4 < unattendPassesParameterItem.unattendComponents.length; loweredIndex4 = loweredIndex4 + 1) {
                      var unattendComponentsParameterItem = unattendPassesParameterItem.unattendComponents[loweredIndex4];
                      if (unattendComponentsParameterItem.componentName === null || unattendComponentsParameterItem.componentName === undefined) {
                        return callback(new Error('parameters.roles.configurationSets.additionalUnattendContent.unattendPasses.unattendComponents.componentName cannot be null.'));
                      }
                      if (unattendComponentsParameterItem.unattendComponentSettings !== null && unattendComponentsParameterItem.unattendComponentSettings !== undefined) {
                        for (var loweredIndex5 = 0; loweredIndex5 < unattendComponentsParameterItem.unattendComponentSettings.length; loweredIndex5 = loweredIndex5 + 1) {
                          var unattendComponentSettingsParameterItem = unattendComponentsParameterItem.unattendComponentSettings[loweredIndex5];
                          if (unattendComponentSettingsParameterItem.settingName === null || unattendComponentSettingsParameterItem.settingName === undefined) {
                            return callback(new Error('parameters.roles.configurationSets.additionalUnattendContent.unattendPasses.unattendComponents.unattendComponentSettings.settingName cannot be null.'));
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
            if (configurationSetsParameterItem.domainJoin !== null && configurationSetsParameterItem.domainJoin !== undefined) {
              if (configurationSetsParameterItem.domainJoin.credentials !== null && configurationSetsParameterItem.domainJoin.credentials !== undefined) {
                if (configurationSetsParameterItem.domainJoin.credentials.password === null || configurationSetsParameterItem.domainJoin.credentials.password === undefined) {
                  return callback(new Error('parameters.roles.configurationSets.domainJoin.credentials.password cannot be null.'));
                }
                if (configurationSetsParameterItem.domainJoin.credentials.userName === null || configurationSetsParameterItem.domainJoin.credentials.userName === undefined) {
                  return callback(new Error('parameters.roles.configurationSets.domainJoin.credentials.userName cannot be null.'));
                }
              }
            }
            if (configurationSetsParameterItem.hostName !== null && configurationSetsParameterItem.hostName !== undefined && configurationSetsParameterItem.hostName.length < 1) {
              return callback(new Error('parameters.roles.configurationSets.hostName is outside the valid range.'));
            }
            if (configurationSetsParameterItem.hostName !== null && configurationSetsParameterItem.hostName !== undefined && configurationSetsParameterItem.hostName.length > 64) {
              return callback(new Error('parameters.roles.configurationSets.hostName is outside the valid range.'));
            }
            if (configurationSetsParameterItem.sshSettings !== null && configurationSetsParameterItem.sshSettings !== undefined) {
              if (configurationSetsParameterItem.sshSettings.keyPairs !== null && configurationSetsParameterItem.sshSettings.keyPairs !== undefined) {
                for (var loweredIndex6 = 0; loweredIndex6 < configurationSetsParameterItem.sshSettings.keyPairs.length; loweredIndex6 = loweredIndex6 + 1) {
                  var keyPairsParameterItem = configurationSetsParameterItem.sshSettings.keyPairs[loweredIndex6];
                  if (keyPairsParameterItem.fingerprint === null || keyPairsParameterItem.fingerprint === undefined) {
                    return callback(new Error('parameters.roles.configurationSets.sshSettings.keyPairs.fingerprint cannot be null.'));
                  }
                  if (keyPairsParameterItem.path === null || keyPairsParameterItem.path === undefined) {
                    return callback(new Error('parameters.roles.configurationSets.sshSettings.keyPairs.path cannot be null.'));
                  }
                }
              }
              if (configurationSetsParameterItem.sshSettings.publicKeys !== null && configurationSetsParameterItem.sshSettings.publicKeys !== undefined) {
                for (var loweredIndex7 = 0; loweredIndex7 < configurationSetsParameterItem.sshSettings.publicKeys.length; loweredIndex7 = loweredIndex7 + 1) {
                  var publicKeysParameterItem = configurationSetsParameterItem.sshSettings.publicKeys[loweredIndex7];
                  if (publicKeysParameterItem.fingerprint === null || publicKeysParameterItem.fingerprint === undefined) {
                    return callback(new Error('parameters.roles.configurationSets.sshSettings.publicKeys.fingerprint cannot be null.'));
                  }
                  if (publicKeysParameterItem.path === null || publicKeysParameterItem.path === undefined) {
                    return callback(new Error('parameters.roles.configurationSets.sshSettings.publicKeys.path cannot be null.'));
                  }
                }
              }
            }
            if (configurationSetsParameterItem.storedCertificateSettings !== null && configurationSetsParameterItem.storedCertificateSettings !== undefined) {
              for (var loweredIndex8 = 0; loweredIndex8 < configurationSetsParameterItem.storedCertificateSettings.length; loweredIndex8 = loweredIndex8 + 1) {
                var storedCertificateSettingsParameterItem = configurationSetsParameterItem.storedCertificateSettings[loweredIndex8];
                if (storedCertificateSettingsParameterItem.storeName === null || storedCertificateSettingsParameterItem.storeName === undefined) {
                  return callback(new Error('parameters.roles.configurationSets.storedCertificateSettings.storeName cannot be null.'));
                }
                if (storedCertificateSettingsParameterItem.thumbprint === null || storedCertificateSettingsParameterItem.thumbprint === undefined) {
                  return callback(new Error('parameters.roles.configurationSets.storedCertificateSettings.thumbprint cannot be null.'));
                }
              }
            }
            if (configurationSetsParameterItem.userName !== null && configurationSetsParameterItem.userName !== undefined && configurationSetsParameterItem.userName.length < 1) {
              return callback(new Error('parameters.roles.configurationSets.userName is outside the valid range.'));
            }
            if (configurationSetsParameterItem.userName !== null && configurationSetsParameterItem.userName !== undefined && configurationSetsParameterItem.userName.length > 32) {
              return callback(new Error('parameters.roles.configurationSets.userName is outside the valid range.'));
            }
            if (configurationSetsParameterItem.userPassword !== null && configurationSetsParameterItem.userPassword !== undefined && configurationSetsParameterItem.userPassword.length < 6) {
              return callback(new Error('parameters.roles.configurationSets.userPassword is outside the valid range.'));
            }
            if (configurationSetsParameterItem.userPassword !== null && configurationSetsParameterItem.userPassword !== undefined && configurationSetsParameterItem.userPassword.length > 72) {
              return callback(new Error('parameters.roles.configurationSets.userPassword is outside the valid range.'));
            }
            if (configurationSetsParameterItem.windowsRemoteManagement !== null && configurationSetsParameterItem.windowsRemoteManagement !== undefined) {
              if (configurationSetsParameterItem.windowsRemoteManagement.listeners !== null && configurationSetsParameterItem.windowsRemoteManagement.listeners !== undefined) {
                for (var loweredIndex9 = 0; loweredIndex9 < configurationSetsParameterItem.windowsRemoteManagement.listeners.length; loweredIndex9 = loweredIndex9 + 1) {
                  var listenersParameterItem = configurationSetsParameterItem.windowsRemoteManagement.listeners[loweredIndex9];
                  if (listenersParameterItem.listenerType === null || listenersParameterItem.listenerType === undefined) {
                    return callback(new Error('parameters.roles.configurationSets.windowsRemoteManagement.listeners.listenerType cannot be null.'));
                  }
                }
              }
            }
          }
        }
        if (rolesParameterItem.debugSettings !== null && rolesParameterItem.debugSettings !== undefined) {
          if (rolesParameterItem.debugSettings.bootDiagnosticsEnabled === null || rolesParameterItem.debugSettings.bootDiagnosticsEnabled === undefined) {
            return callback(new Error('parameters.roles.debugSettings.bootDiagnosticsEnabled cannot be null.'));
          }
        }
      }
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var deploymentElement = js2xml.createElement('Deployment', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, deploymentElement);
    
    var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(nameElement, parameters.name);
    js2xml.addChildElement(deploymentElement, nameElement);
    
    var deploymentSlotElement = js2xml.createElement('DeploymentSlot', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(deploymentSlotElement, parameters.deploymentSlot !== null && parameters.deploymentSlot !== undefined ? parameters.deploymentSlot.toString() : 'Staging');
    js2xml.addChildElement(deploymentElement, deploymentSlotElement);
    
    var labelElement = js2xml.createElement('Label', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(labelElement, parameters.label);
    js2xml.addChildElement(deploymentElement, labelElement);
    
    var roleListSequenceElement = js2xml.createElement('RoleList', 'http://schemas.microsoft.com/windowsazure');
    for (var loweredIndex10 = 0; loweredIndex10 < parameters.roles.length; loweredIndex10 = loweredIndex10 + 1) {
      var roleListItem = parameters.roles[loweredIndex10];
      var roleElement = js2xml.createElement('Role', 'http://schemas.microsoft.com/windowsazure');
      js2xml.addChildElement(roleListSequenceElement, roleElement);
      
      if (roleListItem.roleName !== null && roleListItem.roleName !== undefined) {
        var roleNameElement = js2xml.createElement('RoleName', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(roleNameElement, roleListItem.roleName);
        js2xml.addChildElement(roleElement, roleNameElement);
      }
      
      if (roleListItem.oSVersion !== null && roleListItem.oSVersion !== undefined) {
        var osVersionElement = js2xml.createElement('OsVersion', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(osVersionElement, roleListItem.oSVersion);
        js2xml.addChildElement(roleElement, osVersionElement);
      }
      
      if (roleListItem.roleType !== null && roleListItem.roleType !== undefined) {
        var roleTypeElement = js2xml.createElement('RoleType', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(roleTypeElement, roleListItem.roleType);
        js2xml.addChildElement(roleElement, roleTypeElement);
      }
      
      if (roleListItem.configurationSets !== null && roleListItem.configurationSets !== undefined) {
        var configurationSetsSequenceElement = js2xml.createElement('ConfigurationSets', 'http://schemas.microsoft.com/windowsazure');
        for (var loweredIndex11 = 0; loweredIndex11 < roleListItem.configurationSets.length; loweredIndex11 = loweredIndex11 + 1) {
          var configurationSetsItem = roleListItem.configurationSets[loweredIndex11];
          var configurationSetElement = js2xml.createElement('ConfigurationSet', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(configurationSetsSequenceElement, configurationSetElement);
          
          if (configurationSetsItem.configurationSetType !== null && configurationSetsItem.configurationSetType !== undefined) {
            var configurationSetTypeElement = js2xml.createElement('ConfigurationSetType', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(configurationSetTypeElement, configurationSetsItem.configurationSetType);
            js2xml.addChildElement(configurationSetElement, configurationSetTypeElement);
          }
          
          if (configurationSetsItem.inputEndpoints !== null && configurationSetsItem.inputEndpoints !== undefined) {
            var inputEndpointsSequenceElement = js2xml.createElement('InputEndpoints', 'http://schemas.microsoft.com/windowsazure');
            for (var loweredIndex12 = 0; loweredIndex12 < configurationSetsItem.inputEndpoints.length; loweredIndex12 = loweredIndex12 + 1) {
              var inputEndpointsItem = configurationSetsItem.inputEndpoints[loweredIndex12];
              var inputEndpointElement = js2xml.createElement('InputEndpoint', 'http://schemas.microsoft.com/windowsazure');
              js2xml.addChildElement(inputEndpointsSequenceElement, inputEndpointElement);
              
              if (inputEndpointsItem.loadBalancedEndpointSetName !== null && inputEndpointsItem.loadBalancedEndpointSetName !== undefined) {
                var loadBalancedEndpointSetNameElement = js2xml.createElement('LoadBalancedEndpointSetName', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(loadBalancedEndpointSetNameElement, inputEndpointsItem.loadBalancedEndpointSetName);
                js2xml.addChildElement(inputEndpointElement, loadBalancedEndpointSetNameElement);
              }
              
              if (inputEndpointsItem.localPort !== null && inputEndpointsItem.localPort !== undefined) {
                var localPortElement = js2xml.createElement('LocalPort', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(localPortElement, inputEndpointsItem.localPort.toString());
                js2xml.addChildElement(inputEndpointElement, localPortElement);
              }
              
              if (inputEndpointsItem.name !== null && inputEndpointsItem.name !== undefined) {
                var nameElement2 = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(nameElement2, inputEndpointsItem.name);
                js2xml.addChildElement(inputEndpointElement, nameElement2);
              }
              
              if (inputEndpointsItem.port !== null && inputEndpointsItem.port !== undefined) {
                var portElement = js2xml.createElement('Port', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(portElement, inputEndpointsItem.port.toString());
                js2xml.addChildElement(inputEndpointElement, portElement);
              }
              
              if (inputEndpointsItem.loadBalancerProbe !== null && inputEndpointsItem.loadBalancerProbe !== undefined) {
                var loadBalancerProbeElement = js2xml.createElement('LoadBalancerProbe', 'http://schemas.microsoft.com/windowsazure');
                js2xml.addChildElement(inputEndpointElement, loadBalancerProbeElement);
                
                if (inputEndpointsItem.loadBalancerProbe.path !== null && inputEndpointsItem.loadBalancerProbe.path !== undefined) {
                  var pathElement = js2xml.createElement('Path', 'http://schemas.microsoft.com/windowsazure');
                  js2xml.setElementValue(pathElement, inputEndpointsItem.loadBalancerProbe.path);
                  js2xml.addChildElement(loadBalancerProbeElement, pathElement);
                }
                
                if (inputEndpointsItem.loadBalancerProbe.port !== null && inputEndpointsItem.loadBalancerProbe.port !== undefined) {
                  var portElement2 = js2xml.createElement('Port', 'http://schemas.microsoft.com/windowsazure');
                  js2xml.setElementValue(portElement2, inputEndpointsItem.loadBalancerProbe.port.toString());
                  js2xml.addChildElement(loadBalancerProbeElement, portElement2);
                }
                
                if (inputEndpointsItem.loadBalancerProbe.protocol !== null && inputEndpointsItem.loadBalancerProbe.protocol !== undefined) {
                  var protocolElement = js2xml.createElement('Protocol', 'http://schemas.microsoft.com/windowsazure');
                  js2xml.setElementValue(protocolElement, inputEndpointsItem.loadBalancerProbe.protocol !== null && inputEndpointsItem.loadBalancerProbe.protocol !== undefined ? inputEndpointsItem.loadBalancerProbe.protocol.toString() : 'Tcp');
                  js2xml.addChildElement(loadBalancerProbeElement, protocolElement);
                }
                
                if (inputEndpointsItem.loadBalancerProbe.intervalInSeconds !== null && inputEndpointsItem.loadBalancerProbe.intervalInSeconds !== undefined) {
                  var intervalInSecondsElement = js2xml.createElement('IntervalInSeconds', 'http://schemas.microsoft.com/windowsazure');
                  js2xml.setElementValue(intervalInSecondsElement, inputEndpointsItem.loadBalancerProbe.intervalInSeconds.toString());
                  js2xml.addChildElement(loadBalancerProbeElement, intervalInSecondsElement);
                }
                
                if (inputEndpointsItem.loadBalancerProbe.timeoutInSeconds !== null && inputEndpointsItem.loadBalancerProbe.timeoutInSeconds !== undefined) {
                  var timeoutInSecondsElement = js2xml.createElement('TimeoutInSeconds', 'http://schemas.microsoft.com/windowsazure');
                  js2xml.setElementValue(timeoutInSecondsElement, inputEndpointsItem.loadBalancerProbe.timeoutInSeconds.toString());
                  js2xml.addChildElement(loadBalancerProbeElement, timeoutInSecondsElement);
                }
              }
              
              if (inputEndpointsItem.protocol !== null && inputEndpointsItem.protocol !== undefined) {
                var protocolElement2 = js2xml.createElement('Protocol', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(protocolElement2, inputEndpointsItem.protocol);
                js2xml.addChildElement(inputEndpointElement, protocolElement2);
              }
              
              if (inputEndpointsItem.virtualIPAddress !== null && inputEndpointsItem.virtualIPAddress !== undefined) {
                var vipElement = js2xml.createElement('Vip', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(vipElement, inputEndpointsItem.virtualIPAddress);
                js2xml.addChildElement(inputEndpointElement, vipElement);
              }
              
              if (inputEndpointsItem.enableDirectServerReturn !== null && inputEndpointsItem.enableDirectServerReturn !== undefined) {
                var enableDirectServerReturnElement = js2xml.createElement('EnableDirectServerReturn', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(enableDirectServerReturnElement, inputEndpointsItem.enableDirectServerReturn.toString());
                js2xml.addChildElement(inputEndpointElement, enableDirectServerReturnElement);
              }
              
              if (inputEndpointsItem.loadBalancerName !== null && inputEndpointsItem.loadBalancerName !== undefined) {
                var loadBalancerNameElement = js2xml.createElement('LoadBalancerName', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(loadBalancerNameElement, inputEndpointsItem.loadBalancerName);
                js2xml.addChildElement(inputEndpointElement, loadBalancerNameElement);
              }
              
              if (inputEndpointsItem.endpointAcl !== null && inputEndpointsItem.endpointAcl !== undefined) {
                var endpointAclElement = js2xml.createElement('EndpointAcl', 'http://schemas.microsoft.com/windowsazure');
                js2xml.addChildElement(inputEndpointElement, endpointAclElement);
                
                if (inputEndpointsItem.endpointAcl.rules !== null && inputEndpointsItem.endpointAcl.rules !== undefined) {
                  var rulesSequenceElement = js2xml.createElement('Rules', 'http://schemas.microsoft.com/windowsazure');
                  for (var loweredIndex13 = 0; loweredIndex13 < inputEndpointsItem.endpointAcl.rules.length; loweredIndex13 = loweredIndex13 + 1) {
                    var rulesItem = inputEndpointsItem.endpointAcl.rules[loweredIndex13];
                    var ruleElement = js2xml.createElement('Rule', 'http://schemas.microsoft.com/windowsazure');
                    js2xml.addChildElement(rulesSequenceElement, ruleElement);
                    
                    if (rulesItem.order !== null && rulesItem.order !== undefined) {
                      var orderElement = js2xml.createElement('Order', 'http://schemas.microsoft.com/windowsazure');
                      js2xml.setElementValue(orderElement, rulesItem.order.toString());
                      js2xml.addChildElement(ruleElement, orderElement);
                    }
                    
                    if (rulesItem.action !== null && rulesItem.action !== undefined) {
                      var actionElement = js2xml.createElement('Action', 'http://schemas.microsoft.com/windowsazure');
                      js2xml.setElementValue(actionElement, rulesItem.action);
                      js2xml.addChildElement(ruleElement, actionElement);
                    }
                    
                    if (rulesItem.remoteSubnet !== null && rulesItem.remoteSubnet !== undefined) {
                      var remoteSubnetElement = js2xml.createElement('RemoteSubnet', 'http://schemas.microsoft.com/windowsazure');
                      js2xml.setElementValue(remoteSubnetElement, rulesItem.remoteSubnet);
                      js2xml.addChildElement(ruleElement, remoteSubnetElement);
                    }
                    
                    if (rulesItem.description !== null && rulesItem.description !== undefined) {
                      var descriptionElement = js2xml.createElement('Description', 'http://schemas.microsoft.com/windowsazure');
                      js2xml.setElementValue(descriptionElement, rulesItem.description);
                      js2xml.addChildElement(ruleElement, descriptionElement);
                    }
                  }
                  js2xml.addChildElement(endpointAclElement, rulesSequenceElement);
                }
              }
              
              if (inputEndpointsItem.idleTimeoutInMinutes !== null && inputEndpointsItem.idleTimeoutInMinutes !== undefined) {
                var idleTimeoutInMinutesElement = js2xml.createElement('IdleTimeoutInMinutes', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(idleTimeoutInMinutesElement, inputEndpointsItem.idleTimeoutInMinutes.toString());
                js2xml.addChildElement(inputEndpointElement, idleTimeoutInMinutesElement);
              }
              
              if (inputEndpointsItem.loadBalancerDistribution !== null && inputEndpointsItem.loadBalancerDistribution !== undefined) {
                var loadBalancerDistributionElement = js2xml.createElement('LoadBalancerDistribution', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(loadBalancerDistributionElement, inputEndpointsItem.loadBalancerDistribution);
                js2xml.addChildElement(inputEndpointElement, loadBalancerDistributionElement);
              }
              
              if (inputEndpointsItem.virtualIPName !== null && inputEndpointsItem.virtualIPName !== undefined) {
                var virtualIPNameElement = js2xml.createElement('VirtualIPName', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(virtualIPNameElement, inputEndpointsItem.virtualIPName);
                js2xml.addChildElement(inputEndpointElement, virtualIPNameElement);
              }
            }
            js2xml.addChildElement(configurationSetElement, inputEndpointsSequenceElement);
          }
          
          if (configurationSetsItem.subnetNames !== null && configurationSetsItem.subnetNames !== undefined) {
            var subnetNamesSequenceElement = js2xml.createElement('SubnetNames', 'http://schemas.microsoft.com/windowsazure');
            for (var loweredIndex14 = 0; loweredIndex14 < configurationSetsItem.subnetNames.length; loweredIndex14 = loweredIndex14 + 1) {
              var subnetNamesItem = configurationSetsItem.subnetNames[loweredIndex14];
              var subnetNamesItemElement = js2xml.createElement('SubnetName', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(subnetNamesItemElement, subnetNamesItem);
              js2xml.addChildElement(subnetNamesSequenceElement, subnetNamesItemElement);
            }
            js2xml.addChildElement(configurationSetElement, subnetNamesSequenceElement);
          }
          
          if (configurationSetsItem.staticVirtualNetworkIPAddress !== null && configurationSetsItem.staticVirtualNetworkIPAddress !== undefined) {
            var staticVirtualNetworkIPAddressElement = js2xml.createElement('StaticVirtualNetworkIPAddress', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(staticVirtualNetworkIPAddressElement, configurationSetsItem.staticVirtualNetworkIPAddress);
            js2xml.addChildElement(configurationSetElement, staticVirtualNetworkIPAddressElement);
          }
          
          if (configurationSetsItem.publicIPs !== null && configurationSetsItem.publicIPs !== undefined) {
            var publicIPsSequenceElement = js2xml.createElement('PublicIPs', 'http://schemas.microsoft.com/windowsazure');
            for (var loweredIndex15 = 0; loweredIndex15 < configurationSetsItem.publicIPs.length; loweredIndex15 = loweredIndex15 + 1) {
              var publicIPsItem = configurationSetsItem.publicIPs[loweredIndex15];
              var publicIPElement = js2xml.createElement('PublicIP', 'http://schemas.microsoft.com/windowsazure');
              js2xml.addChildElement(publicIPsSequenceElement, publicIPElement);
              
              if (publicIPsItem.name !== null && publicIPsItem.name !== undefined) {
                var nameElement3 = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(nameElement3, publicIPsItem.name);
                js2xml.addChildElement(publicIPElement, nameElement3);
              }
              
              if (publicIPsItem.idleTimeoutInMinutes !== null && publicIPsItem.idleTimeoutInMinutes !== undefined) {
                var idleTimeoutInMinutesElement2 = js2xml.createElement('IdleTimeoutInMinutes', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(idleTimeoutInMinutesElement2, publicIPsItem.idleTimeoutInMinutes.toString());
                js2xml.addChildElement(publicIPElement, idleTimeoutInMinutesElement2);
              }
              
              if (publicIPsItem.domainNameLabel !== null && publicIPsItem.domainNameLabel !== undefined) {
                var domainNameLabelElement = js2xml.createElement('DomainNameLabel', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(domainNameLabelElement, publicIPsItem.domainNameLabel);
                js2xml.addChildElement(publicIPElement, domainNameLabelElement);
              }
            }
            js2xml.addChildElement(configurationSetElement, publicIPsSequenceElement);
          }
          
          if (configurationSetsItem.networkInterfaces !== null && configurationSetsItem.networkInterfaces !== undefined) {
            var networkInterfacesSequenceElement = js2xml.createElement('NetworkInterfaces', 'http://schemas.microsoft.com/windowsazure');
            for (var loweredIndex16 = 0; loweredIndex16 < configurationSetsItem.networkInterfaces.length; loweredIndex16 = loweredIndex16 + 1) {
              var networkInterfacesItem = configurationSetsItem.networkInterfaces[loweredIndex16];
              var networkInterfaceElement = js2xml.createElement('NetworkInterface', 'http://schemas.microsoft.com/windowsazure');
              js2xml.addChildElement(networkInterfacesSequenceElement, networkInterfaceElement);
              
              if (networkInterfacesItem.name !== null && networkInterfacesItem.name !== undefined) {
                var nameElement4 = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(nameElement4, networkInterfacesItem.name);
                js2xml.addChildElement(networkInterfaceElement, nameElement4);
              }
              
              if (networkInterfacesItem.iPConfigurations !== null && networkInterfacesItem.iPConfigurations !== undefined) {
                var iPConfigurationsSequenceElement = js2xml.createElement('IPConfigurations', 'http://schemas.microsoft.com/windowsazure');
                for (var loweredIndex17 = 0; loweredIndex17 < networkInterfacesItem.iPConfigurations.length; loweredIndex17 = loweredIndex17 + 1) {
                  var iPConfigurationsItem = networkInterfacesItem.iPConfigurations[loweredIndex17];
                  var iPConfigurationElement = js2xml.createElement('IPConfiguration', 'http://schemas.microsoft.com/windowsazure');
                  js2xml.addChildElement(iPConfigurationsSequenceElement, iPConfigurationElement);
                  
                  if (iPConfigurationsItem.subnetName !== null && iPConfigurationsItem.subnetName !== undefined) {
                    var subnetNameElement = js2xml.createElement('SubnetName', 'http://schemas.microsoft.com/windowsazure');
                    js2xml.setElementValue(subnetNameElement, iPConfigurationsItem.subnetName);
                    js2xml.addChildElement(iPConfigurationElement, subnetNameElement);
                  }
                  
                  if (iPConfigurationsItem.staticVirtualNetworkIPAddress !== null && iPConfigurationsItem.staticVirtualNetworkIPAddress !== undefined) {
                    var staticVirtualNetworkIPAddressElement2 = js2xml.createElement('StaticVirtualNetworkIPAddress', 'http://schemas.microsoft.com/windowsazure');
                    js2xml.setElementValue(staticVirtualNetworkIPAddressElement2, iPConfigurationsItem.staticVirtualNetworkIPAddress);
                    js2xml.addChildElement(iPConfigurationElement, staticVirtualNetworkIPAddressElement2);
                  }
                }
                js2xml.addChildElement(networkInterfaceElement, iPConfigurationsSequenceElement);
              }
              
              if (networkInterfacesItem.networkSecurityGroup !== null && networkInterfacesItem.networkSecurityGroup !== undefined) {
                var networkSecurityGroupElement = js2xml.createElement('NetworkSecurityGroup', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(networkSecurityGroupElement, networkInterfacesItem.networkSecurityGroup);
                js2xml.addChildElement(networkInterfaceElement, networkSecurityGroupElement);
              }
              
              if (networkInterfacesItem.iPForwarding !== null && networkInterfacesItem.iPForwarding !== undefined) {
                var iPForwardingElement = js2xml.createElement('IPForwarding', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(iPForwardingElement, networkInterfacesItem.iPForwarding);
                js2xml.addChildElement(networkInterfaceElement, iPForwardingElement);
              }
            }
            js2xml.addChildElement(configurationSetElement, networkInterfacesSequenceElement);
          }
          
          if (configurationSetsItem.networkSecurityGroup !== null && configurationSetsItem.networkSecurityGroup !== undefined) {
            var networkSecurityGroupElement2 = js2xml.createElement('NetworkSecurityGroup', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(networkSecurityGroupElement2, configurationSetsItem.networkSecurityGroup);
            js2xml.addChildElement(configurationSetElement, networkSecurityGroupElement2);
          }
          
          if (configurationSetsItem.iPForwarding !== null && configurationSetsItem.iPForwarding !== undefined) {
            var iPForwardingElement2 = js2xml.createElement('IPForwarding', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(iPForwardingElement2, configurationSetsItem.iPForwarding);
            js2xml.addChildElement(configurationSetElement, iPForwardingElement2);
          }
          
          if (configurationSetsItem.computerName !== null && configurationSetsItem.computerName !== undefined) {
            var computerNameElement = js2xml.createElement('ComputerName', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(computerNameElement, configurationSetsItem.computerName);
            js2xml.addChildElement(configurationSetElement, computerNameElement);
          }
          
          if (configurationSetsItem.adminPassword !== null && configurationSetsItem.adminPassword !== undefined) {
            var adminPasswordElement = js2xml.createElement('AdminPassword', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(adminPasswordElement, configurationSetsItem.adminPassword);
            js2xml.addChildElement(configurationSetElement, adminPasswordElement);
          }
          
          if (configurationSetsItem.resetPasswordOnFirstLogon !== null && configurationSetsItem.resetPasswordOnFirstLogon !== undefined) {
            var resetPasswordOnFirstLogonElement = js2xml.createElement('ResetPasswordOnFirstLogon', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(resetPasswordOnFirstLogonElement, configurationSetsItem.resetPasswordOnFirstLogon.toString());
            js2xml.addChildElement(configurationSetElement, resetPasswordOnFirstLogonElement);
          }
          
          if (configurationSetsItem.enableAutomaticUpdates !== null && configurationSetsItem.enableAutomaticUpdates !== undefined) {
            var enableAutomaticUpdatesElement = js2xml.createElement('EnableAutomaticUpdates', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(enableAutomaticUpdatesElement, configurationSetsItem.enableAutomaticUpdates.toString());
            js2xml.addChildElement(configurationSetElement, enableAutomaticUpdatesElement);
          }
          
          if (configurationSetsItem.timeZone !== null && configurationSetsItem.timeZone !== undefined) {
            var timeZoneElement = js2xml.createElement('TimeZone', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(timeZoneElement, configurationSetsItem.timeZone);
            js2xml.addChildElement(configurationSetElement, timeZoneElement);
          }
          
          if (configurationSetsItem.domainJoin !== null && configurationSetsItem.domainJoin !== undefined) {
            var domainJoinElement = js2xml.createElement('DomainJoin', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(configurationSetElement, domainJoinElement);
            
            if (configurationSetsItem.domainJoin.credentials !== null && configurationSetsItem.domainJoin.credentials !== undefined) {
              var credentialsElement = js2xml.createElement('Credentials', 'http://schemas.microsoft.com/windowsazure');
              js2xml.addChildElement(domainJoinElement, credentialsElement);
              
              if (configurationSetsItem.domainJoin.credentials.domain !== null && configurationSetsItem.domainJoin.credentials.domain !== undefined) {
                var domainElement = js2xml.createElement('Domain', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(domainElement, configurationSetsItem.domainJoin.credentials.domain);
                js2xml.addChildElement(credentialsElement, domainElement);
              }
              
              var usernameElement = js2xml.createElement('Username', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(usernameElement, configurationSetsItem.domainJoin.credentials.userName);
              js2xml.addChildElement(credentialsElement, usernameElement);
              
              var passwordElement = js2xml.createElement('Password', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(passwordElement, configurationSetsItem.domainJoin.credentials.password);
              js2xml.addChildElement(credentialsElement, passwordElement);
            }
            
            if (configurationSetsItem.domainJoin.domainToJoin !== null && configurationSetsItem.domainJoin.domainToJoin !== undefined) {
              var joinDomainElement = js2xml.createElement('JoinDomain', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(joinDomainElement, configurationSetsItem.domainJoin.domainToJoin);
              js2xml.addChildElement(domainJoinElement, joinDomainElement);
            }
            
            if (configurationSetsItem.domainJoin.ldapMachineObjectOU !== null && configurationSetsItem.domainJoin.ldapMachineObjectOU !== undefined) {
              var machineObjectOUElement = js2xml.createElement('MachineObjectOU', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(machineObjectOUElement, configurationSetsItem.domainJoin.ldapMachineObjectOU);
              js2xml.addChildElement(domainJoinElement, machineObjectOUElement);
            }
            
            if (configurationSetsItem.domainJoin.provisioning !== null && configurationSetsItem.domainJoin.provisioning !== undefined) {
              var provisioningElement = js2xml.createElement('Provisioning', 'http://schemas.microsoft.com/windowsazure');
              js2xml.addChildElement(domainJoinElement, provisioningElement);
              
              if (configurationSetsItem.domainJoin.provisioning.accountData !== null && configurationSetsItem.domainJoin.provisioning.accountData !== undefined) {
                var accountDataElement = js2xml.createElement('AccountData', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(accountDataElement, configurationSetsItem.domainJoin.provisioning.accountData);
                js2xml.addChildElement(provisioningElement, accountDataElement);
              }
            }
          }
          
          if (configurationSetsItem.storedCertificateSettings !== null && configurationSetsItem.storedCertificateSettings !== undefined) {
            var storedCertificateSettingsSequenceElement = js2xml.createElement('StoredCertificateSettings', 'http://schemas.microsoft.com/windowsazure');
            for (var loweredIndex18 = 0; loweredIndex18 < configurationSetsItem.storedCertificateSettings.length; loweredIndex18 = loweredIndex18 + 1) {
              var storedCertificateSettingsItem = configurationSetsItem.storedCertificateSettings[loweredIndex18];
              var certificateSettingElement = js2xml.createElement('CertificateSetting', 'http://schemas.microsoft.com/windowsazure');
              js2xml.addChildElement(storedCertificateSettingsSequenceElement, certificateSettingElement);
              
              var storeLocationElement = js2xml.createElement('StoreLocation', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(storeLocationElement, 'LocalMachine');
              js2xml.addChildElement(certificateSettingElement, storeLocationElement);
              
              var storeNameElement = js2xml.createElement('StoreName', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(storeNameElement, storedCertificateSettingsItem.storeName);
              js2xml.addChildElement(certificateSettingElement, storeNameElement);
              
              var thumbprintElement = js2xml.createElement('Thumbprint', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(thumbprintElement, storedCertificateSettingsItem.thumbprint);
              js2xml.addChildElement(certificateSettingElement, thumbprintElement);
            }
            js2xml.addChildElement(configurationSetElement, storedCertificateSettingsSequenceElement);
          }
          
          if (configurationSetsItem.windowsRemoteManagement !== null && configurationSetsItem.windowsRemoteManagement !== undefined) {
            var winRMElement = js2xml.createElement('WinRM', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(configurationSetElement, winRMElement);
            
            if (configurationSetsItem.windowsRemoteManagement.listeners !== null && configurationSetsItem.windowsRemoteManagement.listeners !== undefined) {
              var listenersSequenceElement = js2xml.createElement('Listeners', 'http://schemas.microsoft.com/windowsazure');
              for (var loweredIndex19 = 0; loweredIndex19 < configurationSetsItem.windowsRemoteManagement.listeners.length; loweredIndex19 = loweredIndex19 + 1) {
                var listenersItem = configurationSetsItem.windowsRemoteManagement.listeners[loweredIndex19];
                var listenerElement = js2xml.createElement('Listener', 'http://schemas.microsoft.com/windowsazure');
                js2xml.addChildElement(listenersSequenceElement, listenerElement);
                
                if (listenersItem.certificateThumbprint !== null && listenersItem.certificateThumbprint !== undefined) {
                  var certificateThumbprintElement = js2xml.createElement('CertificateThumbprint', 'http://schemas.microsoft.com/windowsazure');
                  js2xml.setElementValue(certificateThumbprintElement, listenersItem.certificateThumbprint);
                  js2xml.addChildElement(listenerElement, certificateThumbprintElement);
                }
                
                var protocolElement3 = js2xml.createElement('Protocol', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(protocolElement3, listenersItem.listenerType !== null && listenersItem.listenerType !== undefined ? listenersItem.listenerType.toString() : 'Http');
                js2xml.addChildElement(listenerElement, protocolElement3);
              }
              js2xml.addChildElement(winRMElement, listenersSequenceElement);
            }
          }
          
          if (configurationSetsItem.adminUserName !== null && configurationSetsItem.adminUserName !== undefined) {
            var adminUsernameElement = js2xml.createElement('AdminUsername', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(adminUsernameElement, configurationSetsItem.adminUserName);
            js2xml.addChildElement(configurationSetElement, adminUsernameElement);
          }
          
          if (configurationSetsItem.additionalUnattendContent !== null && configurationSetsItem.additionalUnattendContent !== undefined) {
            var additionalUnattendContentElement = js2xml.createElement('AdditionalUnattendContent', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(configurationSetElement, additionalUnattendContentElement);
            
            if (configurationSetsItem.additionalUnattendContent.unattendPasses !== null && configurationSetsItem.additionalUnattendContent.unattendPasses !== undefined) {
              var passesSequenceElement = js2xml.createElement('Passes', 'http://schemas.microsoft.com/windowsazure');
              for (var loweredIndex20 = 0; loweredIndex20 < configurationSetsItem.additionalUnattendContent.unattendPasses.length; loweredIndex20 = loweredIndex20 + 1) {
                var passesItem = configurationSetsItem.additionalUnattendContent.unattendPasses[loweredIndex20];
                var unattendPassElement = js2xml.createElement('UnattendPass', 'http://schemas.microsoft.com/windowsazure');
                js2xml.addChildElement(passesSequenceElement, unattendPassElement);
                
                var passNameElement = js2xml.createElement('PassName', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(passNameElement, passesItem.passName);
                js2xml.addChildElement(unattendPassElement, passNameElement);
                
                if (passesItem.unattendComponents !== null && passesItem.unattendComponents !== undefined) {
                  var componentsSequenceElement = js2xml.createElement('Components', 'http://schemas.microsoft.com/windowsazure');
                  for (var loweredIndex21 = 0; loweredIndex21 < passesItem.unattendComponents.length; loweredIndex21 = loweredIndex21 + 1) {
                    var componentsItem = passesItem.unattendComponents[loweredIndex21];
                    var unattendComponentElement = js2xml.createElement('UnattendComponent', 'http://schemas.microsoft.com/windowsazure');
                    js2xml.addChildElement(componentsSequenceElement, unattendComponentElement);
                    
                    var componentNameElement = js2xml.createElement('ComponentName', 'http://schemas.microsoft.com/windowsazure');
                    js2xml.setElementValue(componentNameElement, componentsItem.componentName);
                    js2xml.addChildElement(unattendComponentElement, componentNameElement);
                    
                    if (componentsItem.unattendComponentSettings !== null && componentsItem.unattendComponentSettings !== undefined) {
                      var componentSettingsSequenceElement = js2xml.createElement('ComponentSettings', 'http://schemas.microsoft.com/windowsazure');
                      for (var loweredIndex22 = 0; loweredIndex22 < componentsItem.unattendComponentSettings.length; loweredIndex22 = loweredIndex22 + 1) {
                        var componentSettingsItem = componentsItem.unattendComponentSettings[loweredIndex22];
                        var componentSettingElement = js2xml.createElement('ComponentSetting', 'http://schemas.microsoft.com/windowsazure');
                        js2xml.addChildElement(componentSettingsSequenceElement, componentSettingElement);
                        
                        var settingNameElement = js2xml.createElement('SettingName', 'http://schemas.microsoft.com/windowsazure');
                        js2xml.setElementValue(settingNameElement, componentSettingsItem.settingName);
                        js2xml.addChildElement(componentSettingElement, settingNameElement);
                        
                        if (componentSettingsItem.content !== null && componentSettingsItem.content !== undefined) {
                          var contentElement = js2xml.createElement('Content', 'http://schemas.microsoft.com/windowsazure');
                          js2xml.setElementValue(contentElement, new Buffer(componentSettingsItem.content).toString('base64'));
                          js2xml.addChildElement(componentSettingElement, contentElement);
                        }
                      }
                      js2xml.addChildElement(unattendComponentElement, componentSettingsSequenceElement);
                    }
                  }
                  js2xml.addChildElement(unattendPassElement, componentsSequenceElement);
                }
              }
              js2xml.addChildElement(additionalUnattendContentElement, passesSequenceElement);
            }
          }
          
          if (configurationSetsItem.hostName !== null && configurationSetsItem.hostName !== undefined) {
            var hostNameElement = js2xml.createElement('HostName', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(hostNameElement, configurationSetsItem.hostName);
            js2xml.addChildElement(configurationSetElement, hostNameElement);
          }
          
          if (configurationSetsItem.userName !== null && configurationSetsItem.userName !== undefined) {
            var userNameElement = js2xml.createElement('UserName', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(userNameElement, configurationSetsItem.userName);
            js2xml.addChildElement(configurationSetElement, userNameElement);
          }
          
          if (configurationSetsItem.userPassword !== null && configurationSetsItem.userPassword !== undefined) {
            var userPasswordElement = js2xml.createElement('UserPassword', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(userPasswordElement, configurationSetsItem.userPassword);
            js2xml.addChildElement(configurationSetElement, userPasswordElement);
          }
          
          if (configurationSetsItem.disableSshPasswordAuthentication !== null && configurationSetsItem.disableSshPasswordAuthentication !== undefined) {
            var disableSshPasswordAuthenticationElement = js2xml.createElement('DisableSshPasswordAuthentication', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(disableSshPasswordAuthenticationElement, configurationSetsItem.disableSshPasswordAuthentication.toString());
            js2xml.addChildElement(configurationSetElement, disableSshPasswordAuthenticationElement);
          }
          
          if (configurationSetsItem.sshSettings !== null && configurationSetsItem.sshSettings !== undefined) {
            var sSHElement = js2xml.createElement('SSH', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(configurationSetElement, sSHElement);
            
            if (configurationSetsItem.sshSettings.publicKeys !== null && configurationSetsItem.sshSettings.publicKeys !== undefined) {
              var publicKeysSequenceElement = js2xml.createElement('PublicKeys', 'http://schemas.microsoft.com/windowsazure');
              for (var loweredIndex23 = 0; loweredIndex23 < configurationSetsItem.sshSettings.publicKeys.length; loweredIndex23 = loweredIndex23 + 1) {
                var publicKeysItem = configurationSetsItem.sshSettings.publicKeys[loweredIndex23];
                var publicKeyElement = js2xml.createElement('PublicKey', 'http://schemas.microsoft.com/windowsazure');
                js2xml.addChildElement(publicKeysSequenceElement, publicKeyElement);
                
                var fingerprintElement = js2xml.createElement('Fingerprint', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(fingerprintElement, publicKeysItem.fingerprint);
                js2xml.addChildElement(publicKeyElement, fingerprintElement);
                
                var pathElement2 = js2xml.createElement('Path', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(pathElement2, publicKeysItem.path);
                js2xml.addChildElement(publicKeyElement, pathElement2);
              }
              js2xml.addChildElement(sSHElement, publicKeysSequenceElement);
            }
            
            if (configurationSetsItem.sshSettings.keyPairs !== null && configurationSetsItem.sshSettings.keyPairs !== undefined) {
              var keyPairsSequenceElement = js2xml.createElement('KeyPairs', 'http://schemas.microsoft.com/windowsazure');
              for (var loweredIndex24 = 0; loweredIndex24 < configurationSetsItem.sshSettings.keyPairs.length; loweredIndex24 = loweredIndex24 + 1) {
                var keyPairsItem = configurationSetsItem.sshSettings.keyPairs[loweredIndex24];
                var keyPairElement = js2xml.createElement('KeyPair', 'http://schemas.microsoft.com/windowsazure');
                js2xml.addChildElement(keyPairsSequenceElement, keyPairElement);
                
                var fingerprintElement2 = js2xml.createElement('Fingerprint', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(fingerprintElement2, keyPairsItem.fingerprint);
                js2xml.addChildElement(keyPairElement, fingerprintElement2);
                
                var pathElement3 = js2xml.createElement('Path', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(pathElement3, keyPairsItem.path);
                js2xml.addChildElement(keyPairElement, pathElement3);
              }
              js2xml.addChildElement(sSHElement, keyPairsSequenceElement);
            }
          }
          
          if (configurationSetsItem.customData !== null && configurationSetsItem.customData !== undefined) {
            var customDataElement = js2xml.createElement('CustomData', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(customDataElement, configurationSetsItem.customData);
            js2xml.addChildElement(configurationSetElement, customDataElement);
          }
        }
        js2xml.addChildElement(roleElement, configurationSetsSequenceElement);
      }
      
      if (roleListItem.resourceExtensionReferences !== null && roleListItem.resourceExtensionReferences !== undefined) {
        var resourceExtensionReferencesSequenceElement = js2xml.createElement('ResourceExtensionReferences', 'http://schemas.microsoft.com/windowsazure');
        for (var loweredIndex25 = 0; loweredIndex25 < roleListItem.resourceExtensionReferences.length; loweredIndex25 = loweredIndex25 + 1) {
          var resourceExtensionReferencesItem = roleListItem.resourceExtensionReferences[loweredIndex25];
          var resourceExtensionReferenceElement = js2xml.createElement('ResourceExtensionReference', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(resourceExtensionReferencesSequenceElement, resourceExtensionReferenceElement);
          
          if (resourceExtensionReferencesItem.referenceName !== null && resourceExtensionReferencesItem.referenceName !== undefined) {
            var referenceNameElement = js2xml.createElement('ReferenceName', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(referenceNameElement, resourceExtensionReferencesItem.referenceName);
            js2xml.addChildElement(resourceExtensionReferenceElement, referenceNameElement);
          }
          
          if (resourceExtensionReferencesItem.publisher !== null && resourceExtensionReferencesItem.publisher !== undefined) {
            var publisherElement = js2xml.createElement('Publisher', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(publisherElement, resourceExtensionReferencesItem.publisher);
            js2xml.addChildElement(resourceExtensionReferenceElement, publisherElement);
          }
          
          if (resourceExtensionReferencesItem.name !== null && resourceExtensionReferencesItem.name !== undefined) {
            var nameElement5 = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(nameElement5, resourceExtensionReferencesItem.name);
            js2xml.addChildElement(resourceExtensionReferenceElement, nameElement5);
          }
          
          if (resourceExtensionReferencesItem.version !== null && resourceExtensionReferencesItem.version !== undefined) {
            var versionElement = js2xml.createElement('Version', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(versionElement, resourceExtensionReferencesItem.version);
            js2xml.addChildElement(resourceExtensionReferenceElement, versionElement);
          }
          
          if (resourceExtensionReferencesItem.resourceExtensionParameterValues !== null && resourceExtensionReferencesItem.resourceExtensionParameterValues !== undefined) {
            var resourceExtensionParameterValuesSequenceElement = js2xml.createElement('ResourceExtensionParameterValues', 'http://schemas.microsoft.com/windowsazure');
            for (var loweredIndex26 = 0; loweredIndex26 < resourceExtensionReferencesItem.resourceExtensionParameterValues.length; loweredIndex26 = loweredIndex26 + 1) {
              var resourceExtensionParameterValuesItem = resourceExtensionReferencesItem.resourceExtensionParameterValues[loweredIndex26];
              var resourceExtensionParameterValueElement = js2xml.createElement('ResourceExtensionParameterValue', 'http://schemas.microsoft.com/windowsazure');
              js2xml.addChildElement(resourceExtensionParameterValuesSequenceElement, resourceExtensionParameterValueElement);
              
              if (resourceExtensionParameterValuesItem.key !== null && resourceExtensionParameterValuesItem.key !== undefined) {
                var keyElement = js2xml.createElement('Key', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(keyElement, resourceExtensionParameterValuesItem.key);
                js2xml.addChildElement(resourceExtensionParameterValueElement, keyElement);
              }
              
              if (resourceExtensionParameterValuesItem.value !== null && resourceExtensionParameterValuesItem.value !== undefined) {
                var valueElement = js2xml.createElement('Value', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(valueElement, new Buffer(resourceExtensionParameterValuesItem.value).toString('base64'));
                js2xml.addChildElement(resourceExtensionParameterValueElement, valueElement);
              }
              
              if (resourceExtensionParameterValuesItem.type !== null && resourceExtensionParameterValuesItem.type !== undefined) {
                var typeElement = js2xml.createElement('Type', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(typeElement, resourceExtensionParameterValuesItem.type);
                js2xml.addChildElement(resourceExtensionParameterValueElement, typeElement);
              }
            }
            js2xml.addChildElement(resourceExtensionReferenceElement, resourceExtensionParameterValuesSequenceElement);
          }
          
          if (resourceExtensionReferencesItem.state !== null && resourceExtensionReferencesItem.state !== undefined) {
            var stateElement = js2xml.createElement('State', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(stateElement, resourceExtensionReferencesItem.state);
            js2xml.addChildElement(resourceExtensionReferenceElement, stateElement);
          }
          
          if (resourceExtensionReferencesItem.forceUpdate !== null && resourceExtensionReferencesItem.forceUpdate !== undefined) {
            var forceUpdateElement = js2xml.createElement('ForceUpdate', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(forceUpdateElement, resourceExtensionReferencesItem.forceUpdate.toString());
            js2xml.addChildElement(resourceExtensionReferenceElement, forceUpdateElement);
          }
        }
        js2xml.addChildElement(roleElement, resourceExtensionReferencesSequenceElement);
      }
      
      if (roleListItem.vMImageName !== null && roleListItem.vMImageName !== undefined) {
        var vMImageNameElement = js2xml.createElement('VMImageName', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(vMImageNameElement, roleListItem.vMImageName);
        js2xml.addChildElement(roleElement, vMImageNameElement);
      }
      
      if (roleListItem.mediaLocation !== null && roleListItem.mediaLocation !== undefined) {
        var mediaLocationElement = js2xml.createElement('MediaLocation', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(mediaLocationElement, roleListItem.mediaLocation);
        js2xml.addChildElement(roleElement, mediaLocationElement);
      }
      
      if (roleListItem.availabilitySetName !== null && roleListItem.availabilitySetName !== undefined) {
        var availabilitySetNameElement = js2xml.createElement('AvailabilitySetName', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(availabilitySetNameElement, roleListItem.availabilitySetName);
        js2xml.addChildElement(roleElement, availabilitySetNameElement);
      }
      
      if (roleListItem.dataVirtualHardDisks !== null && roleListItem.dataVirtualHardDisks !== undefined) {
        var dataVirtualHardDisksSequenceElement = js2xml.createElement('DataVirtualHardDisks', 'http://schemas.microsoft.com/windowsazure');
        for (var loweredIndex27 = 0; loweredIndex27 < roleListItem.dataVirtualHardDisks.length; loweredIndex27 = loweredIndex27 + 1) {
          var dataVirtualHardDisksItem = roleListItem.dataVirtualHardDisks[loweredIndex27];
          var dataVirtualHardDiskElement = js2xml.createElement('DataVirtualHardDisk', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(dataVirtualHardDisksSequenceElement, dataVirtualHardDiskElement);
          
          if (dataVirtualHardDisksItem.hostCaching !== null && dataVirtualHardDisksItem.hostCaching !== undefined) {
            var hostCachingElement = js2xml.createElement('HostCaching', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(hostCachingElement, dataVirtualHardDisksItem.hostCaching);
            js2xml.addChildElement(dataVirtualHardDiskElement, hostCachingElement);
          }
          
          if (dataVirtualHardDisksItem.label !== null && dataVirtualHardDisksItem.label !== undefined) {
            var diskLabelElement = js2xml.createElement('DiskLabel', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(diskLabelElement, dataVirtualHardDisksItem.label);
            js2xml.addChildElement(dataVirtualHardDiskElement, diskLabelElement);
          }
          
          if (dataVirtualHardDisksItem.name !== null && dataVirtualHardDisksItem.name !== undefined) {
            var diskNameElement = js2xml.createElement('DiskName', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(diskNameElement, dataVirtualHardDisksItem.name);
            js2xml.addChildElement(dataVirtualHardDiskElement, diskNameElement);
          }
          
          if (dataVirtualHardDisksItem.logicalUnitNumber !== null && dataVirtualHardDisksItem.logicalUnitNumber !== undefined) {
            var lunElement = js2xml.createElement('Lun', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(lunElement, dataVirtualHardDisksItem.logicalUnitNumber.toString());
            js2xml.addChildElement(dataVirtualHardDiskElement, lunElement);
          }
          
          if (dataVirtualHardDisksItem.logicalDiskSizeInGB !== null && dataVirtualHardDisksItem.logicalDiskSizeInGB !== undefined) {
            var logicalDiskSizeInGBElement = js2xml.createElement('LogicalDiskSizeInGB', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(logicalDiskSizeInGBElement, dataVirtualHardDisksItem.logicalDiskSizeInGB.toString());
            js2xml.addChildElement(dataVirtualHardDiskElement, logicalDiskSizeInGBElement);
          }
          
          if (dataVirtualHardDisksItem.mediaLink !== null && dataVirtualHardDisksItem.mediaLink !== undefined) {
            var mediaLinkElement = js2xml.createElement('MediaLink', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(mediaLinkElement, dataVirtualHardDisksItem.mediaLink);
            js2xml.addChildElement(dataVirtualHardDiskElement, mediaLinkElement);
          }
          
          if (dataVirtualHardDisksItem.sourceMediaLink !== null && dataVirtualHardDisksItem.sourceMediaLink !== undefined) {
            var sourceMediaLinkElement = js2xml.createElement('SourceMediaLink', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(sourceMediaLinkElement, dataVirtualHardDisksItem.sourceMediaLink);
            js2xml.addChildElement(dataVirtualHardDiskElement, sourceMediaLinkElement);
          }
          
          if (dataVirtualHardDisksItem.iOType !== null && dataVirtualHardDisksItem.iOType !== undefined) {
            var iOTypeElement = js2xml.createElement('IOType', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(iOTypeElement, dataVirtualHardDisksItem.iOType);
            js2xml.addChildElement(dataVirtualHardDiskElement, iOTypeElement);
          }
        }
        js2xml.addChildElement(roleElement, dataVirtualHardDisksSequenceElement);
      }
      
      if (roleListItem.label !== null && roleListItem.label !== undefined) {
        var labelElement2 = js2xml.createElement('Label', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(labelElement2, roleListItem.label);
        js2xml.addChildElement(roleElement, labelElement2);
      }
      
      if (roleListItem.oSVirtualHardDisk !== null && roleListItem.oSVirtualHardDisk !== undefined) {
        var oSVirtualHardDiskElement = js2xml.createElement('OSVirtualHardDisk', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(roleElement, oSVirtualHardDiskElement);
        
        if (roleListItem.oSVirtualHardDisk.hostCaching !== null && roleListItem.oSVirtualHardDisk.hostCaching !== undefined) {
          var hostCachingElement2 = js2xml.createElement('HostCaching', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(hostCachingElement2, roleListItem.oSVirtualHardDisk.hostCaching);
          js2xml.addChildElement(oSVirtualHardDiskElement, hostCachingElement2);
        }
        
        if (roleListItem.oSVirtualHardDisk.label !== null && roleListItem.oSVirtualHardDisk.label !== undefined) {
          var diskLabelElement2 = js2xml.createElement('DiskLabel', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(diskLabelElement2, roleListItem.oSVirtualHardDisk.label);
          js2xml.addChildElement(oSVirtualHardDiskElement, diskLabelElement2);
        }
        
        if (roleListItem.oSVirtualHardDisk.name !== null && roleListItem.oSVirtualHardDisk.name !== undefined) {
          var diskNameElement2 = js2xml.createElement('DiskName', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(diskNameElement2, roleListItem.oSVirtualHardDisk.name);
          js2xml.addChildElement(oSVirtualHardDiskElement, diskNameElement2);
        }
        
        if (roleListItem.oSVirtualHardDisk.mediaLink !== null && roleListItem.oSVirtualHardDisk.mediaLink !== undefined) {
          var mediaLinkElement2 = js2xml.createElement('MediaLink', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(mediaLinkElement2, roleListItem.oSVirtualHardDisk.mediaLink);
          js2xml.addChildElement(oSVirtualHardDiskElement, mediaLinkElement2);
        }
        
        if (roleListItem.oSVirtualHardDisk.sourceImageName !== null && roleListItem.oSVirtualHardDisk.sourceImageName !== undefined) {
          var sourceImageNameElement = js2xml.createElement('SourceImageName', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(sourceImageNameElement, roleListItem.oSVirtualHardDisk.sourceImageName);
          js2xml.addChildElement(oSVirtualHardDiskElement, sourceImageNameElement);
        }
        
        if (roleListItem.oSVirtualHardDisk.operatingSystem !== null && roleListItem.oSVirtualHardDisk.operatingSystem !== undefined) {
          var osElement = js2xml.createElement('OS', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(osElement, roleListItem.oSVirtualHardDisk.operatingSystem);
          js2xml.addChildElement(oSVirtualHardDiskElement, osElement);
        }
        
        if (roleListItem.oSVirtualHardDisk.remoteSourceImageLink !== null && roleListItem.oSVirtualHardDisk.remoteSourceImageLink !== undefined) {
          var remoteSourceImageLinkElement = js2xml.createElement('RemoteSourceImageLink', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(remoteSourceImageLinkElement, roleListItem.oSVirtualHardDisk.remoteSourceImageLink);
          js2xml.addChildElement(oSVirtualHardDiskElement, remoteSourceImageLinkElement);
        }
        
        if (roleListItem.oSVirtualHardDisk.iOType !== null && roleListItem.oSVirtualHardDisk.iOType !== undefined) {
          var iOTypeElement2 = js2xml.createElement('IOType', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(iOTypeElement2, roleListItem.oSVirtualHardDisk.iOType);
          js2xml.addChildElement(oSVirtualHardDiskElement, iOTypeElement2);
        }
        
        if (roleListItem.oSVirtualHardDisk.resizedSizeInGB !== null && roleListItem.oSVirtualHardDisk.resizedSizeInGB !== undefined) {
          var resizedSizeInGBElement = js2xml.createElement('ResizedSizeInGB', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(resizedSizeInGBElement, roleListItem.oSVirtualHardDisk.resizedSizeInGB.toString());
          js2xml.addChildElement(oSVirtualHardDiskElement, resizedSizeInGBElement);
        }
      }
      
      if (roleListItem.roleSize !== null && roleListItem.roleSize !== undefined) {
        var roleSizeElement = js2xml.createElement('RoleSize', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(roleSizeElement, roleListItem.roleSize);
        js2xml.addChildElement(roleElement, roleSizeElement);
      }
      
      if (roleListItem.defaultWinRmCertificateThumbprint !== null && roleListItem.defaultWinRmCertificateThumbprint !== undefined) {
        var defaultWinRmCertificateThumbprintElement = js2xml.createElement('DefaultWinRmCertificateThumbprint', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(defaultWinRmCertificateThumbprintElement, roleListItem.defaultWinRmCertificateThumbprint);
        js2xml.addChildElement(roleElement, defaultWinRmCertificateThumbprintElement);
      }
      
      if (roleListItem.provisionGuestAgent !== null && roleListItem.provisionGuestAgent !== undefined) {
        var provisionGuestAgentElement = js2xml.createElement('ProvisionGuestAgent', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(provisionGuestAgentElement, roleListItem.provisionGuestAgent.toString());
        js2xml.addChildElement(roleElement, provisionGuestAgentElement);
      }
      
      if (roleListItem.vMImageInput !== null && roleListItem.vMImageInput !== undefined) {
        var vMImageInputElement = js2xml.createElement('VMImageInput', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(roleElement, vMImageInputElement);
        
        if (roleListItem.vMImageInput.oSDiskConfiguration !== null && roleListItem.vMImageInput.oSDiskConfiguration !== undefined) {
          var oSDiskConfigurationElement = js2xml.createElement('OSDiskConfiguration', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(vMImageInputElement, oSDiskConfigurationElement);
          
          if (roleListItem.vMImageInput.oSDiskConfiguration.resizedSizeInGB !== null && roleListItem.vMImageInput.oSDiskConfiguration.resizedSizeInGB !== undefined) {
            var resizedSizeInGBElement2 = js2xml.createElement('ResizedSizeInGB', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(resizedSizeInGBElement2, roleListItem.vMImageInput.oSDiskConfiguration.resizedSizeInGB.toString());
            js2xml.addChildElement(oSDiskConfigurationElement, resizedSizeInGBElement2);
          }
        }
        
        if (roleListItem.vMImageInput.dataDiskConfigurations !== null && roleListItem.vMImageInput.dataDiskConfigurations !== undefined) {
          var dataDiskConfigurationsSequenceElement = js2xml.createElement('DataDiskConfigurations', 'http://schemas.microsoft.com/windowsazure');
          for (var loweredIndex28 = 0; loweredIndex28 < roleListItem.vMImageInput.dataDiskConfigurations.length; loweredIndex28 = loweredIndex28 + 1) {
            var dataDiskConfigurationsItem = roleListItem.vMImageInput.dataDiskConfigurations[loweredIndex28];
            var dataDiskConfigurationElement = js2xml.createElement('DataDiskConfiguration', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(dataDiskConfigurationsSequenceElement, dataDiskConfigurationElement);
            
            if (dataDiskConfigurationsItem.diskName !== null && dataDiskConfigurationsItem.diskName !== undefined) {
              var nameElement6 = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(nameElement6, dataDiskConfigurationsItem.diskName);
              js2xml.addChildElement(dataDiskConfigurationElement, nameElement6);
            }
            
            if (dataDiskConfigurationsItem.resizedSizeInGB !== null && dataDiskConfigurationsItem.resizedSizeInGB !== undefined) {
              var resizedSizeInGBElement3 = js2xml.createElement('ResizedSizeInGB', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(resizedSizeInGBElement3, dataDiskConfigurationsItem.resizedSizeInGB.toString());
              js2xml.addChildElement(dataDiskConfigurationElement, resizedSizeInGBElement3);
            }
          }
          js2xml.addChildElement(vMImageInputElement, dataDiskConfigurationsSequenceElement);
        }
      }
      
      if (roleListItem.debugSettings !== null && roleListItem.debugSettings !== undefined) {
        var debugSettingsElement = js2xml.createElement('DebugSettings', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(roleElement, debugSettingsElement);
        
        var bootDiagnosticsEnabledElement = js2xml.createElement('BootDiagnosticsEnabled', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(bootDiagnosticsEnabledElement, roleListItem.debugSettings.bootDiagnosticsEnabled.toString());
        js2xml.addChildElement(debugSettingsElement, bootDiagnosticsEnabledElement);
        
        if (roleListItem.debugSettings.consoleScreenshotBlobUri !== null && roleListItem.debugSettings.consoleScreenshotBlobUri !== undefined) {
          var consoleScreenshotBlobUriElement = js2xml.createElement('ConsoleScreenshotBlobUri', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(consoleScreenshotBlobUriElement, roleListItem.debugSettings.consoleScreenshotBlobUri);
          js2xml.addChildElement(debugSettingsElement, consoleScreenshotBlobUriElement);
        }
        
        if (roleListItem.debugSettings.serialOutputBlobUri !== null && roleListItem.debugSettings.serialOutputBlobUri !== undefined) {
          var serialOutputBlobUriElement = js2xml.createElement('SerialOutputBlobUri', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(serialOutputBlobUriElement, roleListItem.debugSettings.serialOutputBlobUri);
          js2xml.addChildElement(debugSettingsElement, serialOutputBlobUriElement);
        }
      }
      
      if (roleListItem.licenseType !== null && roleListItem.licenseType !== undefined) {
        var licenseTypeElement = js2xml.createElement('LicenseType', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(licenseTypeElement, roleListItem.licenseType);
        js2xml.addChildElement(roleElement, licenseTypeElement);
      }
      
      if (roleListItem.migrationState !== null && roleListItem.migrationState !== undefined) {
        var migrationStateElement = js2xml.createElement('MigrationState', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(migrationStateElement, roleListItem.migrationState);
        js2xml.addChildElement(roleElement, migrationStateElement);
      }
    }
    js2xml.addChildElement(deploymentElement, roleListSequenceElement);
    
    if (parameters.virtualNetworkName !== null && parameters.virtualNetworkName !== undefined) {
      var virtualNetworkNameElement = js2xml.createElement('VirtualNetworkName', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(virtualNetworkNameElement, parameters.virtualNetworkName);
      js2xml.addChildElement(deploymentElement, virtualNetworkNameElement);
    }
    
    if (parameters.dnsSettings !== null && parameters.dnsSettings !== undefined) {
      var dnsElement = js2xml.createElement('Dns', 'http://schemas.microsoft.com/windowsazure');
      js2xml.addChildElement(deploymentElement, dnsElement);
      
      if (parameters.dnsSettings.dnsServers !== null && parameters.dnsSettings.dnsServers !== undefined) {
        var dnsServersSequenceElement = js2xml.createElement('DnsServers', 'http://schemas.microsoft.com/windowsazure');
        for (var loweredIndex29 = 0; loweredIndex29 < parameters.dnsSettings.dnsServers.length; loweredIndex29 = loweredIndex29 + 1) {
          var dnsServersItem = parameters.dnsSettings.dnsServers[loweredIndex29];
          var dnsServerElement = js2xml.createElement('DnsServer', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(dnsServersSequenceElement, dnsServerElement);
          
          if (dnsServersItem.name !== null && dnsServersItem.name !== undefined) {
            var nameElement7 = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(nameElement7, dnsServersItem.name);
            js2xml.addChildElement(dnsServerElement, nameElement7);
          }
          
          if (dnsServersItem.address !== null && dnsServersItem.address !== undefined) {
            var addressElement = js2xml.createElement('Address', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(addressElement, dnsServersItem.address);
            js2xml.addChildElement(dnsServerElement, addressElement);
          }
        }
        js2xml.addChildElement(dnsElement, dnsServersSequenceElement);
      }
    }
    
    if (parameters.reservedIPName !== null && parameters.reservedIPName !== undefined) {
      var reservedIPNameElement = js2xml.createElement('ReservedIPName', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(reservedIPNameElement, parameters.reservedIPName);
      js2xml.addChildElement(deploymentElement, reservedIPNameElement);
    }
    
    if (parameters.loadBalancers !== null && parameters.loadBalancers !== undefined) {
      var loadBalancersSequenceElement = js2xml.createElement('LoadBalancers', 'http://schemas.microsoft.com/windowsazure');
      for (var loweredIndex30 = 0; loweredIndex30 < parameters.loadBalancers.length; loweredIndex30 = loweredIndex30 + 1) {
        var loadBalancersItem = parameters.loadBalancers[loweredIndex30];
        var loadBalancerElement = js2xml.createElement('LoadBalancer', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(loadBalancersSequenceElement, loadBalancerElement);
        
        if (loadBalancersItem.name !== null && loadBalancersItem.name !== undefined) {
          var nameElement8 = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(nameElement8, loadBalancersItem.name);
          js2xml.addChildElement(loadBalancerElement, nameElement8);
        }
        
        if (loadBalancersItem.frontendIPConfiguration !== null && loadBalancersItem.frontendIPConfiguration !== undefined) {
          var frontendIpConfigurationElement = js2xml.createElement('FrontendIpConfiguration', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(loadBalancerElement, frontendIpConfigurationElement);
          
          if (loadBalancersItem.frontendIPConfiguration.type !== null && loadBalancersItem.frontendIPConfiguration.type !== undefined) {
            var typeElement2 = js2xml.createElement('Type', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(typeElement2, loadBalancersItem.frontendIPConfiguration.type);
            js2xml.addChildElement(frontendIpConfigurationElement, typeElement2);
          }
          
          if (loadBalancersItem.frontendIPConfiguration.subnetName !== null && loadBalancersItem.frontendIPConfiguration.subnetName !== undefined) {
            var subnetNameElement2 = js2xml.createElement('SubnetName', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(subnetNameElement2, loadBalancersItem.frontendIPConfiguration.subnetName);
            js2xml.addChildElement(frontendIpConfigurationElement, subnetNameElement2);
          }
          
          if (loadBalancersItem.frontendIPConfiguration.staticVirtualNetworkIPAddress !== null && loadBalancersItem.frontendIPConfiguration.staticVirtualNetworkIPAddress !== undefined) {
            var staticVirtualNetworkIPAddressElement3 = js2xml.createElement('StaticVirtualNetworkIPAddress', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(staticVirtualNetworkIPAddressElement3, loadBalancersItem.frontendIPConfiguration.staticVirtualNetworkIPAddress);
            js2xml.addChildElement(frontendIpConfigurationElement, staticVirtualNetworkIPAddressElement3);
          }
        }
      }
      js2xml.addChildElement(deploymentElement, loadBalancersSequenceElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Deleting Role operation deletes the specified virtual machine.
   * (see http://msdn.microsoft.com/en-us/library/windowsazure/jj157184.aspx
   * for more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {string} virtualMachineName The name of the virtual machine to
   * delete.
   * 
   * @param {boolean} [deleteFromStorage] Specifies that the source blob(s) for
   * the virtual machine should also be deleted from storage.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.beginDeleting = function(serviceName, deploymentName, virtualMachineName, deleteFromStorage, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (virtualMachineName === null || virtualMachineName === undefined) {
      return callback(new Error('virtualMachineName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/roles/';
    url2 = url2 + encodeURIComponent(virtualMachineName);
    var queryParameters = [];
    if (deleteFromStorage !== null && deleteFromStorage !== undefined && deleteFromStorage === true) {
      queryParameters.push('comp=media');
    }
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Redeploying role operation redeploys the specified virtual
   * machine.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157197.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {string} virtualMachineName The name of the virtual machine to
   * redeploy.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.beginRedeploying = function(serviceName, deploymentName, virtualMachineName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (virtualMachineName === null || virtualMachineName === undefined) {
      return callback(new Error('virtualMachineName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/roleinstances/';
    url2 = url2 + encodeURIComponent(virtualMachineName);
    url2 = url2 + '/Operations';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = '<RedeployRoleOperation xmlns="http://schemas.microsoft.com/windowsazure"><OperationType>RedeployRoleOperation</OperationType></RedeployRoleOperation>';
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Restarting role operation restarts the specified virtual
   * machine.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157197.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {string} virtualMachineName The name of the virtual machine to
   * restart.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.beginRestarting = function(serviceName, deploymentName, virtualMachineName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (virtualMachineName === null || virtualMachineName === undefined) {
      return callback(new Error('virtualMachineName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/roleinstances/';
    url2 = url2 + encodeURIComponent(virtualMachineName);
    url2 = url2 + '/Operations';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = '<RestartRoleOperation xmlns="http://schemas.microsoft.com/windowsazure"><OperationType>RestartRoleOperation</OperationType></RestartRoleOperation>';
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Shutdown Role operation shuts down the specified virtual machine.
   * (see http://msdn.microsoft.com/en-us/library/windowsazure/jj157195.aspx
   * for more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {string} virtualMachineName The name of the virtual machine to
   * shutdown.
   * 
   * @param {VirtualMachineShutdownParameters} parameters The parameters for
   * the shutdown vm operation.
   * 
   * @param {PostShutdownAction} [parameters.postShutdownAction] The state of
   * the virtual machine after shutdown (Stopped or StoppedDeallocated).
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.beginShutdown = function(serviceName, deploymentName, virtualMachineName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (virtualMachineName === null || virtualMachineName === undefined) {
      return callback(new Error('virtualMachineName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/roleinstances/';
    url2 = url2 + encodeURIComponent(virtualMachineName);
    url2 = url2 + '/Operations';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var shutdownRoleOperationElement = js2xml.createElement('ShutdownRoleOperation', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, shutdownRoleOperationElement);
    
    var operationTypeElement = js2xml.createElement('OperationType', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(operationTypeElement, 'ShutdownRoleOperation');
    js2xml.addChildElement(shutdownRoleOperationElement, operationTypeElement);
    
    if (parameters.postShutdownAction !== null && parameters.postShutdownAction !== undefined) {
      var postShutdownActionElement = js2xml.createElement('PostShutdownAction', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(postShutdownActionElement, parameters.postShutdownAction !== null && parameters.postShutdownAction !== undefined ? parameters.postShutdownAction.toString() : 'Stopped');
      js2xml.addChildElement(shutdownRoleOperationElement, postShutdownActionElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Shutting Down Roles operation stops the specified set of virtual
   * machines.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn469421.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {VirtualMachineShutdownRolesParameters} parameters Parameters to
   * pass to the Begin Shutting Down Roles operation.
   * 
   * @param {array} [parameters.roles] The set of roles to shut down.
   * 
   * @param {PostShutdownAction} [parameters.postShutdownAction] The state of
   * the roles after shutdown. Possible values include Stopped or
   * StoppedDeallocated.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.beginShuttingDownRoles = function(serviceName, deploymentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/Roles/Operations';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var shutdownRolesOperationElement = js2xml.createElement('ShutdownRolesOperation', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, shutdownRolesOperationElement);
    
    var operationTypeElement = js2xml.createElement('OperationType', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(operationTypeElement, 'ShutdownRolesOperation');
    js2xml.addChildElement(shutdownRolesOperationElement, operationTypeElement);
    
    if (parameters.roles !== null && parameters.roles !== undefined) {
      var rolesSequenceElement = js2xml.createElement('Roles', 'http://schemas.microsoft.com/windowsazure');
      for (var loweredIndex1 = 0; loweredIndex1 < parameters.roles.length; loweredIndex1 = loweredIndex1 + 1) {
        var rolesItem = parameters.roles[loweredIndex1];
        var rolesItemElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(rolesItemElement, rolesItem);
        js2xml.addChildElement(rolesSequenceElement, rolesItemElement);
      }
      js2xml.addChildElement(shutdownRolesOperationElement, rolesSequenceElement);
    }
    
    if (parameters.postShutdownAction !== null && parameters.postShutdownAction !== undefined) {
      var postShutdownActionElement = js2xml.createElement('PostShutdownAction', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(postShutdownActionElement, parameters.postShutdownAction !== null && parameters.postShutdownAction !== undefined ? parameters.postShutdownAction.toString() : 'Stopped');
      js2xml.addChildElement(shutdownRolesOperationElement, postShutdownActionElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Starting Role operation starts the specified virtual machine.
   * (see http://msdn.microsoft.com/en-us/library/windowsazure/jj157189.aspx
   * for more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {string} virtualMachineName The name of the virtual machine to
   * start.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.beginStarting = function(serviceName, deploymentName, virtualMachineName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (virtualMachineName === null || virtualMachineName === undefined) {
      return callback(new Error('virtualMachineName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/roleinstances/';
    url2 = url2 + encodeURIComponent(virtualMachineName);
    url2 = url2 + '/Operations';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = '<StartRoleOperation xmlns="http://schemas.microsoft.com/windowsazure"><OperationType>StartRoleOperation</OperationType></StartRoleOperation>';
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Starting Roles operation starts the specified set of virtual
   * machines.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn469419.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {VirtualMachineStartRolesParameters} parameters Parameters to pass
   * to the Begin Starting Roles operation.
   * 
   * @param {array} [parameters.roles] The set of roles to shut down.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.beginStartingRoles = function(serviceName, deploymentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/Roles/Operations';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var startRolesOperationElement = js2xml.createElement('StartRolesOperation', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, startRolesOperationElement);
    
    var operationTypeElement = js2xml.createElement('OperationType', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(operationTypeElement, 'StartRolesOperation');
    js2xml.addChildElement(startRolesOperationElement, operationTypeElement);
    
    if (parameters.roles !== null && parameters.roles !== undefined) {
      var rolesSequenceElement = js2xml.createElement('Roles', 'http://schemas.microsoft.com/windowsazure');
      for (var loweredIndex1 = 0; loweredIndex1 < parameters.roles.length; loweredIndex1 = loweredIndex1 + 1) {
        var rolesItem = parameters.roles[loweredIndex1];
        var rolesItemElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(rolesItemElement, rolesItem);
        js2xml.addChildElement(rolesSequenceElement, rolesItemElement);
      }
      js2xml.addChildElement(startRolesOperationElement, rolesSequenceElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Updating Role operation adds a virtual machine to an existing
   * deployment.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157187.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {string} virtualMachineName The name of your virtual machine.
   * 
   * @param {VirtualMachineUpdateParameters} parameters Parameters supplied to
   * the Begin Updating Virtual Machine operation.
   * 
   * @param {string} parameters.roleName Specifies the name for the virtual
   * machine. The name must be unique within the deployment.
   * 
   * @param {string} [parameters.label] Specifies the friendly name for the
   * virtual machine.
   * 
   * @param {string} [parameters.availabilitySetName] Specifies the name of an
   * availability set to which to add the virtual machine. This value controls
   * the virtual machine allocation in the Azure environment. Virtual machines
   * specified in the same availability set are allocated to different nodes
   * to maximize availability.
   * 
   * @param {string} [parameters.roleSize] The size of the virtual machine.
   * 
   * @param {array} [parameters.configurationSets] Contains the collection of
   * configuration sets that contain system and application configuration
   * settings.
   * 
   * @param {array} [parameters.resourceExtensionReferences] Contains a
   * collection of resource extensions that are to be installed on the Virtual
   * Machine. This element is used if ProvisionGuestAgent is set to true.
   * 
   * @param {array} [parameters.dataVirtualHardDisks] Contains the parameters
   * Azure used to create the data disk for the virtual machine.
   * 
   * @param {OSVirtualHardDisk} parameters.oSVirtualHardDisk Contains the
   * parameters Azure used to create the operating system disk for the virtual
   * machine.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.hostCaching] Specifies the
   * platform caching behavior of the operating system disk blob for
   * read/write efficiency.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.label] Specifies the
   * friendly name of an operating system image in the image repository.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.name] Specifies the name of
   * an operating system image in the image repository.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.mediaLink] Specifies the
   * location of the operating system disk in Azure storage.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.sourceImageName] Specifies
   * the name of the source image that was used to provision the virtual
   * machine.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.operatingSystem] The
   * operating system running in the virtual machine.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.remoteSourceImageLink] Uri
   * of the source OS image that will be copied to the customer’s storage
   * account of VM creation.If RemoteSourceImageLink is specified, then
   * MediaLink must also be specified.If RemoteSourceImageLink is specified,
   * thenSourceIamgeName must not be specified.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.iOType] Gets or sets the IO
   * type.
   * 
   * @param {number} [parameters.oSVirtualHardDisk.resizedSizeInGB] When an OS
   * Image or a RemoteSourceImage is used to create an OSVirtualHardDisk, this
   * parameter can be used to resize the new OSVirtualHardDisk to a larger
   * size. ResizedSizeInGB must be larger than the underlying OS Image’s
   * LogicalSizeInGB.
   * 
   * @param {boolean} [parameters.provisionGuestAgent] Indicates whether the
   * WindowsAzureGuestAgent service is installed on the Virtual Machine. To
   * run a resource extension in a Virtual Machine, this service must be
   * installed.
   * 
   * @param {DebugSettings} [parameters.debugSettings] Debug settings for
   * console output.
   * 
   * @param {boolean} [parameters.debugSettings.bootDiagnosticsEnabled] Enable
   * or disable boot diagnostics.
   * 
   * @param {string} [parameters.debugSettings.consoleScreenshotBlobUri] Blob
   * uri for console screen shot.
   * 
   * @param {string} [parameters.debugSettings.serialOutputBlobUri] Blob uri
   * for serial output.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.beginUpdating = function(serviceName, deploymentName, virtualMachineName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (virtualMachineName === null || virtualMachineName === undefined) {
      return callback(new Error('virtualMachineName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.configurationSets !== null && parameters.configurationSets !== undefined) {
      for (var loweredIndex1 = 0; loweredIndex1 < parameters.configurationSets.length; loweredIndex1 = loweredIndex1 + 1) {
        var configurationSetsParameterItem = parameters.configurationSets[loweredIndex1];
        if (configurationSetsParameterItem.additionalUnattendContent !== null && configurationSetsParameterItem.additionalUnattendContent !== undefined) {
          if (configurationSetsParameterItem.additionalUnattendContent.unattendPasses !== null && configurationSetsParameterItem.additionalUnattendContent.unattendPasses !== undefined) {
            for (var loweredIndex2 = 0; loweredIndex2 < configurationSetsParameterItem.additionalUnattendContent.unattendPasses.length; loweredIndex2 = loweredIndex2 + 1) {
              var unattendPassesParameterItem = configurationSetsParameterItem.additionalUnattendContent.unattendPasses[loweredIndex2];
              if (unattendPassesParameterItem.passName === null || unattendPassesParameterItem.passName === undefined) {
                return callback(new Error('parameters.configurationSets.additionalUnattendContent.unattendPasses.passName cannot be null.'));
              }
              if (unattendPassesParameterItem.unattendComponents !== null && unattendPassesParameterItem.unattendComponents !== undefined) {
                for (var loweredIndex3 = 0; loweredIndex3 < unattendPassesParameterItem.unattendComponents.length; loweredIndex3 = loweredIndex3 + 1) {
                  var unattendComponentsParameterItem = unattendPassesParameterItem.unattendComponents[loweredIndex3];
                  if (unattendComponentsParameterItem.componentName === null || unattendComponentsParameterItem.componentName === undefined) {
                    return callback(new Error('parameters.configurationSets.additionalUnattendContent.unattendPasses.unattendComponents.componentName cannot be null.'));
                  }
                  if (unattendComponentsParameterItem.unattendComponentSettings !== null && unattendComponentsParameterItem.unattendComponentSettings !== undefined) {
                    for (var loweredIndex4 = 0; loweredIndex4 < unattendComponentsParameterItem.unattendComponentSettings.length; loweredIndex4 = loweredIndex4 + 1) {
                      var unattendComponentSettingsParameterItem = unattendComponentsParameterItem.unattendComponentSettings[loweredIndex4];
                      if (unattendComponentSettingsParameterItem.settingName === null || unattendComponentSettingsParameterItem.settingName === undefined) {
                        return callback(new Error('parameters.configurationSets.additionalUnattendContent.unattendPasses.unattendComponents.unattendComponentSettings.settingName cannot be null.'));
                      }
                    }
                  }
                }
              }
            }
          }
        }
        if (configurationSetsParameterItem.domainJoin !== null && configurationSetsParameterItem.domainJoin !== undefined) {
          if (configurationSetsParameterItem.domainJoin.credentials !== null && configurationSetsParameterItem.domainJoin.credentials !== undefined) {
            if (configurationSetsParameterItem.domainJoin.credentials.password === null || configurationSetsParameterItem.domainJoin.credentials.password === undefined) {
              return callback(new Error('parameters.configurationSets.domainJoin.credentials.password cannot be null.'));
            }
            if (configurationSetsParameterItem.domainJoin.credentials.userName === null || configurationSetsParameterItem.domainJoin.credentials.userName === undefined) {
              return callback(new Error('parameters.configurationSets.domainJoin.credentials.userName cannot be null.'));
            }
          }
        }
        if (configurationSetsParameterItem.hostName !== null && configurationSetsParameterItem.hostName !== undefined && configurationSetsParameterItem.hostName.length < 1) {
          return callback(new Error('parameters.configurationSets.hostName is outside the valid range.'));
        }
        if (configurationSetsParameterItem.hostName !== null && configurationSetsParameterItem.hostName !== undefined && configurationSetsParameterItem.hostName.length > 64) {
          return callback(new Error('parameters.configurationSets.hostName is outside the valid range.'));
        }
        if (configurationSetsParameterItem.sshSettings !== null && configurationSetsParameterItem.sshSettings !== undefined) {
          if (configurationSetsParameterItem.sshSettings.keyPairs !== null && configurationSetsParameterItem.sshSettings.keyPairs !== undefined) {
            for (var loweredIndex5 = 0; loweredIndex5 < configurationSetsParameterItem.sshSettings.keyPairs.length; loweredIndex5 = loweredIndex5 + 1) {
              var keyPairsParameterItem = configurationSetsParameterItem.sshSettings.keyPairs[loweredIndex5];
              if (keyPairsParameterItem.fingerprint === null || keyPairsParameterItem.fingerprint === undefined) {
                return callback(new Error('parameters.configurationSets.sshSettings.keyPairs.fingerprint cannot be null.'));
              }
              if (keyPairsParameterItem.path === null || keyPairsParameterItem.path === undefined) {
                return callback(new Error('parameters.configurationSets.sshSettings.keyPairs.path cannot be null.'));
              }
            }
          }
          if (configurationSetsParameterItem.sshSettings.publicKeys !== null && configurationSetsParameterItem.sshSettings.publicKeys !== undefined) {
            for (var loweredIndex6 = 0; loweredIndex6 < configurationSetsParameterItem.sshSettings.publicKeys.length; loweredIndex6 = loweredIndex6 + 1) {
              var publicKeysParameterItem = configurationSetsParameterItem.sshSettings.publicKeys[loweredIndex6];
              if (publicKeysParameterItem.fingerprint === null || publicKeysParameterItem.fingerprint === undefined) {
                return callback(new Error('parameters.configurationSets.sshSettings.publicKeys.fingerprint cannot be null.'));
              }
              if (publicKeysParameterItem.path === null || publicKeysParameterItem.path === undefined) {
                return callback(new Error('parameters.configurationSets.sshSettings.publicKeys.path cannot be null.'));
              }
            }
          }
        }
        if (configurationSetsParameterItem.storedCertificateSettings !== null && configurationSetsParameterItem.storedCertificateSettings !== undefined) {
          for (var loweredIndex7 = 0; loweredIndex7 < configurationSetsParameterItem.storedCertificateSettings.length; loweredIndex7 = loweredIndex7 + 1) {
            var storedCertificateSettingsParameterItem = configurationSetsParameterItem.storedCertificateSettings[loweredIndex7];
            if (storedCertificateSettingsParameterItem.storeName === null || storedCertificateSettingsParameterItem.storeName === undefined) {
              return callback(new Error('parameters.configurationSets.storedCertificateSettings.storeName cannot be null.'));
            }
            if (storedCertificateSettingsParameterItem.thumbprint === null || storedCertificateSettingsParameterItem.thumbprint === undefined) {
              return callback(new Error('parameters.configurationSets.storedCertificateSettings.thumbprint cannot be null.'));
            }
          }
        }
        if (configurationSetsParameterItem.userName !== null && configurationSetsParameterItem.userName !== undefined && configurationSetsParameterItem.userName.length < 1) {
          return callback(new Error('parameters.configurationSets.userName is outside the valid range.'));
        }
        if (configurationSetsParameterItem.userName !== null && configurationSetsParameterItem.userName !== undefined && configurationSetsParameterItem.userName.length > 32) {
          return callback(new Error('parameters.configurationSets.userName is outside the valid range.'));
        }
        if (configurationSetsParameterItem.userPassword !== null && configurationSetsParameterItem.userPassword !== undefined && configurationSetsParameterItem.userPassword.length < 6) {
          return callback(new Error('parameters.configurationSets.userPassword is outside the valid range.'));
        }
        if (configurationSetsParameterItem.userPassword !== null && configurationSetsParameterItem.userPassword !== undefined && configurationSetsParameterItem.userPassword.length > 72) {
          return callback(new Error('parameters.configurationSets.userPassword is outside the valid range.'));
        }
        if (configurationSetsParameterItem.windowsRemoteManagement !== null && configurationSetsParameterItem.windowsRemoteManagement !== undefined) {
          if (configurationSetsParameterItem.windowsRemoteManagement.listeners !== null && configurationSetsParameterItem.windowsRemoteManagement.listeners !== undefined) {
            for (var loweredIndex8 = 0; loweredIndex8 < configurationSetsParameterItem.windowsRemoteManagement.listeners.length; loweredIndex8 = loweredIndex8 + 1) {
              var listenersParameterItem = configurationSetsParameterItem.windowsRemoteManagement.listeners[loweredIndex8];
              if (listenersParameterItem.listenerType === null || listenersParameterItem.listenerType === undefined) {
                return callback(new Error('parameters.configurationSets.windowsRemoteManagement.listeners.listenerType cannot be null.'));
              }
            }
          }
        }
      }
    }
    if (parameters.debugSettings !== null && parameters.debugSettings !== undefined) {
      if (parameters.debugSettings.bootDiagnosticsEnabled === null || parameters.debugSettings.bootDiagnosticsEnabled === undefined) {
        return callback(new Error('parameters.debugSettings.bootDiagnosticsEnabled cannot be null.'));
      }
    }
    if (parameters.oSVirtualHardDisk === null || parameters.oSVirtualHardDisk === undefined) {
      return callback(new Error('parameters.oSVirtualHardDisk cannot be null.'));
    }
    if (parameters.roleName === null || parameters.roleName === undefined) {
      return callback(new Error('parameters.roleName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/roles/';
    url2 = url2 + encodeURIComponent(virtualMachineName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var persistentVMRoleElement = js2xml.createElement('PersistentVMRole', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, persistentVMRoleElement);
    
    var roleNameElement = js2xml.createElement('RoleName', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(roleNameElement, parameters.roleName);
    js2xml.addChildElement(persistentVMRoleElement, roleNameElement);
    
    var roleTypeElement = js2xml.createElement('RoleType', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(roleTypeElement, 'PersistentVMRole');
    js2xml.addChildElement(persistentVMRoleElement, roleTypeElement);
    
    if (parameters.configurationSets !== null && parameters.configurationSets !== undefined) {
      var configurationSetsSequenceElement = js2xml.createElement('ConfigurationSets', 'http://schemas.microsoft.com/windowsazure');
      for (var loweredIndex9 = 0; loweredIndex9 < parameters.configurationSets.length; loweredIndex9 = loweredIndex9 + 1) {
        var configurationSetsItem = parameters.configurationSets[loweredIndex9];
        var configurationSetElement = js2xml.createElement('ConfigurationSet', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(configurationSetsSequenceElement, configurationSetElement);
        
        if (configurationSetsItem.configurationSetType !== null && configurationSetsItem.configurationSetType !== undefined) {
          var configurationSetTypeElement = js2xml.createElement('ConfigurationSetType', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(configurationSetTypeElement, configurationSetsItem.configurationSetType);
          js2xml.addChildElement(configurationSetElement, configurationSetTypeElement);
        }
        
        if (configurationSetsItem.inputEndpoints !== null && configurationSetsItem.inputEndpoints !== undefined) {
          var inputEndpointsSequenceElement = js2xml.createElement('InputEndpoints', 'http://schemas.microsoft.com/windowsazure');
          for (var loweredIndex10 = 0; loweredIndex10 < configurationSetsItem.inputEndpoints.length; loweredIndex10 = loweredIndex10 + 1) {
            var inputEndpointsItem = configurationSetsItem.inputEndpoints[loweredIndex10];
            var inputEndpointElement = js2xml.createElement('InputEndpoint', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(inputEndpointsSequenceElement, inputEndpointElement);
            
            if (inputEndpointsItem.loadBalancedEndpointSetName !== null && inputEndpointsItem.loadBalancedEndpointSetName !== undefined) {
              var loadBalancedEndpointSetNameElement = js2xml.createElement('LoadBalancedEndpointSetName', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(loadBalancedEndpointSetNameElement, inputEndpointsItem.loadBalancedEndpointSetName);
              js2xml.addChildElement(inputEndpointElement, loadBalancedEndpointSetNameElement);
            }
            
            if (inputEndpointsItem.localPort !== null && inputEndpointsItem.localPort !== undefined) {
              var localPortElement = js2xml.createElement('LocalPort', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(localPortElement, inputEndpointsItem.localPort.toString());
              js2xml.addChildElement(inputEndpointElement, localPortElement);
            }
            
            if (inputEndpointsItem.name !== null && inputEndpointsItem.name !== undefined) {
              var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(nameElement, inputEndpointsItem.name);
              js2xml.addChildElement(inputEndpointElement, nameElement);
            }
            
            if (inputEndpointsItem.port !== null && inputEndpointsItem.port !== undefined) {
              var portElement = js2xml.createElement('Port', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(portElement, inputEndpointsItem.port.toString());
              js2xml.addChildElement(inputEndpointElement, portElement);
            }
            
            if (inputEndpointsItem.loadBalancerProbe !== null && inputEndpointsItem.loadBalancerProbe !== undefined) {
              var loadBalancerProbeElement = js2xml.createElement('LoadBalancerProbe', 'http://schemas.microsoft.com/windowsazure');
              js2xml.addChildElement(inputEndpointElement, loadBalancerProbeElement);
              
              if (inputEndpointsItem.loadBalancerProbe.path !== null && inputEndpointsItem.loadBalancerProbe.path !== undefined) {
                var pathElement = js2xml.createElement('Path', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(pathElement, inputEndpointsItem.loadBalancerProbe.path);
                js2xml.addChildElement(loadBalancerProbeElement, pathElement);
              }
              
              if (inputEndpointsItem.loadBalancerProbe.port !== null && inputEndpointsItem.loadBalancerProbe.port !== undefined) {
                var portElement2 = js2xml.createElement('Port', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(portElement2, inputEndpointsItem.loadBalancerProbe.port.toString());
                js2xml.addChildElement(loadBalancerProbeElement, portElement2);
              }
              
              if (inputEndpointsItem.loadBalancerProbe.protocol !== null && inputEndpointsItem.loadBalancerProbe.protocol !== undefined) {
                var protocolElement = js2xml.createElement('Protocol', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(protocolElement, inputEndpointsItem.loadBalancerProbe.protocol !== null && inputEndpointsItem.loadBalancerProbe.protocol !== undefined ? inputEndpointsItem.loadBalancerProbe.protocol.toString() : 'Tcp');
                js2xml.addChildElement(loadBalancerProbeElement, protocolElement);
              }
              
              if (inputEndpointsItem.loadBalancerProbe.intervalInSeconds !== null && inputEndpointsItem.loadBalancerProbe.intervalInSeconds !== undefined) {
                var intervalInSecondsElement = js2xml.createElement('IntervalInSeconds', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(intervalInSecondsElement, inputEndpointsItem.loadBalancerProbe.intervalInSeconds.toString());
                js2xml.addChildElement(loadBalancerProbeElement, intervalInSecondsElement);
              }
              
              if (inputEndpointsItem.loadBalancerProbe.timeoutInSeconds !== null && inputEndpointsItem.loadBalancerProbe.timeoutInSeconds !== undefined) {
                var timeoutInSecondsElement = js2xml.createElement('TimeoutInSeconds', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(timeoutInSecondsElement, inputEndpointsItem.loadBalancerProbe.timeoutInSeconds.toString());
                js2xml.addChildElement(loadBalancerProbeElement, timeoutInSecondsElement);
              }
            }
            
            if (inputEndpointsItem.protocol !== null && inputEndpointsItem.protocol !== undefined) {
              var protocolElement2 = js2xml.createElement('Protocol', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(protocolElement2, inputEndpointsItem.protocol);
              js2xml.addChildElement(inputEndpointElement, protocolElement2);
            }
            
            if (inputEndpointsItem.virtualIPAddress !== null && inputEndpointsItem.virtualIPAddress !== undefined) {
              var vipElement = js2xml.createElement('Vip', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(vipElement, inputEndpointsItem.virtualIPAddress);
              js2xml.addChildElement(inputEndpointElement, vipElement);
            }
            
            if (inputEndpointsItem.enableDirectServerReturn !== null && inputEndpointsItem.enableDirectServerReturn !== undefined) {
              var enableDirectServerReturnElement = js2xml.createElement('EnableDirectServerReturn', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(enableDirectServerReturnElement, inputEndpointsItem.enableDirectServerReturn.toString());
              js2xml.addChildElement(inputEndpointElement, enableDirectServerReturnElement);
            }
            
            if (inputEndpointsItem.loadBalancerName !== null && inputEndpointsItem.loadBalancerName !== undefined) {
              var loadBalancerNameElement = js2xml.createElement('LoadBalancerName', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(loadBalancerNameElement, inputEndpointsItem.loadBalancerName);
              js2xml.addChildElement(inputEndpointElement, loadBalancerNameElement);
            }
            
            if (inputEndpointsItem.endpointAcl !== null && inputEndpointsItem.endpointAcl !== undefined) {
              var endpointAclElement = js2xml.createElement('EndpointAcl', 'http://schemas.microsoft.com/windowsazure');
              js2xml.addChildElement(inputEndpointElement, endpointAclElement);
              
              if (inputEndpointsItem.endpointAcl.rules !== null && inputEndpointsItem.endpointAcl.rules !== undefined) {
                var rulesSequenceElement = js2xml.createElement('Rules', 'http://schemas.microsoft.com/windowsazure');
                for (var loweredIndex11 = 0; loweredIndex11 < inputEndpointsItem.endpointAcl.rules.length; loweredIndex11 = loweredIndex11 + 1) {
                  var rulesItem = inputEndpointsItem.endpointAcl.rules[loweredIndex11];
                  var ruleElement = js2xml.createElement('Rule', 'http://schemas.microsoft.com/windowsazure');
                  js2xml.addChildElement(rulesSequenceElement, ruleElement);
                  
                  if (rulesItem.order !== null && rulesItem.order !== undefined) {
                    var orderElement = js2xml.createElement('Order', 'http://schemas.microsoft.com/windowsazure');
                    js2xml.setElementValue(orderElement, rulesItem.order.toString());
                    js2xml.addChildElement(ruleElement, orderElement);
                  }
                  
                  if (rulesItem.action !== null && rulesItem.action !== undefined) {
                    var actionElement = js2xml.createElement('Action', 'http://schemas.microsoft.com/windowsazure');
                    js2xml.setElementValue(actionElement, rulesItem.action);
                    js2xml.addChildElement(ruleElement, actionElement);
                  }
                  
                  if (rulesItem.remoteSubnet !== null && rulesItem.remoteSubnet !== undefined) {
                    var remoteSubnetElement = js2xml.createElement('RemoteSubnet', 'http://schemas.microsoft.com/windowsazure');
                    js2xml.setElementValue(remoteSubnetElement, rulesItem.remoteSubnet);
                    js2xml.addChildElement(ruleElement, remoteSubnetElement);
                  }
                  
                  if (rulesItem.description !== null && rulesItem.description !== undefined) {
                    var descriptionElement = js2xml.createElement('Description', 'http://schemas.microsoft.com/windowsazure');
                    js2xml.setElementValue(descriptionElement, rulesItem.description);
                    js2xml.addChildElement(ruleElement, descriptionElement);
                  }
                }
                js2xml.addChildElement(endpointAclElement, rulesSequenceElement);
              }
            }
            
            if (inputEndpointsItem.idleTimeoutInMinutes !== null && inputEndpointsItem.idleTimeoutInMinutes !== undefined) {
              var idleTimeoutInMinutesElement = js2xml.createElement('IdleTimeoutInMinutes', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(idleTimeoutInMinutesElement, inputEndpointsItem.idleTimeoutInMinutes.toString());
              js2xml.addChildElement(inputEndpointElement, idleTimeoutInMinutesElement);
            }
            
            if (inputEndpointsItem.loadBalancerDistribution !== null && inputEndpointsItem.loadBalancerDistribution !== undefined) {
              var loadBalancerDistributionElement = js2xml.createElement('LoadBalancerDistribution', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(loadBalancerDistributionElement, inputEndpointsItem.loadBalancerDistribution);
              js2xml.addChildElement(inputEndpointElement, loadBalancerDistributionElement);
            }
            
            if (inputEndpointsItem.virtualIPName !== null && inputEndpointsItem.virtualIPName !== undefined) {
              var virtualIPNameElement = js2xml.createElement('VirtualIPName', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(virtualIPNameElement, inputEndpointsItem.virtualIPName);
              js2xml.addChildElement(inputEndpointElement, virtualIPNameElement);
            }
          }
          js2xml.addChildElement(configurationSetElement, inputEndpointsSequenceElement);
        }
        
        if (configurationSetsItem.subnetNames !== null && configurationSetsItem.subnetNames !== undefined) {
          var subnetNamesSequenceElement = js2xml.createElement('SubnetNames', 'http://schemas.microsoft.com/windowsazure');
          for (var loweredIndex12 = 0; loweredIndex12 < configurationSetsItem.subnetNames.length; loweredIndex12 = loweredIndex12 + 1) {
            var subnetNamesItem = configurationSetsItem.subnetNames[loweredIndex12];
            var subnetNamesItemElement = js2xml.createElement('SubnetName', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(subnetNamesItemElement, subnetNamesItem);
            js2xml.addChildElement(subnetNamesSequenceElement, subnetNamesItemElement);
          }
          js2xml.addChildElement(configurationSetElement, subnetNamesSequenceElement);
        }
        
        if (configurationSetsItem.staticVirtualNetworkIPAddress !== null && configurationSetsItem.staticVirtualNetworkIPAddress !== undefined) {
          var staticVirtualNetworkIPAddressElement = js2xml.createElement('StaticVirtualNetworkIPAddress', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(staticVirtualNetworkIPAddressElement, configurationSetsItem.staticVirtualNetworkIPAddress);
          js2xml.addChildElement(configurationSetElement, staticVirtualNetworkIPAddressElement);
        }
        
        if (configurationSetsItem.publicIPs !== null && configurationSetsItem.publicIPs !== undefined) {
          var publicIPsSequenceElement = js2xml.createElement('PublicIPs', 'http://schemas.microsoft.com/windowsazure');
          for (var loweredIndex13 = 0; loweredIndex13 < configurationSetsItem.publicIPs.length; loweredIndex13 = loweredIndex13 + 1) {
            var publicIPsItem = configurationSetsItem.publicIPs[loweredIndex13];
            var publicIPElement = js2xml.createElement('PublicIP', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(publicIPsSequenceElement, publicIPElement);
            
            if (publicIPsItem.name !== null && publicIPsItem.name !== undefined) {
              var nameElement2 = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(nameElement2, publicIPsItem.name);
              js2xml.addChildElement(publicIPElement, nameElement2);
            }
            
            if (publicIPsItem.idleTimeoutInMinutes !== null && publicIPsItem.idleTimeoutInMinutes !== undefined) {
              var idleTimeoutInMinutesElement2 = js2xml.createElement('IdleTimeoutInMinutes', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(idleTimeoutInMinutesElement2, publicIPsItem.idleTimeoutInMinutes.toString());
              js2xml.addChildElement(publicIPElement, idleTimeoutInMinutesElement2);
            }
            
            if (publicIPsItem.domainNameLabel !== null && publicIPsItem.domainNameLabel !== undefined) {
              var domainNameLabelElement = js2xml.createElement('DomainNameLabel', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(domainNameLabelElement, publicIPsItem.domainNameLabel);
              js2xml.addChildElement(publicIPElement, domainNameLabelElement);
            }
          }
          js2xml.addChildElement(configurationSetElement, publicIPsSequenceElement);
        }
        
        if (configurationSetsItem.networkInterfaces !== null && configurationSetsItem.networkInterfaces !== undefined) {
          var networkInterfacesSequenceElement = js2xml.createElement('NetworkInterfaces', 'http://schemas.microsoft.com/windowsazure');
          for (var loweredIndex14 = 0; loweredIndex14 < configurationSetsItem.networkInterfaces.length; loweredIndex14 = loweredIndex14 + 1) {
            var networkInterfacesItem = configurationSetsItem.networkInterfaces[loweredIndex14];
            var networkInterfaceElement = js2xml.createElement('NetworkInterface', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(networkInterfacesSequenceElement, networkInterfaceElement);
            
            if (networkInterfacesItem.name !== null && networkInterfacesItem.name !== undefined) {
              var nameElement3 = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(nameElement3, networkInterfacesItem.name);
              js2xml.addChildElement(networkInterfaceElement, nameElement3);
            }
            
            if (networkInterfacesItem.iPConfigurations !== null && networkInterfacesItem.iPConfigurations !== undefined) {
              var iPConfigurationsSequenceElement = js2xml.createElement('IPConfigurations', 'http://schemas.microsoft.com/windowsazure');
              for (var loweredIndex15 = 0; loweredIndex15 < networkInterfacesItem.iPConfigurations.length; loweredIndex15 = loweredIndex15 + 1) {
                var iPConfigurationsItem = networkInterfacesItem.iPConfigurations[loweredIndex15];
                var iPConfigurationElement = js2xml.createElement('IPConfiguration', 'http://schemas.microsoft.com/windowsazure');
                js2xml.addChildElement(iPConfigurationsSequenceElement, iPConfigurationElement);
                
                if (iPConfigurationsItem.subnetName !== null && iPConfigurationsItem.subnetName !== undefined) {
                  var subnetNameElement = js2xml.createElement('SubnetName', 'http://schemas.microsoft.com/windowsazure');
                  js2xml.setElementValue(subnetNameElement, iPConfigurationsItem.subnetName);
                  js2xml.addChildElement(iPConfigurationElement, subnetNameElement);
                }
                
                if (iPConfigurationsItem.staticVirtualNetworkIPAddress !== null && iPConfigurationsItem.staticVirtualNetworkIPAddress !== undefined) {
                  var staticVirtualNetworkIPAddressElement2 = js2xml.createElement('StaticVirtualNetworkIPAddress', 'http://schemas.microsoft.com/windowsazure');
                  js2xml.setElementValue(staticVirtualNetworkIPAddressElement2, iPConfigurationsItem.staticVirtualNetworkIPAddress);
                  js2xml.addChildElement(iPConfigurationElement, staticVirtualNetworkIPAddressElement2);
                }
              }
              js2xml.addChildElement(networkInterfaceElement, iPConfigurationsSequenceElement);
            }
            
            if (networkInterfacesItem.networkSecurityGroup !== null && networkInterfacesItem.networkSecurityGroup !== undefined) {
              var networkSecurityGroupElement = js2xml.createElement('NetworkSecurityGroup', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(networkSecurityGroupElement, networkInterfacesItem.networkSecurityGroup);
              js2xml.addChildElement(networkInterfaceElement, networkSecurityGroupElement);
            }
            
            if (networkInterfacesItem.iPForwarding !== null && networkInterfacesItem.iPForwarding !== undefined) {
              var iPForwardingElement = js2xml.createElement('IPForwarding', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(iPForwardingElement, networkInterfacesItem.iPForwarding);
              js2xml.addChildElement(networkInterfaceElement, iPForwardingElement);
            }
          }
          js2xml.addChildElement(configurationSetElement, networkInterfacesSequenceElement);
        }
        
        if (configurationSetsItem.networkSecurityGroup !== null && configurationSetsItem.networkSecurityGroup !== undefined) {
          var networkSecurityGroupElement2 = js2xml.createElement('NetworkSecurityGroup', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(networkSecurityGroupElement2, configurationSetsItem.networkSecurityGroup);
          js2xml.addChildElement(configurationSetElement, networkSecurityGroupElement2);
        }
        
        if (configurationSetsItem.iPForwarding !== null && configurationSetsItem.iPForwarding !== undefined) {
          var iPForwardingElement2 = js2xml.createElement('IPForwarding', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(iPForwardingElement2, configurationSetsItem.iPForwarding);
          js2xml.addChildElement(configurationSetElement, iPForwardingElement2);
        }
        
        if (configurationSetsItem.computerName !== null && configurationSetsItem.computerName !== undefined) {
          var computerNameElement = js2xml.createElement('ComputerName', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(computerNameElement, configurationSetsItem.computerName);
          js2xml.addChildElement(configurationSetElement, computerNameElement);
        }
        
        if (configurationSetsItem.adminPassword !== null && configurationSetsItem.adminPassword !== undefined) {
          var adminPasswordElement = js2xml.createElement('AdminPassword', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(adminPasswordElement, configurationSetsItem.adminPassword);
          js2xml.addChildElement(configurationSetElement, adminPasswordElement);
        }
        
        if (configurationSetsItem.resetPasswordOnFirstLogon !== null && configurationSetsItem.resetPasswordOnFirstLogon !== undefined) {
          var resetPasswordOnFirstLogonElement = js2xml.createElement('ResetPasswordOnFirstLogon', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(resetPasswordOnFirstLogonElement, configurationSetsItem.resetPasswordOnFirstLogon.toString());
          js2xml.addChildElement(configurationSetElement, resetPasswordOnFirstLogonElement);
        }
        
        if (configurationSetsItem.enableAutomaticUpdates !== null && configurationSetsItem.enableAutomaticUpdates !== undefined) {
          var enableAutomaticUpdatesElement = js2xml.createElement('EnableAutomaticUpdates', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(enableAutomaticUpdatesElement, configurationSetsItem.enableAutomaticUpdates.toString());
          js2xml.addChildElement(configurationSetElement, enableAutomaticUpdatesElement);
        }
        
        if (configurationSetsItem.timeZone !== null && configurationSetsItem.timeZone !== undefined) {
          var timeZoneElement = js2xml.createElement('TimeZone', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(timeZoneElement, configurationSetsItem.timeZone);
          js2xml.addChildElement(configurationSetElement, timeZoneElement);
        }
        
        if (configurationSetsItem.domainJoin !== null && configurationSetsItem.domainJoin !== undefined) {
          var domainJoinElement = js2xml.createElement('DomainJoin', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(configurationSetElement, domainJoinElement);
          
          if (configurationSetsItem.domainJoin.credentials !== null && configurationSetsItem.domainJoin.credentials !== undefined) {
            var credentialsElement = js2xml.createElement('Credentials', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(domainJoinElement, credentialsElement);
            
            if (configurationSetsItem.domainJoin.credentials.domain !== null && configurationSetsItem.domainJoin.credentials.domain !== undefined) {
              var domainElement = js2xml.createElement('Domain', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(domainElement, configurationSetsItem.domainJoin.credentials.domain);
              js2xml.addChildElement(credentialsElement, domainElement);
            }
            
            var usernameElement = js2xml.createElement('Username', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(usernameElement, configurationSetsItem.domainJoin.credentials.userName);
            js2xml.addChildElement(credentialsElement, usernameElement);
            
            var passwordElement = js2xml.createElement('Password', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(passwordElement, configurationSetsItem.domainJoin.credentials.password);
            js2xml.addChildElement(credentialsElement, passwordElement);
          }
          
          if (configurationSetsItem.domainJoin.domainToJoin !== null && configurationSetsItem.domainJoin.domainToJoin !== undefined) {
            var joinDomainElement = js2xml.createElement('JoinDomain', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(joinDomainElement, configurationSetsItem.domainJoin.domainToJoin);
            js2xml.addChildElement(domainJoinElement, joinDomainElement);
          }
          
          if (configurationSetsItem.domainJoin.ldapMachineObjectOU !== null && configurationSetsItem.domainJoin.ldapMachineObjectOU !== undefined) {
            var machineObjectOUElement = js2xml.createElement('MachineObjectOU', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(machineObjectOUElement, configurationSetsItem.domainJoin.ldapMachineObjectOU);
            js2xml.addChildElement(domainJoinElement, machineObjectOUElement);
          }
          
          if (configurationSetsItem.domainJoin.provisioning !== null && configurationSetsItem.domainJoin.provisioning !== undefined) {
            var provisioningElement = js2xml.createElement('Provisioning', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(domainJoinElement, provisioningElement);
            
            if (configurationSetsItem.domainJoin.provisioning.accountData !== null && configurationSetsItem.domainJoin.provisioning.accountData !== undefined) {
              var accountDataElement = js2xml.createElement('AccountData', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(accountDataElement, configurationSetsItem.domainJoin.provisioning.accountData);
              js2xml.addChildElement(provisioningElement, accountDataElement);
            }
          }
        }
        
        if (configurationSetsItem.storedCertificateSettings !== null && configurationSetsItem.storedCertificateSettings !== undefined) {
          var storedCertificateSettingsSequenceElement = js2xml.createElement('StoredCertificateSettings', 'http://schemas.microsoft.com/windowsazure');
          for (var loweredIndex16 = 0; loweredIndex16 < configurationSetsItem.storedCertificateSettings.length; loweredIndex16 = loweredIndex16 + 1) {
            var storedCertificateSettingsItem = configurationSetsItem.storedCertificateSettings[loweredIndex16];
            var certificateSettingElement = js2xml.createElement('CertificateSetting', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(storedCertificateSettingsSequenceElement, certificateSettingElement);
            
            var storeLocationElement = js2xml.createElement('StoreLocation', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(storeLocationElement, 'LocalMachine');
            js2xml.addChildElement(certificateSettingElement, storeLocationElement);
            
            var storeNameElement = js2xml.createElement('StoreName', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(storeNameElement, storedCertificateSettingsItem.storeName);
            js2xml.addChildElement(certificateSettingElement, storeNameElement);
            
            var thumbprintElement = js2xml.createElement('Thumbprint', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(thumbprintElement, storedCertificateSettingsItem.thumbprint);
            js2xml.addChildElement(certificateSettingElement, thumbprintElement);
          }
          js2xml.addChildElement(configurationSetElement, storedCertificateSettingsSequenceElement);
        }
        
        if (configurationSetsItem.windowsRemoteManagement !== null && configurationSetsItem.windowsRemoteManagement !== undefined) {
          var winRMElement = js2xml.createElement('WinRM', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(configurationSetElement, winRMElement);
          
          if (configurationSetsItem.windowsRemoteManagement.listeners !== null && configurationSetsItem.windowsRemoteManagement.listeners !== undefined) {
            var listenersSequenceElement = js2xml.createElement('Listeners', 'http://schemas.microsoft.com/windowsazure');
            for (var loweredIndex17 = 0; loweredIndex17 < configurationSetsItem.windowsRemoteManagement.listeners.length; loweredIndex17 = loweredIndex17 + 1) {
              var listenersItem = configurationSetsItem.windowsRemoteManagement.listeners[loweredIndex17];
              var listenerElement = js2xml.createElement('Listener', 'http://schemas.microsoft.com/windowsazure');
              js2xml.addChildElement(listenersSequenceElement, listenerElement);
              
              if (listenersItem.certificateThumbprint !== null && listenersItem.certificateThumbprint !== undefined) {
                var certificateThumbprintElement = js2xml.createElement('CertificateThumbprint', 'http://schemas.microsoft.com/windowsazure');
                js2xml.setElementValue(certificateThumbprintElement, listenersItem.certificateThumbprint);
                js2xml.addChildElement(listenerElement, certificateThumbprintElement);
              }
              
              var protocolElement3 = js2xml.createElement('Protocol', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(protocolElement3, listenersItem.listenerType !== null && listenersItem.listenerType !== undefined ? listenersItem.listenerType.toString() : 'Http');
              js2xml.addChildElement(listenerElement, protocolElement3);
            }
            js2xml.addChildElement(winRMElement, listenersSequenceElement);
          }
        }
        
        if (configurationSetsItem.adminUserName !== null && configurationSetsItem.adminUserName !== undefined) {
          var adminUsernameElement = js2xml.createElement('AdminUsername', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(adminUsernameElement, configurationSetsItem.adminUserName);
          js2xml.addChildElement(configurationSetElement, adminUsernameElement);
        }
        
        if (configurationSetsItem.additionalUnattendContent !== null && configurationSetsItem.additionalUnattendContent !== undefined) {
          var additionalUnattendContentElement = js2xml.createElement('AdditionalUnattendContent', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(configurationSetElement, additionalUnattendContentElement);
          
          if (configurationSetsItem.additionalUnattendContent.unattendPasses !== null && configurationSetsItem.additionalUnattendContent.unattendPasses !== undefined) {
            var passesSequenceElement = js2xml.createElement('Passes', 'http://schemas.microsoft.com/windowsazure');
            for (var loweredIndex18 = 0; loweredIndex18 < configurationSetsItem.additionalUnattendContent.unattendPasses.length; loweredIndex18 = loweredIndex18 + 1) {
              var passesItem = configurationSetsItem.additionalUnattendContent.unattendPasses[loweredIndex18];
              var unattendPassElement = js2xml.createElement('UnattendPass', 'http://schemas.microsoft.com/windowsazure');
              js2xml.addChildElement(passesSequenceElement, unattendPassElement);
              
              var passNameElement = js2xml.createElement('PassName', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(passNameElement, passesItem.passName);
              js2xml.addChildElement(unattendPassElement, passNameElement);
              
              if (passesItem.unattendComponents !== null && passesItem.unattendComponents !== undefined) {
                var componentsSequenceElement = js2xml.createElement('Components', 'http://schemas.microsoft.com/windowsazure');
                for (var loweredIndex19 = 0; loweredIndex19 < passesItem.unattendComponents.length; loweredIndex19 = loweredIndex19 + 1) {
                  var componentsItem = passesItem.unattendComponents[loweredIndex19];
                  var unattendComponentElement = js2xml.createElement('UnattendComponent', 'http://schemas.microsoft.com/windowsazure');
                  js2xml.addChildElement(componentsSequenceElement, unattendComponentElement);
                  
                  var componentNameElement = js2xml.createElement('ComponentName', 'http://schemas.microsoft.com/windowsazure');
                  js2xml.setElementValue(componentNameElement, componentsItem.componentName);
                  js2xml.addChildElement(unattendComponentElement, componentNameElement);
                  
                  if (componentsItem.unattendComponentSettings !== null && componentsItem.unattendComponentSettings !== undefined) {
                    var componentSettingsSequenceElement = js2xml.createElement('ComponentSettings', 'http://schemas.microsoft.com/windowsazure');
                    for (var loweredIndex20 = 0; loweredIndex20 < componentsItem.unattendComponentSettings.length; loweredIndex20 = loweredIndex20 + 1) {
                      var componentSettingsItem = componentsItem.unattendComponentSettings[loweredIndex20];
                      var componentSettingElement = js2xml.createElement('ComponentSetting', 'http://schemas.microsoft.com/windowsazure');
                      js2xml.addChildElement(componentSettingsSequenceElement, componentSettingElement);
                      
                      var settingNameElement = js2xml.createElement('SettingName', 'http://schemas.microsoft.com/windowsazure');
                      js2xml.setElementValue(settingNameElement, componentSettingsItem.settingName);
                      js2xml.addChildElement(componentSettingElement, settingNameElement);
                      
                      if (componentSettingsItem.content !== null && componentSettingsItem.content !== undefined) {
                        var contentElement = js2xml.createElement('Content', 'http://schemas.microsoft.com/windowsazure');
                        js2xml.setElementValue(contentElement, new Buffer(componentSettingsItem.content).toString('base64'));
                        js2xml.addChildElement(componentSettingElement, contentElement);
                      }
                    }
                    js2xml.addChildElement(unattendComponentElement, componentSettingsSequenceElement);
                  }
                }
                js2xml.addChildElement(unattendPassElement, componentsSequenceElement);
              }
            }
            js2xml.addChildElement(additionalUnattendContentElement, passesSequenceElement);
          }
        }
        
        if (configurationSetsItem.hostName !== null && configurationSetsItem.hostName !== undefined) {
          var hostNameElement = js2xml.createElement('HostName', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(hostNameElement, configurationSetsItem.hostName);
          js2xml.addChildElement(configurationSetElement, hostNameElement);
        }
        
        if (configurationSetsItem.userName !== null && configurationSetsItem.userName !== undefined) {
          var userNameElement = js2xml.createElement('UserName', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(userNameElement, configurationSetsItem.userName);
          js2xml.addChildElement(configurationSetElement, userNameElement);
        }
        
        if (configurationSetsItem.userPassword !== null && configurationSetsItem.userPassword !== undefined) {
          var userPasswordElement = js2xml.createElement('UserPassword', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(userPasswordElement, configurationSetsItem.userPassword);
          js2xml.addChildElement(configurationSetElement, userPasswordElement);
        }
        
        if (configurationSetsItem.disableSshPasswordAuthentication !== null && configurationSetsItem.disableSshPasswordAuthentication !== undefined) {
          var disableSshPasswordAuthenticationElement = js2xml.createElement('DisableSshPasswordAuthentication', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(disableSshPasswordAuthenticationElement, configurationSetsItem.disableSshPasswordAuthentication.toString());
          js2xml.addChildElement(configurationSetElement, disableSshPasswordAuthenticationElement);
        }
        
        if (configurationSetsItem.sshSettings !== null && configurationSetsItem.sshSettings !== undefined) {
          var sSHElement = js2xml.createElement('SSH', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(configurationSetElement, sSHElement);
          
          if (configurationSetsItem.sshSettings.publicKeys !== null && configurationSetsItem.sshSettings.publicKeys !== undefined) {
            var publicKeysSequenceElement = js2xml.createElement('PublicKeys', 'http://schemas.microsoft.com/windowsazure');
            for (var loweredIndex21 = 0; loweredIndex21 < configurationSetsItem.sshSettings.publicKeys.length; loweredIndex21 = loweredIndex21 + 1) {
              var publicKeysItem = configurationSetsItem.sshSettings.publicKeys[loweredIndex21];
              var publicKeyElement = js2xml.createElement('PublicKey', 'http://schemas.microsoft.com/windowsazure');
              js2xml.addChildElement(publicKeysSequenceElement, publicKeyElement);
              
              var fingerprintElement = js2xml.createElement('Fingerprint', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(fingerprintElement, publicKeysItem.fingerprint);
              js2xml.addChildElement(publicKeyElement, fingerprintElement);
              
              var pathElement2 = js2xml.createElement('Path', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(pathElement2, publicKeysItem.path);
              js2xml.addChildElement(publicKeyElement, pathElement2);
            }
            js2xml.addChildElement(sSHElement, publicKeysSequenceElement);
          }
          
          if (configurationSetsItem.sshSettings.keyPairs !== null && configurationSetsItem.sshSettings.keyPairs !== undefined) {
            var keyPairsSequenceElement = js2xml.createElement('KeyPairs', 'http://schemas.microsoft.com/windowsazure');
            for (var loweredIndex22 = 0; loweredIndex22 < configurationSetsItem.sshSettings.keyPairs.length; loweredIndex22 = loweredIndex22 + 1) {
              var keyPairsItem = configurationSetsItem.sshSettings.keyPairs[loweredIndex22];
              var keyPairElement = js2xml.createElement('KeyPair', 'http://schemas.microsoft.com/windowsazure');
              js2xml.addChildElement(keyPairsSequenceElement, keyPairElement);
              
              var fingerprintElement2 = js2xml.createElement('Fingerprint', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(fingerprintElement2, keyPairsItem.fingerprint);
              js2xml.addChildElement(keyPairElement, fingerprintElement2);
              
              var pathElement3 = js2xml.createElement('Path', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(pathElement3, keyPairsItem.path);
              js2xml.addChildElement(keyPairElement, pathElement3);
            }
            js2xml.addChildElement(sSHElement, keyPairsSequenceElement);
          }
        }
        
        if (configurationSetsItem.customData !== null && configurationSetsItem.customData !== undefined) {
          var customDataElement = js2xml.createElement('CustomData', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(customDataElement, configurationSetsItem.customData);
          js2xml.addChildElement(configurationSetElement, customDataElement);
        }
      }
      js2xml.addChildElement(persistentVMRoleElement, configurationSetsSequenceElement);
    }
    
    if (parameters.resourceExtensionReferences !== null && parameters.resourceExtensionReferences !== undefined) {
      var resourceExtensionReferencesSequenceElement = js2xml.createElement('ResourceExtensionReferences', 'http://schemas.microsoft.com/windowsazure');
      for (var loweredIndex23 = 0; loweredIndex23 < parameters.resourceExtensionReferences.length; loweredIndex23 = loweredIndex23 + 1) {
        var resourceExtensionReferencesItem = parameters.resourceExtensionReferences[loweredIndex23];
        var resourceExtensionReferenceElement = js2xml.createElement('ResourceExtensionReference', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(resourceExtensionReferencesSequenceElement, resourceExtensionReferenceElement);
        
        if (resourceExtensionReferencesItem.referenceName !== null && resourceExtensionReferencesItem.referenceName !== undefined) {
          var referenceNameElement = js2xml.createElement('ReferenceName', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(referenceNameElement, resourceExtensionReferencesItem.referenceName);
          js2xml.addChildElement(resourceExtensionReferenceElement, referenceNameElement);
        }
        
        if (resourceExtensionReferencesItem.publisher !== null && resourceExtensionReferencesItem.publisher !== undefined) {
          var publisherElement = js2xml.createElement('Publisher', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(publisherElement, resourceExtensionReferencesItem.publisher);
          js2xml.addChildElement(resourceExtensionReferenceElement, publisherElement);
        }
        
        if (resourceExtensionReferencesItem.name !== null && resourceExtensionReferencesItem.name !== undefined) {
          var nameElement4 = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(nameElement4, resourceExtensionReferencesItem.name);
          js2xml.addChildElement(resourceExtensionReferenceElement, nameElement4);
        }
        
        if (resourceExtensionReferencesItem.version !== null && resourceExtensionReferencesItem.version !== undefined) {
          var versionElement = js2xml.createElement('Version', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(versionElement, resourceExtensionReferencesItem.version);
          js2xml.addChildElement(resourceExtensionReferenceElement, versionElement);
        }
        
        if (resourceExtensionReferencesItem.resourceExtensionParameterValues !== null && resourceExtensionReferencesItem.resourceExtensionParameterValues !== undefined) {
          var resourceExtensionParameterValuesSequenceElement = js2xml.createElement('ResourceExtensionParameterValues', 'http://schemas.microsoft.com/windowsazure');
          for (var loweredIndex24 = 0; loweredIndex24 < resourceExtensionReferencesItem.resourceExtensionParameterValues.length; loweredIndex24 = loweredIndex24 + 1) {
            var resourceExtensionParameterValuesItem = resourceExtensionReferencesItem.resourceExtensionParameterValues[loweredIndex24];
            var resourceExtensionParameterValueElement = js2xml.createElement('ResourceExtensionParameterValue', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(resourceExtensionParameterValuesSequenceElement, resourceExtensionParameterValueElement);
            
            if (resourceExtensionParameterValuesItem.key !== null && resourceExtensionParameterValuesItem.key !== undefined) {
              var keyElement = js2xml.createElement('Key', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(keyElement, resourceExtensionParameterValuesItem.key);
              js2xml.addChildElement(resourceExtensionParameterValueElement, keyElement);
            }
            
            if (resourceExtensionParameterValuesItem.value !== null && resourceExtensionParameterValuesItem.value !== undefined) {
              var valueElement = js2xml.createElement('Value', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(valueElement, new Buffer(resourceExtensionParameterValuesItem.value).toString('base64'));
              js2xml.addChildElement(resourceExtensionParameterValueElement, valueElement);
            }
            
            if (resourceExtensionParameterValuesItem.type !== null && resourceExtensionParameterValuesItem.type !== undefined) {
              var typeElement = js2xml.createElement('Type', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(typeElement, resourceExtensionParameterValuesItem.type);
              js2xml.addChildElement(resourceExtensionParameterValueElement, typeElement);
            }
          }
          js2xml.addChildElement(resourceExtensionReferenceElement, resourceExtensionParameterValuesSequenceElement);
        }
        
        if (resourceExtensionReferencesItem.state !== null && resourceExtensionReferencesItem.state !== undefined) {
          var stateElement = js2xml.createElement('State', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(stateElement, resourceExtensionReferencesItem.state);
          js2xml.addChildElement(resourceExtensionReferenceElement, stateElement);
        }
        
        if (resourceExtensionReferencesItem.forceUpdate !== null && resourceExtensionReferencesItem.forceUpdate !== undefined) {
          var forceUpdateElement = js2xml.createElement('ForceUpdate', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(forceUpdateElement, resourceExtensionReferencesItem.forceUpdate.toString());
          js2xml.addChildElement(resourceExtensionReferenceElement, forceUpdateElement);
        }
      }
      js2xml.addChildElement(persistentVMRoleElement, resourceExtensionReferencesSequenceElement);
    }
    
    if (parameters.availabilitySetName !== null && parameters.availabilitySetName !== undefined) {
      var availabilitySetNameElement = js2xml.createElement('AvailabilitySetName', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(availabilitySetNameElement, parameters.availabilitySetName);
      js2xml.addChildElement(persistentVMRoleElement, availabilitySetNameElement);
    }
    
    if (parameters.dataVirtualHardDisks !== null && parameters.dataVirtualHardDisks !== undefined) {
      var dataVirtualHardDisksSequenceElement = js2xml.createElement('DataVirtualHardDisks', 'http://schemas.microsoft.com/windowsazure');
      for (var loweredIndex25 = 0; loweredIndex25 < parameters.dataVirtualHardDisks.length; loweredIndex25 = loweredIndex25 + 1) {
        var dataVirtualHardDisksItem = parameters.dataVirtualHardDisks[loweredIndex25];
        var dataVirtualHardDiskElement = js2xml.createElement('DataVirtualHardDisk', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(dataVirtualHardDisksSequenceElement, dataVirtualHardDiskElement);
        
        if (dataVirtualHardDisksItem.hostCaching !== null && dataVirtualHardDisksItem.hostCaching !== undefined) {
          var hostCachingElement = js2xml.createElement('HostCaching', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(hostCachingElement, dataVirtualHardDisksItem.hostCaching);
          js2xml.addChildElement(dataVirtualHardDiskElement, hostCachingElement);
        }
        
        if (dataVirtualHardDisksItem.label !== null && dataVirtualHardDisksItem.label !== undefined) {
          var diskLabelElement = js2xml.createElement('DiskLabel', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(diskLabelElement, dataVirtualHardDisksItem.label);
          js2xml.addChildElement(dataVirtualHardDiskElement, diskLabelElement);
        }
        
        if (dataVirtualHardDisksItem.name !== null && dataVirtualHardDisksItem.name !== undefined) {
          var diskNameElement = js2xml.createElement('DiskName', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(diskNameElement, dataVirtualHardDisksItem.name);
          js2xml.addChildElement(dataVirtualHardDiskElement, diskNameElement);
        }
        
        if (dataVirtualHardDisksItem.logicalUnitNumber !== null && dataVirtualHardDisksItem.logicalUnitNumber !== undefined) {
          var lunElement = js2xml.createElement('Lun', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(lunElement, dataVirtualHardDisksItem.logicalUnitNumber.toString());
          js2xml.addChildElement(dataVirtualHardDiskElement, lunElement);
        }
        
        if (dataVirtualHardDisksItem.logicalDiskSizeInGB !== null && dataVirtualHardDisksItem.logicalDiskSizeInGB !== undefined) {
          var logicalDiskSizeInGBElement = js2xml.createElement('LogicalDiskSizeInGB', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(logicalDiskSizeInGBElement, dataVirtualHardDisksItem.logicalDiskSizeInGB.toString());
          js2xml.addChildElement(dataVirtualHardDiskElement, logicalDiskSizeInGBElement);
        }
        
        if (dataVirtualHardDisksItem.mediaLink !== null && dataVirtualHardDisksItem.mediaLink !== undefined) {
          var mediaLinkElement = js2xml.createElement('MediaLink', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(mediaLinkElement, dataVirtualHardDisksItem.mediaLink);
          js2xml.addChildElement(dataVirtualHardDiskElement, mediaLinkElement);
        }
        
        if (dataVirtualHardDisksItem.sourceMediaLink !== null && dataVirtualHardDisksItem.sourceMediaLink !== undefined) {
          var sourceMediaLinkElement = js2xml.createElement('SourceMediaLink', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(sourceMediaLinkElement, dataVirtualHardDisksItem.sourceMediaLink);
          js2xml.addChildElement(dataVirtualHardDiskElement, sourceMediaLinkElement);
        }
        
        if (dataVirtualHardDisksItem.iOType !== null && dataVirtualHardDisksItem.iOType !== undefined) {
          var iOTypeElement = js2xml.createElement('IOType', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(iOTypeElement, dataVirtualHardDisksItem.iOType);
          js2xml.addChildElement(dataVirtualHardDiskElement, iOTypeElement);
        }
      }
      js2xml.addChildElement(persistentVMRoleElement, dataVirtualHardDisksSequenceElement);
    }
    
    var oSVirtualHardDiskElement = js2xml.createElement('OSVirtualHardDisk', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(persistentVMRoleElement, oSVirtualHardDiskElement);
    
    if (parameters.oSVirtualHardDisk.hostCaching !== null && parameters.oSVirtualHardDisk.hostCaching !== undefined) {
      var hostCachingElement2 = js2xml.createElement('HostCaching', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(hostCachingElement2, parameters.oSVirtualHardDisk.hostCaching);
      js2xml.addChildElement(oSVirtualHardDiskElement, hostCachingElement2);
    }
    
    if (parameters.oSVirtualHardDisk.label !== null && parameters.oSVirtualHardDisk.label !== undefined) {
      var diskLabelElement2 = js2xml.createElement('DiskLabel', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(diskLabelElement2, parameters.oSVirtualHardDisk.label);
      js2xml.addChildElement(oSVirtualHardDiskElement, diskLabelElement2);
    }
    
    if (parameters.oSVirtualHardDisk.name !== null && parameters.oSVirtualHardDisk.name !== undefined) {
      var diskNameElement2 = js2xml.createElement('DiskName', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(diskNameElement2, parameters.oSVirtualHardDisk.name);
      js2xml.addChildElement(oSVirtualHardDiskElement, diskNameElement2);
    }
    
    if (parameters.oSVirtualHardDisk.mediaLink !== null && parameters.oSVirtualHardDisk.mediaLink !== undefined) {
      var mediaLinkElement2 = js2xml.createElement('MediaLink', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(mediaLinkElement2, parameters.oSVirtualHardDisk.mediaLink);
      js2xml.addChildElement(oSVirtualHardDiskElement, mediaLinkElement2);
    }
    
    if (parameters.oSVirtualHardDisk.sourceImageName !== null && parameters.oSVirtualHardDisk.sourceImageName !== undefined) {
      var sourceImageNameElement = js2xml.createElement('SourceImageName', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(sourceImageNameElement, parameters.oSVirtualHardDisk.sourceImageName);
      js2xml.addChildElement(oSVirtualHardDiskElement, sourceImageNameElement);
    }
    
    if (parameters.oSVirtualHardDisk.operatingSystem !== null && parameters.oSVirtualHardDisk.operatingSystem !== undefined) {
      var osElement = js2xml.createElement('OS', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(osElement, parameters.oSVirtualHardDisk.operatingSystem);
      js2xml.addChildElement(oSVirtualHardDiskElement, osElement);
    }
    
    if (parameters.oSVirtualHardDisk.remoteSourceImageLink !== null && parameters.oSVirtualHardDisk.remoteSourceImageLink !== undefined) {
      var remoteSourceImageLinkElement = js2xml.createElement('RemoteSourceImageLink', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(remoteSourceImageLinkElement, parameters.oSVirtualHardDisk.remoteSourceImageLink);
      js2xml.addChildElement(oSVirtualHardDiskElement, remoteSourceImageLinkElement);
    }
    
    if (parameters.oSVirtualHardDisk.iOType !== null && parameters.oSVirtualHardDisk.iOType !== undefined) {
      var iOTypeElement2 = js2xml.createElement('IOType', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(iOTypeElement2, parameters.oSVirtualHardDisk.iOType);
      js2xml.addChildElement(oSVirtualHardDiskElement, iOTypeElement2);
    }
    
    if (parameters.oSVirtualHardDisk.resizedSizeInGB !== null && parameters.oSVirtualHardDisk.resizedSizeInGB !== undefined) {
      var resizedSizeInGBElement = js2xml.createElement('ResizedSizeInGB', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(resizedSizeInGBElement, parameters.oSVirtualHardDisk.resizedSizeInGB.toString());
      js2xml.addChildElement(oSVirtualHardDiskElement, resizedSizeInGBElement);
    }
    
    if (parameters.roleSize !== null && parameters.roleSize !== undefined) {
      var roleSizeElement = js2xml.createElement('RoleSize', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(roleSizeElement, parameters.roleSize);
      js2xml.addChildElement(persistentVMRoleElement, roleSizeElement);
    }
    
    if (parameters.provisionGuestAgent !== null && parameters.provisionGuestAgent !== undefined) {
      var provisionGuestAgentElement = js2xml.createElement('ProvisionGuestAgent', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(provisionGuestAgentElement, parameters.provisionGuestAgent.toString());
      js2xml.addChildElement(persistentVMRoleElement, provisionGuestAgentElement);
    }
    
    if (parameters.debugSettings !== null && parameters.debugSettings !== undefined) {
      var debugSettingsElement = js2xml.createElement('DebugSettings', 'http://schemas.microsoft.com/windowsazure');
      js2xml.addChildElement(persistentVMRoleElement, debugSettingsElement);
      
      var bootDiagnosticsEnabledElement = js2xml.createElement('BootDiagnosticsEnabled', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(bootDiagnosticsEnabledElement, parameters.debugSettings.bootDiagnosticsEnabled.toString());
      js2xml.addChildElement(debugSettingsElement, bootDiagnosticsEnabledElement);
      
      if (parameters.debugSettings.consoleScreenshotBlobUri !== null && parameters.debugSettings.consoleScreenshotBlobUri !== undefined) {
        var consoleScreenshotBlobUriElement = js2xml.createElement('ConsoleScreenshotBlobUri', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(consoleScreenshotBlobUriElement, parameters.debugSettings.consoleScreenshotBlobUri);
        js2xml.addChildElement(debugSettingsElement, consoleScreenshotBlobUriElement);
      }
      
      if (parameters.debugSettings.serialOutputBlobUri !== null && parameters.debugSettings.serialOutputBlobUri !== undefined) {
        var serialOutputBlobUriElement = js2xml.createElement('SerialOutputBlobUri', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(serialOutputBlobUriElement, parameters.debugSettings.serialOutputBlobUri);
        js2xml.addChildElement(debugSettingsElement, serialOutputBlobUriElement);
      }
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Updating Load Balanced Endpoint Set operation changes the
   * specified load-balanced InputEndpoints on all the roles of an
   * Infrastructure as a Service deployment. Non-load-balanced endpoints must
   * be changed using UpdateRole.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn469417.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {VirtualMachineUpdateLoadBalancedSetParameters} parameters
   * Parameters supplied to the Begin Updating Load Balanced Endpoint Set
   * operation.
   * 
   * @param {array} [parameters.loadBalancedEndpoints] A list of load balanced
   * InputEndpoints to update.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.beginUpdatingLoadBalancedEndpointSet = function(serviceName, deploymentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.loadBalancedEndpoints !== null && parameters.loadBalancedEndpoints !== undefined) {
      for (var loweredIndex1 = 0; loweredIndex1 < parameters.loadBalancedEndpoints.length; loweredIndex1 = loweredIndex1 + 1) {
        var loadBalancedEndpointsParameterItem = parameters.loadBalancedEndpoints[loweredIndex1];
        if (loadBalancedEndpointsParameterItem.loadBalancedEndpointSetName === null || loadBalancedEndpointsParameterItem.loadBalancedEndpointSetName === undefined) {
          return callback(new Error('parameters.loadBalancedEndpoints. cannot be null.'));
        }
      }
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    var queryParameters = [];
    queryParameters.push('comp=UpdateLbSet');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var loadBalancedEndpointListElement = js2xml.createElement('LoadBalancedEndpointList', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, loadBalancedEndpointListElement);
    
    if (parameters.loadBalancedEndpoints !== null && parameters.loadBalancedEndpoints !== undefined) {
      for (var loweredIndex2 = 0; loweredIndex2 < parameters.loadBalancedEndpoints.length; loweredIndex2 = loweredIndex2 + 1) {
        var loadBalancedEndpointsItem = parameters.loadBalancedEndpoints[loweredIndex2];
        var inputEndpointElement = js2xml.createElement('InputEndpoint', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(loadBalancedEndpointListElement, inputEndpointElement);
        
        var loadBalancedEndpointSetNameElement = js2xml.createElement('LoadBalancedEndpointSetName', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(loadBalancedEndpointSetNameElement, loadBalancedEndpointsItem.loadBalancedEndpointSetName);
        js2xml.addChildElement(inputEndpointElement, loadBalancedEndpointSetNameElement);
        
        if (loadBalancedEndpointsItem.localPort !== null && loadBalancedEndpointsItem.localPort !== undefined) {
          var localPortElement = js2xml.createElement('LocalPort', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(localPortElement, loadBalancedEndpointsItem.localPort.toString());
          js2xml.addChildElement(inputEndpointElement, localPortElement);
        }
        
        if (loadBalancedEndpointsItem.name !== null && loadBalancedEndpointsItem.name !== undefined) {
          var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(nameElement, loadBalancedEndpointsItem.name);
          js2xml.addChildElement(inputEndpointElement, nameElement);
        }
        
        if (loadBalancedEndpointsItem.port !== null && loadBalancedEndpointsItem.port !== undefined) {
          var portElement = js2xml.createElement('Port', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(portElement, loadBalancedEndpointsItem.port.toString());
          js2xml.addChildElement(inputEndpointElement, portElement);
        }
        
        if (loadBalancedEndpointsItem.loadBalancerProbe !== null && loadBalancedEndpointsItem.loadBalancerProbe !== undefined) {
          var loadBalancerProbeElement = js2xml.createElement('LoadBalancerProbe', 'http://schemas.microsoft.com/windowsazure');
          js2xml.addChildElement(inputEndpointElement, loadBalancerProbeElement);
          
          if (loadBalancedEndpointsItem.loadBalancerProbe.path !== null && loadBalancedEndpointsItem.loadBalancerProbe.path !== undefined) {
            var pathElement = js2xml.createElement('Path', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(pathElement, loadBalancedEndpointsItem.loadBalancerProbe.path);
            js2xml.addChildElement(loadBalancerProbeElement, pathElement);
          }
          
          if (loadBalancedEndpointsItem.loadBalancerProbe.port !== null && loadBalancedEndpointsItem.loadBalancerProbe.port !== undefined) {
            var portElement2 = js2xml.createElement('Port', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(portElement2, loadBalancedEndpointsItem.loadBalancerProbe.port.toString());
            js2xml.addChildElement(loadBalancerProbeElement, portElement2);
          }
          
          if (loadBalancedEndpointsItem.loadBalancerProbe.protocol !== null && loadBalancedEndpointsItem.loadBalancerProbe.protocol !== undefined) {
            var protocolElement = js2xml.createElement('Protocol', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(protocolElement, loadBalancedEndpointsItem.loadBalancerProbe.protocol !== null && loadBalancedEndpointsItem.loadBalancerProbe.protocol !== undefined ? loadBalancedEndpointsItem.loadBalancerProbe.protocol.toString() : 'Tcp');
            js2xml.addChildElement(loadBalancerProbeElement, protocolElement);
          }
          
          if (loadBalancedEndpointsItem.loadBalancerProbe.intervalInSeconds !== null && loadBalancedEndpointsItem.loadBalancerProbe.intervalInSeconds !== undefined) {
            var intervalInSecondsElement = js2xml.createElement('IntervalInSeconds', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(intervalInSecondsElement, loadBalancedEndpointsItem.loadBalancerProbe.intervalInSeconds.toString());
            js2xml.addChildElement(loadBalancerProbeElement, intervalInSecondsElement);
          }
          
          if (loadBalancedEndpointsItem.loadBalancerProbe.timeoutInSeconds !== null && loadBalancedEndpointsItem.loadBalancerProbe.timeoutInSeconds !== undefined) {
            var timeoutInSecondsElement = js2xml.createElement('TimeoutInSeconds', 'http://schemas.microsoft.com/windowsazure');
            js2xml.setElementValue(timeoutInSecondsElement, loadBalancedEndpointsItem.loadBalancerProbe.timeoutInSeconds.toString());
            js2xml.addChildElement(loadBalancerProbeElement, timeoutInSecondsElement);
          }
        }
        
        if (loadBalancedEndpointsItem.protocol !== null && loadBalancedEndpointsItem.protocol !== undefined) {
          var protocolElement2 = js2xml.createElement('Protocol', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(protocolElement2, loadBalancedEndpointsItem.protocol);
          js2xml.addChildElement(inputEndpointElement, protocolElement2);
        }
        
        if (loadBalancedEndpointsItem.virtualIPAddress !== null && loadBalancedEndpointsItem.virtualIPAddress !== undefined) {
          var vipElement = js2xml.createElement('Vip', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(vipElement, loadBalancedEndpointsItem.virtualIPAddress);
          js2xml.addChildElement(inputEndpointElement, vipElement);
        }
        
        if (loadBalancedEndpointsItem.enableDirectServerReturn !== null && loadBalancedEndpointsItem.enableDirectServerReturn !== undefined) {
          var enableDirectServerReturnElement = js2xml.createElement('EnableDirectServerReturn', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(enableDirectServerReturnElement, loadBalancedEndpointsItem.enableDirectServerReturn.toString());
          js2xml.addChildElement(inputEndpointElement, enableDirectServerReturnElement);
        }
        
        var endpointAclElement = js2xml.createElement('EndpointAcl', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(inputEndpointElement, endpointAclElement);
        
        if (loadBalancedEndpointsItem.rules !== null && loadBalancedEndpointsItem.rules !== undefined) {
          var rulesSequenceElement = js2xml.createElement('Rules', 'http://schemas.microsoft.com/windowsazure');
          for (var loweredIndex3 = 0; loweredIndex3 < loadBalancedEndpointsItem.rules.length; loweredIndex3 = loweredIndex3 + 1) {
            var rulesItem = loadBalancedEndpointsItem.rules[loweredIndex3];
            var ruleElement = js2xml.createElement('Rule', 'http://schemas.microsoft.com/windowsazure');
            js2xml.addChildElement(rulesSequenceElement, ruleElement);
            
            if (rulesItem.order !== null && rulesItem.order !== undefined) {
              var orderElement = js2xml.createElement('Order', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(orderElement, rulesItem.order.toString());
              js2xml.addChildElement(ruleElement, orderElement);
            }
            
            if (rulesItem.action !== null && rulesItem.action !== undefined) {
              var actionElement = js2xml.createElement('Action', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(actionElement, rulesItem.action);
              js2xml.addChildElement(ruleElement, actionElement);
            }
            
            if (rulesItem.remoteSubnet !== null && rulesItem.remoteSubnet !== undefined) {
              var remoteSubnetElement = js2xml.createElement('RemoteSubnet', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(remoteSubnetElement, rulesItem.remoteSubnet);
              js2xml.addChildElement(ruleElement, remoteSubnetElement);
            }
            
            if (rulesItem.description !== null && rulesItem.description !== undefined) {
              var descriptionElement = js2xml.createElement('Description', 'http://schemas.microsoft.com/windowsazure');
              js2xml.setElementValue(descriptionElement, rulesItem.description);
              js2xml.addChildElement(ruleElement, descriptionElement);
            }
          }
          js2xml.addChildElement(endpointAclElement, rulesSequenceElement);
        }
        
        if (loadBalancedEndpointsItem.loadBalancerName !== null && loadBalancedEndpointsItem.loadBalancerName !== undefined) {
          var loadBalancerNameElement = js2xml.createElement('LoadBalancerName', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(loadBalancerNameElement, loadBalancedEndpointsItem.loadBalancerName);
          js2xml.addChildElement(inputEndpointElement, loadBalancerNameElement);
        }
        
        if (loadBalancedEndpointsItem.idleTimeoutInMinutes !== null && loadBalancedEndpointsItem.idleTimeoutInMinutes !== undefined) {
          var idleTimeoutInMinutesElement = js2xml.createElement('IdleTimeoutInMinutes', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(idleTimeoutInMinutesElement, loadBalancedEndpointsItem.idleTimeoutInMinutes.toString());
          js2xml.addChildElement(inputEndpointElement, idleTimeoutInMinutesElement);
        }
        
        if (loadBalancedEndpointsItem.loadBalancerDistribution !== null && loadBalancedEndpointsItem.loadBalancerDistribution !== undefined) {
          var loadBalancerDistributionElement = js2xml.createElement('LoadBalancerDistribution', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(loadBalancerDistributionElement, loadBalancedEndpointsItem.loadBalancerDistribution);
          js2xml.addChildElement(inputEndpointElement, loadBalancerDistributionElement);
        }
        
        if (loadBalancedEndpointsItem.virtualIPName !== null && loadBalancedEndpointsItem.virtualIPName !== undefined) {
          var virtualIPNameElement = js2xml.createElement('VirtualIPName', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(virtualIPNameElement, loadBalancedEndpointsItem.virtualIPName);
          js2xml.addChildElement(inputEndpointElement, virtualIPNameElement);
        }
      }
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Capture Role operation creates a copy of the operating system virtual
   * hard disk (VHD) that is deployed in the virtual machine, saves the VHD
   * copy in the same storage location as the operating system VHD, and
   * registers the copy as an image in your image gallery. From the captured
   * image, you can create additional customized virtual machines. For more
   * information about images and disks, see Manage Disks and Images at
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj672979.aspx. For
   * more information about capturing images, see How to Capture an Image of a
   * Virtual Machine Running Windows Server 2008 R2 at
   * http://www.windowsazure.com/en-us/documentation/articles/virtual-machines-capture-image-windows-server/
   * or How to Capture an Image of a Virtual Machine Running Linux at
   * http://www.windowsazure.com/en-us/documentation/articles/virtual-machines-linux-capture-image/.
   * (see http://msdn.microsoft.com/en-us/library/windowsazure/jj157201.aspx
   * for more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {string} virtualMachineName The name of the virtual machine to
   * restart.
   * 
   * @param {VirtualMachineCaptureOSImageParameters} parameters Parameters
   * supplied to the Capture Virtual Machine operation.
   * 
   * @param {PostCaptureAction} parameters.postCaptureAction Specifies the
   * action that is performed after the capture operation finishes. Possible
   * values are: Delete - this value causes the virtual machine to be deleted
   * after the image has been captured; or Reprovision - this value causes the
   * virtual machine to be redeployed after the image is captured by using the
   * specified information in ProvisioningConfiguration.
   * 
   * @param {ConfigurationSet} [parameters.provisioningConfiguration] Provides
   * information to be used to redeploy the virtual machine after the image
   * has been captured. This element is only used when the PostCaptureAction
   * is set to Reprovision.
   * 
   * @param {string}
   * [parameters.provisioningConfiguration.configurationSetType] Specifies the
   * configuration type for the configuration set.
   * 
   * @param {array} [parameters.provisioningConfiguration.inputEndpoints]
   * Contains a collection of external endpoints for the virtual machine. This
   * element is only used with the NetworkConfigurationSet type.
   * 
   * @param {array} [parameters.provisioningConfiguration.subnetNames] The list
   * of Virtual Network subnet names that the deployment belongs to. This
   * element is only used with the NetworkConfigurationSet type.
   * 
   * @param {string}
   * [parameters.provisioningConfiguration.staticVirtualNetworkIPAddress]
   * Specifies a Customer Address, i.e. an IP address assigned to a VM in a
   * VNet's SubNet. For example: 10.0.0.4.
   * 
   * @param {array} [parameters.provisioningConfiguration.publicIPs] Optional.
   * A set of public IPs. Currently, only one additional public IP per role is
   * supported in an IaaS deployment. The IP address is in addition to the
   * default VIP for the deployment.
   * 
   * @param {array} [parameters.provisioningConfiguration.networkInterfaces]
   * 
   * @param {string}
   * [parameters.provisioningConfiguration.networkSecurityGroup] Gets or sets
   * the Network Security Group associated with this role. Optional
   * 
   * @param {string} [parameters.provisioningConfiguration.iPForwarding] Gets
   * or sets the IP Forwarding status for this role. Optional
   * 
   * @param {string} [parameters.provisioningConfiguration.computerName]
   * Specifies the computer name for the virtual machine. If the computer name
   * is not specified, a name is created based on the name of the role.
   * Computer names must be 1 to 15 characters in length. This element is only
   * used with the WindowsProvisioningConfiguration set.
   * 
   * @param {string} [parameters.provisioningConfiguration.adminPassword]
   * Specifies the string representing the administrator password to use for
   * the virtual machine. If the VM will be created from a 'Specialized' VM
   * image, the password is not required.
   * 
   * @param {boolean}
   * [parameters.provisioningConfiguration.resetPasswordOnFirstLogon]
   * Specifies whether password should be reset the first time the
   * administrator logs in.
   * 
   * @param {boolean}
   * [parameters.provisioningConfiguration.enableAutomaticUpdates] Specifies
   * whether automatic updates are enabled for the virtual machine. This
   * element is only used with the WindowsProvisioningConfiguration set. The
   * default value is false.
   * 
   * @param {string} [parameters.provisioningConfiguration.timeZone] Specifies
   * the time zone for the virtual machine. This element is only used with the
   * WindowsProvisioningConfiguration set. For a complete list of supported
   * time zone entries, you can refer to the values listed in the registry
   * entry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
   * NT\CurrentVersion\Time Zones on a computer running Windows 7, Windows
   * Server 2008, and Windows Server 2008 R2 or you can use the tzutil
   * command-line tool to list the valid time. The tzutil tool is installed by
   * default on Windows 7, Windows Server 2008, and Windows Server 2008 R2.
   * 
   * @param {DomainJoinSettings}
   * [parameters.provisioningConfiguration.domainJoin] Contains properties
   * that specify a domain to which the virtual machine will be joined. This
   * element is only used with the WindowsProvisioningConfiguration set.
   * 
   * @param {DomainJoinCredentials}
   * [parameters.provisioningConfiguration.domainJoin.credentials] Specifies
   * the values to use to join the virtual machine to the domain.
   * 
   * @param {string}
   * [parameters.provisioningConfiguration.domainJoin.credentials.domain]
   * Specifies the name of the domain used to authenticate an account. The
   * value is a fully qualified DNS domain. If the domains name is not
   * specified, Username must specify the user principal name (UPN) format
   * (user@fully-qualified-DNS-domain) or the
   * fully-qualified-DNS-domain\username format. Example: example.com.
   * 
   * @param {string}
   * [parameters.provisioningConfiguration.domainJoin.credentials.userName]
   * Specifies a user name in the domain that can be used to join the domain.
   * 
   * @param {string}
   * [parameters.provisioningConfiguration.domainJoin.credentials.password]
   * Specifies the password to use to join the domain.
   * 
   * @param {string}
   * [parameters.provisioningConfiguration.domainJoin.domainToJoin] Specifies
   * the domain to join.
   * 
   * @param {string}
   * [parameters.provisioningConfiguration.domainJoin.ldapMachineObjectOU]
   * Specifies the Lightweight Directory Access Protocol (LDAP) X
   * 500-distinguished name of the organizational unit (OU) in which the
   * computer account is created. This account is in Active Directory on a
   * domain controller in the domain to which the computer is being joined.
   * Example: OU=MyOu,OU=MyParentOu,DC=example.com,DC=MyCompany,DC=com.
   * 
   * @param {DomainJoinProvisioning}
   * [parameters.provisioningConfiguration.domainJoin.provisioning] Additional
   * information for domain join provisioning.
   * 
   * @param {string}
   * [parameters.provisioningConfiguration.domainJoin.provisioning.accountData]
   * The account info for joining the domain.
   * 
   * @param {array}
   * [parameters.provisioningConfiguration.storedCertificateSettings] Contains
   * a list of service certificates with which to provision to the new role.
   * This element is only used with the WindowsProvisioningConfiguration set.
   * 
   * @param {WindowsRemoteManagementSettings}
   * [parameters.provisioningConfiguration.windowsRemoteManagement] Configures
   * the Windows Remote Management service on the virtual machine, which
   * enables remote Windows PowerShell.
   * 
   * @param {array}
   * [parameters.provisioningConfiguration.windowsRemoteManagement.listeners]
   * Contains a collection of information for enabling remote Windows
   * PowerShell.
   * 
   * @param {string} [parameters.provisioningConfiguration.adminUserName]
   * Specifies the name that is used to rename the default administrator
   * account. If the VM will be created from a 'Specialized' VM image, the
   * user name is not required.
   * 
   * @param {AdditionalUnattendContentSettings}
   * [parameters.provisioningConfiguration.additionalUnattendContent]
   * Specifies additional base-64 encoded XML formatted information that can
   * be included in the Unattend.xml file, which is used by Windows Setup.
   * 
   * @param {array}
   * [parameters.provisioningConfiguration.additionalUnattendContent.unattendPasses]
   * Specifies the unattend passes
   * 
   * @param {string} [parameters.provisioningConfiguration.hostName] Specifies
   * the host name for the VM. Host names are ASCII character strings 1 to 64
   * characters in length. This element is only used with the
   * LinuxProvisioningConfiguration set.
   * 
   * @param {string} [parameters.provisioningConfiguration.userName] Specifies
   * the name of a user to be created in the sudoer group of the virtual
   * machine. User names are ASCII character strings 1 to 32 characters in
   * length. This element is only used with the LinuxProvisioningConfiguration
   * set.
   * 
   * @param {string} [parameters.provisioningConfiguration.userPassword]
   * Specifies the password for user name. Passwords are ASCII character
   * strings 6 to 72 characters in length. This element is only used with the
   * LinuxProvisioningConfiguration set.
   * 
   * @param {boolean}
   * [parameters.provisioningConfiguration.disableSshPasswordAuthentication]
   * Specifies whether or not SSH authentication is disabled for the password.
   * This element is only used with the LinuxProvisioningConfiguration set. By
   * default this value is set to true.
   * 
   * @param {SshSettings} [parameters.provisioningConfiguration.sshSettings]
   * Specifies the SSH public keys and key pairs to populate in the image
   * during provisioning. This element is only used with the
   * LinuxProvisioningConfiguration set.
   * 
   * @param {array}
   * [parameters.provisioningConfiguration.sshSettings.publicKeys] Specifies
   * the collection of SSH public keys.
   * 
   * @param {array} [parameters.provisioningConfiguration.sshSettings.keyPairs]
   * Specifies the collection of SSH key pairs.
   * 
   * @param {string} [parameters.provisioningConfiguration.customData]
   * Optional. Provides base64 encoded custom data to be passed to VM.
   * 
   * @param {string} parameters.targetImageLabel Specifies the friendly name of
   * the captured image. This is the value that appears in the Name column for
   * the image in the Azure Management Portal.
   * 
   * @param {string} parameters.targetImageName Specifies the image name of the
   * captured image.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.captureOSImage = function(serviceName, deploymentName, virtualMachineName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachines.beginCapturingOSImage(serviceName, deploymentName, virtualMachineName, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * Capture role as VM template.
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {string} virtualMachineName The name of the virtual machine to
   * restart.
   * 
   * @param {VirtualMachineCaptureVMImageParameters} parameters Parameters
   * supplied to the Capture Virtual Machine operation.
   * 
   * @param {string} [parameters.operationType] Required. Must be set to
   * CaptureRoleOperation.
   * 
   * @param {string} [parameters.oSState] Required. The OS state: Generalized |
   * Specialized.
   * 
   * @param {string} [parameters.vMImageName] Required. The VM Template Name.
   * 
   * @param {string} [parameters.vMImageLabel] Required. The VM Template Label.
   * 
   * @param {HttpStatusCode} [parameters.statusCode]
   * 
   * @param {string} [parameters.requestId]
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.captureVMImage = function(serviceName, deploymentName, virtualMachineName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachines.beginCapturingVMImage(serviceName, deploymentName, virtualMachineName, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Create Role operation adds a virtual machine to an existing
   * deployment. You can refer to the OSDisk in the Add Role operation in the
   * following ways: Platform/User Image - Set the SourceImageName to a
   * platform or user image. You can optionally specify the DiskName and
   * MediaLink values as part the operation to control the name and location
   * of target disk. When DiskName and MediaLink are specified in this mode,
   * they must not already exist in the system, otherwise a conflict fault is
   * returned; UserDisk - Set DiskName to a user supplied image in image
   * repository. SourceImageName must be set to NULL. All other properties are
   * ignored; or Blob in a Storage Account - Set MediaLink to a blob
   * containing the image. SourceImageName and DiskName are set to NULL.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157186.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {VirtualMachineCreateParameters} parameters Parameters supplied to
   * the Create Virtual Machine operation.
   * 
   * @param {string} parameters.roleName Specifies the name for the virtual
   * machine. The name must be unique within the deployment.
   * 
   * @param {string} [parameters.availabilitySetName] Specifies the name of an
   * availability set to which to add the virtual machine. This value controls
   * the virtual machine allocation in the Azure environment. Virtual machines
   * specified in the same availability set are allocated to different nodes
   * to maximize availability.
   * 
   * @param {string} [parameters.roleSize] The size of the virtual machine.
   * 
   * @param {array} [parameters.configurationSets] Contains the collection of
   * configuration sets that contain system and application configuration
   * settings.
   * 
   * @param {array} [parameters.resourceExtensionReferences] Contains a
   * collection of resource extensions that are to be installed on the Virtual
   * Machine. This element is used if ProvisionGuestAgent is set to true.
   * 
   * @param {string} [parameters.vMImageName] Name of the VMImage from which
   * this Role is to be created. If the OSDisk in the VMImage was Specialized,
   * then no WindowsProvisioningConfigurationSet or
   * LinuxProvisioningConfigurationSet should be provided. No
   * OSVirtualHardDisk or DataVirtualHardDisk should be specified when using
   * this argument.
   * 
   * @param {array} [parameters.dataVirtualHardDisks] Contains the parameters
   * Azure used to create the data disk for the virtual machine.
   * 
   * @param {OSVirtualHardDisk} [parameters.oSVirtualHardDisk] Contains the
   * parameters Azure used to create the operating system disk for the virtual
   * machine.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.hostCaching] Specifies the
   * platform caching behavior of the operating system disk blob for
   * read/write efficiency.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.label] Specifies the
   * friendly name of an operating system image in the image repository.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.name] Specifies the name of
   * an operating system image in the image repository.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.mediaLink] Specifies the
   * location of the operating system disk in Azure storage.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.sourceImageName] Specifies
   * the name of the source image that was used to provision the virtual
   * machine.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.operatingSystem] The
   * operating system running in the virtual machine.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.remoteSourceImageLink] Uri
   * of the source OS image that will be copied to the customer’s storage
   * account of VM creation.If RemoteSourceImageLink is specified, then
   * MediaLink must also be specified.If RemoteSourceImageLink is specified,
   * thenSourceIamgeName must not be specified.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.iOType] Gets or sets the IO
   * type.
   * 
   * @param {number} [parameters.oSVirtualHardDisk.resizedSizeInGB] When an OS
   * Image or a RemoteSourceImage is used to create an OSVirtualHardDisk, this
   * parameter can be used to resize the new OSVirtualHardDisk to a larger
   * size. ResizedSizeInGB must be larger than the underlying OS Image’s
   * LogicalSizeInGB.
   * 
   * @param {boolean} [parameters.provisionGuestAgent] Indicates whether the
   * WindowsAzureGuestAgent service is installed on the Virtual Machine. To
   * run a resource extension in a Virtual Machine, this service must be
   * installed.
   * 
   * @param {string} [parameters.mediaLocation] Location where VMImage VHDs
   * should be copied, for published VMImages.
   * 
   * @param {VMImageInput} [parameters.vMImageInput] When a VM Image is used to
   * create a new PersistantVMRole, the DiskConfigurations in the VM Image are
   * used to create new Disks for the new VM. This parameter can be used to
   * resize the newly created Disks to a larger size than the underlying
   * DiskConfigurations in the VM Image.This property is only returned with a
   * version header of 2014-10-01 or newer.
   * 
   * @param {OSDiskConfiguration} [parameters.vMImageInput.oSDiskConfiguration]
   * This corresponds to the OSDiskConfiguration of the VM Image used to
   * create a new role. The OSDiskConfiguration element is only available
   * using version 2014-10-01 or higher.
   * 
   * @param {number}
   * [parameters.vMImageInput.oSDiskConfiguration.resizedSizeInGB] This
   * specifies the new (larger) size of the OSVirtualHardDisk created using a
   * VM Image. The ResizedSizeInGB element is only available using version
   * 2014-10-01 or higher.
   * 
   * @param {IEnumerable} [parameters.vMImageInput.dataDiskConfigurations] This
   * corresponds to the DataDiskConfigurations of the VM Image used to create
   * a new role. The DataDiskConfigurations element is only available using
   * version 2014-10-01 or higher.
   * 
   * @param {DebugSettings} [parameters.debugSettings] Debug settings for
   * console output.
   * 
   * @param {boolean} [parameters.debugSettings.bootDiagnosticsEnabled] Enable
   * or disable boot diagnostics.
   * 
   * @param {string} [parameters.debugSettings.consoleScreenshotBlobUri] Blob
   * uri for console screen shot.
   * 
   * @param {string} [parameters.debugSettings.serialOutputBlobUri] Blob uri
   * for serial output.
   * 
   * @param {string} [parameters.licenseType] Specifies that the image or disk
   * that is being used was licensed on-premises. This element is only used
   * for images that contain the Windows Server operating system. Possible
   * values are: Windows_Client, Windows_Server
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.create = function(serviceName, deploymentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachines.beginCreating(serviceName, deploymentName, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Create Virtual Machine Deployment operation provisions a virtual
   * machine based on the supplied configuration. When you create a deployment
   * of a virtual machine, you should make sure that the cloud service and the
   * disk or image that you use are located in the same region. For example,
   * if the cloud service was created in the West US region, the disk or image
   * that you use should also be located in a storage account in the West US
   * region.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157194.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {VirtualMachineCreateDeploymentParameters} parameters Parameters
   * supplied to the Create Virtual Machine Deployment operation.
   * 
   * @param {string} parameters.name A name for the deployment. The deployment
   * name must be unique among other deployments for the hosted service.
   * 
   * @param {DeploymentSlot} parameters.deploymentSlot Specifies the
   * environment in which to deploy the virtual machine. Possible values are:
   * Staging or Production.
   * 
   * @param {string} parameters.label A name for the hosted service. The name
   * can be up to 100 characters in length. It is recommended that the label
   * be unique within the subscription. The name can be used identify the
   * hosted service for tracking purposes.
   * 
   * @param {array} parameters.roles Contains the provisioning details for the
   * new virtual machine deployment.
   * 
   * @param {string} [parameters.virtualNetworkName] Specifies the name of an
   * existing virtual network to which the deployment will belong. Virtual
   * networks are created by calling the Set Network Configuration operation.
   * 
   * @param {DnsSettings} [parameters.dnsSettings] Contains a list of DNS
   * servers to associate with the machine.
   * 
   * @param {array} [parameters.dnsSettings.dnsServers] Contains a collection
   * of objects that define the DNS server settings.
   * 
   * @param {string} [parameters.reservedIPName] Optional. Specifies the name
   * of an existing reserved IP to which the deployment will belong. Reserved
   * IPs are created by calling the Create Reserved IP operation.
   * 
   * @param {IEnumerable} [parameters.loadBalancers] A list of internal load
   * balancers that each provide load balancing on a private VIP.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.createDeployment = function(serviceName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachines.beginCreatingDeployment(serviceName, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Delete Role operation deletes the specified virtual machine.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157184.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {string} virtualMachineName The name of the virtual machine to
   * delete.
   * 
   * @param {boolean} [deleteFromStorage] Specifies that the source blob(s) for
   * the virtual machine should also be deleted from storage.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.deleteMethod = function(serviceName, deploymentName, virtualMachineName, deleteFromStorage, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachines.beginDeleting(serviceName, deploymentName, virtualMachineName, deleteFromStorage, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Get Role operation retrieves information about the specified virtual
   * machine.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157193.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {string} virtualMachineName The name of the virtual machine.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.get = function(serviceName, deploymentName, virtualMachineName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (virtualMachineName === null || virtualMachineName === undefined) {
      return callback(new Error('virtualMachineName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/roles/';
    url2 = url2 + encodeURIComponent(virtualMachineName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { configurationSets: [], dataVirtualHardDisks: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var persistentVMRoleElement = js2xml.getElement(responseDoc, responseDoc, 'PERSISTENTVMROLE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (persistentVMRoleElement !== null && persistentVMRoleElement !== undefined) {
            var roleNameElement = js2xml.getElement(responseDoc, persistentVMRoleElement, 'ROLENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (roleNameElement !== null && roleNameElement !== undefined) {
              var roleNameInstance = roleNameElement;
              result.roleName = roleNameInstance;
            }
            
            var osVersionElement = js2xml.getElement(responseDoc, persistentVMRoleElement, 'OSVERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (osVersionElement !== null && osVersionElement !== undefined) {
              var osVersionInstance = osVersionElement;
              result.osVersion = osVersionInstance;
            }
            
            var roleTypeElement = js2xml.getElement(responseDoc, persistentVMRoleElement, 'ROLETYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (roleTypeElement !== null && roleTypeElement !== undefined && roleTypeElement.length !== 0) {
              var roleTypeInstance = roleTypeElement;
              result.roleType = roleTypeInstance;
            }
            
            var availabilitySetNameElement = js2xml.getElement(responseDoc, persistentVMRoleElement, 'AVAILABILITYSETNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (availabilitySetNameElement !== null && availabilitySetNameElement !== undefined) {
              var availabilitySetNameInstance = availabilitySetNameElement;
              result.availabilitySetName = availabilitySetNameInstance;
            }
            
            var roleSizeElement = js2xml.getElement(responseDoc, persistentVMRoleElement, 'ROLESIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (roleSizeElement !== null && roleSizeElement !== undefined) {
              var roleSizeInstance = roleSizeElement;
              result.roleSize = roleSizeInstance;
            }
            
            var defaultWinRmCertificateThumbprintElement = js2xml.getElement(responseDoc, persistentVMRoleElement, 'DEFAULTWINRMCERTIFICATETHUMBPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (defaultWinRmCertificateThumbprintElement !== null && defaultWinRmCertificateThumbprintElement !== undefined) {
              var defaultWinRmCertificateThumbprintInstance = defaultWinRmCertificateThumbprintElement;
              result.defaultWinRmCertificateThumbprint = defaultWinRmCertificateThumbprintInstance;
            }
            
            var configurationSetsSequenceElement = js2xml.getElement(responseDoc, persistentVMRoleElement, 'CONFIGURATIONSETS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (configurationSetsSequenceElement !== null && configurationSetsSequenceElement !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, configurationSetsSequenceElement, 'CONFIGURATIONSET', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
                var configurationSetsElement = js2xml.getElements(responseDoc, configurationSetsSequenceElement, 'CONFIGURATIONSET', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
                var configurationSetInstance = { inputEndpoints: [], networkInterfaces: [], publicIPs: [], storedCertificateSettings: [], subnetNames: [] };
                result.configurationSets.push(configurationSetInstance);
                
                var configurationSetTypeElement = js2xml.getElement(responseDoc, configurationSetsElement, 'CONFIGURATIONSETTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (configurationSetTypeElement !== null && configurationSetTypeElement !== undefined) {
                  var configurationSetTypeInstance = configurationSetTypeElement;
                  configurationSetInstance.configurationSetType = configurationSetTypeInstance;
                }
                
                var inputEndpointsSequenceElement = js2xml.getElement(responseDoc, configurationSetsElement, 'INPUTENDPOINTS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (inputEndpointsSequenceElement !== null && inputEndpointsSequenceElement !== undefined) {
                  for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, inputEndpointsSequenceElement, 'INPUTENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex2 = loweredIndex2 + 1) {
                    var inputEndpointsElement = js2xml.getElements(responseDoc, inputEndpointsSequenceElement, 'INPUTENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex2];
                    var inputEndpointInstance = {};
                    configurationSetInstance.inputEndpoints.push(inputEndpointInstance);
                    
                    var loadBalancedEndpointSetNameElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'LOADBALANCEDENDPOINTSETNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (loadBalancedEndpointSetNameElement !== null && loadBalancedEndpointSetNameElement !== undefined) {
                      var loadBalancedEndpointSetNameInstance = loadBalancedEndpointSetNameElement;
                      inputEndpointInstance.loadBalancedEndpointSetName = loadBalancedEndpointSetNameInstance;
                    }
                    
                    var localPortElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'LOCALPORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (localPortElement !== null && localPortElement !== undefined && localPortElement.length !== 0) {
                      var localPortInstance = parseInt(localPortElement, 10);
                      inputEndpointInstance.localPort = localPortInstance;
                    }
                    
                    var nameElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (nameElement !== null && nameElement !== undefined) {
                      var nameInstance = nameElement;
                      inputEndpointInstance.name = nameInstance;
                    }
                    
                    var portElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'PORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (portElement !== null && portElement !== undefined && portElement.length !== 0) {
                      var portInstance = parseInt(portElement, 10);
                      inputEndpointInstance.port = portInstance;
                    }
                    
                    var loadBalancerProbeElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'LOADBALANCERPROBE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (loadBalancerProbeElement !== null && loadBalancerProbeElement !== undefined) {
                      var loadBalancerProbeInstance = {};
                      inputEndpointInstance.loadBalancerProbe = loadBalancerProbeInstance;
                      
                      var pathElement = js2xml.getElement(responseDoc, loadBalancerProbeElement, 'PATH', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (pathElement !== null && pathElement !== undefined) {
                        var pathInstance = pathElement;
                        loadBalancerProbeInstance.path = pathInstance;
                      }
                      
                      var portElement2 = js2xml.getElement(responseDoc, loadBalancerProbeElement, 'PORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (portElement2 !== null && portElement2 !== undefined && portElement2.length !== 0) {
                        var portInstance2 = parseInt(portElement2, 10);
                        loadBalancerProbeInstance.port = portInstance2;
                      }
                      
                      var protocolElement = js2xml.getElement(responseDoc, loadBalancerProbeElement, 'PROTOCOL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (protocolElement !== null && protocolElement !== undefined && protocolElement.length !== 0) {
                        var protocolInstance = protocolElement;
                        loadBalancerProbeInstance.protocol = protocolInstance;
                      }
                      
                      var intervalInSecondsElement = js2xml.getElement(responseDoc, loadBalancerProbeElement, 'INTERVALINSECONDS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (intervalInSecondsElement !== null && intervalInSecondsElement !== undefined && intervalInSecondsElement.length !== 0) {
                        var intervalInSecondsInstance = parseInt(intervalInSecondsElement, 10);
                        loadBalancerProbeInstance.intervalInSeconds = intervalInSecondsInstance;
                      }
                      
                      var timeoutInSecondsElement = js2xml.getElement(responseDoc, loadBalancerProbeElement, 'TIMEOUTINSECONDS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (timeoutInSecondsElement !== null && timeoutInSecondsElement !== undefined && timeoutInSecondsElement.length !== 0) {
                        var timeoutInSecondsInstance = parseInt(timeoutInSecondsElement, 10);
                        loadBalancerProbeInstance.timeoutInSeconds = timeoutInSecondsInstance;
                      }
                    }
                    
                    var protocolElement2 = js2xml.getElement(responseDoc, inputEndpointsElement, 'PROTOCOL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (protocolElement2 !== null && protocolElement2 !== undefined) {
                      var protocolInstance2 = protocolElement2;
                      inputEndpointInstance.protocol = protocolInstance2;
                    }
                    
                    var vipElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'VIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (vipElement !== null && vipElement !== undefined) {
                      var vipInstance = vipElement;
                      inputEndpointInstance.virtualIPAddress = vipInstance;
                    }
                    
                    var enableDirectServerReturnElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'ENABLEDIRECTSERVERRETURN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (enableDirectServerReturnElement !== null && enableDirectServerReturnElement !== undefined && enableDirectServerReturnElement.length !== 0) {
                      var enableDirectServerReturnInstance = enableDirectServerReturnElement === 'true';
                      inputEndpointInstance.enableDirectServerReturn = enableDirectServerReturnInstance;
                    }
                    
                    var loadBalancerNameElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'LOADBALANCERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (loadBalancerNameElement !== null && loadBalancerNameElement !== undefined) {
                      var loadBalancerNameInstance = loadBalancerNameElement;
                      inputEndpointInstance.loadBalancerName = loadBalancerNameInstance;
                    }
                    
                    var endpointAclElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'ENDPOINTACL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (endpointAclElement !== null && endpointAclElement !== undefined) {
                      var endpointAclInstance = { rules: [] };
                      inputEndpointInstance.endpointAcl = endpointAclInstance;
                      
                      var rulesSequenceElement = js2xml.getElement(responseDoc, endpointAclElement, 'RULES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (rulesSequenceElement !== null && rulesSequenceElement !== undefined) {
                        for (var loweredIndex3 = 0; loweredIndex3 < js2xml.getElements(responseDoc, rulesSequenceElement, 'RULE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex3 = loweredIndex3 + 1) {
                          var rulesElement = js2xml.getElements(responseDoc, rulesSequenceElement, 'RULE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex3];
                          var ruleInstance = {};
                          endpointAclInstance.rules.push(ruleInstance);
                          
                          var orderElement = js2xml.getElement(responseDoc, rulesElement, 'ORDER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (orderElement !== null && orderElement !== undefined && orderElement.length !== 0) {
                            var orderInstance = parseInt(orderElement, 10);
                            ruleInstance.order = orderInstance;
                          }
                          
                          var actionElement = js2xml.getElement(responseDoc, rulesElement, 'ACTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (actionElement !== null && actionElement !== undefined) {
                            var actionInstance = actionElement;
                            ruleInstance.action = actionInstance;
                          }
                          
                          var remoteSubnetElement = js2xml.getElement(responseDoc, rulesElement, 'REMOTESUBNET', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (remoteSubnetElement !== null && remoteSubnetElement !== undefined) {
                            var remoteSubnetInstance = remoteSubnetElement;
                            ruleInstance.remoteSubnet = remoteSubnetInstance;
                          }
                          
                          var descriptionElement = js2xml.getElement(responseDoc, rulesElement, 'DESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (descriptionElement !== null && descriptionElement !== undefined) {
                            var descriptionInstance = descriptionElement;
                            ruleInstance.description = descriptionInstance;
                          }
                        }
                      }
                    }
                    
                    var idleTimeoutInMinutesElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'IDLETIMEOUTINMINUTES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (idleTimeoutInMinutesElement !== null && idleTimeoutInMinutesElement !== undefined && idleTimeoutInMinutesElement.length !== 0) {
                      var idleTimeoutInMinutesInstance = parseInt(idleTimeoutInMinutesElement, 10);
                      inputEndpointInstance.idleTimeoutInMinutes = idleTimeoutInMinutesInstance;
                    }
                    
                    var loadBalancerDistributionElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'LOADBALANCERDISTRIBUTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (loadBalancerDistributionElement !== null && loadBalancerDistributionElement !== undefined) {
                      var loadBalancerDistributionInstance = loadBalancerDistributionElement;
                      inputEndpointInstance.loadBalancerDistribution = loadBalancerDistributionInstance;
                    }
                    
                    var virtualIPNameElement = js2xml.getElement(responseDoc, inputEndpointsElement, 'VIRTUALIPNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (virtualIPNameElement !== null && virtualIPNameElement !== undefined) {
                      var virtualIPNameInstance = virtualIPNameElement;
                      inputEndpointInstance.virtualIPName = virtualIPNameInstance;
                    }
                  }
                }
                
                var subnetNamesSequenceElement = js2xml.getElement(responseDoc, configurationSetsElement, 'SUBNETNAMES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (subnetNamesSequenceElement !== null && subnetNamesSequenceElement !== undefined) {
                  for (var loweredIndex4 = 0; loweredIndex4 < js2xml.getElements(responseDoc, subnetNamesSequenceElement, 'SUBNETNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex4 = loweredIndex4 + 1) {
                    var subnetNamesElement = js2xml.getElements(responseDoc, subnetNamesSequenceElement, 'SUBNETNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex4];
                    configurationSetInstance.subnetNames.push(subnetNamesElement);
                  }
                }
                
                var staticVirtualNetworkIPAddressElement = js2xml.getElement(responseDoc, configurationSetsElement, 'STATICVIRTUALNETWORKIPADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (staticVirtualNetworkIPAddressElement !== null && staticVirtualNetworkIPAddressElement !== undefined) {
                  var staticVirtualNetworkIPAddressInstance = staticVirtualNetworkIPAddressElement;
                  configurationSetInstance.staticVirtualNetworkIPAddress = staticVirtualNetworkIPAddressInstance;
                }
                
                var publicIPsSequenceElement = js2xml.getElement(responseDoc, configurationSetsElement, 'PUBLICIPS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (publicIPsSequenceElement !== null && publicIPsSequenceElement !== undefined) {
                  for (var loweredIndex5 = 0; loweredIndex5 < js2xml.getElements(responseDoc, publicIPsSequenceElement, 'PUBLICIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex5 = loweredIndex5 + 1) {
                    var publicIPsElement = js2xml.getElements(responseDoc, publicIPsSequenceElement, 'PUBLICIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex5];
                    var publicIPInstance = {};
                    configurationSetInstance.publicIPs.push(publicIPInstance);
                    
                    var nameElement2 = js2xml.getElement(responseDoc, publicIPsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (nameElement2 !== null && nameElement2 !== undefined) {
                      var nameInstance2 = nameElement2;
                      publicIPInstance.name = nameInstance2;
                    }
                    
                    var idleTimeoutInMinutesElement2 = js2xml.getElement(responseDoc, publicIPsElement, 'IDLETIMEOUTINMINUTES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (idleTimeoutInMinutesElement2 !== null && idleTimeoutInMinutesElement2 !== undefined && idleTimeoutInMinutesElement2.length !== 0) {
                      var idleTimeoutInMinutesInstance2 = parseInt(idleTimeoutInMinutesElement2, 10);
                      publicIPInstance.idleTimeoutInMinutes = idleTimeoutInMinutesInstance2;
                    }
                    
                    var domainNameLabelElement = js2xml.getElement(responseDoc, publicIPsElement, 'DOMAINNAMELABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (domainNameLabelElement !== null && domainNameLabelElement !== undefined) {
                      var domainNameLabelInstance = domainNameLabelElement;
                      publicIPInstance.domainNameLabel = domainNameLabelInstance;
                    }
                  }
                }
                
                var networkInterfacesSequenceElement = js2xml.getElement(responseDoc, configurationSetsElement, 'NETWORKINTERFACES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (networkInterfacesSequenceElement !== null && networkInterfacesSequenceElement !== undefined) {
                  for (var loweredIndex6 = 0; loweredIndex6 < js2xml.getElements(responseDoc, networkInterfacesSequenceElement, 'NETWORKINTERFACE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex6 = loweredIndex6 + 1) {
                    var networkInterfacesElement = js2xml.getElements(responseDoc, networkInterfacesSequenceElement, 'NETWORKINTERFACE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex6];
                    var networkInterfaceInstance = { iPConfigurations: [] };
                    configurationSetInstance.networkInterfaces.push(networkInterfaceInstance);
                    
                    var nameElement3 = js2xml.getElement(responseDoc, networkInterfacesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (nameElement3 !== null && nameElement3 !== undefined) {
                      var nameInstance3 = nameElement3;
                      networkInterfaceInstance.name = nameInstance3;
                    }
                    
                    var iPConfigurationsSequenceElement = js2xml.getElement(responseDoc, networkInterfacesElement, 'IPCONFIGURATIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (iPConfigurationsSequenceElement !== null && iPConfigurationsSequenceElement !== undefined) {
                      for (var loweredIndex7 = 0; loweredIndex7 < js2xml.getElements(responseDoc, iPConfigurationsSequenceElement, 'IPCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex7 = loweredIndex7 + 1) {
                        var iPConfigurationsElement = js2xml.getElements(responseDoc, iPConfigurationsSequenceElement, 'IPCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex7];
                        var iPConfigurationInstance = {};
                        networkInterfaceInstance.iPConfigurations.push(iPConfigurationInstance);
                        
                        var subnetNameElement = js2xml.getElement(responseDoc, iPConfigurationsElement, 'SUBNETNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (subnetNameElement !== null && subnetNameElement !== undefined) {
                          var subnetNameInstance = subnetNameElement;
                          iPConfigurationInstance.subnetName = subnetNameInstance;
                        }
                        
                        var staticVirtualNetworkIPAddressElement2 = js2xml.getElement(responseDoc, iPConfigurationsElement, 'STATICVIRTUALNETWORKIPADDRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                        if (staticVirtualNetworkIPAddressElement2 !== null && staticVirtualNetworkIPAddressElement2 !== undefined) {
                          var staticVirtualNetworkIPAddressInstance2 = staticVirtualNetworkIPAddressElement2;
                          iPConfigurationInstance.staticVirtualNetworkIPAddress = staticVirtualNetworkIPAddressInstance2;
                        }
                      }
                    }
                    
                    var networkSecurityGroupElement = js2xml.getElement(responseDoc, networkInterfacesElement, 'NETWORKSECURITYGROUP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (networkSecurityGroupElement !== null && networkSecurityGroupElement !== undefined) {
                      var networkSecurityGroupInstance = networkSecurityGroupElement;
                      networkInterfaceInstance.networkSecurityGroup = networkSecurityGroupInstance;
                    }
                    
                    var iPForwardingElement = js2xml.getElement(responseDoc, networkInterfacesElement, 'IPFORWARDING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (iPForwardingElement !== null && iPForwardingElement !== undefined) {
                      var iPForwardingInstance = iPForwardingElement;
                      networkInterfaceInstance.iPForwarding = iPForwardingInstance;
                    }
                  }
                }
                
                var networkSecurityGroupElement2 = js2xml.getElement(responseDoc, configurationSetsElement, 'NETWORKSECURITYGROUP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (networkSecurityGroupElement2 !== null && networkSecurityGroupElement2 !== undefined) {
                  var networkSecurityGroupInstance2 = networkSecurityGroupElement2;
                  configurationSetInstance.networkSecurityGroup = networkSecurityGroupInstance2;
                }
                
                var iPForwardingElement2 = js2xml.getElement(responseDoc, configurationSetsElement, 'IPFORWARDING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (iPForwardingElement2 !== null && iPForwardingElement2 !== undefined) {
                  var iPForwardingInstance2 = iPForwardingElement2;
                  configurationSetInstance.iPForwarding = iPForwardingInstance2;
                }
                
                var computerNameElement = js2xml.getElement(responseDoc, configurationSetsElement, 'COMPUTERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (computerNameElement !== null && computerNameElement !== undefined) {
                  var computerNameInstance = computerNameElement;
                  configurationSetInstance.computerName = computerNameInstance;
                }
                
                var adminPasswordElement = js2xml.getElement(responseDoc, configurationSetsElement, 'ADMINPASSWORD', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (adminPasswordElement !== null && adminPasswordElement !== undefined) {
                  var adminPasswordInstance = adminPasswordElement;
                  configurationSetInstance.adminPassword = adminPasswordInstance;
                }
                
                var resetPasswordOnFirstLogonElement = js2xml.getElement(responseDoc, configurationSetsElement, 'RESETPASSWORDONFIRSTLOGON', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (resetPasswordOnFirstLogonElement !== null && resetPasswordOnFirstLogonElement !== undefined && resetPasswordOnFirstLogonElement.length !== 0) {
                  var resetPasswordOnFirstLogonInstance = resetPasswordOnFirstLogonElement === 'true';
                  configurationSetInstance.resetPasswordOnFirstLogon = resetPasswordOnFirstLogonInstance;
                }
                
                var enableAutomaticUpdatesElement = js2xml.getElement(responseDoc, configurationSetsElement, 'ENABLEAUTOMATICUPDATES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (enableAutomaticUpdatesElement !== null && enableAutomaticUpdatesElement !== undefined && enableAutomaticUpdatesElement.length !== 0) {
                  var enableAutomaticUpdatesInstance = enableAutomaticUpdatesElement === 'true';
                  configurationSetInstance.enableAutomaticUpdates = enableAutomaticUpdatesInstance;
                }
                
                var timeZoneElement = js2xml.getElement(responseDoc, configurationSetsElement, 'TIMEZONE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (timeZoneElement !== null && timeZoneElement !== undefined) {
                  var timeZoneInstance = timeZoneElement;
                  configurationSetInstance.timeZone = timeZoneInstance;
                }
                
                var domainJoinElement = js2xml.getElement(responseDoc, configurationSetsElement, 'DOMAINJOIN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (domainJoinElement !== null && domainJoinElement !== undefined) {
                  var domainJoinInstance = {};
                  configurationSetInstance.domainJoin = domainJoinInstance;
                  
                  var credentialsElement = js2xml.getElement(responseDoc, domainJoinElement, 'CREDENTIALS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (credentialsElement !== null && credentialsElement !== undefined) {
                    var credentialsInstance = {};
                    domainJoinInstance.credentials = credentialsInstance;
                    
                    var domainElement = js2xml.getElement(responseDoc, credentialsElement, 'DOMAIN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (domainElement !== null && domainElement !== undefined) {
                      var domainInstance = domainElement;
                      credentialsInstance.domain = domainInstance;
                    }
                    
                    var usernameElement = js2xml.getElement(responseDoc, credentialsElement, 'USERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (usernameElement !== null && usernameElement !== undefined) {
                      var usernameInstance = usernameElement;
                      credentialsInstance.userName = usernameInstance;
                    }
                    
                    var passwordElement = js2xml.getElement(responseDoc, credentialsElement, 'PASSWORD', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (passwordElement !== null && passwordElement !== undefined) {
                      var passwordInstance = passwordElement;
                      credentialsInstance.password = passwordInstance;
                    }
                  }
                  
                  var joinDomainElement = js2xml.getElement(responseDoc, domainJoinElement, 'JOINDOMAIN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (joinDomainElement !== null && joinDomainElement !== undefined) {
                    var joinDomainInstance = joinDomainElement;
                    domainJoinInstance.domainToJoin = joinDomainInstance;
                  }
                  
                  var machineObjectOUElement = js2xml.getElement(responseDoc, domainJoinElement, 'MACHINEOBJECTOU', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (machineObjectOUElement !== null && machineObjectOUElement !== undefined) {
                    var machineObjectOUInstance = machineObjectOUElement;
                    domainJoinInstance.ldapMachineObjectOU = machineObjectOUInstance;
                  }
                  
                  var provisioningElement = js2xml.getElement(responseDoc, domainJoinElement, 'PROVISIONING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (provisioningElement !== null && provisioningElement !== undefined) {
                    var provisioningInstance = {};
                    domainJoinInstance.provisioning = provisioningInstance;
                    
                    var accountDataElement = js2xml.getElement(responseDoc, provisioningElement, 'ACCOUNTDATA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (accountDataElement !== null && accountDataElement !== undefined) {
                      var accountDataInstance = accountDataElement;
                      provisioningInstance.accountData = accountDataInstance;
                    }
                  }
                }
                
                var storedCertificateSettingsSequenceElement = js2xml.getElement(responseDoc, configurationSetsElement, 'STOREDCERTIFICATESETTINGS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (storedCertificateSettingsSequenceElement !== null && storedCertificateSettingsSequenceElement !== undefined) {
                  for (var loweredIndex8 = 0; loweredIndex8 < js2xml.getElements(responseDoc, storedCertificateSettingsSequenceElement, 'CERTIFICATESETTING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex8 = loweredIndex8 + 1) {
                    var storedCertificateSettingsElement = js2xml.getElements(responseDoc, storedCertificateSettingsSequenceElement, 'CERTIFICATESETTING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex8];
                    var certificateSettingInstance = {};
                    configurationSetInstance.storedCertificateSettings.push(certificateSettingInstance);
                    
                    var storeLocationElement = js2xml.getElement(responseDoc, storedCertificateSettingsElement, 'STORELOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (storeLocationElement !== null && storeLocationElement !== undefined) {
                    }
                    
                    var storeNameElement = js2xml.getElement(responseDoc, storedCertificateSettingsElement, 'STORENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (storeNameElement !== null && storeNameElement !== undefined) {
                      var storeNameInstance = storeNameElement;
                      certificateSettingInstance.storeName = storeNameInstance;
                    }
                    
                    var thumbprintElement = js2xml.getElement(responseDoc, storedCertificateSettingsElement, 'THUMBPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (thumbprintElement !== null && thumbprintElement !== undefined) {
                      var thumbprintInstance = thumbprintElement;
                      certificateSettingInstance.thumbprint = thumbprintInstance;
                    }
                  }
                }
                
                var winRMElement = js2xml.getElement(responseDoc, configurationSetsElement, 'WINRM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (winRMElement !== null && winRMElement !== undefined) {
                  var winRMInstance = { listeners: [] };
                  configurationSetInstance.windowsRemoteManagement = winRMInstance;
                  
                  var listenersSequenceElement = js2xml.getElement(responseDoc, winRMElement, 'LISTENERS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (listenersSequenceElement !== null && listenersSequenceElement !== undefined) {
                    for (var loweredIndex9 = 0; loweredIndex9 < js2xml.getElements(responseDoc, listenersSequenceElement, 'LISTENER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex9 = loweredIndex9 + 1) {
                      var listenersElement = js2xml.getElements(responseDoc, listenersSequenceElement, 'LISTENER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex9];
                      var listenerInstance = {};
                      winRMInstance.listeners.push(listenerInstance);
                      
                      var protocolElement3 = js2xml.getElement(responseDoc, listenersElement, 'PROTOCOL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (protocolElement3 !== null && protocolElement3 !== undefined && protocolElement3.length !== 0) {
                        var protocolInstance3 = protocolElement3;
                        listenerInstance.listenerType = protocolInstance3;
                      }
                      
                      var certificateThumbprintElement = js2xml.getElement(responseDoc, listenersElement, 'CERTIFICATETHUMBPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (certificateThumbprintElement !== null && certificateThumbprintElement !== undefined) {
                        var certificateThumbprintInstance = certificateThumbprintElement;
                        listenerInstance.certificateThumbprint = certificateThumbprintInstance;
                      }
                    }
                  }
                }
                
                var adminUsernameElement = js2xml.getElement(responseDoc, configurationSetsElement, 'ADMINUSERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (adminUsernameElement !== null && adminUsernameElement !== undefined) {
                  var adminUsernameInstance = adminUsernameElement;
                  configurationSetInstance.adminUserName = adminUsernameInstance;
                }
                
                var additionalUnattendContentElement = js2xml.getElement(responseDoc, configurationSetsElement, 'ADDITIONALUNATTENDCONTENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (additionalUnattendContentElement !== null && additionalUnattendContentElement !== undefined) {
                  var additionalUnattendContentInstance = { unattendPasses: [] };
                  configurationSetInstance.additionalUnattendContent = additionalUnattendContentInstance;
                  
                  var passesSequenceElement = js2xml.getElement(responseDoc, additionalUnattendContentElement, 'PASSES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (passesSequenceElement !== null && passesSequenceElement !== undefined) {
                    for (var loweredIndex10 = 0; loweredIndex10 < js2xml.getElements(responseDoc, passesSequenceElement, 'UNATTENDPASS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex10 = loweredIndex10 + 1) {
                      var passesElement = js2xml.getElements(responseDoc, passesSequenceElement, 'UNATTENDPASS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex10];
                      var unattendPassInstance = { unattendComponents: [] };
                      additionalUnattendContentInstance.unattendPasses.push(unattendPassInstance);
                      
                      var passNameElement = js2xml.getElement(responseDoc, passesElement, 'PASSNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (passNameElement !== null && passNameElement !== undefined) {
                        var passNameInstance = passNameElement;
                        unattendPassInstance.passName = passNameInstance;
                      }
                      
                      var componentsSequenceElement = js2xml.getElement(responseDoc, passesElement, 'COMPONENTS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (componentsSequenceElement !== null && componentsSequenceElement !== undefined) {
                        for (var loweredIndex11 = 0; loweredIndex11 < js2xml.getElements(responseDoc, componentsSequenceElement, 'UNATTENDCOMPONENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex11 = loweredIndex11 + 1) {
                          var componentsElement = js2xml.getElements(responseDoc, componentsSequenceElement, 'UNATTENDCOMPONENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex11];
                          var unattendComponentInstance = { unattendComponentSettings: [] };
                          unattendPassInstance.unattendComponents.push(unattendComponentInstance);
                          
                          var componentNameElement = js2xml.getElement(responseDoc, componentsElement, 'COMPONENTNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (componentNameElement !== null && componentNameElement !== undefined) {
                            var componentNameInstance = componentNameElement;
                            unattendComponentInstance.componentName = componentNameInstance;
                          }
                          
                          var componentSettingsSequenceElement = js2xml.getElement(responseDoc, componentsElement, 'COMPONENTSETTINGS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                          if (componentSettingsSequenceElement !== null && componentSettingsSequenceElement !== undefined) {
                            for (var loweredIndex12 = 0; loweredIndex12 < js2xml.getElements(responseDoc, componentSettingsSequenceElement, 'COMPONENTSETTING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex12 = loweredIndex12 + 1) {
                              var componentSettingsElement = js2xml.getElements(responseDoc, componentSettingsSequenceElement, 'COMPONENTSETTING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex12];
                              var componentSettingInstance = {};
                              unattendComponentInstance.unattendComponentSettings.push(componentSettingInstance);
                              
                              var settingNameElement = js2xml.getElement(responseDoc, componentSettingsElement, 'SETTINGNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (settingNameElement !== null && settingNameElement !== undefined) {
                                var settingNameInstance = settingNameElement;
                                componentSettingInstance.settingName = settingNameInstance;
                              }
                              
                              var contentElement = js2xml.getElement(responseDoc, componentSettingsElement, 'CONTENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                              if (contentElement !== null && contentElement !== undefined) {
                                var contentInstance = new Buffer(contentElement, 'base64').toString('utf8');
                                componentSettingInstance.content = contentInstance;
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
                
                var hostNameElement = js2xml.getElement(responseDoc, configurationSetsElement, 'HOSTNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (hostNameElement !== null && hostNameElement !== undefined) {
                  var hostNameInstance = hostNameElement;
                  configurationSetInstance.hostName = hostNameInstance;
                }
                
                var userNameElement = js2xml.getElement(responseDoc, configurationSetsElement, 'USERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (userNameElement !== null && userNameElement !== undefined) {
                  var userNameInstance = userNameElement;
                  configurationSetInstance.userName = userNameInstance;
                }
                
                var userPasswordElement = js2xml.getElement(responseDoc, configurationSetsElement, 'USERPASSWORD', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (userPasswordElement !== null && userPasswordElement !== undefined) {
                  var userPasswordInstance = userPasswordElement;
                  configurationSetInstance.userPassword = userPasswordInstance;
                }
                
                var disableSshPasswordAuthenticationElement = js2xml.getElement(responseDoc, configurationSetsElement, 'DISABLESSHPASSWORDAUTHENTICATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (disableSshPasswordAuthenticationElement !== null && disableSshPasswordAuthenticationElement !== undefined && disableSshPasswordAuthenticationElement.length !== 0) {
                  var disableSshPasswordAuthenticationInstance = disableSshPasswordAuthenticationElement === 'true';
                  configurationSetInstance.disableSshPasswordAuthentication = disableSshPasswordAuthenticationInstance;
                }
                
                var sSHElement = js2xml.getElement(responseDoc, configurationSetsElement, 'SSH', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (sSHElement !== null && sSHElement !== undefined) {
                  var sSHInstance = { keyPairs: [], publicKeys: [] };
                  configurationSetInstance.sshSettings = sSHInstance;
                  
                  var publicKeysSequenceElement = js2xml.getElement(responseDoc, sSHElement, 'PUBLICKEYS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (publicKeysSequenceElement !== null && publicKeysSequenceElement !== undefined) {
                    for (var loweredIndex13 = 0; loweredIndex13 < js2xml.getElements(responseDoc, publicKeysSequenceElement, 'PUBLICKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex13 = loweredIndex13 + 1) {
                      var publicKeysElement = js2xml.getElements(responseDoc, publicKeysSequenceElement, 'PUBLICKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex13];
                      var publicKeyInstance = {};
                      sSHInstance.publicKeys.push(publicKeyInstance);
                      
                      var fingerprintElement = js2xml.getElement(responseDoc, publicKeysElement, 'FINGERPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (fingerprintElement !== null && fingerprintElement !== undefined) {
                        var fingerprintInstance = fingerprintElement;
                        publicKeyInstance.fingerprint = fingerprintInstance;
                      }
                      
                      var pathElement2 = js2xml.getElement(responseDoc, publicKeysElement, 'PATH', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (pathElement2 !== null && pathElement2 !== undefined) {
                        var pathInstance2 = pathElement2;
                        publicKeyInstance.path = pathInstance2;
                      }
                    }
                  }
                  
                  var keyPairsSequenceElement = js2xml.getElement(responseDoc, sSHElement, 'KEYPAIRS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (keyPairsSequenceElement !== null && keyPairsSequenceElement !== undefined) {
                    for (var loweredIndex14 = 0; loweredIndex14 < js2xml.getElements(responseDoc, keyPairsSequenceElement, 'KEYPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex14 = loweredIndex14 + 1) {
                      var keyPairsElement = js2xml.getElements(responseDoc, keyPairsSequenceElement, 'KEYPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex14];
                      var keyPairInstance = {};
                      sSHInstance.keyPairs.push(keyPairInstance);
                      
                      var fingerprintElement2 = js2xml.getElement(responseDoc, keyPairsElement, 'FINGERPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (fingerprintElement2 !== null && fingerprintElement2 !== undefined) {
                        var fingerprintInstance2 = fingerprintElement2;
                        keyPairInstance.fingerprint = fingerprintInstance2;
                      }
                      
                      var pathElement3 = js2xml.getElement(responseDoc, keyPairsElement, 'PATH', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (pathElement3 !== null && pathElement3 !== undefined) {
                        var pathInstance3 = pathElement3;
                        keyPairInstance.path = pathInstance3;
                      }
                    }
                  }
                }
                
                var customDataElement = js2xml.getElement(responseDoc, configurationSetsElement, 'CUSTOMDATA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (customDataElement !== null && customDataElement !== undefined) {
                  var customDataInstance = customDataElement;
                  configurationSetInstance.customData = customDataInstance;
                }
              }
            }
            
            var dataVirtualHardDisksSequenceElement = js2xml.getElement(responseDoc, persistentVMRoleElement, 'DATAVIRTUALHARDDISKS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (dataVirtualHardDisksSequenceElement !== null && dataVirtualHardDisksSequenceElement !== undefined) {
              for (var loweredIndex15 = 0; loweredIndex15 < js2xml.getElements(responseDoc, dataVirtualHardDisksSequenceElement, 'DATAVIRTUALHARDDISK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex15 = loweredIndex15 + 1) {
                var dataVirtualHardDisksElement = js2xml.getElements(responseDoc, dataVirtualHardDisksSequenceElement, 'DATAVIRTUALHARDDISK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex15];
                var dataVirtualHardDiskInstance = {};
                result.dataVirtualHardDisks.push(dataVirtualHardDiskInstance);
                
                var hostCachingElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'HOSTCACHING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (hostCachingElement !== null && hostCachingElement !== undefined) {
                  var hostCachingInstance = hostCachingElement;
                  dataVirtualHardDiskInstance.hostCaching = hostCachingInstance;
                }
                
                var diskLabelElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'DISKLABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (diskLabelElement !== null && diskLabelElement !== undefined) {
                  var diskLabelInstance = diskLabelElement;
                  dataVirtualHardDiskInstance.label = diskLabelInstance;
                }
                
                var diskNameElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'DISKNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (diskNameElement !== null && diskNameElement !== undefined) {
                  var diskNameInstance = diskNameElement;
                  dataVirtualHardDiskInstance.name = diskNameInstance;
                }
                
                var lunElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'LUN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (lunElement !== null && lunElement !== undefined && lunElement.length !== 0) {
                  var lunInstance = parseInt(lunElement, 10);
                  dataVirtualHardDiskInstance.logicalUnitNumber = lunInstance;
                }
                
                var logicalDiskSizeInGBElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'LOGICALDISKSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (logicalDiskSizeInGBElement !== null && logicalDiskSizeInGBElement !== undefined && logicalDiskSizeInGBElement.length !== 0) {
                  var logicalDiskSizeInGBInstance = parseInt(logicalDiskSizeInGBElement, 10);
                  dataVirtualHardDiskInstance.logicalDiskSizeInGB = logicalDiskSizeInGBInstance;
                }
                
                var mediaLinkElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'MEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (mediaLinkElement !== null && mediaLinkElement !== undefined) {
                  var mediaLinkInstance = mediaLinkElement;
                  dataVirtualHardDiskInstance.mediaLink = mediaLinkInstance;
                }
                
                var sourceMediaLinkElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'SOURCEMEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (sourceMediaLinkElement !== null && sourceMediaLinkElement !== undefined) {
                  var sourceMediaLinkInstance = sourceMediaLinkElement;
                  dataVirtualHardDiskInstance.sourceMediaLink = sourceMediaLinkInstance;
                }
                
                var iOTypeElement = js2xml.getElement(responseDoc, dataVirtualHardDisksElement, 'IOTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (iOTypeElement !== null && iOTypeElement !== undefined) {
                  var iOTypeInstance = iOTypeElement;
                  dataVirtualHardDiskInstance.iOType = iOTypeInstance;
                }
              }
            }
            
            var oSVirtualHardDiskElement = js2xml.getElement(responseDoc, persistentVMRoleElement, 'OSVIRTUALHARDDISK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (oSVirtualHardDiskElement !== null && oSVirtualHardDiskElement !== undefined) {
              var oSVirtualHardDiskInstance = {};
              result.oSVirtualHardDisk = oSVirtualHardDiskInstance;
              
              var hostCachingElement2 = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'HOSTCACHING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (hostCachingElement2 !== null && hostCachingElement2 !== undefined) {
                var hostCachingInstance2 = hostCachingElement2;
                oSVirtualHardDiskInstance.hostCaching = hostCachingInstance2;
              }
              
              var diskLabelElement2 = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'DISKLABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (diskLabelElement2 !== null && diskLabelElement2 !== undefined) {
                var diskLabelInstance2 = diskLabelElement2;
                oSVirtualHardDiskInstance.label = diskLabelInstance2;
              }
              
              var diskNameElement2 = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'DISKNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (diskNameElement2 !== null && diskNameElement2 !== undefined) {
                var diskNameInstance2 = diskNameElement2;
                oSVirtualHardDiskInstance.name = diskNameInstance2;
              }
              
              var mediaLinkElement2 = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'MEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (mediaLinkElement2 !== null && mediaLinkElement2 !== undefined) {
                var mediaLinkInstance2 = mediaLinkElement2;
                oSVirtualHardDiskInstance.mediaLink = mediaLinkInstance2;
              }
              
              var sourceImageNameElement = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'SOURCEIMAGENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (sourceImageNameElement !== null && sourceImageNameElement !== undefined) {
                var sourceImageNameInstance = sourceImageNameElement;
                oSVirtualHardDiskInstance.sourceImageName = sourceImageNameInstance;
              }
              
              var osElement = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'OS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (osElement !== null && osElement !== undefined) {
                var osInstance = osElement;
                oSVirtualHardDiskInstance.operatingSystem = osInstance;
              }
              
              var remoteSourceImageLinkElement = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'REMOTESOURCEIMAGELINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (remoteSourceImageLinkElement !== null && remoteSourceImageLinkElement !== undefined) {
                var remoteSourceImageLinkInstance = remoteSourceImageLinkElement;
                oSVirtualHardDiskInstance.remoteSourceImageLink = remoteSourceImageLinkInstance;
              }
              
              var iOTypeElement2 = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'IOTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (iOTypeElement2 !== null && iOTypeElement2 !== undefined) {
                var iOTypeInstance2 = iOTypeElement2;
                oSVirtualHardDiskInstance.iOType = iOTypeInstance2;
              }
              
              var resizedSizeInGBElement = js2xml.getElement(responseDoc, oSVirtualHardDiskElement, 'RESIZEDSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (resizedSizeInGBElement !== null && resizedSizeInGBElement !== undefined && resizedSizeInGBElement.length !== 0) {
                var resizedSizeInGBInstance = parseInt(resizedSizeInGBElement, 10);
                oSVirtualHardDiskInstance.resizedSizeInGB = resizedSizeInGBInstance;
              }
            }
            
            var provisionGuestAgentElement = js2xml.getElement(responseDoc, persistentVMRoleElement, 'PROVISIONGUESTAGENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (provisionGuestAgentElement !== null && provisionGuestAgentElement !== undefined && provisionGuestAgentElement.length !== 0) {
              var provisionGuestAgentInstance = provisionGuestAgentElement === 'true';
              result.provisionGuestAgent = provisionGuestAgentInstance;
            }
            
            var debugSettingsElement = js2xml.getElement(responseDoc, persistentVMRoleElement, 'DEBUGSETTINGS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (debugSettingsElement !== null && debugSettingsElement !== undefined) {
              var debugSettingsInstance = {};
              result.debugSettings = debugSettingsInstance;
              
              var bootDiagnosticsEnabledElement = js2xml.getElement(responseDoc, debugSettingsElement, 'BOOTDIAGNOSTICSENABLED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (bootDiagnosticsEnabledElement !== null && bootDiagnosticsEnabledElement !== undefined && bootDiagnosticsEnabledElement.length !== 0) {
                var bootDiagnosticsEnabledInstance = bootDiagnosticsEnabledElement === 'true';
                debugSettingsInstance.bootDiagnosticsEnabled = bootDiagnosticsEnabledInstance;
              }
              
              var consoleScreenshotBlobUriElement = js2xml.getElement(responseDoc, debugSettingsElement, 'CONSOLESCREENSHOTBLOBURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (consoleScreenshotBlobUriElement !== null && consoleScreenshotBlobUriElement !== undefined) {
                var consoleScreenshotBlobUriInstance = consoleScreenshotBlobUriElement;
                debugSettingsInstance.consoleScreenshotBlobUri = consoleScreenshotBlobUriInstance;
              }
              
              var serialOutputBlobUriElement = js2xml.getElement(responseDoc, debugSettingsElement, 'SERIALOUTPUTBLOBURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (serialOutputBlobUriElement !== null && serialOutputBlobUriElement !== undefined) {
                var serialOutputBlobUriInstance = serialOutputBlobUriElement;
                debugSettingsInstance.serialOutputBlobUri = serialOutputBlobUriInstance;
              }
            }
            
            var licenseTypeElement = js2xml.getElement(responseDoc, persistentVMRoleElement, 'LICENSETYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (licenseTypeElement !== null && licenseTypeElement !== undefined) {
              var licenseTypeInstance = licenseTypeElement;
              result.licenseType = licenseTypeInstance;
            }
            
            var migrationStateElement = js2xml.getElement(responseDoc, persistentVMRoleElement, 'MIGRATIONSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (migrationStateElement !== null && migrationStateElement !== undefined) {
              var migrationStateInstance = migrationStateElement;
              result.migrationState = migrationStateInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Download RDP file operation retrieves the Remote Desktop Protocol
   * configuration file from the specified virtual machine.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157183.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {string} virtualMachineName The name of the virtual machine.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.getRemoteDesktopFile = function(serviceName, deploymentName, virtualMachineName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (serviceName === null || serviceName === undefined) {
      return callback(new Error('serviceName cannot be null.'));
    }
    if (deploymentName === null || deploymentName === undefined) {
      return callback(new Error('deploymentName cannot be null.'));
    }
    if (virtualMachineName === null || virtualMachineName === undefined) {
      return callback(new Error('virtualMachineName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/hostedservices/';
    url2 = url2 + encodeURIComponent(serviceName);
    url2 = url2 + '/deployments/';
    url2 = url2 + encodeURIComponent(deploymentName);
    url2 = url2 + '/roleinstances/';
    url2 = url2 + encodeURIComponent(virtualMachineName);
    url2 = url2 + '/ModelFile';
    var queryParameters = [];
    queryParameters.push('FileType=RDP');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        result.remoteDesktopFile = responseContent;
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Redeploy role operation redeploys the specified virtual machine.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157197.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {string} virtualMachineName The name of the virtual machine to
   * redeploy.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.redeploy = function(serviceName, deploymentName, virtualMachineName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachines.beginRedeploying(serviceName, deploymentName, virtualMachineName, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Restart role operation restarts the specified virtual machine.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157197.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {string} virtualMachineName The name of the virtual machine to
   * restart.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.restart = function(serviceName, deploymentName, virtualMachineName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachines.beginRestarting(serviceName, deploymentName, virtualMachineName, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Shutdown Role operation shuts down the specified virtual machine.
   * (see http://msdn.microsoft.com/en-us/library/windowsazure/jj157195.aspx
   * for more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {string} virtualMachineName The name of the virtual machine to
   * shutdown.
   * 
   * @param {VirtualMachineShutdownParameters} parameters The parameters for
   * the shutdown virtual machine operation.
   * 
   * @param {PostShutdownAction} [parameters.postShutdownAction] The state of
   * the virtual machine after shutdown (Stopped or StoppedDeallocated).
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.shutdown = function(serviceName, deploymentName, virtualMachineName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachines.beginShutdown(serviceName, deploymentName, virtualMachineName, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Shutdown Roles operation stops the specified set of virtual machines.
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {VirtualMachineShutdownRolesParameters} parameters Parameters to
   * pass to the Shutdown Roles operation.
   * 
   * @param {array} [parameters.roles] The set of roles to shut down.
   * 
   * @param {PostShutdownAction} [parameters.postShutdownAction] The state of
   * the roles after shutdown. Possible values include Stopped or
   * StoppedDeallocated.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.shutdownRoles = function(serviceName, deploymentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachines.beginShuttingDownRoles(serviceName, deploymentName, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Start Role operation starts the specified virtual machine.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157189.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {string} virtualMachineName The name of the virtual machine to
   * start.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.start = function(serviceName, deploymentName, virtualMachineName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachines.beginStarting(serviceName, deploymentName, virtualMachineName, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Start Roles operation starts the specified set of virtual machines.
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {VirtualMachineStartRolesParameters} parameters Parameters to pass
   * to the Start Roles operation.
   * 
   * @param {array} [parameters.roles] The set of roles to shut down.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.startRoles = function(serviceName, deploymentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachines.beginStartingRoles(serviceName, deploymentName, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Update Role operation adds a virtual machine to an existing
   * deployment.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157187.aspx for
   * more information)
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {string} virtualMachineName The name of your virtual machine.
   * 
   * @param {VirtualMachineUpdateParameters} parameters Parameters supplied to
   * the Update Virtual Machine operation.
   * 
   * @param {string} parameters.roleName Specifies the name for the virtual
   * machine. The name must be unique within the deployment.
   * 
   * @param {string} [parameters.label] Specifies the friendly name for the
   * virtual machine.
   * 
   * @param {string} [parameters.availabilitySetName] Specifies the name of an
   * availability set to which to add the virtual machine. This value controls
   * the virtual machine allocation in the Azure environment. Virtual machines
   * specified in the same availability set are allocated to different nodes
   * to maximize availability.
   * 
   * @param {string} [parameters.roleSize] The size of the virtual machine.
   * 
   * @param {array} [parameters.configurationSets] Contains the collection of
   * configuration sets that contain system and application configuration
   * settings.
   * 
   * @param {array} [parameters.resourceExtensionReferences] Contains a
   * collection of resource extensions that are to be installed on the Virtual
   * Machine. This element is used if ProvisionGuestAgent is set to true.
   * 
   * @param {array} [parameters.dataVirtualHardDisks] Contains the parameters
   * Azure used to create the data disk for the virtual machine.
   * 
   * @param {OSVirtualHardDisk} parameters.oSVirtualHardDisk Contains the
   * parameters Azure used to create the operating system disk for the virtual
   * machine.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.hostCaching] Specifies the
   * platform caching behavior of the operating system disk blob for
   * read/write efficiency.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.label] Specifies the
   * friendly name of an operating system image in the image repository.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.name] Specifies the name of
   * an operating system image in the image repository.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.mediaLink] Specifies the
   * location of the operating system disk in Azure storage.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.sourceImageName] Specifies
   * the name of the source image that was used to provision the virtual
   * machine.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.operatingSystem] The
   * operating system running in the virtual machine.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.remoteSourceImageLink] Uri
   * of the source OS image that will be copied to the customer’s storage
   * account of VM creation.If RemoteSourceImageLink is specified, then
   * MediaLink must also be specified.If RemoteSourceImageLink is specified,
   * thenSourceIamgeName must not be specified.
   * 
   * @param {string} [parameters.oSVirtualHardDisk.iOType] Gets or sets the IO
   * type.
   * 
   * @param {number} [parameters.oSVirtualHardDisk.resizedSizeInGB] When an OS
   * Image or a RemoteSourceImage is used to create an OSVirtualHardDisk, this
   * parameter can be used to resize the new OSVirtualHardDisk to a larger
   * size. ResizedSizeInGB must be larger than the underlying OS Image’s
   * LogicalSizeInGB.
   * 
   * @param {boolean} [parameters.provisionGuestAgent] Indicates whether the
   * WindowsAzureGuestAgent service is installed on the Virtual Machine. To
   * run a resource extension in a Virtual Machine, this service must be
   * installed.
   * 
   * @param {DebugSettings} [parameters.debugSettings] Debug settings for
   * console output.
   * 
   * @param {boolean} [parameters.debugSettings.bootDiagnosticsEnabled] Enable
   * or disable boot diagnostics.
   * 
   * @param {string} [parameters.debugSettings.consoleScreenshotBlobUri] Blob
   * uri for console screen shot.
   * 
   * @param {string} [parameters.debugSettings.serialOutputBlobUri] Blob uri
   * for serial output.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.update = function(serviceName, deploymentName, virtualMachineName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachines.beginUpdating(serviceName, deploymentName, virtualMachineName, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Update Load Balanced Endpoint Set operation changes the specified
   * load-balanced InputEndpoints on all the roles of an Infrastructure as a
   * Service deployment. Non-load-balanced endpoints must be changed using
   * UpdateRole.
   * 
   * @param {string} serviceName The name of your service.
   * 
   * @param {string} deploymentName The name of your deployment.
   * 
   * @param {VirtualMachineUpdateLoadBalancedSetParameters} parameters
   * Parameters supplied to the Update Load Balanced Endpoint Set operation.
   * 
   * @param {array} [parameters.loadBalancedEndpoints] A list of load balanced
   * InputEndpoints to update.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.updateLoadBalancedEndpointSet = function(serviceName, deploymentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachines.beginUpdatingLoadBalancedEndpointSet(serviceName, deploymentName, parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  return VirtualMachineOperations;
})();

var VirtualMachineOSImageOperations = ( /** @lends VirtualMachineOSImageOperations */ function() {
  /**
   * @class
   * The Service Management API includes operations for managing the OS images
   * in your subscription.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157175.aspx for
   * more information)
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [ComputeManagementClient] {@link
   * ComputeManagementClient~ComputeManagementClient}.
   * See [virtualMachineOSImages] {@link
   * ComputeManagementClient~ComputeManagementClient#virtualMachineOSImages}.
   * Initializes a new instance of the VirtualMachineOSImageOperations class.
   * @constructor
   * 
   * @param {ComputeManagementClient} client Reference to the service client.
   */
  function VirtualMachineOSImageOperations(client) {
    this.client = client;
  }
  
  /**
   * Share an already replicated OS image. This operation is only for
   * publishers. You have to be registered as image publisher with Windows
   * Azure to be able to call this.
   * 
   * @param {string} imageName The name of the virtual machine image to share.
   * 
   * @param {string} permission The sharing permission: public, msdn, or
   * private.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOSImageOperations.prototype.beginSharing = function(imageName, permission, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (imageName === null || imageName === undefined) {
      return callback(new Error('imageName cannot be null.'));
    }
    if (permission === null || permission === undefined) {
      return callback(new Error('permission cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/images/';
    url2 = url2 + encodeURIComponent(imageName);
    url2 = url2 + '/shareasync';
    var queryParameters = [];
    queryParameters.push('permission=' + encodeURIComponent(permission));
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Unreplicate an OS image to multiple target locations. This operation is
   * only for publishers. You have to be registered as image publisher with
   * Windows Azure to be able to call this. Note: The operation removes the
   * published copies of the user OS Image. It does not remove the actual user
   * OS Image. To remove the actual user OS Image, the publisher will have to
   * call Delete OS Image.
   * 
   * @param {string} imageName The name of the virtual machine image to
   * replicate. Note: The OS Image Name should be the user OS Image, not the
   * published name of the OS Image.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOSImageOperations.prototype.beginUnreplicating = function(imageName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (imageName === null || imageName === undefined) {
      return callback(new Error('imageName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/images/';
    url2 = url2 + encodeURIComponent(imageName);
    url2 = url2 + '/unreplicate';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Create OS Image operation adds an operating system image that is
   * stored in a storage account and is available from the image repository.
   * (see http://msdn.microsoft.com/en-us/library/windowsazure/jj157192.aspx
   * for more information)
   * 
   * @param {VirtualMachineOSImageCreateParameters} parameters Parameters
   * supplied to the Create Virtual Machine Image operation.
   * 
   * @param {string} parameters.label Specifies the friendly name of the image.
   * 
   * @param {string} parameters.mediaLinkUri Specifies the location of the blob
   * in Azure storage. The blob location must belong to a storage account in
   * the subscription specified by the SubscriptionId value in the operation
   * call. Example: http://example.blob.core.windows.net/disks/mydisk.vhd.
   * 
   * @param {string} parameters.name Specifies a name that Azure uses to
   * identify the image when creating one or more virtual machines.
   * 
   * @param {string} parameters.operatingSystemType The operating system type
   * of the OS image. Possible values are: Linux or Windows.
   * 
   * @param {string} [parameters.eula] Specifies the End User License Agreement
   * that is associated with the image. The value for this element is a
   * string, but it is recommended that the value be a URL that points to a
   * EULA.
   * 
   * @param {string} [parameters.description] Specifies the description of the
   * OS image.
   * 
   * @param {string} [parameters.imageFamily] Specifies a value that can be
   * used to group OS images.
   * 
   * @param {date} [parameters.publishedDate] Specifies the date when the OS
   * image was added to the image repository.
   * 
   * @param {boolean} parameters.isPremium Indicates if the image contains
   * software or associated services that will incur charges above the core
   * price for the virtual machine.
   * 
   * @param {boolean} parameters.showInGui Specifies whether the image should
   * appear in the image gallery.
   * 
   * @param {string} [parameters.privacyUri] Specifies the URI that points to a
   * document that contains the privacy policy related to the OS image.
   * 
   * @param {string} [parameters.iconUri] Specifies the URI to the icon that is
   * displayed for the image in the Management Portal.
   * 
   * @param {string} [parameters.recommendedVMSize] Specifies the size to use
   * for the virtual machine that is created from the OS image.
   * 
   * @param {string} [parameters.smallIconUri] Specifies the URI to the small
   * icon that is displayed when the image is presented in the Azure
   * Management Portal. The SmallIconUri element is only available using
   * version 2013-03-01 or higher.
   * 
   * @param {string} [parameters.language] Specifies the language of the image.
   * The Language element is only available using version 2013-03-01 or higher.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOSImageOperations.prototype.create = function(parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.isPremium === null || parameters.isPremium === undefined) {
      return callback(new Error('parameters.isPremium cannot be null.'));
    }
    if (parameters.label === null || parameters.label === undefined) {
      return callback(new Error('parameters.label cannot be null.'));
    }
    if (parameters.mediaLinkUri === null || parameters.mediaLinkUri === undefined) {
      return callback(new Error('parameters.mediaLinkUri cannot be null.'));
    }
    if (parameters.name === null || parameters.name === undefined) {
      return callback(new Error('parameters.name cannot be null.'));
    }
    if (parameters.operatingSystemType === null || parameters.operatingSystemType === undefined) {
      return callback(new Error('parameters.operatingSystemType cannot be null.'));
    }
    if (parameters.showInGui === null || parameters.showInGui === undefined) {
      return callback(new Error('parameters.showInGui cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/images';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var oSImageElement = js2xml.createElement('OSImage', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, oSImageElement);
    
    var labelElement = js2xml.createElement('Label', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(labelElement, parameters.label);
    js2xml.addChildElement(oSImageElement, labelElement);
    
    var mediaLinkElement = js2xml.createElement('MediaLink', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(mediaLinkElement, parameters.mediaLinkUri);
    js2xml.addChildElement(oSImageElement, mediaLinkElement);
    
    var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(nameElement, parameters.name);
    js2xml.addChildElement(oSImageElement, nameElement);
    
    var osElement = js2xml.createElement('OS', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(osElement, parameters.operatingSystemType);
    js2xml.addChildElement(oSImageElement, osElement);
    
    if (parameters.eula !== null && parameters.eula !== undefined) {
      var eulaElement = js2xml.createElement('Eula', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(eulaElement, parameters.eula);
      js2xml.addChildElement(oSImageElement, eulaElement);
    }
    
    if (parameters.description !== null && parameters.description !== undefined) {
      var descriptionElement = js2xml.createElement('Description', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(descriptionElement, parameters.description);
      js2xml.addChildElement(oSImageElement, descriptionElement);
    }
    
    if (parameters.imageFamily !== null && parameters.imageFamily !== undefined) {
      var imageFamilyElement = js2xml.createElement('ImageFamily', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(imageFamilyElement, parameters.imageFamily);
      js2xml.addChildElement(oSImageElement, imageFamilyElement);
    }
    
    if (parameters.publishedDate !== null && parameters.publishedDate !== undefined) {
      var publishedDateElement = js2xml.createElement('PublishedDate', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(publishedDateElement, parameters.publishedDate.toISOString());
      js2xml.addChildElement(oSImageElement, publishedDateElement);
    }
    
    var isPremiumElement = js2xml.createElement('IsPremium', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(isPremiumElement, parameters.isPremium.toString());
    js2xml.addChildElement(oSImageElement, isPremiumElement);
    
    var showInGuiElement = js2xml.createElement('ShowInGui', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(showInGuiElement, parameters.showInGui.toString());
    js2xml.addChildElement(oSImageElement, showInGuiElement);
    
    if (parameters.privacyUri !== null && parameters.privacyUri !== undefined) {
      var privacyUriElement = js2xml.createElement('PrivacyUri', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(privacyUriElement, parameters.privacyUri);
      js2xml.addChildElement(oSImageElement, privacyUriElement);
    }
    
    if (parameters.iconUri !== null && parameters.iconUri !== undefined) {
      var iconUriElement = js2xml.createElement('IconUri', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(iconUriElement, parameters.iconUri);
      js2xml.addChildElement(oSImageElement, iconUriElement);
    }
    
    if (parameters.recommendedVMSize !== null && parameters.recommendedVMSize !== undefined) {
      var recommendedVMSizeElement = js2xml.createElement('RecommendedVMSize', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(recommendedVMSizeElement, parameters.recommendedVMSize);
      js2xml.addChildElement(oSImageElement, recommendedVMSizeElement);
    }
    
    if (parameters.smallIconUri !== null && parameters.smallIconUri !== undefined) {
      var smallIconUriElement = js2xml.createElement('SmallIconUri', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(smallIconUriElement, parameters.smallIconUri);
      js2xml.addChildElement(oSImageElement, smallIconUriElement);
    }
    
    if (parameters.language !== null && parameters.language !== undefined) {
      var languageElement = js2xml.createElement('Language', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(languageElement, parameters.language);
      js2xml.addChildElement(oSImageElement, languageElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var oSImageElement2 = js2xml.getElement(responseDoc, responseDoc, 'OSIMAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (oSImageElement2 !== null && oSImageElement2 !== undefined) {
            var locationElement = js2xml.getElement(responseDoc, oSImageElement2, 'LOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (locationElement !== null && locationElement !== undefined) {
              var locationInstance = locationElement;
              result.location = locationInstance;
            }
            
            var categoryElement = js2xml.getElement(responseDoc, oSImageElement2, 'CATEGORY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (categoryElement !== null && categoryElement !== undefined) {
              var categoryInstance = categoryElement;
              result.category = categoryInstance;
            }
            
            var labelElement2 = js2xml.getElement(responseDoc, oSImageElement2, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (labelElement2 !== null && labelElement2 !== undefined) {
              var labelInstance = labelElement2;
              result.label = labelInstance;
            }
            
            var logicalSizeInGBElement = js2xml.getElement(responseDoc, oSImageElement2, 'LOGICALSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (logicalSizeInGBElement !== null && logicalSizeInGBElement !== undefined && logicalSizeInGBElement.length !== 0) {
              var logicalSizeInGBInstance = parseFloat(logicalSizeInGBElement, 10);
              result.logicalSizeInGB = logicalSizeInGBInstance;
            }
            
            var mediaLinkElement2 = js2xml.getElement(responseDoc, oSImageElement2, 'MEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (mediaLinkElement2 !== null && mediaLinkElement2 !== undefined) {
              var mediaLinkInstance = mediaLinkElement2;
              result.mediaLinkUri = mediaLinkInstance;
            }
            
            var nameElement2 = js2xml.getElement(responseDoc, oSImageElement2, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (nameElement2 !== null && nameElement2 !== undefined) {
              var nameInstance = nameElement2;
              result.name = nameInstance;
            }
            
            var osElement2 = js2xml.getElement(responseDoc, oSImageElement2, 'OS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (osElement2 !== null && osElement2 !== undefined) {
              var osInstance = osElement2;
              result.operatingSystemType = osInstance;
            }
            
            var eulaElement2 = js2xml.getElement(responseDoc, oSImageElement2, 'EULA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (eulaElement2 !== null && eulaElement2 !== undefined) {
              var eulaInstance = eulaElement2;
              result.eula = eulaInstance;
            }
            
            var descriptionElement2 = js2xml.getElement(responseDoc, oSImageElement2, 'DESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (descriptionElement2 !== null && descriptionElement2 !== undefined) {
              var descriptionInstance = descriptionElement2;
              result.description = descriptionInstance;
            }
            
            var imageFamilyElement2 = js2xml.getElement(responseDoc, oSImageElement2, 'IMAGEFAMILY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (imageFamilyElement2 !== null && imageFamilyElement2 !== undefined) {
              var imageFamilyInstance = imageFamilyElement2;
              result.imageFamily = imageFamilyInstance;
            }
            
            var publishedDateElement2 = js2xml.getElement(responseDoc, oSImageElement2, 'PUBLISHEDDATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (publishedDateElement2 !== null && publishedDateElement2 !== undefined && publishedDateElement2.length !== 0) {
              var publishedDateInstance = new Date(publishedDateElement2);
              result.publishedDate = publishedDateInstance;
            }
            
            var publisherNameElement = js2xml.getElement(responseDoc, oSImageElement2, 'PUBLISHERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (publisherNameElement !== null && publisherNameElement !== undefined) {
              var publisherNameInstance = publisherNameElement;
              result.publisherName = publisherNameInstance;
            }
            
            var isPremiumElement2 = js2xml.getElement(responseDoc, oSImageElement2, 'ISPREMIUM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (isPremiumElement2 !== null && isPremiumElement2 !== undefined && isPremiumElement2.length !== 0) {
              var isPremiumInstance = isPremiumElement2 === 'true';
              result.isPremium = isPremiumInstance;
            }
            
            var showInGuiElement2 = js2xml.getElement(responseDoc, oSImageElement2, 'SHOWINGUI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (showInGuiElement2 !== null && showInGuiElement2 !== undefined && showInGuiElement2.length !== 0) {
              var showInGuiInstance = showInGuiElement2 === 'true';
              result.showInGui = showInGuiInstance;
            }
            
            var privacyUriElement2 = js2xml.getElement(responseDoc, oSImageElement2, 'PRIVACYURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (privacyUriElement2 !== null && privacyUriElement2 !== undefined) {
              var privacyUriInstance = privacyUriElement2;
              result.privacyUri = privacyUriInstance;
            }
            
            var iconUriElement2 = js2xml.getElement(responseDoc, oSImageElement2, 'ICONURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (iconUriElement2 !== null && iconUriElement2 !== undefined) {
              var iconUriInstance = iconUriElement2;
              result.iconUri = iconUriInstance;
            }
            
            var recommendedVMSizeElement2 = js2xml.getElement(responseDoc, oSImageElement2, 'RECOMMENDEDVMSIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (recommendedVMSizeElement2 !== null && recommendedVMSizeElement2 !== undefined) {
              var recommendedVMSizeInstance = recommendedVMSizeElement2;
              result.recommendedVMSize = recommendedVMSizeInstance;
            }
            
            var smallIconUriElement2 = js2xml.getElement(responseDoc, oSImageElement2, 'SMALLICONURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (smallIconUriElement2 !== null && smallIconUriElement2 !== undefined) {
              var smallIconUriInstance = smallIconUriElement2;
              result.smallIconUri = smallIconUriInstance;
            }
            
            var languageElement2 = js2xml.getElement(responseDoc, oSImageElement2, 'LANGUAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (languageElement2 !== null && languageElement2 !== undefined) {
              var languageInstance = languageElement2;
              result.language = languageInstance;
            }
            
            var iOTypeElement = js2xml.getElement(responseDoc, oSImageElement2, 'IOTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (iOTypeElement !== null && iOTypeElement !== undefined) {
              var iOTypeInstance = iOTypeElement;
              result.iOType = iOTypeInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Delete OS Image operation deletes the specified OS image from your
   * image repository.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157203.aspx for
   * more information)
   * 
   * @param {string} imageName The name of the image to delete.
   * 
   * @param {boolean} [deleteFromStorage] Specifies that the source blob for
   * the image should also be deleted from storage.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOSImageOperations.prototype.deleteMethod = function(imageName, deleteFromStorage, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (imageName === null || imageName === undefined) {
      return callback(new Error('imageName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/images/';
    url2 = url2 + encodeURIComponent(imageName);
    var queryParameters = [];
    if (deleteFromStorage !== null && deleteFromStorage !== undefined && deleteFromStorage === true) {
      queryParameters.push('comp=media');
    }
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Get OS Image operation retrieves the details for an operating system
   * image from the image repository.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157191.aspx for
   * more information)
   * 
   * @param {string} imageName The name of the OS image to retrieve.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOSImageOperations.prototype.get = function(imageName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (imageName === null || imageName === undefined) {
      return callback(new Error('imageName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/images/';
    url2 = url2 + encodeURIComponent(imageName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var oSImageElement = js2xml.getElement(responseDoc, responseDoc, 'OSIMAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (oSImageElement !== null && oSImageElement !== undefined) {
            var affinityGroupElement = js2xml.getElement(responseDoc, oSImageElement, 'AFFINITYGROUP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (affinityGroupElement !== null && affinityGroupElement !== undefined) {
              var affinityGroupInstance = affinityGroupElement;
              result.affinityGroup = affinityGroupInstance;
            }
            
            var categoryElement = js2xml.getElement(responseDoc, oSImageElement, 'CATEGORY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (categoryElement !== null && categoryElement !== undefined) {
              var categoryInstance = categoryElement;
              result.category = categoryInstance;
            }
            
            var labelElement = js2xml.getElement(responseDoc, oSImageElement, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (labelElement !== null && labelElement !== undefined) {
              var labelInstance = labelElement;
              result.label = labelInstance;
            }
            
            var locationElement = js2xml.getElement(responseDoc, oSImageElement, 'LOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (locationElement !== null && locationElement !== undefined) {
              var locationInstance = locationElement;
              result.location = locationInstance;
            }
            
            var logicalSizeInGBElement = js2xml.getElement(responseDoc, oSImageElement, 'LOGICALSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (logicalSizeInGBElement !== null && logicalSizeInGBElement !== undefined && logicalSizeInGBElement.length !== 0) {
              var logicalSizeInGBInstance = parseFloat(logicalSizeInGBElement, 10);
              result.logicalSizeInGB = logicalSizeInGBInstance;
            }
            
            var mediaLinkElement = js2xml.getElement(responseDoc, oSImageElement, 'MEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (mediaLinkElement !== null && mediaLinkElement !== undefined) {
              var mediaLinkInstance = mediaLinkElement;
              result.mediaLinkUri = mediaLinkInstance;
            }
            
            var nameElement = js2xml.getElement(responseDoc, oSImageElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (nameElement !== null && nameElement !== undefined) {
              var nameInstance = nameElement;
              result.name = nameInstance;
            }
            
            var osElement = js2xml.getElement(responseDoc, oSImageElement, 'OS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (osElement !== null && osElement !== undefined) {
              var osInstance = osElement;
              result.operatingSystemType = osInstance;
            }
            
            var eulaElement = js2xml.getElement(responseDoc, oSImageElement, 'EULA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (eulaElement !== null && eulaElement !== undefined) {
              var eulaInstance = eulaElement;
              result.eula = eulaInstance;
            }
            
            var descriptionElement = js2xml.getElement(responseDoc, oSImageElement, 'DESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (descriptionElement !== null && descriptionElement !== undefined) {
              var descriptionInstance = descriptionElement;
              result.description = descriptionInstance;
            }
            
            var imageFamilyElement = js2xml.getElement(responseDoc, oSImageElement, 'IMAGEFAMILY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (imageFamilyElement !== null && imageFamilyElement !== undefined) {
              var imageFamilyInstance = imageFamilyElement;
              result.imageFamily = imageFamilyInstance;
            }
            
            var showInGuiElement = js2xml.getElement(responseDoc, oSImageElement, 'SHOWINGUI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (showInGuiElement !== null && showInGuiElement !== undefined && showInGuiElement.length !== 0) {
              var showInGuiInstance = showInGuiElement === 'true';
              result.showInGui = showInGuiInstance;
            }
            
            var publishedDateElement = js2xml.getElement(responseDoc, oSImageElement, 'PUBLISHEDDATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (publishedDateElement !== null && publishedDateElement !== undefined && publishedDateElement.length !== 0) {
              var publishedDateInstance = new Date(publishedDateElement);
              result.publishedDate = publishedDateInstance;
            }
            
            var isPremiumElement = js2xml.getElement(responseDoc, oSImageElement, 'ISPREMIUM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (isPremiumElement !== null && isPremiumElement !== undefined && isPremiumElement.length !== 0) {
              var isPremiumInstance = isPremiumElement === 'true';
              result.isPremium = isPremiumInstance;
            }
            
            var iconUriElement = js2xml.getElement(responseDoc, oSImageElement, 'ICONURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (iconUriElement !== null && iconUriElement !== undefined) {
              var iconUriInstance = iconUriElement;
              result.iconUri = iconUriInstance;
            }
            
            var privacyUriElement = js2xml.getElement(responseDoc, oSImageElement, 'PRIVACYURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (privacyUriElement !== null && privacyUriElement !== undefined) {
              var privacyUriInstance = privacyUriElement;
              result.privacyUri = privacyUriInstance;
            }
            
            var recommendedVMSizeElement = js2xml.getElement(responseDoc, oSImageElement, 'RECOMMENDEDVMSIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (recommendedVMSizeElement !== null && recommendedVMSizeElement !== undefined) {
              var recommendedVMSizeInstance = recommendedVMSizeElement;
              result.recommendedVMSize = recommendedVMSizeInstance;
            }
            
            var publisherNameElement = js2xml.getElement(responseDoc, oSImageElement, 'PUBLISHERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (publisherNameElement !== null && publisherNameElement !== undefined) {
              var publisherNameInstance = publisherNameElement;
              result.publisherName = publisherNameInstance;
            }
            
            var smallIconUriElement = js2xml.getElement(responseDoc, oSImageElement, 'SMALLICONURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (smallIconUriElement !== null && smallIconUriElement !== undefined) {
              var smallIconUriInstance = smallIconUriElement;
              result.smallIconUri = smallIconUriInstance;
            }
            
            var languageElement = js2xml.getElement(responseDoc, oSImageElement, 'LANGUAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (languageElement !== null && languageElement !== undefined) {
              var languageInstance = languageElement;
              result.language = languageInstance;
            }
            
            var iOTypeElement = js2xml.getElement(responseDoc, oSImageElement, 'IOTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (iOTypeElement !== null && iOTypeElement !== undefined) {
              var iOTypeInstance = iOTypeElement;
              result.iOType = iOTypeInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets OS Image's properties and its replication details. This operation is
   * only for publishers. You have to be registered as image publisher with
   * Windows Azure to be able to call this.
   * 
   * @param {string} imageName The name of the virtual machine image to
   * replicate.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOSImageOperations.prototype.getDetails = function(imageName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (imageName === null || imageName === undefined) {
      return callback(new Error('imageName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/images/';
    url2 = url2 + encodeURIComponent(imageName);
    url2 = url2 + '/details';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { replicationProgress: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var oSImageDetailsElement = js2xml.getElement(responseDoc, responseDoc, 'OSIMAGEDETAILS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (oSImageDetailsElement !== null && oSImageDetailsElement !== undefined) {
            var isCorruptedElement = js2xml.getElement(responseDoc, oSImageDetailsElement, 'ISCORRUPTED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (isCorruptedElement !== null && isCorruptedElement !== undefined && isCorruptedElement.length !== 0) {
              var isCorruptedInstance = isCorruptedElement === 'true';
              result.isCorrupted = isCorruptedInstance;
            }
            
            var replicationProgressSequenceElement = js2xml.getElement(responseDoc, oSImageDetailsElement, 'REPLICATIONPROGRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (replicationProgressSequenceElement !== null && replicationProgressSequenceElement !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, replicationProgressSequenceElement, 'REPLICATIONPROGRESSELEMENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
                var replicationProgressElement = js2xml.getElements(responseDoc, replicationProgressSequenceElement, 'REPLICATIONPROGRESSELEMENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
                var replicationProgressElementInstance = {};
                result.replicationProgress.push(replicationProgressElementInstance);
                
                var locationElement = js2xml.getElement(responseDoc, replicationProgressElement, 'LOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (locationElement !== null && locationElement !== undefined) {
                  var locationInstance = locationElement;
                  replicationProgressElementInstance.location = locationInstance;
                }
                
                var progressElement = js2xml.getElement(responseDoc, replicationProgressElement, 'PROGRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (progressElement !== null && progressElement !== undefined) {
                  var progressInstance = progressElement;
                  replicationProgressElementInstance.progress = progressInstance;
                }
              }
            }
            
            var computeImageAttributesElement = js2xml.getElement(responseDoc, oSImageDetailsElement, 'COMPUTEIMAGEATTRIBUTES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (computeImageAttributesElement !== null && computeImageAttributesElement !== undefined) {
              var computeImageAttributesInstance = {};
              result.computeImageAttributes = computeImageAttributesInstance;
              
              var offerElement = js2xml.getElement(responseDoc, computeImageAttributesElement, 'OFFER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (offerElement !== null && offerElement !== undefined) {
                var offerInstance = offerElement;
                computeImageAttributesInstance.offer = offerInstance;
              }
              
              var skuElement = js2xml.getElement(responseDoc, computeImageAttributesElement, 'SKU', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (skuElement !== null && skuElement !== undefined) {
                var skuInstance = skuElement;
                computeImageAttributesInstance.sku = skuInstance;
              }
              
              var versionElement = js2xml.getElement(responseDoc, computeImageAttributesElement, 'VERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (versionElement !== null && versionElement !== undefined) {
                var versionInstance = versionElement;
                computeImageAttributesInstance.version = versionInstance;
              }
            }
            
            var marketplaceImageAttributesElement = js2xml.getElement(responseDoc, oSImageDetailsElement, 'MARKETPLACEIMAGEATTRIBUTES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (marketplaceImageAttributesElement !== null && marketplaceImageAttributesElement !== undefined) {
              var marketplaceImageAttributesInstance = {};
              result.marketplaceImageAttributes = marketplaceImageAttributesInstance;
              
              var publisherIdElement = js2xml.getElement(responseDoc, marketplaceImageAttributesElement, 'PUBLISHERID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (publisherIdElement !== null && publisherIdElement !== undefined) {
                var publisherIdInstance = publisherIdElement;
                marketplaceImageAttributesInstance.publisherId = publisherIdInstance;
              }
              
              var planElement = js2xml.getElement(responseDoc, marketplaceImageAttributesElement, 'PLAN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (planElement !== null && planElement !== undefined) {
                var planInstance = {};
                marketplaceImageAttributesInstance.plan = planInstance;
                
                var nameElement = js2xml.getElement(responseDoc, planElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (nameElement !== null && nameElement !== undefined) {
                  var nameInstance = nameElement;
                  planInstance.name = nameInstance;
                }
                
                var publisherElement = js2xml.getElement(responseDoc, planElement, 'PUBLISHER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (publisherElement !== null && publisherElement !== undefined) {
                  var publisherInstance = publisherElement;
                  planInstance.publisher = publisherInstance;
                }
                
                var productElement = js2xml.getElement(responseDoc, planElement, 'PRODUCT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (productElement !== null && productElement !== undefined) {
                  var productInstance = productElement;
                  planInstance.product = productInstance;
                }
              }
            }
            
            var affinityGroupElement = js2xml.getElement(responseDoc, oSImageDetailsElement, 'AFFINITYGROUP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (affinityGroupElement !== null && affinityGroupElement !== undefined) {
              var affinityGroupInstance = affinityGroupElement;
              result.affinityGroup = affinityGroupInstance;
            }
            
            var categoryElement = js2xml.getElement(responseDoc, oSImageDetailsElement, 'CATEGORY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (categoryElement !== null && categoryElement !== undefined) {
              var categoryInstance = categoryElement;
              result.category = categoryInstance;
            }
            
            var labelElement = js2xml.getElement(responseDoc, oSImageDetailsElement, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (labelElement !== null && labelElement !== undefined) {
              var labelInstance = labelElement;
              result.label = labelInstance;
            }
            
            var locationElement2 = js2xml.getElement(responseDoc, oSImageDetailsElement, 'LOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (locationElement2 !== null && locationElement2 !== undefined) {
              var locationInstance2 = locationElement2;
              result.location = locationInstance2;
            }
            
            var logicalSizeInGBElement = js2xml.getElement(responseDoc, oSImageDetailsElement, 'LOGICALSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (logicalSizeInGBElement !== null && logicalSizeInGBElement !== undefined && logicalSizeInGBElement.length !== 0) {
              var logicalSizeInGBInstance = parseFloat(logicalSizeInGBElement, 10);
              result.logicalSizeInGB = logicalSizeInGBInstance;
            }
            
            var mediaLinkElement = js2xml.getElement(responseDoc, oSImageDetailsElement, 'MEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (mediaLinkElement !== null && mediaLinkElement !== undefined) {
              var mediaLinkInstance = mediaLinkElement;
              result.mediaLinkUri = mediaLinkInstance;
            }
            
            var nameElement2 = js2xml.getElement(responseDoc, oSImageDetailsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (nameElement2 !== null && nameElement2 !== undefined) {
              var nameInstance2 = nameElement2;
              result.name = nameInstance2;
            }
            
            var osElement = js2xml.getElement(responseDoc, oSImageDetailsElement, 'OS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (osElement !== null && osElement !== undefined) {
              var osInstance = osElement;
              result.operatingSystemType = osInstance;
            }
            
            var eulaElement = js2xml.getElement(responseDoc, oSImageDetailsElement, 'EULA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (eulaElement !== null && eulaElement !== undefined) {
              var eulaInstance = eulaElement;
              result.eula = eulaInstance;
            }
            
            var descriptionElement = js2xml.getElement(responseDoc, oSImageDetailsElement, 'DESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (descriptionElement !== null && descriptionElement !== undefined) {
              var descriptionInstance = descriptionElement;
              result.description = descriptionInstance;
            }
            
            var imageFamilyElement = js2xml.getElement(responseDoc, oSImageDetailsElement, 'IMAGEFAMILY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (imageFamilyElement !== null && imageFamilyElement !== undefined) {
              var imageFamilyInstance = imageFamilyElement;
              result.imageFamily = imageFamilyInstance;
            }
            
            var showInGuiElement = js2xml.getElement(responseDoc, oSImageDetailsElement, 'SHOWINGUI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (showInGuiElement !== null && showInGuiElement !== undefined && showInGuiElement.length !== 0) {
              var showInGuiInstance = showInGuiElement === 'true';
              result.showInGui = showInGuiInstance;
            }
            
            var publishedDateElement = js2xml.getElement(responseDoc, oSImageDetailsElement, 'PUBLISHEDDATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (publishedDateElement !== null && publishedDateElement !== undefined && publishedDateElement.length !== 0) {
              var publishedDateInstance = new Date(publishedDateElement);
              result.publishedDate = publishedDateInstance;
            }
            
            var isPremiumElement = js2xml.getElement(responseDoc, oSImageDetailsElement, 'ISPREMIUM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (isPremiumElement !== null && isPremiumElement !== undefined && isPremiumElement.length !== 0) {
              var isPremiumInstance = isPremiumElement === 'true';
              result.isPremium = isPremiumInstance;
            }
            
            var iconUriElement = js2xml.getElement(responseDoc, oSImageDetailsElement, 'ICONURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (iconUriElement !== null && iconUriElement !== undefined) {
              var iconUriInstance = iconUriElement;
              result.iconUri = iconUriInstance;
            }
            
            var privacyUriElement = js2xml.getElement(responseDoc, oSImageDetailsElement, 'PRIVACYURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (privacyUriElement !== null && privacyUriElement !== undefined) {
              var privacyUriInstance = privacyUriElement;
              result.privacyUri = privacyUriInstance;
            }
            
            var recommendedVMSizeElement = js2xml.getElement(responseDoc, oSImageDetailsElement, 'RECOMMENDEDVMSIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (recommendedVMSizeElement !== null && recommendedVMSizeElement !== undefined) {
              var recommendedVMSizeInstance = recommendedVMSizeElement;
              result.recommendedVMSize = recommendedVMSizeInstance;
            }
            
            var publisherNameElement = js2xml.getElement(responseDoc, oSImageDetailsElement, 'PUBLISHERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (publisherNameElement !== null && publisherNameElement !== undefined) {
              var publisherNameInstance = publisherNameElement;
              result.publisherName = publisherNameInstance;
            }
            
            var smallIconUriElement = js2xml.getElement(responseDoc, oSImageDetailsElement, 'SMALLICONURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (smallIconUriElement !== null && smallIconUriElement !== undefined) {
              var smallIconUriInstance = smallIconUriElement;
              result.smallIconUri = smallIconUriInstance;
            }
            
            var languageElement = js2xml.getElement(responseDoc, oSImageDetailsElement, 'LANGUAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (languageElement !== null && languageElement !== undefined) {
              var languageInstance = languageElement;
              result.language = languageInstance;
            }
            
            var iOTypeElement = js2xml.getElement(responseDoc, oSImageDetailsElement, 'IOTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (iOTypeElement !== null && iOTypeElement !== undefined) {
              var iOTypeInstance = iOTypeElement;
              result.iOType = iOTypeInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The List OS Images operation retrieves a list of the operating system
   * images from the image repository.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157191.aspx for
   * more information)
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOSImageOperations.prototype.list = function(callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/images';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { images: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var imagesSequenceElement = js2xml.getElement(responseDoc, responseDoc, 'IMAGES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (imagesSequenceElement !== null && imagesSequenceElement !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, imagesSequenceElement, 'OSIMAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
              var imagesElement = js2xml.getElements(responseDoc, imagesSequenceElement, 'OSIMAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
              var oSImageInstance = {};
              result.images.push(oSImageInstance);
              
              var affinityGroupElement = js2xml.getElement(responseDoc, imagesElement, 'AFFINITYGROUP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (affinityGroupElement !== null && affinityGroupElement !== undefined) {
                var affinityGroupInstance = affinityGroupElement;
                oSImageInstance.affinityGroup = affinityGroupInstance;
              }
              
              var categoryElement = js2xml.getElement(responseDoc, imagesElement, 'CATEGORY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (categoryElement !== null && categoryElement !== undefined) {
                var categoryInstance = categoryElement;
                oSImageInstance.category = categoryInstance;
              }
              
              var labelElement = js2xml.getElement(responseDoc, imagesElement, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (labelElement !== null && labelElement !== undefined) {
                var labelInstance = labelElement;
                oSImageInstance.label = labelInstance;
              }
              
              var locationElement = js2xml.getElement(responseDoc, imagesElement, 'LOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (locationElement !== null && locationElement !== undefined) {
                var locationInstance = locationElement;
                oSImageInstance.location = locationInstance;
              }
              
              var logicalSizeInGBElement = js2xml.getElement(responseDoc, imagesElement, 'LOGICALSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (logicalSizeInGBElement !== null && logicalSizeInGBElement !== undefined && logicalSizeInGBElement.length !== 0) {
                var logicalSizeInGBInstance = parseFloat(logicalSizeInGBElement, 10);
                oSImageInstance.logicalSizeInGB = logicalSizeInGBInstance;
              }
              
              var mediaLinkElement = js2xml.getElement(responseDoc, imagesElement, 'MEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (mediaLinkElement !== null && mediaLinkElement !== undefined) {
                var mediaLinkInstance = mediaLinkElement;
                oSImageInstance.mediaLinkUri = mediaLinkInstance;
              }
              
              var nameElement = js2xml.getElement(responseDoc, imagesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (nameElement !== null && nameElement !== undefined) {
                var nameInstance = nameElement;
                oSImageInstance.name = nameInstance;
              }
              
              var osElement = js2xml.getElement(responseDoc, imagesElement, 'OS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (osElement !== null && osElement !== undefined) {
                var osInstance = osElement;
                oSImageInstance.operatingSystemType = osInstance;
              }
              
              var eulaElement = js2xml.getElement(responseDoc, imagesElement, 'EULA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (eulaElement !== null && eulaElement !== undefined) {
                var eulaInstance = eulaElement;
                oSImageInstance.eula = eulaInstance;
              }
              
              var descriptionElement = js2xml.getElement(responseDoc, imagesElement, 'DESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (descriptionElement !== null && descriptionElement !== undefined) {
                var descriptionInstance = descriptionElement;
                oSImageInstance.description = descriptionInstance;
              }
              
              var imageFamilyElement = js2xml.getElement(responseDoc, imagesElement, 'IMAGEFAMILY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (imageFamilyElement !== null && imageFamilyElement !== undefined) {
                var imageFamilyInstance = imageFamilyElement;
                oSImageInstance.imageFamily = imageFamilyInstance;
              }
              
              var showInGuiElement = js2xml.getElement(responseDoc, imagesElement, 'SHOWINGUI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (showInGuiElement !== null && showInGuiElement !== undefined && showInGuiElement.length !== 0) {
                var showInGuiInstance = showInGuiElement === 'true';
                oSImageInstance.showInGui = showInGuiInstance;
              }
              
              var publishedDateElement = js2xml.getElement(responseDoc, imagesElement, 'PUBLISHEDDATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (publishedDateElement !== null && publishedDateElement !== undefined && publishedDateElement.length !== 0) {
                var publishedDateInstance = new Date(publishedDateElement);
                oSImageInstance.publishedDate = publishedDateInstance;
              }
              
              var isPremiumElement = js2xml.getElement(responseDoc, imagesElement, 'ISPREMIUM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (isPremiumElement !== null && isPremiumElement !== undefined && isPremiumElement.length !== 0) {
                var isPremiumInstance = isPremiumElement === 'true';
                oSImageInstance.isPremium = isPremiumInstance;
              }
              
              var privacyUriElement = js2xml.getElement(responseDoc, imagesElement, 'PRIVACYURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (privacyUriElement !== null && privacyUriElement !== undefined) {
                var privacyUriInstance = privacyUriElement;
                oSImageInstance.privacyUri = privacyUriInstance;
              }
              
              var recommendedVMSizeElement = js2xml.getElement(responseDoc, imagesElement, 'RECOMMENDEDVMSIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (recommendedVMSizeElement !== null && recommendedVMSizeElement !== undefined) {
                var recommendedVMSizeInstance = recommendedVMSizeElement;
                oSImageInstance.recommendedVMSize = recommendedVMSizeInstance;
              }
              
              var publisherNameElement = js2xml.getElement(responseDoc, imagesElement, 'PUBLISHERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (publisherNameElement !== null && publisherNameElement !== undefined) {
                var publisherNameInstance = publisherNameElement;
                oSImageInstance.publisherName = publisherNameInstance;
              }
              
              var pricingDetailLinkElement = js2xml.getElement(responseDoc, imagesElement, 'PRICINGDETAILLINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (pricingDetailLinkElement !== null && pricingDetailLinkElement !== undefined) {
                var pricingDetailLinkInstance = pricingDetailLinkElement;
                oSImageInstance.pricingDetailUri = pricingDetailLinkInstance;
              }
              
              var iconUriElement = js2xml.getElement(responseDoc, imagesElement, 'ICONURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (iconUriElement !== null && iconUriElement !== undefined) {
                var iconUriInstance = iconUriElement;
                oSImageInstance.iconUri = iconUriInstance;
              }
              
              var smallIconUriElement = js2xml.getElement(responseDoc, imagesElement, 'SMALLICONURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (smallIconUriElement !== null && smallIconUriElement !== undefined) {
                var smallIconUriInstance = smallIconUriElement;
                oSImageInstance.smallIconUri = smallIconUriInstance;
              }
              
              var languageElement = js2xml.getElement(responseDoc, imagesElement, 'LANGUAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (languageElement !== null && languageElement !== undefined) {
                var languageInstance = languageElement;
                oSImageInstance.language = languageInstance;
              }
              
              var iOTypeElement = js2xml.getElement(responseDoc, imagesElement, 'IOTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (iOTypeElement !== null && iOTypeElement !== undefined) {
                var iOTypeInstance = iOTypeElement;
                oSImageInstance.iOType = iOTypeInstance;
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Replicate an OS image to multiple target locations. This operation is only
   * for publishers. You have to be registered as image publisher with Windows
   * Azure to be able to call this.
   * 
   * @param {string} imageName The name of the virtual machine OS image to
   * replicate.
   * 
   * @param {VirtualMachineOSImageReplicateParameters} parameters Parameters
   * supplied to the Replicate Virtual Machine Image operation.
   * 
   * @param {array} [parameters.targetLocations] The replication target
   * regional locations.Note: The regions in the request body are not
   * additive. If an OS Image has already been replicated to Regions A, B, and
   * C, and a request is made to replicate to Regions A and D, the VM Image
   * will remain in Region A, will be replicated in Region D, and will be
   * unreplicated from Regions B and C.
   * 
   * @param {ComputeImageAttributes} parameters.computeImageAttributes The
   * compute image attributes. Metadata which is required for this image to be
   * useablein the Microsoft.Compute Provider.The combination of values
   * provided for Offer, Sku, and Verison must be unique for a publisher.
   * 
   * @param {string} parameters.computeImageAttributes.offer Gets or sets the
   * publisher defined name of the offer.The allowed characters are uppercase
   * or lowercase letters, digit, hypen(-), period (.).The maximum allowed
   * length is 64 characters.
   * 
   * @param {string} parameters.computeImageAttributes.sku Gets or sets the
   * publisher defined name of the Sku. The allowed characters are uppercase
   * or lowercase letters, digit, hypen(-), period (.). The maximum allowed
   * length is 64 characters.
   * 
   * @param {string} parameters.computeImageAttributes.version Gets or sets the
   * publisher defined version of the image. The allowed characters are digit
   * and period. Format: <MajorVersion>.<MinorVersion>.<Patch>Example: '1.0.0'
   * or '1.1.0' The 3 version number to follow standard of most of the RPs.See
   * http://semver.org/.
   * 
   * @param {MarketplaceImageAttributes}
   * [parameters.marketplaceImageAttributes] The market place image
   * attributes.Metadata which is required for VM Marketplace sourced imagesto
   * be useable in the Microsoft.Compute Provider.
   * 
   * @param {string} [parameters.marketplaceImageAttributes.publisherId] Gets
   * or sets the publisher Id. This is the Microsoft.Compute Provider
   * publisher name to use for image.
   * 
   * @param {Plan} [parameters.marketplaceImageAttributes.plan] Gets or sets
   * the purchase context of any 3rd party artifact.
   * 
   * @param {string} [parameters.marketplaceImageAttributes.plan.name] Gets or
   * sets a user defined name of the 3rd party artifact that is being procured.
   * 
   * @param {string} [parameters.marketplaceImageAttributes.plan.publisher]
   * Gets or sets the publisher of the 3rd party artifact that is being
   * bought.E.g. Contoso.
   * 
   * @param {string} [parameters.marketplaceImageAttributes.plan.product] Gets
   * or sets the 3rd party artifact that is being procured.E.g. Northwind.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOSImageOperations.prototype.replicate = function(imageName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (imageName === null || imageName === undefined) {
      return callback(new Error('imageName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.computeImageAttributes === null || parameters.computeImageAttributes === undefined) {
      return callback(new Error('parameters.computeImageAttributes cannot be null.'));
    }
    if (parameters.computeImageAttributes.offer === null || parameters.computeImageAttributes.offer === undefined) {
      return callback(new Error('parameters.computeImageAttributes.offer cannot be null.'));
    }
    if (parameters.computeImageAttributes.sku === null || parameters.computeImageAttributes.sku === undefined) {
      return callback(new Error('parameters.computeImageAttributes.sku cannot be null.'));
    }
    if (parameters.computeImageAttributes.version === null || parameters.computeImageAttributes.version === undefined) {
      return callback(new Error('parameters.computeImageAttributes.version cannot be null.'));
    }
    if (parameters.marketplaceImageAttributes !== null && parameters.marketplaceImageAttributes !== undefined) {
      if (parameters.marketplaceImageAttributes.plan === null || parameters.marketplaceImageAttributes.plan === undefined) {
        return callback(new Error('parameters.marketplaceImageAttributes.plan cannot be null.'));
      }
      if (parameters.marketplaceImageAttributes.plan.name === null || parameters.marketplaceImageAttributes.plan.name === undefined) {
        return callback(new Error('parameters.marketplaceImageAttributes.plan.name cannot be null.'));
      }
      if (parameters.marketplaceImageAttributes.plan.product === null || parameters.marketplaceImageAttributes.plan.product === undefined) {
        return callback(new Error('parameters.marketplaceImageAttributes.plan.product cannot be null.'));
      }
      if (parameters.marketplaceImageAttributes.plan.publisher === null || parameters.marketplaceImageAttributes.plan.publisher === undefined) {
        return callback(new Error('parameters.marketplaceImageAttributes.plan.publisher cannot be null.'));
      }
      if (parameters.marketplaceImageAttributes.publisherId === null || parameters.marketplaceImageAttributes.publisherId === undefined) {
        return callback(new Error('parameters.marketplaceImageAttributes.publisherId cannot be null.'));
      }
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/images/';
    url2 = url2 + encodeURIComponent(imageName);
    url2 = url2 + '/replicate';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var replicationInputElement = js2xml.createElement('ReplicationInput', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, replicationInputElement);
    
    if (parameters.targetLocations !== null && parameters.targetLocations !== undefined) {
      var targetLocationsSequenceElement = js2xml.createElement('TargetLocations', 'http://schemas.microsoft.com/windowsazure');
      for (var loweredIndex1 = 0; loweredIndex1 < parameters.targetLocations.length; loweredIndex1 = loweredIndex1 + 1) {
        var targetLocationsItem = parameters.targetLocations[loweredIndex1];
        var targetLocationsItemElement = js2xml.createElement('Region', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(targetLocationsItemElement, targetLocationsItem);
        js2xml.addChildElement(targetLocationsSequenceElement, targetLocationsItemElement);
      }
      js2xml.addChildElement(replicationInputElement, targetLocationsSequenceElement);
    }
    
    var computeImageAttributesElement = js2xml.createElement('ComputeImageAttributes', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(replicationInputElement, computeImageAttributesElement);
    
    var offerElement = js2xml.createElement('Offer', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(offerElement, parameters.computeImageAttributes.offer);
    js2xml.addChildElement(computeImageAttributesElement, offerElement);
    
    var skuElement = js2xml.createElement('Sku', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(skuElement, parameters.computeImageAttributes.sku);
    js2xml.addChildElement(computeImageAttributesElement, skuElement);
    
    var versionElement = js2xml.createElement('Version', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(versionElement, parameters.computeImageAttributes.version);
    js2xml.addChildElement(computeImageAttributesElement, versionElement);
    
    if (parameters.marketplaceImageAttributes !== null && parameters.marketplaceImageAttributes !== undefined) {
      var marketplaceImageAttributesElement = js2xml.createElement('MarketplaceImageAttributes', 'http://schemas.microsoft.com/windowsazure');
      js2xml.addChildElement(replicationInputElement, marketplaceImageAttributesElement);
      
      var publisherIdElement = js2xml.createElement('PublisherId', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(publisherIdElement, parameters.marketplaceImageAttributes.publisherId);
      js2xml.addChildElement(marketplaceImageAttributesElement, publisherIdElement);
      
      var planElement = js2xml.createElement('Plan', 'http://schemas.microsoft.com/windowsazure');
      js2xml.addChildElement(marketplaceImageAttributesElement, planElement);
      
      var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(nameElement, parameters.marketplaceImageAttributes.plan.name);
      js2xml.addChildElement(planElement, nameElement);
      
      var publisherElement = js2xml.createElement('Publisher', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(publisherElement, parameters.marketplaceImageAttributes.plan.publisher);
      js2xml.addChildElement(planElement, publisherElement);
      
      var productElement = js2xml.createElement('Product', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(productElement, parameters.marketplaceImageAttributes.plan.product);
      js2xml.addChildElement(planElement, productElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var virtualMachineOSImageReplicateResponseElement = js2xml.getElement(responseDoc, responseDoc, 'VIRTUALMACHINEOSIMAGEREPLICATERESPONSE', '');
          if (virtualMachineOSImageReplicateResponseElement !== null && virtualMachineOSImageReplicateResponseElement !== undefined) {
            var stringElement = js2xml.getElement(responseDoc, virtualMachineOSImageReplicateResponseElement, 'STRING', '');
            if (stringElement !== null && stringElement !== undefined) {
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Share an already replicated OS image. This operation is only for
   * publishers. You have to be registered as image publisher with Windows
   * Azure to be able to call this.
   * 
   * @param {string} imageName The name of the virtual machine image to share.
   * 
   * @param {string} permission The sharing permission: public, msdn, or
   * private.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOSImageOperations.prototype.share = function(imageName, permission, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachineOSImages.beginSharing(imageName, permission, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * Unreplicate an OS image to multiple target locations. This operation is
   * only for publishers. You have to be registered as image publisher with
   * Windows Azure to be able to call this. Note: The operation removes the
   * published copies of the user OS Image. It does not remove the actual user
   * OS Image. To remove the actual user OS Image, the publisher will have to
   * call Delete OS Image.
   * 
   * @param {string} imageName The name of the virtual machine image to
   * replicate. Note: The OS Image Name should be the user OS Image, not the
   * published name of the OS Image.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOSImageOperations.prototype.unreplicate = function(imageName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachineOSImages.beginUnreplicating(imageName, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Update OS Image operation updates an OS image that in your image
   * repository.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj157198.aspx for
   * more information)
   * 
   * @param {string} imageName The name of the virtual machine image to be
   * updated.
   * 
   * @param {VirtualMachineOSImageUpdateParameters} parameters Parameters
   * supplied to the Update Virtual Machine Image operation.
   * 
   * @param {string} parameters.label Specifies the friendly name of the image
   * to be updated. You cannot use this operation to update images provided by
   * the Azure platform.
   * 
   * @param {string} [parameters.eula] Specifies the End User License Agreement
   * that is associated with the image. The value for this element is a
   * string, but it is recommended that the value be a URL that points to a
   * EULA.
   * 
   * @param {string} [parameters.description] Specifies the description of the
   * OS image.
   * 
   * @param {string} [parameters.imageFamily] Specifies a value that can be
   * used to group OS images.
   * 
   * @param {boolean} [parameters.showInGui] When published, should this image
   * show up in the windows azure image gallery or not. True by default.
   * 
   * @param {date} [parameters.publishedDate] Specifies the date when the OS
   * image was added to the image repository.
   * 
   * @param {boolean} [parameters.isPremium] Indicates if the image contains
   * software or associated services that will incur charges above the core
   * price for the virtual machine.
   * 
   * @param {string} [parameters.privacyUri] Specifies the URI that points to a
   * document that contains the privacy policy related to the OS image.
   * 
   * @param {string} [parameters.iconUri] Specifies the URI to the icon that is
   * displayed for the image in the Management Portal.
   * 
   * @param {string} [parameters.recommendedVMSize] Specifies the size to use
   * for the virtual machine that is created from the OS image.
   * 
   * @param {string} [parameters.smallIconUri] Specifies the URI to the small
   * icon that is displayed when the image is presented in the Azure
   * Management Portal. The SmallIconUri element is only available using
   * version 2013-03-01 or higher.
   * 
   * @param {string} [parameters.language] Specifies the language of the image.
   * The Language element is only available using version 2013-03-01 or higher.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOSImageOperations.prototype.update = function(imageName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (imageName === null || imageName === undefined) {
      return callback(new Error('imageName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.label === null || parameters.label === undefined) {
      return callback(new Error('parameters.label cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/images/';
    url2 = url2 + encodeURIComponent(imageName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var oSImageElement = js2xml.createElement('OSImage', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, oSImageElement);
    
    var labelElement = js2xml.createElement('Label', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(labelElement, parameters.label);
    js2xml.addChildElement(oSImageElement, labelElement);
    
    if (parameters.eula !== null && parameters.eula !== undefined) {
      var eulaElement = js2xml.createElement('Eula', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(eulaElement, parameters.eula);
      js2xml.addChildElement(oSImageElement, eulaElement);
    }
    
    if (parameters.description !== null && parameters.description !== undefined) {
      var descriptionElement = js2xml.createElement('Description', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(descriptionElement, parameters.description);
      js2xml.addChildElement(oSImageElement, descriptionElement);
    }
    
    if (parameters.imageFamily !== null && parameters.imageFamily !== undefined) {
      var imageFamilyElement = js2xml.createElement('ImageFamily', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(imageFamilyElement, parameters.imageFamily);
      js2xml.addChildElement(oSImageElement, imageFamilyElement);
    }
    
    if (parameters.showInGui !== null && parameters.showInGui !== undefined) {
      var showInGuiElement = js2xml.createElement('ShowInGui', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(showInGuiElement, parameters.showInGui.toString());
      js2xml.addChildElement(oSImageElement, showInGuiElement);
    }
    
    if (parameters.publishedDate !== null && parameters.publishedDate !== undefined) {
      var publishedDateElement = js2xml.createElement('PublishedDate', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(publishedDateElement, parameters.publishedDate.toISOString());
      js2xml.addChildElement(oSImageElement, publishedDateElement);
    }
    
    if (parameters.isPremium !== null && parameters.isPremium !== undefined) {
      var isPremiumElement = js2xml.createElement('IsPremium', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(isPremiumElement, parameters.isPremium.toString());
      js2xml.addChildElement(oSImageElement, isPremiumElement);
    }
    
    if (parameters.privacyUri !== null && parameters.privacyUri !== undefined) {
      var privacyUriElement = js2xml.createElement('PrivacyUri', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(privacyUriElement, parameters.privacyUri);
      js2xml.addChildElement(oSImageElement, privacyUriElement);
    }
    
    if (parameters.iconUri !== null && parameters.iconUri !== undefined) {
      var iconUriElement = js2xml.createElement('IconUri', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(iconUriElement, parameters.iconUri);
      js2xml.addChildElement(oSImageElement, iconUriElement);
    }
    
    if (parameters.recommendedVMSize !== null && parameters.recommendedVMSize !== undefined) {
      var recommendedVMSizeElement = js2xml.createElement('RecommendedVMSize', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(recommendedVMSizeElement, parameters.recommendedVMSize);
      js2xml.addChildElement(oSImageElement, recommendedVMSizeElement);
    }
    
    if (parameters.smallIconUri !== null && parameters.smallIconUri !== undefined) {
      var smallIconUriElement = js2xml.createElement('SmallIconUri', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(smallIconUriElement, parameters.smallIconUri);
      js2xml.addChildElement(oSImageElement, smallIconUriElement);
    }
    
    if (parameters.language !== null && parameters.language !== undefined) {
      var languageElement = js2xml.createElement('Language', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(languageElement, parameters.language);
      js2xml.addChildElement(oSImageElement, languageElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var oSImageElement2 = js2xml.getElement(responseDoc, responseDoc, 'OSIMAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (oSImageElement2 !== null && oSImageElement2 !== undefined) {
            var locationElement = js2xml.getElement(responseDoc, oSImageElement2, 'LOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (locationElement !== null && locationElement !== undefined) {
              var locationInstance = locationElement;
              result.location = locationInstance;
            }
            
            var categoryElement = js2xml.getElement(responseDoc, oSImageElement2, 'CATEGORY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (categoryElement !== null && categoryElement !== undefined) {
              var categoryInstance = categoryElement;
              result.category = categoryInstance;
            }
            
            var labelElement2 = js2xml.getElement(responseDoc, oSImageElement2, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (labelElement2 !== null && labelElement2 !== undefined) {
              var labelInstance = labelElement2;
              result.label = labelInstance;
            }
            
            var logicalSizeInGBElement = js2xml.getElement(responseDoc, oSImageElement2, 'LOGICALSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (logicalSizeInGBElement !== null && logicalSizeInGBElement !== undefined && logicalSizeInGBElement.length !== 0) {
              var logicalSizeInGBInstance = parseFloat(logicalSizeInGBElement, 10);
              result.logicalSizeInGB = logicalSizeInGBInstance;
            }
            
            var mediaLinkElement = js2xml.getElement(responseDoc, oSImageElement2, 'MEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (mediaLinkElement !== null && mediaLinkElement !== undefined) {
              var mediaLinkInstance = mediaLinkElement;
              result.mediaLinkUri = mediaLinkInstance;
            }
            
            var nameElement = js2xml.getElement(responseDoc, oSImageElement2, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (nameElement !== null && nameElement !== undefined) {
              var nameInstance = nameElement;
              result.name = nameInstance;
            }
            
            var osElement = js2xml.getElement(responseDoc, oSImageElement2, 'OS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (osElement !== null && osElement !== undefined) {
              var osInstance = osElement;
              result.operatingSystemType = osInstance;
            }
            
            var eulaElement2 = js2xml.getElement(responseDoc, oSImageElement2, 'EULA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (eulaElement2 !== null && eulaElement2 !== undefined) {
              var eulaInstance = eulaElement2;
              result.eula = eulaInstance;
            }
            
            var descriptionElement2 = js2xml.getElement(responseDoc, oSImageElement2, 'DESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (descriptionElement2 !== null && descriptionElement2 !== undefined) {
              var descriptionInstance = descriptionElement2;
              result.description = descriptionInstance;
            }
            
            var imageFamilyElement2 = js2xml.getElement(responseDoc, oSImageElement2, 'IMAGEFAMILY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (imageFamilyElement2 !== null && imageFamilyElement2 !== undefined) {
              var imageFamilyInstance = imageFamilyElement2;
              result.imageFamily = imageFamilyInstance;
            }
            
            var publishedDateElement2 = js2xml.getElement(responseDoc, oSImageElement2, 'PUBLISHEDDATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (publishedDateElement2 !== null && publishedDateElement2 !== undefined && publishedDateElement2.length !== 0) {
              var publishedDateInstance = new Date(publishedDateElement2);
              result.publishedDate = publishedDateInstance;
            }
            
            var publisherNameElement = js2xml.getElement(responseDoc, oSImageElement2, 'PUBLISHERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (publisherNameElement !== null && publisherNameElement !== undefined) {
              var publisherNameInstance = publisherNameElement;
              result.publisherName = publisherNameInstance;
            }
            
            var isPremiumElement2 = js2xml.getElement(responseDoc, oSImageElement2, 'ISPREMIUM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (isPremiumElement2 !== null && isPremiumElement2 !== undefined && isPremiumElement2.length !== 0) {
              var isPremiumInstance = isPremiumElement2 === 'true';
              result.isPremium = isPremiumInstance;
            }
            
            var showInGuiElement2 = js2xml.getElement(responseDoc, oSImageElement2, 'SHOWINGUI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (showInGuiElement2 !== null && showInGuiElement2 !== undefined && showInGuiElement2.length !== 0) {
              var showInGuiInstance = showInGuiElement2 === 'true';
              result.showInGui = showInGuiInstance;
            }
            
            var privacyUriElement2 = js2xml.getElement(responseDoc, oSImageElement2, 'PRIVACYURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (privacyUriElement2 !== null && privacyUriElement2 !== undefined) {
              var privacyUriInstance = privacyUriElement2;
              result.privacyUri = privacyUriInstance;
            }
            
            var iconUriElement2 = js2xml.getElement(responseDoc, oSImageElement2, 'ICONURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (iconUriElement2 !== null && iconUriElement2 !== undefined) {
              var iconUriInstance = iconUriElement2;
              result.iconUri = iconUriInstance;
            }
            
            var recommendedVMSizeElement2 = js2xml.getElement(responseDoc, oSImageElement2, 'RECOMMENDEDVMSIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (recommendedVMSizeElement2 !== null && recommendedVMSizeElement2 !== undefined) {
              var recommendedVMSizeInstance = recommendedVMSizeElement2;
              result.recommendedVMSize = recommendedVMSizeInstance;
            }
            
            var smallIconUriElement2 = js2xml.getElement(responseDoc, oSImageElement2, 'SMALLICONURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (smallIconUriElement2 !== null && smallIconUriElement2 !== undefined) {
              var smallIconUriInstance = smallIconUriElement2;
              result.smallIconUri = smallIconUriInstance;
            }
            
            var languageElement2 = js2xml.getElement(responseDoc, oSImageElement2, 'LANGUAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (languageElement2 !== null && languageElement2 !== undefined) {
              var languageInstance = languageElement2;
              result.language = languageInstance;
            }
            
            var iOTypeElement = js2xml.getElement(responseDoc, oSImageElement2, 'IOTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (iOTypeElement !== null && iOTypeElement !== undefined) {
              var iOTypeInstance = iOTypeElement;
              result.iOType = iOTypeInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return VirtualMachineOSImageOperations;
})();

var VirtualMachineVMImageOperations = ( /** @lends VirtualMachineVMImageOperations */ function() {
  /**
   * @class
   * The Service Management API includes operations for managing the virtual
   * machine templates in your subscription.
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [ComputeManagementClient] {@link
   * ComputeManagementClient~ComputeManagementClient}.
   * See [virtualMachineVMImages] {@link
   * ComputeManagementClient~ComputeManagementClient#virtualMachineVMImages}.
   * Initializes a new instance of the VirtualMachineVMImageOperations class.
   * @constructor
   * 
   * @param {ComputeManagementClient} client Reference to the service client.
   */
  function VirtualMachineVMImageOperations(client) {
    this.client = client;
  }
  
  /**
   * The Create VM Image operation creates a VM image that in your image
   * repository.  (see
   * http://msdn.microsoft.com/en-us/library/azure/dn775054.aspx for more
   * information)
   * 
   * @param {VirtualMachineVMImageCreateParameters} parameters Parameters
   * supplied to the virtual machine VM image create operation.
   * 
   * @param {string} parameters.name Gets or sets the name of the image.
   * 
   * @param {string} parameters.label Gets or sets an identifier for the image.
   * 
   * @param {string} [parameters.description] Gets or sets the description of
   * the image.
   * 
   * @param {OSDiskConfigurationCreateParameters}
   * parameters.oSDiskConfiguration Gets or sets configuration information for
   * the operating system disk that is associated with the image.
   * 
   * @param {string} [parameters.oSDiskConfiguration.hostCaching] Gets or sets
   * the platform caching behavior of the operating system disk blob for
   * read/write efficiency.
   * 
   * @param {string} parameters.oSDiskConfiguration.oSState Gets or sets the
   * state of the operating system in the image.
   * 
   * @param {string} parameters.oSDiskConfiguration.os Gets or sets the
   * operating system in the image.
   * 
   * @param {string} parameters.oSDiskConfiguration.mediaLink Gets or sets the
   * location of the blob in Windows Azure storage. The blob location belongs
   * to a storage account in the subscription specified by the
   * <subscription-id> value in the operation call.
   * 
   * @param {array} [parameters.dataDiskConfigurations] Specifies configuration
   * information for the data disks that are associated with the image. A VM
   * Image might not have data disks associated with it.
   * 
   * @param {string} [parameters.language] Gets or sets the language of the
   * image.
   * 
   * @param {string} [parameters.imageFamily] Gets or sets a value that can be
   * used to group VM Images.
   * 
   * @param {string} [parameters.recommendedVMSize] Gets or sets the size to
   * use for the Virtual Machine that is created from the VM Image.
   * 
   * @param {string} [parameters.eula] Gets or sets the End User License
   * Agreement that is associated with the image. The value for this element
   * is a string, but it is recommended that the value be a URL that points to
   * a EULA.
   * 
   * @param {string} [parameters.iconUri] Gets or sets the URI to the icon that
   * is displayed for the image in the Management Portal.
   * 
   * @param {string} [parameters.smallIconUri] Gets or sets the URI to the
   * small icon that is displayed for the image in the Management Portal.
   * 
   * @param {string} [parameters.privacyUri] Gets or sets the URI that points
   * to a document that contains the privacy policy related to the image.
   * 
   * @param {date} [parameters.publishedDate] Gets or sets the date when the
   * image was added to the image repository.
   * 
   * @param {boolean} [parameters.showInGui] Gets or sets whether the VM Images
   * should be listed in the portal.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineVMImageOperations.prototype.beginCreating = function(parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.dataDiskConfigurations !== null && parameters.dataDiskConfigurations !== undefined) {
      for (var loweredIndex1 = 0; loweredIndex1 < parameters.dataDiskConfigurations.length; loweredIndex1 = loweredIndex1 + 1) {
        var dataDiskConfigurationsParameterItem = parameters.dataDiskConfigurations[loweredIndex1];
        if (dataDiskConfigurationsParameterItem.mediaLink === null || dataDiskConfigurationsParameterItem.mediaLink === undefined) {
          return callback(new Error('parameters.dataDiskConfigurations.mediaLink cannot be null.'));
        }
      }
    }
    if (parameters.label === null || parameters.label === undefined) {
      return callback(new Error('parameters.label cannot be null.'));
    }
    if (parameters.name === null || parameters.name === undefined) {
      return callback(new Error('parameters.name cannot be null.'));
    }
    if (parameters.oSDiskConfiguration === null || parameters.oSDiskConfiguration === undefined) {
      return callback(new Error('parameters.oSDiskConfiguration cannot be null.'));
    }
    if (parameters.oSDiskConfiguration.mediaLink === null || parameters.oSDiskConfiguration.mediaLink === undefined) {
      return callback(new Error('parameters.oSDiskConfiguration.mediaLink cannot be null.'));
    }
    if (parameters.oSDiskConfiguration.os === null || parameters.oSDiskConfiguration.os === undefined) {
      return callback(new Error('parameters.oSDiskConfiguration.os cannot be null.'));
    }
    if (parameters.oSDiskConfiguration.oSState === null || parameters.oSDiskConfiguration.oSState === undefined) {
      return callback(new Error('parameters.oSDiskConfiguration.oSState cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/vmimages';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var vMImageElement = js2xml.createElement('VMImage', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, vMImageElement);
    
    var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(nameElement, parameters.name);
    js2xml.addChildElement(vMImageElement, nameElement);
    
    var labelElement = js2xml.createElement('Label', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(labelElement, parameters.label);
    js2xml.addChildElement(vMImageElement, labelElement);
    
    if (parameters.description !== null && parameters.description !== undefined) {
      var descriptionElement = js2xml.createElement('Description', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(descriptionElement, parameters.description);
      js2xml.addChildElement(vMImageElement, descriptionElement);
    }
    
    var oSDiskConfigurationElement = js2xml.createElement('OSDiskConfiguration', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(vMImageElement, oSDiskConfigurationElement);
    
    if (parameters.oSDiskConfiguration.hostCaching !== null && parameters.oSDiskConfiguration.hostCaching !== undefined) {
      var hostCachingElement = js2xml.createElement('HostCaching', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(hostCachingElement, parameters.oSDiskConfiguration.hostCaching);
      js2xml.addChildElement(oSDiskConfigurationElement, hostCachingElement);
    }
    
    var oSStateElement = js2xml.createElement('OSState', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(oSStateElement, parameters.oSDiskConfiguration.oSState);
    js2xml.addChildElement(oSDiskConfigurationElement, oSStateElement);
    
    var osElement = js2xml.createElement('OS', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(osElement, parameters.oSDiskConfiguration.os);
    js2xml.addChildElement(oSDiskConfigurationElement, osElement);
    
    var mediaLinkElement = js2xml.createElement('MediaLink', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(mediaLinkElement, parameters.oSDiskConfiguration.mediaLink);
    js2xml.addChildElement(oSDiskConfigurationElement, mediaLinkElement);
    
    if (parameters.dataDiskConfigurations !== null && parameters.dataDiskConfigurations !== undefined) {
      var dataDiskConfigurationsSequenceElement = js2xml.createElement('DataDiskConfigurations', 'http://schemas.microsoft.com/windowsazure');
      for (var loweredIndex2 = 0; loweredIndex2 < parameters.dataDiskConfigurations.length; loweredIndex2 = loweredIndex2 + 1) {
        var dataDiskConfigurationsItem = parameters.dataDiskConfigurations[loweredIndex2];
        var dataDiskConfigurationElement = js2xml.createElement('DataDiskConfiguration', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(dataDiskConfigurationsSequenceElement, dataDiskConfigurationElement);
        
        if (dataDiskConfigurationsItem.hostCaching !== null && dataDiskConfigurationsItem.hostCaching !== undefined) {
          var hostCachingElement2 = js2xml.createElement('HostCaching', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(hostCachingElement2, dataDiskConfigurationsItem.hostCaching);
          js2xml.addChildElement(dataDiskConfigurationElement, hostCachingElement2);
        }
        
        if (dataDiskConfigurationsItem.logicalUnitNumber !== null && dataDiskConfigurationsItem.logicalUnitNumber !== undefined) {
          var lunElement = js2xml.createElement('Lun', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(lunElement, dataDiskConfigurationsItem.logicalUnitNumber.toString());
          js2xml.addChildElement(dataDiskConfigurationElement, lunElement);
        }
        
        var mediaLinkElement2 = js2xml.createElement('MediaLink', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(mediaLinkElement2, dataDiskConfigurationsItem.mediaLink);
        js2xml.addChildElement(dataDiskConfigurationElement, mediaLinkElement2);
      }
      js2xml.addChildElement(vMImageElement, dataDiskConfigurationsSequenceElement);
    }
    
    if (parameters.language !== null && parameters.language !== undefined) {
      var languageElement = js2xml.createElement('Language', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(languageElement, parameters.language);
      js2xml.addChildElement(vMImageElement, languageElement);
    }
    
    if (parameters.imageFamily !== null && parameters.imageFamily !== undefined) {
      var imageFamilyElement = js2xml.createElement('ImageFamily', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(imageFamilyElement, parameters.imageFamily);
      js2xml.addChildElement(vMImageElement, imageFamilyElement);
    }
    
    if (parameters.recommendedVMSize !== null && parameters.recommendedVMSize !== undefined) {
      var recommendedVMSizeElement = js2xml.createElement('RecommendedVMSize', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(recommendedVMSizeElement, parameters.recommendedVMSize);
      js2xml.addChildElement(vMImageElement, recommendedVMSizeElement);
    }
    
    if (parameters.eula !== null && parameters.eula !== undefined) {
      var eulaElement = js2xml.createElement('Eula', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(eulaElement, parameters.eula);
      js2xml.addChildElement(vMImageElement, eulaElement);
    }
    
    if (parameters.iconUri !== null && parameters.iconUri !== undefined) {
      var iconUriElement = js2xml.createElement('IconUri', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(iconUriElement, parameters.iconUri);
      js2xml.addChildElement(vMImageElement, iconUriElement);
    }
    
    if (parameters.smallIconUri !== null && parameters.smallIconUri !== undefined) {
      var smallIconUriElement = js2xml.createElement('SmallIconUri', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(smallIconUriElement, parameters.smallIconUri);
      js2xml.addChildElement(vMImageElement, smallIconUriElement);
    }
    
    if (parameters.privacyUri !== null && parameters.privacyUri !== undefined) {
      var privacyUriElement = js2xml.createElement('PrivacyUri', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(privacyUriElement, parameters.privacyUri);
      js2xml.addChildElement(vMImageElement, privacyUriElement);
    }
    
    if (parameters.publishedDate !== null && parameters.publishedDate !== undefined) {
      var publishedDateElement = js2xml.createElement('PublishedDate', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(publishedDateElement, parameters.publishedDate.toISOString());
      js2xml.addChildElement(vMImageElement, publishedDateElement);
    }
    
    if (parameters.showInGui !== null && parameters.showInGui !== undefined) {
      var showInGuiElement = js2xml.createElement('ShowInGui', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(showInGuiElement, parameters.showInGui.toString());
      js2xml.addChildElement(vMImageElement, showInGuiElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Begin Deleting Virtual Machine Image operation deletes the specified
   * virtual machine image.
   * 
   * @param {string} vmImageName The name of the virtual machine image to
   * delete.
   * 
   * @param {boolean} [deleteFromStorage] Specifies that the source blob for
   * the image should also be deleted from storage.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineVMImageOperations.prototype.beginDeleting = function(vmImageName, deleteFromStorage, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (vmImageName === null || vmImageName === undefined) {
      return callback(new Error('vmImageName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/vmimages/';
    url2 = url2 + encodeURIComponent(vmImageName);
    var queryParameters = [];
    if (deleteFromStorage !== null && deleteFromStorage !== undefined && deleteFromStorage === true) {
      queryParameters.push('comp=media');
    }
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Share an already replicated VM image. This operation is only for
   * publishers. You have to be registered as image publisher with Windows
   * Azure to be able to call this.
   * 
   * @param {string} vmImageName The name of the virtual machine image to share.
   * 
   * @param {string} permission The sharing permission: public, msdn, or
   * private.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineVMImageOperations.prototype.beginSharing = function(vmImageName, permission, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (vmImageName === null || vmImageName === undefined) {
      return callback(new Error('vmImageName cannot be null.'));
    }
    if (permission === null || permission === undefined) {
      return callback(new Error('permission cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/vmimages/';
    url2 = url2 + encodeURIComponent(vmImageName);
    url2 = url2 + '/shareasync';
    var queryParameters = [];
    queryParameters.push('permission=' + encodeURIComponent(permission));
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Unreplicate an VM image to multiple target locations. This operation is
   * only for publishers. You have to be registered as image publisher with
   * Windows Azure to be able to call this. Note: The operation removes the
   * published copies of the user VM Image. It does not remove the actual user
   * VM Image. To remove the actual user VM Image, the publisher will have to
   * call Delete VM Image.
   * 
   * @param {string} vmImageName The name of the virtual machine image to
   * replicate. Note: The VM Image Name should be the user VM Image, not the
   * published name of the VM Image.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineVMImageOperations.prototype.beginUnreplicating = function(vmImageName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (vmImageName === null || vmImageName === undefined) {
      return callback(new Error('vmImageName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/vmimages/';
    url2 = url2 + encodeURIComponent(vmImageName);
    url2 = url2 + '/unreplicate';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Create VM Image operation creates a VM image that in your image
   * repository.  (see
   * http://msdn.microsoft.com/en-us/library/azure/dn775054.aspx for more
   * information)
   * 
   * @param {VirtualMachineVMImageCreateParameters} parameters Parameters
   * supplied to the Create Virtual Machine Image operation.
   * 
   * @param {string} parameters.name Gets or sets the name of the image.
   * 
   * @param {string} parameters.label Gets or sets an identifier for the image.
   * 
   * @param {string} [parameters.description] Gets or sets the description of
   * the image.
   * 
   * @param {OSDiskConfigurationCreateParameters}
   * parameters.oSDiskConfiguration Gets or sets configuration information for
   * the operating system disk that is associated with the image.
   * 
   * @param {string} [parameters.oSDiskConfiguration.hostCaching] Gets or sets
   * the platform caching behavior of the operating system disk blob for
   * read/write efficiency.
   * 
   * @param {string} parameters.oSDiskConfiguration.oSState Gets or sets the
   * state of the operating system in the image.
   * 
   * @param {string} parameters.oSDiskConfiguration.os Gets or sets the
   * operating system in the image.
   * 
   * @param {string} parameters.oSDiskConfiguration.mediaLink Gets or sets the
   * location of the blob in Windows Azure storage. The blob location belongs
   * to a storage account in the subscription specified by the
   * <subscription-id> value in the operation call.
   * 
   * @param {array} [parameters.dataDiskConfigurations] Specifies configuration
   * information for the data disks that are associated with the image. A VM
   * Image might not have data disks associated with it.
   * 
   * @param {string} [parameters.language] Gets or sets the language of the
   * image.
   * 
   * @param {string} [parameters.imageFamily] Gets or sets a value that can be
   * used to group VM Images.
   * 
   * @param {string} [parameters.recommendedVMSize] Gets or sets the size to
   * use for the Virtual Machine that is created from the VM Image.
   * 
   * @param {string} [parameters.eula] Gets or sets the End User License
   * Agreement that is associated with the image. The value for this element
   * is a string, but it is recommended that the value be a URL that points to
   * a EULA.
   * 
   * @param {string} [parameters.iconUri] Gets or sets the URI to the icon that
   * is displayed for the image in the Management Portal.
   * 
   * @param {string} [parameters.smallIconUri] Gets or sets the URI to the
   * small icon that is displayed for the image in the Management Portal.
   * 
   * @param {string} [parameters.privacyUri] Gets or sets the URI that points
   * to a document that contains the privacy policy related to the image.
   * 
   * @param {date} [parameters.publishedDate] Gets or sets the date when the
   * image was added to the image repository.
   * 
   * @param {boolean} [parameters.showInGui] Gets or sets whether the VM Images
   * should be listed in the portal.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineVMImageOperations.prototype.create = function(parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachineVMImages.beginCreating(parameters, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Delete Virtual Machine Image operation deletes the specified virtual
   * machine image.
   * 
   * @param {string} vmImageName The name of the virtual machine image to
   * delete.
   * 
   * @param {boolean} [deleteFromStorage] Specifies that the source blob for
   * the image should also be deleted from storage.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineVMImageOperations.prototype.deleteMethod = function(vmImageName, deleteFromStorage, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachineVMImages.beginDeleting(vmImageName, deleteFromStorage, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * Gets VMImage's properties and its replication details. This operation is
   * only for publishers. You have to be registered as image publisher with
   * Windows Azure to be able to call this.
   * 
   * @param {string} vmImageName The name of the virtual machine image to
   * replicate.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineVMImageOperations.prototype.getDetails = function(vmImageName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (vmImageName === null || vmImageName === undefined) {
      return callback(new Error('vmImageName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/vmimages/';
    url2 = url2 + encodeURIComponent(vmImageName);
    url2 = url2 + '/details';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { dataDiskConfigurations: [], replicationProgress: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var vMImageDetailsElement = js2xml.getElement(responseDoc, responseDoc, 'VMIMAGEDETAILS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (vMImageDetailsElement !== null && vMImageDetailsElement !== undefined) {
            var nameElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (nameElement !== null && nameElement !== undefined) {
              var nameInstance = nameElement;
              result.name = nameInstance;
            }
            
            var labelElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (labelElement !== null && labelElement !== undefined) {
              var labelInstance = labelElement;
              result.label = labelInstance;
            }
            
            var categoryElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'CATEGORY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (categoryElement !== null && categoryElement !== undefined) {
              var categoryInstance = categoryElement;
              result.category = categoryInstance;
            }
            
            var descriptionElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'DESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (descriptionElement !== null && descriptionElement !== undefined) {
              var descriptionInstance = descriptionElement;
              result.description = descriptionInstance;
            }
            
            var oSDiskConfigurationElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'OSDISKCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (oSDiskConfigurationElement !== null && oSDiskConfigurationElement !== undefined) {
              var oSDiskConfigurationInstance = {};
              result.oSDiskConfiguration = oSDiskConfigurationInstance;
              
              var nameElement2 = js2xml.getElement(responseDoc, oSDiskConfigurationElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (nameElement2 !== null && nameElement2 !== undefined) {
                var nameInstance2 = nameElement2;
                oSDiskConfigurationInstance.name = nameInstance2;
              }
              
              var hostCachingElement = js2xml.getElement(responseDoc, oSDiskConfigurationElement, 'HOSTCACHING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (hostCachingElement !== null && hostCachingElement !== undefined) {
                var hostCachingInstance = hostCachingElement;
                oSDiskConfigurationInstance.hostCaching = hostCachingInstance;
              }
              
              var oSStateElement = js2xml.getElement(responseDoc, oSDiskConfigurationElement, 'OSSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (oSStateElement !== null && oSStateElement !== undefined) {
                var oSStateInstance = oSStateElement;
                oSDiskConfigurationInstance.oSState = oSStateInstance;
              }
              
              var osElement = js2xml.getElement(responseDoc, oSDiskConfigurationElement, 'OS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (osElement !== null && osElement !== undefined) {
                var osInstance = osElement;
                oSDiskConfigurationInstance.operatingSystem = osInstance;
              }
              
              var mediaLinkElement = js2xml.getElement(responseDoc, oSDiskConfigurationElement, 'MEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (mediaLinkElement !== null && mediaLinkElement !== undefined) {
                var mediaLinkInstance = mediaLinkElement;
                oSDiskConfigurationInstance.mediaLink = mediaLinkInstance;
              }
              
              var logicalDiskSizeInGBElement = js2xml.getElement(responseDoc, oSDiskConfigurationElement, 'LOGICALDISKSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (logicalDiskSizeInGBElement !== null && logicalDiskSizeInGBElement !== undefined && logicalDiskSizeInGBElement.length !== 0) {
                var logicalDiskSizeInGBInstance = parseInt(logicalDiskSizeInGBElement, 10);
                oSDiskConfigurationInstance.logicalDiskSizeInGB = logicalDiskSizeInGBInstance;
              }
              
              var iOTypeElement = js2xml.getElement(responseDoc, oSDiskConfigurationElement, 'IOTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (iOTypeElement !== null && iOTypeElement !== undefined) {
                var iOTypeInstance = iOTypeElement;
                oSDiskConfigurationInstance.iOType = iOTypeInstance;
              }
            }
            
            var dataDiskConfigurationsSequenceElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'DATADISKCONFIGURATIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (dataDiskConfigurationsSequenceElement !== null && dataDiskConfigurationsSequenceElement !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, dataDiskConfigurationsSequenceElement, 'DATADISKCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
                var dataDiskConfigurationsElement = js2xml.getElements(responseDoc, dataDiskConfigurationsSequenceElement, 'DATADISKCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
                var dataDiskConfigurationInstance = {};
                result.dataDiskConfigurations.push(dataDiskConfigurationInstance);
                
                var nameElement3 = js2xml.getElement(responseDoc, dataDiskConfigurationsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (nameElement3 !== null && nameElement3 !== undefined) {
                  var nameInstance3 = nameElement3;
                  dataDiskConfigurationInstance.name = nameInstance3;
                }
                
                var hostCachingElement2 = js2xml.getElement(responseDoc, dataDiskConfigurationsElement, 'HOSTCACHING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (hostCachingElement2 !== null && hostCachingElement2 !== undefined) {
                  var hostCachingInstance2 = hostCachingElement2;
                  dataDiskConfigurationInstance.hostCaching = hostCachingInstance2;
                }
                
                var lunElement = js2xml.getElement(responseDoc, dataDiskConfigurationsElement, 'LUN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (lunElement !== null && lunElement !== undefined && lunElement.length !== 0) {
                  var lunInstance = parseInt(lunElement, 10);
                  dataDiskConfigurationInstance.logicalUnitNumber = lunInstance;
                }
                
                var mediaLinkElement2 = js2xml.getElement(responseDoc, dataDiskConfigurationsElement, 'MEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (mediaLinkElement2 !== null && mediaLinkElement2 !== undefined) {
                  var mediaLinkInstance2 = mediaLinkElement2;
                  dataDiskConfigurationInstance.mediaLink = mediaLinkInstance2;
                }
                
                var logicalDiskSizeInGBElement2 = js2xml.getElement(responseDoc, dataDiskConfigurationsElement, 'LOGICALDISKSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (logicalDiskSizeInGBElement2 !== null && logicalDiskSizeInGBElement2 !== undefined && logicalDiskSizeInGBElement2.length !== 0) {
                  var logicalDiskSizeInGBInstance2 = parseInt(logicalDiskSizeInGBElement2, 10);
                  dataDiskConfigurationInstance.logicalDiskSizeInGB = logicalDiskSizeInGBInstance2;
                }
                
                var iOTypeElement2 = js2xml.getElement(responseDoc, dataDiskConfigurationsElement, 'IOTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (iOTypeElement2 !== null && iOTypeElement2 !== undefined) {
                  var iOTypeInstance2 = iOTypeElement2;
                  dataDiskConfigurationInstance.iOType = iOTypeInstance2;
                }
              }
            }
            
            var serviceNameElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'SERVICENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (serviceNameElement !== null && serviceNameElement !== undefined) {
              var serviceNameInstance = serviceNameElement;
              result.serviceName = serviceNameInstance;
            }
            
            var deploymentNameElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'DEPLOYMENTNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (deploymentNameElement !== null && deploymentNameElement !== undefined) {
              var deploymentNameInstance = deploymentNameElement;
              result.deploymentName = deploymentNameInstance;
            }
            
            var roleNameElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'ROLENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (roleNameElement !== null && roleNameElement !== undefined) {
              var roleNameInstance = roleNameElement;
              result.roleName = roleNameInstance;
            }
            
            var affinityGroupElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'AFFINITYGROUP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (affinityGroupElement !== null && affinityGroupElement !== undefined) {
              var affinityGroupInstance = affinityGroupElement;
              result.affinityGroup = affinityGroupInstance;
            }
            
            var locationElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'LOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (locationElement !== null && locationElement !== undefined) {
              var locationInstance = locationElement;
              result.location = locationInstance;
            }
            
            var createdTimeElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'CREATEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (createdTimeElement !== null && createdTimeElement !== undefined && createdTimeElement.length !== 0) {
              var createdTimeInstance = new Date(createdTimeElement);
              result.createdTime = createdTimeInstance;
            }
            
            var modifiedTimeElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'MODIFIEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (modifiedTimeElement !== null && modifiedTimeElement !== undefined && modifiedTimeElement.length !== 0) {
              var modifiedTimeInstance = new Date(modifiedTimeElement);
              result.modifiedTime = modifiedTimeInstance;
            }
            
            var languageElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'LANGUAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (languageElement !== null && languageElement !== undefined) {
              var languageInstance = languageElement;
              result.language = languageInstance;
            }
            
            var imageFamilyElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'IMAGEFAMILY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (imageFamilyElement !== null && imageFamilyElement !== undefined) {
              var imageFamilyInstance = imageFamilyElement;
              result.imageFamily = imageFamilyInstance;
            }
            
            var recommendedVMSizeElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'RECOMMENDEDVMSIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (recommendedVMSizeElement !== null && recommendedVMSizeElement !== undefined) {
              var recommendedVMSizeInstance = recommendedVMSizeElement;
              result.recommendedVMSize = recommendedVMSizeInstance;
            }
            
            var isPremiumElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'ISPREMIUM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (isPremiumElement !== null && isPremiumElement !== undefined && isPremiumElement.length !== 0) {
              var isPremiumInstance = isPremiumElement === 'true';
              result.isPremium = isPremiumInstance;
            }
            
            var eulaElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'EULA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (eulaElement !== null && eulaElement !== undefined) {
              var eulaInstance = eulaElement;
              result.eula = eulaInstance;
            }
            
            var iconUriElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'ICONURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (iconUriElement !== null && iconUriElement !== undefined) {
              var iconUriInstance = iconUriElement;
              result.iconUri = iconUriInstance;
            }
            
            var smallIconUriElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'SMALLICONURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (smallIconUriElement !== null && smallIconUriElement !== undefined) {
              var smallIconUriInstance = smallIconUriElement;
              result.smallIconUri = smallIconUriInstance;
            }
            
            var privacyUriElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'PRIVACYURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (privacyUriElement !== null && privacyUriElement !== undefined) {
              var privacyUriInstance = privacyUriElement;
              result.privacyUri = privacyUriInstance;
            }
            
            var publisherNameElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'PUBLISHERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (publisherNameElement !== null && publisherNameElement !== undefined) {
              var publisherNameInstance = publisherNameElement;
              result.publisherName = publisherNameInstance;
            }
            
            var publishedDateElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'PUBLISHEDDATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (publishedDateElement !== null && publishedDateElement !== undefined && publishedDateElement.length !== 0) {
              var publishedDateInstance = new Date(publishedDateElement);
              result.publishedDate = publishedDateInstance;
            }
            
            var showInGuiElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'SHOWINGUI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (showInGuiElement !== null && showInGuiElement !== undefined && showInGuiElement.length !== 0) {
              var showInGuiInstance = showInGuiElement === 'true';
              result.showInGui = showInGuiInstance;
            }
            
            var pricingDetailLinkElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'PRICINGDETAILLINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (pricingDetailLinkElement !== null && pricingDetailLinkElement !== undefined) {
              var pricingDetailLinkInstance = pricingDetailLinkElement;
              result.pricingDetailLink = pricingDetailLinkInstance;
            }
            
            var isCorruptedElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'ISCORRUPTED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (isCorruptedElement !== null && isCorruptedElement !== undefined && isCorruptedElement.length !== 0) {
              var isCorruptedInstance = isCorruptedElement === 'true';
              result.isCorrupted = isCorruptedInstance;
            }
            
            var publishedNameElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'PUBLISHEDNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (publishedNameElement !== null && publishedNameElement !== undefined) {
              var publishedNameInstance = publishedNameElement;
              result.publishedName = publishedNameInstance;
            }
            
            var sharingStatusElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'SHARINGSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (sharingStatusElement !== null && sharingStatusElement !== undefined) {
              var sharingStatusInstance = sharingStatusElement;
              result.sharingStatus = sharingStatusInstance;
            }
            
            var replicationProgressSequenceElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'REPLICATIONPROGRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (replicationProgressSequenceElement !== null && replicationProgressSequenceElement !== undefined) {
              for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, replicationProgressSequenceElement, 'REPLICATIONPROGRESSELEMENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex2 = loweredIndex2 + 1) {
                var replicationProgressElement = js2xml.getElements(responseDoc, replicationProgressSequenceElement, 'REPLICATIONPROGRESSELEMENT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex2];
                var replicationProgressElementInstance = {};
                result.replicationProgress.push(replicationProgressElementInstance);
                
                var locationElement2 = js2xml.getElement(responseDoc, replicationProgressElement, 'LOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (locationElement2 !== null && locationElement2 !== undefined) {
                  var locationInstance2 = locationElement2;
                  replicationProgressElementInstance.location = locationInstance2;
                }
                
                var progressElement = js2xml.getElement(responseDoc, replicationProgressElement, 'PROGRESS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (progressElement !== null && progressElement !== undefined) {
                  var progressInstance = progressElement;
                  replicationProgressElementInstance.progress = progressInstance;
                }
              }
            }
            
            var computeImageAttributesElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'COMPUTEIMAGEATTRIBUTES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (computeImageAttributesElement !== null && computeImageAttributesElement !== undefined) {
              var computeImageAttributesInstance = {};
              result.computeImageAttributes = computeImageAttributesInstance;
              
              var offerElement = js2xml.getElement(responseDoc, computeImageAttributesElement, 'OFFER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (offerElement !== null && offerElement !== undefined) {
                var offerInstance = offerElement;
                computeImageAttributesInstance.offer = offerInstance;
              }
              
              var skuElement = js2xml.getElement(responseDoc, computeImageAttributesElement, 'SKU', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (skuElement !== null && skuElement !== undefined) {
                var skuInstance = skuElement;
                computeImageAttributesInstance.sku = skuInstance;
              }
              
              var versionElement = js2xml.getElement(responseDoc, computeImageAttributesElement, 'VERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (versionElement !== null && versionElement !== undefined) {
                var versionInstance = versionElement;
                computeImageAttributesInstance.version = versionInstance;
              }
            }
            
            var marketplaceImageAttributesElement = js2xml.getElement(responseDoc, vMImageDetailsElement, 'MARKETPLACEIMAGEATTRIBUTES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (marketplaceImageAttributesElement !== null && marketplaceImageAttributesElement !== undefined) {
              var marketplaceImageAttributesInstance = {};
              result.marketplaceImageAttributes = marketplaceImageAttributesInstance;
              
              var publisherIdElement = js2xml.getElement(responseDoc, marketplaceImageAttributesElement, 'PUBLISHERID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (publisherIdElement !== null && publisherIdElement !== undefined) {
                var publisherIdInstance = publisherIdElement;
                marketplaceImageAttributesInstance.publisherId = publisherIdInstance;
              }
              
              var planElement = js2xml.getElement(responseDoc, marketplaceImageAttributesElement, 'PLAN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (planElement !== null && planElement !== undefined) {
                var planInstance = {};
                marketplaceImageAttributesInstance.plan = planInstance;
                
                var nameElement4 = js2xml.getElement(responseDoc, planElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (nameElement4 !== null && nameElement4 !== undefined) {
                  var nameInstance4 = nameElement4;
                  planInstance.name = nameInstance4;
                }
                
                var publisherElement = js2xml.getElement(responseDoc, planElement, 'PUBLISHER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (publisherElement !== null && publisherElement !== undefined) {
                  var publisherInstance = publisherElement;
                  planInstance.publisher = publisherInstance;
                }
                
                var productElement = js2xml.getElement(responseDoc, planElement, 'PRODUCT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (productElement !== null && productElement !== undefined) {
                  var productInstance = productElement;
                  planInstance.product = productInstance;
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The List Virtual Machine Images operation retrieves a list of the virtual
   * machine images.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineVMImageOperations.prototype.list = function(callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/vmimages';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { vMImages: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var vMImagesSequenceElement = js2xml.getElement(responseDoc, responseDoc, 'VMIMAGES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (vMImagesSequenceElement !== null && vMImagesSequenceElement !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, vMImagesSequenceElement, 'VMIMAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
              var vMImagesElement = js2xml.getElements(responseDoc, vMImagesSequenceElement, 'VMIMAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
              var vMImageInstance = { dataDiskConfigurations: [] };
              result.vMImages.push(vMImageInstance);
              
              var nameElement = js2xml.getElement(responseDoc, vMImagesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (nameElement !== null && nameElement !== undefined) {
                var nameInstance = nameElement;
                vMImageInstance.name = nameInstance;
              }
              
              var labelElement = js2xml.getElement(responseDoc, vMImagesElement, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (labelElement !== null && labelElement !== undefined) {
                var labelInstance = labelElement;
                vMImageInstance.label = labelInstance;
              }
              
              var categoryElement = js2xml.getElement(responseDoc, vMImagesElement, 'CATEGORY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (categoryElement !== null && categoryElement !== undefined) {
                var categoryInstance = categoryElement;
                vMImageInstance.category = categoryInstance;
              }
              
              var descriptionElement = js2xml.getElement(responseDoc, vMImagesElement, 'DESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (descriptionElement !== null && descriptionElement !== undefined) {
                var descriptionInstance = descriptionElement;
                vMImageInstance.description = descriptionInstance;
              }
              
              var oSDiskConfigurationElement = js2xml.getElement(responseDoc, vMImagesElement, 'OSDISKCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (oSDiskConfigurationElement !== null && oSDiskConfigurationElement !== undefined) {
                var oSDiskConfigurationInstance = {};
                vMImageInstance.oSDiskConfiguration = oSDiskConfigurationInstance;
                
                var nameElement2 = js2xml.getElement(responseDoc, oSDiskConfigurationElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (nameElement2 !== null && nameElement2 !== undefined) {
                  var nameInstance2 = nameElement2;
                  oSDiskConfigurationInstance.name = nameInstance2;
                }
                
                var hostCachingElement = js2xml.getElement(responseDoc, oSDiskConfigurationElement, 'HOSTCACHING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (hostCachingElement !== null && hostCachingElement !== undefined) {
                  var hostCachingInstance = hostCachingElement;
                  oSDiskConfigurationInstance.hostCaching = hostCachingInstance;
                }
                
                var oSStateElement = js2xml.getElement(responseDoc, oSDiskConfigurationElement, 'OSSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (oSStateElement !== null && oSStateElement !== undefined) {
                  var oSStateInstance = oSStateElement;
                  oSDiskConfigurationInstance.oSState = oSStateInstance;
                }
                
                var osElement = js2xml.getElement(responseDoc, oSDiskConfigurationElement, 'OS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (osElement !== null && osElement !== undefined) {
                  var osInstance = osElement;
                  oSDiskConfigurationInstance.operatingSystem = osInstance;
                }
                
                var mediaLinkElement = js2xml.getElement(responseDoc, oSDiskConfigurationElement, 'MEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (mediaLinkElement !== null && mediaLinkElement !== undefined) {
                  var mediaLinkInstance = mediaLinkElement;
                  oSDiskConfigurationInstance.mediaLink = mediaLinkInstance;
                }
                
                var logicalDiskSizeInGBElement = js2xml.getElement(responseDoc, oSDiskConfigurationElement, 'LOGICALDISKSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (logicalDiskSizeInGBElement !== null && logicalDiskSizeInGBElement !== undefined && logicalDiskSizeInGBElement.length !== 0) {
                  var logicalDiskSizeInGBInstance = parseInt(logicalDiskSizeInGBElement, 10);
                  oSDiskConfigurationInstance.logicalDiskSizeInGB = logicalDiskSizeInGBInstance;
                }
                
                var iOTypeElement = js2xml.getElement(responseDoc, oSDiskConfigurationElement, 'IOTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (iOTypeElement !== null && iOTypeElement !== undefined) {
                  var iOTypeInstance = iOTypeElement;
                  oSDiskConfigurationInstance.iOType = iOTypeInstance;
                }
              }
              
              var dataDiskConfigurationsSequenceElement = js2xml.getElement(responseDoc, vMImagesElement, 'DATADISKCONFIGURATIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (dataDiskConfigurationsSequenceElement !== null && dataDiskConfigurationsSequenceElement !== undefined) {
                for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, dataDiskConfigurationsSequenceElement, 'DATADISKCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex2 = loweredIndex2 + 1) {
                  var dataDiskConfigurationsElement = js2xml.getElements(responseDoc, dataDiskConfigurationsSequenceElement, 'DATADISKCONFIGURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex2];
                  var dataDiskConfigurationInstance = {};
                  vMImageInstance.dataDiskConfigurations.push(dataDiskConfigurationInstance);
                  
                  var nameElement3 = js2xml.getElement(responseDoc, dataDiskConfigurationsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (nameElement3 !== null && nameElement3 !== undefined) {
                    var nameInstance3 = nameElement3;
                    dataDiskConfigurationInstance.name = nameInstance3;
                  }
                  
                  var hostCachingElement2 = js2xml.getElement(responseDoc, dataDiskConfigurationsElement, 'HOSTCACHING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (hostCachingElement2 !== null && hostCachingElement2 !== undefined) {
                    var hostCachingInstance2 = hostCachingElement2;
                    dataDiskConfigurationInstance.hostCaching = hostCachingInstance2;
                  }
                  
                  var lunElement = js2xml.getElement(responseDoc, dataDiskConfigurationsElement, 'LUN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (lunElement !== null && lunElement !== undefined && lunElement.length !== 0) {
                    var lunInstance = parseInt(lunElement, 10);
                    dataDiskConfigurationInstance.logicalUnitNumber = lunInstance;
                  }
                  
                  var mediaLinkElement2 = js2xml.getElement(responseDoc, dataDiskConfigurationsElement, 'MEDIALINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (mediaLinkElement2 !== null && mediaLinkElement2 !== undefined) {
                    var mediaLinkInstance2 = mediaLinkElement2;
                    dataDiskConfigurationInstance.mediaLink = mediaLinkInstance2;
                  }
                  
                  var logicalDiskSizeInGBElement2 = js2xml.getElement(responseDoc, dataDiskConfigurationsElement, 'LOGICALDISKSIZEINGB', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (logicalDiskSizeInGBElement2 !== null && logicalDiskSizeInGBElement2 !== undefined && logicalDiskSizeInGBElement2.length !== 0) {
                    var logicalDiskSizeInGBInstance2 = parseInt(logicalDiskSizeInGBElement2, 10);
                    dataDiskConfigurationInstance.logicalDiskSizeInGB = logicalDiskSizeInGBInstance2;
                  }
                  
                  var iOTypeElement2 = js2xml.getElement(responseDoc, dataDiskConfigurationsElement, 'IOTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (iOTypeElement2 !== null && iOTypeElement2 !== undefined) {
                    var iOTypeInstance2 = iOTypeElement2;
                    dataDiskConfigurationInstance.iOType = iOTypeInstance2;
                  }
                }
              }
              
              var serviceNameElement = js2xml.getElement(responseDoc, vMImagesElement, 'SERVICENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (serviceNameElement !== null && serviceNameElement !== undefined) {
                var serviceNameInstance = serviceNameElement;
                vMImageInstance.serviceName = serviceNameInstance;
              }
              
              var deploymentNameElement = js2xml.getElement(responseDoc, vMImagesElement, 'DEPLOYMENTNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (deploymentNameElement !== null && deploymentNameElement !== undefined) {
                var deploymentNameInstance = deploymentNameElement;
                vMImageInstance.deploymentName = deploymentNameInstance;
              }
              
              var roleNameElement = js2xml.getElement(responseDoc, vMImagesElement, 'ROLENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (roleNameElement !== null && roleNameElement !== undefined) {
                var roleNameInstance = roleNameElement;
                vMImageInstance.roleName = roleNameInstance;
              }
              
              var affinityGroupElement = js2xml.getElement(responseDoc, vMImagesElement, 'AFFINITYGROUP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (affinityGroupElement !== null && affinityGroupElement !== undefined) {
                var affinityGroupInstance = affinityGroupElement;
                vMImageInstance.affinityGroup = affinityGroupInstance;
              }
              
              var locationElement = js2xml.getElement(responseDoc, vMImagesElement, 'LOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (locationElement !== null && locationElement !== undefined) {
                var locationInstance = locationElement;
                vMImageInstance.location = locationInstance;
              }
              
              var createdTimeElement = js2xml.getElement(responseDoc, vMImagesElement, 'CREATEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (createdTimeElement !== null && createdTimeElement !== undefined && createdTimeElement.length !== 0) {
                var createdTimeInstance = new Date(createdTimeElement);
                vMImageInstance.createdTime = createdTimeInstance;
              }
              
              var modifiedTimeElement = js2xml.getElement(responseDoc, vMImagesElement, 'MODIFIEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (modifiedTimeElement !== null && modifiedTimeElement !== undefined && modifiedTimeElement.length !== 0) {
                var modifiedTimeInstance = new Date(modifiedTimeElement);
                vMImageInstance.modifiedTime = modifiedTimeInstance;
              }
              
              var languageElement = js2xml.getElement(responseDoc, vMImagesElement, 'LANGUAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (languageElement !== null && languageElement !== undefined) {
                var languageInstance = languageElement;
                vMImageInstance.language = languageInstance;
              }
              
              var imageFamilyElement = js2xml.getElement(responseDoc, vMImagesElement, 'IMAGEFAMILY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (imageFamilyElement !== null && imageFamilyElement !== undefined) {
                var imageFamilyInstance = imageFamilyElement;
                vMImageInstance.imageFamily = imageFamilyInstance;
              }
              
              var recommendedVMSizeElement = js2xml.getElement(responseDoc, vMImagesElement, 'RECOMMENDEDVMSIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (recommendedVMSizeElement !== null && recommendedVMSizeElement !== undefined) {
                var recommendedVMSizeInstance = recommendedVMSizeElement;
                vMImageInstance.recommendedVMSize = recommendedVMSizeInstance;
              }
              
              var isPremiumElement = js2xml.getElement(responseDoc, vMImagesElement, 'ISPREMIUM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (isPremiumElement !== null && isPremiumElement !== undefined && isPremiumElement.length !== 0) {
                var isPremiumInstance = isPremiumElement === 'true';
                vMImageInstance.isPremium = isPremiumInstance;
              }
              
              var eulaElement = js2xml.getElement(responseDoc, vMImagesElement, 'EULA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (eulaElement !== null && eulaElement !== undefined) {
                var eulaInstance = eulaElement;
                vMImageInstance.eula = eulaInstance;
              }
              
              var iconUriElement = js2xml.getElement(responseDoc, vMImagesElement, 'ICONURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (iconUriElement !== null && iconUriElement !== undefined) {
                var iconUriInstance = iconUriElement;
                vMImageInstance.iconUri = iconUriInstance;
              }
              
              var smallIconUriElement = js2xml.getElement(responseDoc, vMImagesElement, 'SMALLICONURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (smallIconUriElement !== null && smallIconUriElement !== undefined) {
                var smallIconUriInstance = smallIconUriElement;
                vMImageInstance.smallIconUri = smallIconUriInstance;
              }
              
              var privacyUriElement = js2xml.getElement(responseDoc, vMImagesElement, 'PRIVACYURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (privacyUriElement !== null && privacyUriElement !== undefined) {
                var privacyUriInstance = privacyUriElement;
                vMImageInstance.privacyUri = privacyUriInstance;
              }
              
              var publisherNameElement = js2xml.getElement(responseDoc, vMImagesElement, 'PUBLISHERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (publisherNameElement !== null && publisherNameElement !== undefined) {
                var publisherNameInstance = publisherNameElement;
                vMImageInstance.publisherName = publisherNameInstance;
              }
              
              var publishedDateElement = js2xml.getElement(responseDoc, vMImagesElement, 'PUBLISHEDDATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (publishedDateElement !== null && publishedDateElement !== undefined && publishedDateElement.length !== 0) {
                var publishedDateInstance = new Date(publishedDateElement);
                vMImageInstance.publishedDate = publishedDateInstance;
              }
              
              var showInGuiElement = js2xml.getElement(responseDoc, vMImagesElement, 'SHOWINGUI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (showInGuiElement !== null && showInGuiElement !== undefined && showInGuiElement.length !== 0) {
                var showInGuiInstance = showInGuiElement === 'true';
                vMImageInstance.showInGui = showInGuiInstance;
              }
              
              var pricingDetailLinkElement = js2xml.getElement(responseDoc, vMImagesElement, 'PRICINGDETAILLINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (pricingDetailLinkElement !== null && pricingDetailLinkElement !== undefined) {
                var pricingDetailLinkInstance = pricingDetailLinkElement;
                vMImageInstance.pricingDetailLink = pricingDetailLinkInstance;
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Replicate an VM image to multiple target locations. This operation is only
   * for publishers. You have to be registered as image publisher with Windows
   * Azure to be able to call this.
   * 
   * @param {string} vmImageName The name of the virtual machine image to
   * replicate.
   * 
   * @param {VirtualMachineVMImageReplicateParameters} parameters Parameters
   * supplied to the Replicate Virtual Machine Image operation.
   * 
   * @param {array} parameters.targetLocations The replication target regional
   * locations.Note: The regions in the request body are not additive. If a VM
   * Image has already been replicated to Regions A, B, and C, and a request
   * is made to replicate to Regions A and D, the VM Image will remain in
   * Region A, will be replicated in Region D, and will be unreplicated from
   * Regions B and C.
   * 
   * @param {ComputeImageAttributes} parameters.computeImageAttributes The
   * compute image attributes. Metadata which is required for this image to be
   * useablein the Microsoft.Compute Provider.The combination of values
   * provided for Offer, Sku, and Verison must be unique for a publisher.
   * 
   * @param {string} parameters.computeImageAttributes.offer Gets or sets the
   * publisher defined name of the offer.The allowed characters are uppercase
   * or lowercase letters, digit, hypen(-), period (.).The maximum allowed
   * length is 64 characters.
   * 
   * @param {string} parameters.computeImageAttributes.sku Gets or sets the
   * publisher defined name of the Sku. The allowed characters are uppercase
   * or lowercase letters, digit, hypen(-), period (.). The maximum allowed
   * length is 64 characters.
   * 
   * @param {string} parameters.computeImageAttributes.version Gets or sets the
   * publisher defined version of the image. The allowed characters are digit
   * and period. Format: <MajorVersion>.<MinorVersion>.<Patch>Example: '1.0.0'
   * or '1.1.0' The 3 version number to follow standard of most of the RPs.See
   * http://semver.org/.
   * 
   * @param {MarketplaceImageAttributes}
   * [parameters.marketplaceImageAttributes] The market place image
   * attributes.Metadata which is required for VM Marketplace sourced imagesto
   * be useable in the Microsoft.Compute Provider.
   * 
   * @param {string} [parameters.marketplaceImageAttributes.publisherId] Gets
   * or sets the publisher Id. This is the Microsoft.Compute Provider
   * publisher name to use for image.
   * 
   * @param {Plan} [parameters.marketplaceImageAttributes.plan] Gets or sets
   * the purchase context of any 3rd party artifact.
   * 
   * @param {string} [parameters.marketplaceImageAttributes.plan.name] Gets or
   * sets a user defined name of the 3rd party artifact that is being procured.
   * 
   * @param {string} [parameters.marketplaceImageAttributes.plan.publisher]
   * Gets or sets the publisher of the 3rd party artifact that is being
   * bought.E.g. Contoso.
   * 
   * @param {string} [parameters.marketplaceImageAttributes.plan.product] Gets
   * or sets the 3rd party artifact that is being procured.E.g. Northwind.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineVMImageOperations.prototype.replicate = function(vmImageName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (vmImageName === null || vmImageName === undefined) {
      return callback(new Error('vmImageName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.computeImageAttributes === null || parameters.computeImageAttributes === undefined) {
      return callback(new Error('parameters.computeImageAttributes cannot be null.'));
    }
    if (parameters.computeImageAttributes.offer === null || parameters.computeImageAttributes.offer === undefined) {
      return callback(new Error('parameters.computeImageAttributes.offer cannot be null.'));
    }
    if (parameters.computeImageAttributes.sku === null || parameters.computeImageAttributes.sku === undefined) {
      return callback(new Error('parameters.computeImageAttributes.sku cannot be null.'));
    }
    if (parameters.computeImageAttributes.version === null || parameters.computeImageAttributes.version === undefined) {
      return callback(new Error('parameters.computeImageAttributes.version cannot be null.'));
    }
    if (parameters.marketplaceImageAttributes !== null && parameters.marketplaceImageAttributes !== undefined) {
      if (parameters.marketplaceImageAttributes.plan === null || parameters.marketplaceImageAttributes.plan === undefined) {
        return callback(new Error('parameters.marketplaceImageAttributes.plan cannot be null.'));
      }
      if (parameters.marketplaceImageAttributes.plan.name === null || parameters.marketplaceImageAttributes.plan.name === undefined) {
        return callback(new Error('parameters.marketplaceImageAttributes.plan.name cannot be null.'));
      }
      if (parameters.marketplaceImageAttributes.plan.product === null || parameters.marketplaceImageAttributes.plan.product === undefined) {
        return callback(new Error('parameters.marketplaceImageAttributes.plan.product cannot be null.'));
      }
      if (parameters.marketplaceImageAttributes.plan.publisher === null || parameters.marketplaceImageAttributes.plan.publisher === undefined) {
        return callback(new Error('parameters.marketplaceImageAttributes.plan.publisher cannot be null.'));
      }
      if (parameters.marketplaceImageAttributes.publisherId === null || parameters.marketplaceImageAttributes.publisherId === undefined) {
        return callback(new Error('parameters.marketplaceImageAttributes.publisherId cannot be null.'));
      }
    }
    if (parameters.targetLocations === null || parameters.targetLocations === undefined) {
      return callback(new Error('parameters.targetLocations cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/vmimages/';
    url2 = url2 + encodeURIComponent(vmImageName);
    url2 = url2 + '/replicate';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var replicationInputElement = js2xml.createElement('ReplicationInput', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, replicationInputElement);
    
    var targetLocationsSequenceElement = js2xml.createElement('TargetLocations', 'http://schemas.microsoft.com/windowsazure');
    for (var loweredIndex1 = 0; loweredIndex1 < parameters.targetLocations.length; loweredIndex1 = loweredIndex1 + 1) {
      var targetLocationsItem = parameters.targetLocations[loweredIndex1];
      var targetLocationsItemElement = js2xml.createElement('Region', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(targetLocationsItemElement, targetLocationsItem);
      js2xml.addChildElement(targetLocationsSequenceElement, targetLocationsItemElement);
    }
    js2xml.addChildElement(replicationInputElement, targetLocationsSequenceElement);
    
    var computeImageAttributesElement = js2xml.createElement('ComputeImageAttributes', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(replicationInputElement, computeImageAttributesElement);
    
    var offerElement = js2xml.createElement('Offer', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(offerElement, parameters.computeImageAttributes.offer);
    js2xml.addChildElement(computeImageAttributesElement, offerElement);
    
    var skuElement = js2xml.createElement('Sku', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(skuElement, parameters.computeImageAttributes.sku);
    js2xml.addChildElement(computeImageAttributesElement, skuElement);
    
    var versionElement = js2xml.createElement('Version', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(versionElement, parameters.computeImageAttributes.version);
    js2xml.addChildElement(computeImageAttributesElement, versionElement);
    
    if (parameters.marketplaceImageAttributes !== null && parameters.marketplaceImageAttributes !== undefined) {
      var marketplaceImageAttributesElement = js2xml.createElement('MarketplaceImageAttributes', 'http://schemas.microsoft.com/windowsazure');
      js2xml.addChildElement(replicationInputElement, marketplaceImageAttributesElement);
      
      var publisherIdElement = js2xml.createElement('PublisherId', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(publisherIdElement, parameters.marketplaceImageAttributes.publisherId);
      js2xml.addChildElement(marketplaceImageAttributesElement, publisherIdElement);
      
      var planElement = js2xml.createElement('Plan', 'http://schemas.microsoft.com/windowsazure');
      js2xml.addChildElement(marketplaceImageAttributesElement, planElement);
      
      var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(nameElement, parameters.marketplaceImageAttributes.plan.name);
      js2xml.addChildElement(planElement, nameElement);
      
      var publisherElement = js2xml.createElement('Publisher', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(publisherElement, parameters.marketplaceImageAttributes.plan.publisher);
      js2xml.addChildElement(planElement, publisherElement);
      
      var productElement = js2xml.createElement('Product', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(productElement, parameters.marketplaceImageAttributes.plan.product);
      js2xml.addChildElement(planElement, productElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var virtualMachineVMImageReplicateResponseElement = js2xml.getElement(responseDoc, responseDoc, 'VIRTUALMACHINEVMIMAGEREPLICATERESPONSE', '');
          if (virtualMachineVMImageReplicateResponseElement !== null && virtualMachineVMImageReplicateResponseElement !== undefined) {
            var stringElement = js2xml.getElement(responseDoc, virtualMachineVMImageReplicateResponseElement, 'STRING', '');
            if (stringElement !== null && stringElement !== undefined) {
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Share an already replicated VM image. This operation is only for
   * publishers. You have to be registered as image publisher with Windows
   * Azure to be able to call this.
   * 
   * @param {string} vmImageName The name of the virtual machine image to share.
   * 
   * @param {string} permission The sharing permission: public, msdn, or
   * private.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineVMImageOperations.prototype.share = function(vmImageName, permission, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachineVMImages.beginSharing(vmImageName, permission, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * Unreplicate an VM image to multiple target locations. This operation is
   * only for publishers. You have to be registered as image publisher with
   * Windows Azure to be able to call this. Note: The operation removes the
   * published copies of the user VM Image. It does not remove the actual user
   * VM Image. To remove the actual user VM Image, the publisher will have to
   * call Delete VM Image.
   * 
   * @param {string} vmImageName The name of the virtual machine image to
   * replicate. Note: The VM Image Name should be the user VM Image, not the
   * published name of the VM Image.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineVMImageOperations.prototype.unreplicate = function(vmImageName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachineVMImages.beginUnreplicating(vmImageName, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(result.requestId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.error !== null && result2.error !== undefined) {
                    var ex = new Error(result2.error.code + ' : ' + result2.error.message);
                    ex.error = new Error();
                    ex.error.code = result2.error.code;
                    ex.error.message = result2.error.message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The Update VM Image operation updates a VM image that in your image
   * repository.
   * 
   * @param {string} imageName The name of the virtual machine image to be
   * updated.
   * 
   * @param {VirtualMachineVMImageUpdateParameters} parameters Parameters
   * supplied to the Update Virtual Machine Image operation.
   * 
   * @param {string} parameters.label Specifies the friendly name of the image
   * to be updated. You cannot use this operation to update images provided by
   * the Azure platform.
   * 
   * @param {OSDiskConfigurationUpdateParameters}
   * [parameters.oSDiskConfiguration] Optional. The OS Disk Configuration.
   * 
   * @param {string} [parameters.oSDiskConfiguration.hostCaching] Specifies the
   * platform caching behavior of the operating system disk blob for
   * read/write efficiency.
   * 
   * @param {array} [parameters.dataDiskConfigurations] Optional. The Data Disk
   * Configurations.
   * 
   * @param {string} [parameters.description] Specifies the description of the
   * OS image.
   * 
   * @param {string} [parameters.language] Specifies the language of the image.
   * 
   * @param {string} [parameters.imageFamily] Specifies a value that can be
   * used to group OS images.
   * 
   * @param {string} [parameters.recommendedVMSize] Specifies the size to use
   * for the virtual machine that is created from the OS image.
   * 
   * @param {string} [parameters.eula] Specifies the End User License Agreement
   * that is associated with the image. The value for this element is a
   * string, but it is recommended that the value be a URL that points to a
   * EULA.
   * 
   * @param {string} [parameters.iconUri] Specifies the URI to the icon that is
   * displayed for the image in the Management Portal.
   * 
   * @param {string} [parameters.smallIconUri] Specifies the URI to the small
   * icon that is displayed when the image is presented in the Azure
   * Management Portal.
   * 
   * @param {string} [parameters.privacyUri] Specifies the URI that points to a
   * document that contains the privacy policy related to the OS image.
   * 
   * @param {date} [parameters.publishedDate] Specifies the date when the OS
   * image was added to the image repository.
   * 
   * @param {boolean} [parameters.showInGui] Optional. True or False.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineVMImageOperations.prototype.update = function(imageName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (imageName === null || imageName === undefined) {
      return callback(new Error('imageName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.label === null || parameters.label === undefined) {
      return callback(new Error('parameters.label cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/vmimages/';
    url2 = url2 + encodeURIComponent(imageName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2016-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var vMImageElement = js2xml.createElement('VMImage', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, vMImageElement);
    
    var labelElement = js2xml.createElement('Label', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(labelElement, parameters.label);
    js2xml.addChildElement(vMImageElement, labelElement);
    
    if (parameters.oSDiskConfiguration !== null && parameters.oSDiskConfiguration !== undefined) {
      var oSDiskConfigurationElement = js2xml.createElement('OSDiskConfiguration', 'http://schemas.microsoft.com/windowsazure');
      js2xml.addChildElement(vMImageElement, oSDiskConfigurationElement);
      
      if (parameters.oSDiskConfiguration.hostCaching !== null && parameters.oSDiskConfiguration.hostCaching !== undefined) {
        var hostCachingElement = js2xml.createElement('HostCaching', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(hostCachingElement, parameters.oSDiskConfiguration.hostCaching);
        js2xml.addChildElement(oSDiskConfigurationElement, hostCachingElement);
      }
    }
    
    if (parameters.dataDiskConfigurations !== null && parameters.dataDiskConfigurations !== undefined) {
      var dataDiskConfigurationsSequenceElement = js2xml.createElement('DataDiskConfigurations', 'http://schemas.microsoft.com/windowsazure');
      for (var loweredIndex1 = 0; loweredIndex1 < parameters.dataDiskConfigurations.length; loweredIndex1 = loweredIndex1 + 1) {
        var dataDiskConfigurationsItem = parameters.dataDiskConfigurations[loweredIndex1];
        var dataDiskConfigurationElement = js2xml.createElement('DataDiskConfiguration', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(dataDiskConfigurationsSequenceElement, dataDiskConfigurationElement);
        
        if (dataDiskConfigurationsItem.name !== null && dataDiskConfigurationsItem.name !== undefined) {
          var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(nameElement, dataDiskConfigurationsItem.name);
          js2xml.addChildElement(dataDiskConfigurationElement, nameElement);
        }
        
        if (dataDiskConfigurationsItem.hostCaching !== null && dataDiskConfigurationsItem.hostCaching !== undefined) {
          var hostCachingElement2 = js2xml.createElement('HostCaching', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(hostCachingElement2, dataDiskConfigurationsItem.hostCaching);
          js2xml.addChildElement(dataDiskConfigurationElement, hostCachingElement2);
        }
        
        if (dataDiskConfigurationsItem.logicalUnitNumber !== null && dataDiskConfigurationsItem.logicalUnitNumber !== undefined) {
          var lunElement = js2xml.createElement('Lun', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(lunElement, dataDiskConfigurationsItem.logicalUnitNumber.toString());
          js2xml.addChildElement(dataDiskConfigurationElement, lunElement);
        }
      }
      js2xml.addChildElement(vMImageElement, dataDiskConfigurationsSequenceElement);
    }
    
    if (parameters.description !== null && parameters.description !== undefined) {
      var descriptionElement = js2xml.createElement('Description', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(descriptionElement, parameters.description);
      js2xml.addChildElement(vMImageElement, descriptionElement);
    }
    
    if (parameters.language !== null && parameters.language !== undefined) {
      var languageElement = js2xml.createElement('Language', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(languageElement, parameters.language);
      js2xml.addChildElement(vMImageElement, languageElement);
    }
    
    if (parameters.imageFamily !== null && parameters.imageFamily !== undefined) {
      var imageFamilyElement = js2xml.createElement('ImageFamily', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(imageFamilyElement, parameters.imageFamily);
      js2xml.addChildElement(vMImageElement, imageFamilyElement);
    }
    
    if (parameters.recommendedVMSize !== null && parameters.recommendedVMSize !== undefined) {
      var recommendedVMSizeElement = js2xml.createElement('RecommendedVMSize', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(recommendedVMSizeElement, parameters.recommendedVMSize);
      js2xml.addChildElement(vMImageElement, recommendedVMSizeElement);
    }
    
    if (parameters.eula !== null && parameters.eula !== undefined) {
      var eulaElement = js2xml.createElement('Eula', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(eulaElement, parameters.eula);
      js2xml.addChildElement(vMImageElement, eulaElement);
    }
    
    if (parameters.iconUri !== null && parameters.iconUri !== undefined) {
      var iconUriElement = js2xml.createElement('IconUri', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(iconUriElement, parameters.iconUri);
      js2xml.addChildElement(vMImageElement, iconUriElement);
    }
    
    if (parameters.smallIconUri !== null && parameters.smallIconUri !== undefined) {
      var smallIconUriElement = js2xml.createElement('SmallIconUri', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(smallIconUriElement, parameters.smallIconUri);
      js2xml.addChildElement(vMImageElement, smallIconUriElement);
    }
    
    if (parameters.privacyUri !== null && parameters.privacyUri !== undefined) {
      var privacyUriElement = js2xml.createElement('PrivacyUri', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(privacyUriElement, parameters.privacyUri);
      js2xml.addChildElement(vMImageElement, privacyUriElement);
    }
    
    if (parameters.publishedDate !== null && parameters.publishedDate !== undefined) {
      var publishedDateElement = js2xml.createElement('PublishedDate', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(publishedDateElement, parameters.publishedDate.toISOString());
      js2xml.addChildElement(vMImageElement, publishedDateElement);
    }
    
    if (parameters.showInGui !== null && parameters.showInGui !== undefined) {
      var showInGuiElement = js2xml.createElement('ShowInGui', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(showInGuiElement, parameters.showInGui.toString());
      js2xml.addChildElement(vMImageElement, showInGuiElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return VirtualMachineVMImageOperations;
})();
