/* 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 _ = require('underscore');
var azureCommon = require('azure-common');
var Service = azureCommon.Service;
var WebResource = azureCommon.WebResource;
var OperationStatus = azureCommon.OperationStatus;

var ComputeManagementClient = ( /** @lends ComputeManagementClient */ function() {
  /**
   * @class
   * The Compute Management Client.
   * 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.azure.com';
    }
    if (this.apiVersion === null || this.apiVersion === undefined) {
      this.apiVersion = '2015-06-15';
    }
    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
     * [AvailabilitySetOperations](-AvailabilitySetOperations.html) object.
     * @type {object}
     */
    this.availabilitySets = new AvailabilitySetOperations(this);
    /**
     * Provides an instance of the [UsageOperations](-UsageOperations.html)
     * object.
     * @type {object}
     */
    this.usage = new UsageOperations(this);
    /**
     * Provides an instance of the
     * [VirtualMachineExtensionImageOperations](-VirtualMachineExtensionImageOperations.html)
     * object.
     * @type {object}
     */
    this.virtualMachineExtensionImages = new VirtualMachineExtensionImageOperations(this);
    /**
     * Provides an instance of the
     * [VirtualMachineExtensionOperations](-VirtualMachineExtensionOperations.html)
     * object.
     * @type {object}
     */
    this.virtualMachineExtensions = new VirtualMachineExtensionOperations(this);
    /**
     * Provides an instance of the
     * [VirtualMachineImageOperations](-VirtualMachineImageOperations.html)
     * object.
     * @type {object}
     */
    this.virtualMachineImages = new VirtualMachineImageOperations(this);
    /**
     * Provides an instance of the
     * [VirtualMachineOperations](-VirtualMachineOperations.html) object.
     * @type {object}
     */
    this.virtualMachines = new VirtualMachineOperations(this);
    /**
     * Provides an instance of the
     * [VirtualMachineSizeOperations](-VirtualMachineSizeOperations.html)
     * object.
     * @type {object}
     */
    this.virtualMachineSizes = new VirtualMachineSizeOperations(this);
  }
  
  util.inherits(ComputeManagementClient, Service);
  
  /**
   * The Get Delete Operation Status operation returns the status of the
   * specified operation. After calling an asynchronous operation, you can
   * call GetDeleteOperationStatus to determine whether the operation has
   * succeeded, failed, or is still in progress.
   * 
   * @param {string} operationStatusLink Location value returned by the Begin
   * operation.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ComputeManagementClient.prototype.getDeleteOperationStatus = function(operationStatusLink, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (operationStatusLink === null || operationStatusLink === undefined) {
      return callback(new Error('operationStatusLink cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + operationStatusLink;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    
    // 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 && statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200 || statusCode === 202) {
        var responseContent = body;
        result = {};
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var operationIdValue = responseDoc['operationId'];
          if (operationIdValue !== null && operationIdValue !== undefined) {
            var operationIdInstance = operationIdValue;
            result.trackingOperationId = operationIdInstance;
          }
          
          var statusValue = responseDoc['status'];
          if (statusValue !== null && statusValue !== undefined) {
            var statusInstance = statusValue;
            result.status = statusInstance;
          }
          
          var startTimeValue = responseDoc['startTime'];
          if (startTimeValue !== null && startTimeValue !== undefined) {
            var startTimeInstance = startTimeValue;
            result.startTime = startTimeInstance;
          }
          
          var endTimeValue = responseDoc['endTime'];
          if (endTimeValue !== null && endTimeValue !== undefined) {
            var endTimeInstance = endTimeValue;
            result.endTime = endTimeInstance;
          }
          
          var errorValue = responseDoc['error'];
          if (errorValue !== null && errorValue !== undefined) {
            var errorInstance = { details: [] };
            result.error = errorInstance;
            
            var detailsArray = errorValue['details'];
            if (detailsArray !== null && detailsArray !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < detailsArray.length; loweredIndex1 = loweredIndex1 + 1) {
                var detailsValue = detailsArray[loweredIndex1];
                var apiErrorBaseInstance = {};
                errorInstance.details.push(apiErrorBaseInstance);
                
                var codeValue = detailsValue['code'];
                if (codeValue !== null && codeValue !== undefined) {
                  var codeInstance = codeValue;
                  apiErrorBaseInstance.code = codeInstance;
                }
                
                var targetValue = detailsValue['target'];
                if (targetValue !== null && targetValue !== undefined) {
                  var targetInstance = targetValue;
                  apiErrorBaseInstance.target = targetInstance;
                }
                
                var messageValue = detailsValue['message'];
                if (messageValue !== null && messageValue !== undefined) {
                  var messageInstance = messageValue;
                  apiErrorBaseInstance.message = messageInstance;
                }
              }
            }
            
            var innererrorValue = errorValue['innererror'];
            if (innererrorValue !== null && innererrorValue !== undefined) {
              var innererrorInstance = {};
              errorInstance.innerError = innererrorInstance;
              
              var exceptiontypeValue = innererrorValue['exceptiontype'];
              if (exceptiontypeValue !== null && exceptiontypeValue !== undefined) {
                var exceptiontypeInstance = exceptiontypeValue;
                innererrorInstance.exceptionType = exceptiontypeInstance;
              }
              
              var errordetailValue = innererrorValue['errordetail'];
              if (errordetailValue !== null && errordetailValue !== undefined) {
                var errordetailInstance = errordetailValue;
                innererrorInstance.errorDetail = errordetailInstance;
              }
            }
            
            var codeValue2 = errorValue['code'];
            if (codeValue2 !== null && codeValue2 !== undefined) {
              var codeInstance2 = codeValue2;
              errorInstance.code = codeInstance2;
            }
            
            var targetValue2 = errorValue['target'];
            if (targetValue2 !== null && targetValue2 !== undefined) {
              var targetInstance2 = targetValue2;
              errorInstance.target = targetInstance2;
            }
            
            var messageValue2 = errorValue['message'];
            if (messageValue2 !== null && messageValue2 !== undefined) {
              var messageInstance2 = messageValue2;
              errorInstance.message = messageInstance2;
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The Get Operation Status operation returns the status of the specified
   * operation. After calling an asynchronous operation, you can call
   * GetLongRunningOperationStatus to determine whether the operation has
   * succeeded, failed, or is still in progress.
   * 
   * @param {string} operationStatusLink Location value returned by the Begin
   * operation.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ComputeManagementClient.prototype.getLongRunningOperationStatus = function(operationStatusLink, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (operationStatusLink === null || operationStatusLink === undefined) {
      return callback(new Error('operationStatusLink cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + operationStatusLink;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    
    // 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 && statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200 || statusCode === 202) {
        var responseContent = body;
        result = {};
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var operationIdValue = responseDoc['operationId'];
          if (operationIdValue !== null && operationIdValue !== undefined) {
            var operationIdInstance = operationIdValue;
            result.trackingOperationId = operationIdInstance;
          }
          
          var statusValue = responseDoc['status'];
          if (statusValue !== null && statusValue !== undefined) {
            var statusInstance = statusValue;
            result.status = statusInstance;
          }
          
          var startTimeValue = responseDoc['startTime'];
          if (startTimeValue !== null && startTimeValue !== undefined) {
            var startTimeInstance = startTimeValue;
            result.startTime = startTimeInstance;
          }
          
          var endTimeValue = responseDoc['endTime'];
          if (endTimeValue !== null && endTimeValue !== undefined) {
            var endTimeInstance = endTimeValue;
            result.endTime = endTimeInstance;
          }
          
          var propertiesValue = responseDoc['properties'];
          if (propertiesValue !== null && propertiesValue !== undefined) {
            var outputValue = propertiesValue['output'];
            if (outputValue !== null && outputValue !== undefined) {
              var outputInstance = outputValue;
              result.output = outputInstance;
            }
          }
          
          var errorValue = responseDoc['error'];
          if (errorValue !== null && errorValue !== undefined) {
            var errorInstance = { details: [] };
            result.error = errorInstance;
            
            var detailsArray = errorValue['details'];
            if (detailsArray !== null && detailsArray !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < detailsArray.length; loweredIndex1 = loweredIndex1 + 1) {
                var detailsValue = detailsArray[loweredIndex1];
                var apiErrorBaseInstance = {};
                errorInstance.details.push(apiErrorBaseInstance);
                
                var codeValue = detailsValue['code'];
                if (codeValue !== null && codeValue !== undefined) {
                  var codeInstance = codeValue;
                  apiErrorBaseInstance.code = codeInstance;
                }
                
                var targetValue = detailsValue['target'];
                if (targetValue !== null && targetValue !== undefined) {
                  var targetInstance = targetValue;
                  apiErrorBaseInstance.target = targetInstance;
                }
                
                var messageValue = detailsValue['message'];
                if (messageValue !== null && messageValue !== undefined) {
                  var messageInstance = messageValue;
                  apiErrorBaseInstance.message = messageInstance;
                }
              }
            }
            
            var innererrorValue = errorValue['innererror'];
            if (innererrorValue !== null && innererrorValue !== undefined) {
              var innererrorInstance = {};
              errorInstance.innerError = innererrorInstance;
              
              var exceptiontypeValue = innererrorValue['exceptiontype'];
              if (exceptiontypeValue !== null && exceptiontypeValue !== undefined) {
                var exceptiontypeInstance = exceptiontypeValue;
                innererrorInstance.exceptionType = exceptiontypeInstance;
              }
              
              var errordetailValue = innererrorValue['errordetail'];
              if (errordetailValue !== null && errordetailValue !== undefined) {
                var errordetailInstance = errordetailValue;
                innererrorInstance.errorDetail = errordetailInstance;
              }
            }
            
            var codeValue2 = errorValue['code'];
            if (codeValue2 !== null && codeValue2 !== undefined) {
              var codeInstance2 = codeValue2;
              errorInstance.code = codeInstance2;
            }
            
            var targetValue2 = errorValue['target'];
            if (targetValue2 !== null && targetValue2 !== undefined) {
              var targetInstance2 = targetValue2;
              errorInstance.target = targetInstance2;
            }
            
            var messageValue2 = errorValue['message'];
            if (messageValue2 !== null && messageValue2 !== undefined) {
              var messageInstance2 = messageValue2;
              errorInstance.message = messageInstance2;
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return ComputeManagementClient;
})();
exports.ComputeManagementClient = ComputeManagementClient;

var AvailabilitySetOperations = ( /** @lends AvailabilitySetOperations */ function() {
  /**
   * @class
   * Operations for managing the availability sets in compute management.
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [ComputeManagementClient] {@link
   * ComputeManagementClient~ComputeManagementClient}.
   * See [availabilitySets] {@link
   * ComputeManagementClient~ComputeManagementClient#availabilitySets}.
   * Initializes a new instance of the AvailabilitySetOperations class.
   * @constructor
   * 
   * @param {ComputeManagementClient} client Reference to the service client.
   */
  function AvailabilitySetOperations(client) {
    this.client = client;
  }
  
  /**
   * The operation to create or update the availability set.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {AvailabilitySet} parameters Parameters supplied to the Create
   * Availability Set operation.
   * 
   * @param {number} [parameters.platformUpdateDomainCount] Gets or sets Update
   * Domain count.
   * 
   * @param {number} [parameters.platformFaultDomainCount] Gets or sets Fault
   * Domain count.
   * 
   * @param {array} [parameters.virtualMachinesReferences] Gets or sets a list
   * containing reference to all Virtual Machines  created under this
   * Availability Set.
   * 
   * @param {array} [parameters.statuses] Gets or sets the resource status
   * information.
   * 
   * @param {string} [parameters.id] Gets or sets the ID of the resource.
   * 
   * @param {string} [parameters.name] Gets or sets the name of the resource.
   * 
   * @param {string} [parameters.type] Gets or sets the type of the resource.
   * 
   * @param {string} parameters.location Gets or sets the location of the
   * resource.
   * 
   * @param {object} [parameters.tags] Gets or sets the tags attached to the
   * resource.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  AvailabilitySetOperations.prototype.createOrUpdate = function(resourceGroupName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.location === null || parameters.location === undefined) {
      return callback(new Error('parameters.location cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/availabilitySets/';
    if (parameters.name !== null && parameters.name !== undefined) {
      url2 = url2 + encodeURIComponent(parameters.name);
    }
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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/json';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var availabilitySetJsonValue = {};
    requestDoc = availabilitySetJsonValue;
    
    var propertiesValue = {};
    availabilitySetJsonValue['properties'] = propertiesValue;
    
    if (parameters.platformUpdateDomainCount !== null && parameters.platformUpdateDomainCount !== undefined) {
      propertiesValue['platformUpdateDomainCount'] = parameters.platformUpdateDomainCount;
    }
    
    if (parameters.platformFaultDomainCount !== null && parameters.platformFaultDomainCount !== undefined) {
      propertiesValue['platformFaultDomainCount'] = parameters.platformFaultDomainCount;
    }
    
    if (parameters.virtualMachinesReferences !== null && parameters.virtualMachinesReferences !== undefined) {
      var virtualMachinesArray = [];
      for (var loweredIndex1 = 0; loweredIndex1 < parameters.virtualMachinesReferences.length; loweredIndex1 = loweredIndex1 + 1) {
        var virtualMachinesItem = parameters.virtualMachinesReferences[loweredIndex1];
        var virtualMachineReferenceValue = {};
        virtualMachinesArray.push(virtualMachineReferenceValue);
        
        if (virtualMachinesItem.referenceUri !== null && virtualMachinesItem.referenceUri !== undefined) {
          virtualMachineReferenceValue['id'] = virtualMachinesItem.referenceUri;
        }
      }
      propertiesValue['virtualMachines'] = virtualMachinesArray;
    }
    
    if (parameters.statuses !== null && parameters.statuses !== undefined) {
      var statusesArray = [];
      for (var loweredIndex2 = 0; loweredIndex2 < parameters.statuses.length; loweredIndex2 = loweredIndex2 + 1) {
        var statusesItem = parameters.statuses[loweredIndex2];
        var instanceViewStatusValue = {};
        statusesArray.push(instanceViewStatusValue);
        
        if (statusesItem.code !== null && statusesItem.code !== undefined) {
          instanceViewStatusValue['code'] = statusesItem.code;
        }
        
        if (statusesItem.level !== null && statusesItem.level !== undefined) {
          instanceViewStatusValue['level'] = statusesItem.level;
        }
        
        if (statusesItem.displayStatus !== null && statusesItem.displayStatus !== undefined) {
          instanceViewStatusValue['displayStatus'] = statusesItem.displayStatus;
        }
        
        if (statusesItem.message !== null && statusesItem.message !== undefined) {
          instanceViewStatusValue['message'] = statusesItem.message;
        }
        
        if (statusesItem.time !== null && statusesItem.time !== undefined) {
          instanceViewStatusValue['time'] = statusesItem.time;
        }
      }
      propertiesValue['statuses'] = statusesArray;
    }
    
    if (parameters.id !== null && parameters.id !== undefined) {
      availabilitySetJsonValue['id'] = parameters.id;
    }
    
    if (parameters.name !== null && parameters.name !== undefined) {
      availabilitySetJsonValue['name'] = parameters.name;
    }
    
    if (parameters.type !== null && parameters.type !== undefined) {
      availabilitySetJsonValue['type'] = parameters.type;
    }
    
    availabilitySetJsonValue['location'] = parameters.location;
    
    if (parameters.tags !== null && parameters.tags !== undefined) {
      var tagsDictionary = {};
      for (var tagsKey in parameters.tags) {
        var tagsValue = parameters.tags[tagsKey];
        tagsDictionary[tagsKey] = tagsValue;
      }
      availabilitySetJsonValue['tags'] = tagsDictionary;
    }
    
    requestContent = JSON.stringify(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 responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var availabilitySetInstance = { statuses: [], tags: {}, virtualMachinesReferences: [] };
          result.availabilitySet = availabilitySetInstance;
          
          var propertiesValue2 = responseDoc['properties'];
          if (propertiesValue2 !== null && propertiesValue2 !== undefined) {
            var platformUpdateDomainCountValue = propertiesValue2['platformUpdateDomainCount'];
            if (platformUpdateDomainCountValue !== null && platformUpdateDomainCountValue !== undefined) {
              var platformUpdateDomainCountInstance = platformUpdateDomainCountValue;
              availabilitySetInstance.platformUpdateDomainCount = platformUpdateDomainCountInstance;
            }
            
            var platformFaultDomainCountValue = propertiesValue2['platformFaultDomainCount'];
            if (platformFaultDomainCountValue !== null && platformFaultDomainCountValue !== undefined) {
              var platformFaultDomainCountInstance = platformFaultDomainCountValue;
              availabilitySetInstance.platformFaultDomainCount = platformFaultDomainCountInstance;
            }
            
            var virtualMachinesArray2 = propertiesValue2['virtualMachines'];
            if (virtualMachinesArray2 !== null && virtualMachinesArray2 !== undefined) {
              for (var loweredIndex3 = 0; loweredIndex3 < virtualMachinesArray2.length; loweredIndex3 = loweredIndex3 + 1) {
                var virtualMachinesValue = virtualMachinesArray2[loweredIndex3];
                var virtualMachineReferenceInstance = {};
                availabilitySetInstance.virtualMachinesReferences.push(virtualMachineReferenceInstance);
                
                var idValue = virtualMachinesValue['id'];
                if (idValue !== null && idValue !== undefined) {
                  var idInstance = idValue;
                  virtualMachineReferenceInstance.referenceUri = idInstance;
                }
              }
            }
            
            var statusesArray2 = propertiesValue2['statuses'];
            if (statusesArray2 !== null && statusesArray2 !== undefined) {
              for (var loweredIndex4 = 0; loweredIndex4 < statusesArray2.length; loweredIndex4 = loweredIndex4 + 1) {
                var statusesValue = statusesArray2[loweredIndex4];
                var instanceViewStatusInstance = {};
                availabilitySetInstance.statuses.push(instanceViewStatusInstance);
                
                var codeValue = statusesValue['code'];
                if (codeValue !== null && codeValue !== undefined) {
                  var codeInstance = codeValue;
                  instanceViewStatusInstance.code = codeInstance;
                }
                
                var levelValue = statusesValue['level'];
                if (levelValue !== null && levelValue !== undefined) {
                  var levelInstance = levelValue;
                  instanceViewStatusInstance.level = levelInstance;
                }
                
                var displayStatusValue = statusesValue['displayStatus'];
                if (displayStatusValue !== null && displayStatusValue !== undefined) {
                  var displayStatusInstance = displayStatusValue;
                  instanceViewStatusInstance.displayStatus = displayStatusInstance;
                }
                
                var messageValue = statusesValue['message'];
                if (messageValue !== null && messageValue !== undefined) {
                  var messageInstance = messageValue;
                  instanceViewStatusInstance.message = messageInstance;
                }
                
                var timeValue = statusesValue['time'];
                if (timeValue !== null && timeValue !== undefined) {
                  var timeInstance = timeValue;
                  instanceViewStatusInstance.time = timeInstance;
                }
              }
            }
          }
          
          var idValue2 = responseDoc['id'];
          if (idValue2 !== null && idValue2 !== undefined) {
            var idInstance2 = idValue2;
            availabilitySetInstance.id = idInstance2;
          }
          
          var nameValue = responseDoc['name'];
          if (nameValue !== null && nameValue !== undefined) {
            var nameInstance = nameValue;
            availabilitySetInstance.name = nameInstance;
          }
          
          var typeValue = responseDoc['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            availabilitySetInstance.type = typeInstance;
          }
          
          var locationValue = responseDoc['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            availabilitySetInstance.location = locationInstance;
          }
          
          var tagsSequenceElement = responseDoc['tags'];
          if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
            for (var property in tagsSequenceElement) {
              var tagsKey2 = property;
              var tagsValue2 = tagsSequenceElement[property];
              availabilitySetInstance.tags[tagsKey2] = tagsValue2;
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The operation to delete the availability set.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} availabilitySetName The name of the availability set.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  AvailabilitySetOperations.prototype.deleteMethod = function(resourceGroupName, availabilitySetName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (availabilitySetName === null || availabilitySetName === undefined) {
      return callback(new Error('availabilitySetName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/availabilitySets/';
    url2 = url2 + encodeURIComponent(availabilitySetName);
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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['Content-Type'] = 'application/json';
    
    // 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 !== 204) {
        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 operation to get the availability set.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} availabilitySetName The name of the availability set.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  AvailabilitySetOperations.prototype.get = function(resourceGroupName, availabilitySetName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (availabilitySetName === null || availabilitySetName === undefined) {
      return callback(new Error('availabilitySetName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/availabilitySets/';
    url2 = url2 + encodeURIComponent(availabilitySetName);
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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['Content-Type'] = 'application/json';
    
    // 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 responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var availabilitySetInstance = { statuses: [], tags: {}, virtualMachinesReferences: [] };
          result.availabilitySet = availabilitySetInstance;
          
          var propertiesValue = responseDoc['properties'];
          if (propertiesValue !== null && propertiesValue !== undefined) {
            var platformUpdateDomainCountValue = propertiesValue['platformUpdateDomainCount'];
            if (platformUpdateDomainCountValue !== null && platformUpdateDomainCountValue !== undefined) {
              var platformUpdateDomainCountInstance = platformUpdateDomainCountValue;
              availabilitySetInstance.platformUpdateDomainCount = platformUpdateDomainCountInstance;
            }
            
            var platformFaultDomainCountValue = propertiesValue['platformFaultDomainCount'];
            if (platformFaultDomainCountValue !== null && platformFaultDomainCountValue !== undefined) {
              var platformFaultDomainCountInstance = platformFaultDomainCountValue;
              availabilitySetInstance.platformFaultDomainCount = platformFaultDomainCountInstance;
            }
            
            var virtualMachinesArray = propertiesValue['virtualMachines'];
            if (virtualMachinesArray !== null && virtualMachinesArray !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < virtualMachinesArray.length; loweredIndex1 = loweredIndex1 + 1) {
                var virtualMachinesValue = virtualMachinesArray[loweredIndex1];
                var virtualMachineReferenceInstance = {};
                availabilitySetInstance.virtualMachinesReferences.push(virtualMachineReferenceInstance);
                
                var idValue = virtualMachinesValue['id'];
                if (idValue !== null && idValue !== undefined) {
                  var idInstance = idValue;
                  virtualMachineReferenceInstance.referenceUri = idInstance;
                }
              }
            }
            
            var statusesArray = propertiesValue['statuses'];
            if (statusesArray !== null && statusesArray !== undefined) {
              for (var loweredIndex2 = 0; loweredIndex2 < statusesArray.length; loweredIndex2 = loweredIndex2 + 1) {
                var statusesValue = statusesArray[loweredIndex2];
                var instanceViewStatusInstance = {};
                availabilitySetInstance.statuses.push(instanceViewStatusInstance);
                
                var codeValue = statusesValue['code'];
                if (codeValue !== null && codeValue !== undefined) {
                  var codeInstance = codeValue;
                  instanceViewStatusInstance.code = codeInstance;
                }
                
                var levelValue = statusesValue['level'];
                if (levelValue !== null && levelValue !== undefined) {
                  var levelInstance = levelValue;
                  instanceViewStatusInstance.level = levelInstance;
                }
                
                var displayStatusValue = statusesValue['displayStatus'];
                if (displayStatusValue !== null && displayStatusValue !== undefined) {
                  var displayStatusInstance = displayStatusValue;
                  instanceViewStatusInstance.displayStatus = displayStatusInstance;
                }
                
                var messageValue = statusesValue['message'];
                if (messageValue !== null && messageValue !== undefined) {
                  var messageInstance = messageValue;
                  instanceViewStatusInstance.message = messageInstance;
                }
                
                var timeValue = statusesValue['time'];
                if (timeValue !== null && timeValue !== undefined) {
                  var timeInstance = timeValue;
                  instanceViewStatusInstance.time = timeInstance;
                }
              }
            }
          }
          
          var idValue2 = responseDoc['id'];
          if (idValue2 !== null && idValue2 !== undefined) {
            var idInstance2 = idValue2;
            availabilitySetInstance.id = idInstance2;
          }
          
          var nameValue = responseDoc['name'];
          if (nameValue !== null && nameValue !== undefined) {
            var nameInstance = nameValue;
            availabilitySetInstance.name = nameInstance;
          }
          
          var typeValue = responseDoc['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            availabilitySetInstance.type = typeInstance;
          }
          
          var locationValue = responseDoc['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            availabilitySetInstance.location = locationInstance;
          }
          
          var tagsSequenceElement = responseDoc['tags'];
          if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
            for (var property in tagsSequenceElement) {
              var tagsKey = property;
              var tagsValue = tagsSequenceElement[property];
              availabilitySetInstance.tags[tagsKey] = tagsValue;
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The operation to list the availability sets.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  AvailabilitySetOperations.prototype.list = function(resourceGroupName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/availabilitySets';
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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['Content-Type'] = 'application/json';
    
    // 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 = { availabilitySets: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var valueArray = responseDoc['value'];
          if (valueArray !== null && valueArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var valueValue = valueArray[loweredIndex1];
              var availabilitySetJsonInstance = { statuses: [], tags: {}, virtualMachinesReferences: [] };
              result.availabilitySets.push(availabilitySetJsonInstance);
              
              var propertiesValue = valueValue['properties'];
              if (propertiesValue !== null && propertiesValue !== undefined) {
                var platformUpdateDomainCountValue = propertiesValue['platformUpdateDomainCount'];
                if (platformUpdateDomainCountValue !== null && platformUpdateDomainCountValue !== undefined) {
                  var platformUpdateDomainCountInstance = platformUpdateDomainCountValue;
                  availabilitySetJsonInstance.platformUpdateDomainCount = platformUpdateDomainCountInstance;
                }
                
                var platformFaultDomainCountValue = propertiesValue['platformFaultDomainCount'];
                if (platformFaultDomainCountValue !== null && platformFaultDomainCountValue !== undefined) {
                  var platformFaultDomainCountInstance = platformFaultDomainCountValue;
                  availabilitySetJsonInstance.platformFaultDomainCount = platformFaultDomainCountInstance;
                }
                
                var virtualMachinesArray = propertiesValue['virtualMachines'];
                if (virtualMachinesArray !== null && virtualMachinesArray !== undefined) {
                  for (var loweredIndex2 = 0; loweredIndex2 < virtualMachinesArray.length; loweredIndex2 = loweredIndex2 + 1) {
                    var virtualMachinesValue = virtualMachinesArray[loweredIndex2];
                    var virtualMachineReferenceInstance = {};
                    availabilitySetJsonInstance.virtualMachinesReferences.push(virtualMachineReferenceInstance);
                    
                    var idValue = virtualMachinesValue['id'];
                    if (idValue !== null && idValue !== undefined) {
                      var idInstance = idValue;
                      virtualMachineReferenceInstance.referenceUri = idInstance;
                    }
                  }
                }
                
                var statusesArray = propertiesValue['statuses'];
                if (statusesArray !== null && statusesArray !== undefined) {
                  for (var loweredIndex3 = 0; loweredIndex3 < statusesArray.length; loweredIndex3 = loweredIndex3 + 1) {
                    var statusesValue = statusesArray[loweredIndex3];
                    var instanceViewStatusInstance = {};
                    availabilitySetJsonInstance.statuses.push(instanceViewStatusInstance);
                    
                    var codeValue = statusesValue['code'];
                    if (codeValue !== null && codeValue !== undefined) {
                      var codeInstance = codeValue;
                      instanceViewStatusInstance.code = codeInstance;
                    }
                    
                    var levelValue = statusesValue['level'];
                    if (levelValue !== null && levelValue !== undefined) {
                      var levelInstance = levelValue;
                      instanceViewStatusInstance.level = levelInstance;
                    }
                    
                    var displayStatusValue = statusesValue['displayStatus'];
                    if (displayStatusValue !== null && displayStatusValue !== undefined) {
                      var displayStatusInstance = displayStatusValue;
                      instanceViewStatusInstance.displayStatus = displayStatusInstance;
                    }
                    
                    var messageValue = statusesValue['message'];
                    if (messageValue !== null && messageValue !== undefined) {
                      var messageInstance = messageValue;
                      instanceViewStatusInstance.message = messageInstance;
                    }
                    
                    var timeValue = statusesValue['time'];
                    if (timeValue !== null && timeValue !== undefined) {
                      var timeInstance = timeValue;
                      instanceViewStatusInstance.time = timeInstance;
                    }
                  }
                }
              }
              
              var idValue2 = valueValue['id'];
              if (idValue2 !== null && idValue2 !== undefined) {
                var idInstance2 = idValue2;
                availabilitySetJsonInstance.id = idInstance2;
              }
              
              var nameValue = valueValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                availabilitySetJsonInstance.name = nameInstance;
              }
              
              var typeValue = valueValue['type'];
              if (typeValue !== null && typeValue !== undefined) {
                var typeInstance = typeValue;
                availabilitySetJsonInstance.type = typeInstance;
              }
              
              var locationValue = valueValue['location'];
              if (locationValue !== null && locationValue !== undefined) {
                var locationInstance = locationValue;
                availabilitySetJsonInstance.location = locationInstance;
              }
              
              var tagsSequenceElement = valueValue['tags'];
              if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
                for (var property in tagsSequenceElement) {
                  var tagsKey = property;
                  var tagsValue = tagsSequenceElement[property];
                  availabilitySetJsonInstance.tags[tagsKey] = tagsValue;
                }
              }
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Lists virtual-machine-sizes available to be used for an availability set.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} availabilitySetName The name of the availability set.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  AvailabilitySetOperations.prototype.listAvailableSizes = function(resourceGroupName, availabilitySetName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (availabilitySetName === null || availabilitySetName === undefined) {
      return callback(new Error('availabilitySetName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/availabilitySets/';
    url2 = url2 + encodeURIComponent(availabilitySetName);
    url2 = url2 + '/vmSizes';
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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['Content-Type'] = 'application/json';
    
    // 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 = { virtualMachineSizes: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var valueArray = responseDoc['value'];
          if (valueArray !== null && valueArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var valueValue = valueArray[loweredIndex1];
              var virtualMachineSizeInstance = {};
              result.virtualMachineSizes.push(virtualMachineSizeInstance);
              
              var nameValue = valueValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                virtualMachineSizeInstance.name = nameInstance;
              }
              
              var numberOfCoresValue = valueValue['numberOfCores'];
              if (numberOfCoresValue !== null && numberOfCoresValue !== undefined) {
                var numberOfCoresInstance = numberOfCoresValue;
                virtualMachineSizeInstance.numberOfCores = numberOfCoresInstance;
              }
              
              var osDiskSizeInMBValue = valueValue['osDiskSizeInMB'];
              if (osDiskSizeInMBValue !== null && osDiskSizeInMBValue !== undefined) {
                var osDiskSizeInMBInstance = osDiskSizeInMBValue;
                virtualMachineSizeInstance.oSDiskSizeInMB = osDiskSizeInMBInstance;
              }
              
              var resourceDiskSizeInMBValue = valueValue['resourceDiskSizeInMB'];
              if (resourceDiskSizeInMBValue !== null && resourceDiskSizeInMBValue !== undefined) {
                var resourceDiskSizeInMBInstance = resourceDiskSizeInMBValue;
                virtualMachineSizeInstance.resourceDiskSizeInMB = resourceDiskSizeInMBInstance;
              }
              
              var memoryInMBValue = valueValue['memoryInMB'];
              if (memoryInMBValue !== null && memoryInMBValue !== undefined) {
                var memoryInMBInstance = memoryInMBValue;
                virtualMachineSizeInstance.memoryInMB = memoryInMBInstance;
              }
              
              var maxDataDiskCountValue = valueValue['maxDataDiskCount'];
              if (maxDataDiskCountValue !== null && maxDataDiskCountValue !== undefined) {
                var maxDataDiskCountInstance = maxDataDiskCountValue;
                virtualMachineSizeInstance.maxDataDiskCount = maxDataDiskCountInstance;
              }
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return AvailabilitySetOperations;
})();

var UsageOperations = ( /** @lends UsageOperations */ function() {
  /**
   * @class
   * Operations for listing usage.
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [ComputeManagementClient] {@link
   * ComputeManagementClient~ComputeManagementClient}.
   * See [usage] {@link ComputeManagementClient~ComputeManagementClient#usage}.
   * Initializes a new instance of the UsageOperations class.
   * @constructor
   * 
   * @param {ComputeManagementClient} client Reference to the service client.
   */
  function UsageOperations(client) {
    this.client = client;
  }
  
  /**
   * Lists compute usages for a subscription.
   * 
   * @param {string} location The location upon which resource usage is queried.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  UsageOperations.prototype.list = function(location, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (location === null || location === undefined) {
      return callback(new Error('location cannot be null.'));
    }
    if (location !== null && location !== undefined && location.length > 1000) {
      return callback(new Error('location is outside the valid range.'));
    }
    if (/^[-\w\._]+$/.test(location) === false) {
      return callback(new Error('location is outside the valid range.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/locations/';
    url2 = url2 + encodeURIComponent(location);
    url2 = url2 + '/usages';
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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['Content-Type'] = 'application/json';
    
    // 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 = { usages: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var valueArray = responseDoc['value'];
          if (valueArray !== null && valueArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var valueValue = valueArray[loweredIndex1];
              var usageInstance = {};
              result.usages.push(usageInstance);
              
              var unitValue = valueValue['unit'];
              if (unitValue !== null && unitValue !== undefined) {
                var unitInstance = unitValue;
                usageInstance.unit = unitInstance;
              }
              
              var currentValueValue = valueValue['currentValue'];
              if (currentValueValue !== null && currentValueValue !== undefined) {
                var currentValueInstance = currentValueValue;
                usageInstance.currentValue = currentValueInstance;
              }
              
              var limitValue = valueValue['limit'];
              if (limitValue !== null && limitValue !== undefined) {
                var limitInstance = limitValue;
                usageInstance.limit = limitInstance;
              }
              
              var nameValue = valueValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = {};
                usageInstance.name = nameInstance;
                
                var valueValue2 = nameValue['value'];
                if (valueValue2 !== null && valueValue2 !== undefined) {
                  var valueInstance = valueValue2;
                  nameInstance.value = valueInstance;
                }
                
                var localizedValueValue = nameValue['localizedValue'];
                if (localizedValueValue !== null && localizedValueValue !== undefined) {
                  var localizedValueInstance = localizedValueValue;
                  nameInstance.localizedValue = localizedValueInstance;
                }
              }
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return UsageOperations;
})();

var VirtualMachineExtensionImageOperations = ( /** @lends VirtualMachineExtensionImageOperations */ function() {
  /**
   * @class
   * Operations for managing the virtual machine extension images in compute
   * management.
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [ComputeManagementClient] {@link
   * ComputeManagementClient~ComputeManagementClient}.
   * See [virtualMachineExtensionImages] {@link
   * ComputeManagementClient~ComputeManagementClient#virtualMachineExtensionImages}.
   * Initializes a new instance of the VirtualMachineExtensionImageOperations
   * class.
   * @constructor
   * 
   * @param {ComputeManagementClient} client Reference to the service client.
   */
  function VirtualMachineExtensionImageOperations(client) {
    this.client = client;
  }
  
  /**
   * Gets a virtual machine extension image.
   * 
   * @param {VirtualMachineExtensionImageGetParameters} [parametersOrCallback]
   * 
   * @param {string} [parametersOrCallback.version] Unique version number that
   * distinguish each monthly release of this product. The allowed characters
   * are digit and period.Format: <MajorVersion>.<MinorVersion>Example: 1.0.0
   * or 1.1.0
   * 
   * @param {string} [parametersOrCallback.type] Unique (across the publisher)
   * identifier to distinguish an extension for this publisher. Example:
   * 'BGInfo' or 'VMAccess'.The allowed characters are uppercase or lowercase
   * letters, digit, hypen(-), period (.)Dot or hyphen is not allowed the end
   * of value. Max length is 64.
   * 
   * @param {string} [parametersOrCallback.filterExpression] ODAta filter
   * expression.https://msdn.microsoft.com/en-us/library/hh169248(v=nav.70).aspxSupported
   * operatives: -eq -startswith Examples:    To list the all version that
   * begin with 1.0 $filter=startswith(name, ‘1.0’)    To get the latest
   * version $filter= name eq ‘latest’
   * 
   * @param {string} [parametersOrCallback.location] Location of the PIR, used
   * for orchestration and required by CSM to direct request to appropriate
   * PIR region. Example: westus, eastus.
   * 
   * @param {string} [parametersOrCallback.publisherName] Publisher identifier.
   * For example: Microsoft.Windows or Canonical.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineExtensionImageOperations.prototype.get = function(parametersOrCallback, callback) {
    var parameters = parametersOrCallback;
    if (_.isFunction(parameters)) {
      callback = parameters;
      parameters = null;
    }
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (parameters !== null && parameters !== undefined) {
      if (parameters.location === null || parameters.location === undefined) {
        return callback(new Error('parameters.location cannot be null.'));
      }
      if (parameters.publisherName === null || parameters.publisherName === undefined) {
        return callback(new Error('parameters.publisherName 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 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/locations/';
    if (parameters !== null && parameters !== undefined) {
      url2 = url2 + encodeURIComponent(parameters.location);
    }
    url2 = url2 + '/publishers/';
    if (parameters !== null && parameters !== undefined) {
      url2 = url2 + encodeURIComponent(parameters.publisherName);
    }
    url2 = url2 + '/artifacttypes/vmextension/types/';
    if (parameters !== null && parameters !== undefined) {
      url2 = url2 + encodeURIComponent(parameters.type);
    }
    url2 = url2 + '/versions/';
    if (parameters !== null && parameters !== undefined) {
      url2 = url2 + encodeURIComponent(parameters.version);
    }
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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['Content-Type'] = 'application/json';
    
    // 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 responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var virtualMachineExtensionImageInstance = {};
          result.virtualMachineExtensionImage = virtualMachineExtensionImageInstance;
          
          var propertiesValue = responseDoc['properties'];
          if (propertiesValue !== null && propertiesValue !== undefined) {
            var operatingSystemValue = propertiesValue['operatingSystem'];
            if (operatingSystemValue !== null && operatingSystemValue !== undefined) {
              var operatingSystemInstance = operatingSystemValue;
              virtualMachineExtensionImageInstance.operatingSystem = operatingSystemInstance;
            }
            
            var computeRoleValue = propertiesValue['computeRole'];
            if (computeRoleValue !== null && computeRoleValue !== undefined) {
              var computeRoleInstance = computeRoleValue;
              virtualMachineExtensionImageInstance.computeRole = computeRoleInstance;
            }
            
            var handlerSchemaValue = propertiesValue['handlerSchema'];
            if (handlerSchemaValue !== null && handlerSchemaValue !== undefined) {
              var handlerSchemaInstance = handlerSchemaValue;
              virtualMachineExtensionImageInstance.handlerSchema = handlerSchemaInstance;
            }
            
            var vmScaleSetEnabledValue = propertiesValue['vmScaleSetEnabled'];
            if (vmScaleSetEnabledValue !== null && vmScaleSetEnabledValue !== undefined) {
              var vmScaleSetEnabledInstance = vmScaleSetEnabledValue;
              virtualMachineExtensionImageInstance.vMScaleSetEnabled = vmScaleSetEnabledInstance;
            }
            
            var supportsMultipleExtensionsValue = propertiesValue['supportsMultipleExtensions'];
            if (supportsMultipleExtensionsValue !== null && supportsMultipleExtensionsValue !== undefined) {
              var supportsMultipleExtensionsInstance = supportsMultipleExtensionsValue;
              virtualMachineExtensionImageInstance.supportsMultipleExtensions = supportsMultipleExtensionsInstance;
            }
          }
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            virtualMachineExtensionImageInstance.id = idInstance;
          }
          
          var nameValue = responseDoc['name'];
          if (nameValue !== null && nameValue !== undefined) {
            var nameInstance = nameValue;
            virtualMachineExtensionImageInstance.name = nameInstance;
          }
          
          var locationValue = responseDoc['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            virtualMachineExtensionImageInstance.location = locationInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets a list of virtual machine extension image types.
   * 
   * @param {VirtualMachineExtensionImageListTypesParameters}
   * [parametersOrCallback]
   * 
   * @param {string} [parametersOrCallback.location] Location of the PIR, used
   * for orchestration and required by CSM to direct request to appropriate
   * PIR region. Example: westus, eastus.
   * 
   * @param {string} [parametersOrCallback.publisherName] Publisher identifier.
   * For example: Microsoft.Windows or Canonical.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineExtensionImageOperations.prototype.listTypes = function(parametersOrCallback, callback) {
    var parameters = parametersOrCallback;
    if (_.isFunction(parameters)) {
      callback = parameters;
      parameters = null;
    }
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (parameters !== null && parameters !== undefined) {
      if (parameters.location === null || parameters.location === undefined) {
        return callback(new Error('parameters.location cannot be null.'));
      }
      if (parameters.publisherName === null || parameters.publisherName === undefined) {
        return callback(new Error('parameters.publisherName cannot be null.'));
      }
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/locations/';
    if (parameters !== null && parameters !== undefined) {
      url2 = url2 + encodeURIComponent(parameters.location);
    }
    url2 = url2 + '/publishers/';
    if (parameters !== null && parameters !== undefined) {
      url2 = url2 + encodeURIComponent(parameters.publisherName);
    }
    url2 = url2 + '/artifacttypes/vmextension/types';
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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['Content-Type'] = 'application/json';
    
    // 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 = { resources: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var resourcesArray = responseDoc;
          if (resourcesArray !== null && resourcesArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < resourcesArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var resourcesValue = resourcesArray[loweredIndex1];
              var virtualMachineImageResourceInstance = {};
              result.resources.push(virtualMachineImageResourceInstance);
              
              var idValue = resourcesValue['id'];
              if (idValue !== null && idValue !== undefined) {
                var idInstance = idValue;
                virtualMachineImageResourceInstance.id = idInstance;
              }
              
              var nameValue = resourcesValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                virtualMachineImageResourceInstance.name = nameInstance;
              }
              
              var locationValue = resourcesValue['location'];
              if (locationValue !== null && locationValue !== undefined) {
                var locationInstance = locationValue;
                virtualMachineImageResourceInstance.location = locationInstance;
              }
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets a list of virtual machine extension image versions.
   * 
   * @param {VirtualMachineExtensionImageListVersionsParameters}
   * [parametersOrCallback]
   * 
   * @param {string} [parametersOrCallback.type] Unique (across the publisher)
   * identifier to distinguish an extension for this publisher. Example:
   * 'BGInfo' or 'VMAccess'.The allowed characters are uppercase or lowercase
   * letters, digit, hypen(-), period (.)Dot or hyphen is not allowed the end
   * of value. Max length is 64.
   * 
   * @param {string} [parametersOrCallback.filterExpression] ODAta filter
   * expression.https://msdn.microsoft.com/en-us/library/hh169248(v=nav.70).aspxSupported
   * operatives: -eq -startswith Examples:    To list the all version that
   * begin with 1.0 $filter=startswith(name, ‘1.0’)    To get the latest
   * version $filter= name eq ‘latest’
   * 
   * @param {string} [parametersOrCallback.location] Location of the PIR, used
   * for orchestration and required by CSM to direct request to appropriate
   * PIR region. Example: westus, eastus.
   * 
   * @param {string} [parametersOrCallback.publisherName] Publisher identifier.
   * For example: Microsoft.Windows or Canonical.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineExtensionImageOperations.prototype.listVersions = function(parametersOrCallback, callback) {
    var parameters = parametersOrCallback;
    if (_.isFunction(parameters)) {
      callback = parameters;
      parameters = null;
    }
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (parameters !== null && parameters !== undefined) {
      if (parameters.location === null || parameters.location === undefined) {
        return callback(new Error('parameters.location cannot be null.'));
      }
      if (parameters.publisherName === null || parameters.publisherName === undefined) {
        return callback(new Error('parameters.publisherName 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 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/locations/';
    if (parameters !== null && parameters !== undefined) {
      url2 = url2 + encodeURIComponent(parameters.location);
    }
    url2 = url2 + '/publishers/';
    if (parameters !== null && parameters !== undefined) {
      url2 = url2 + encodeURIComponent(parameters.publisherName);
    }
    url2 = url2 + '/artifacttypes/vmextension/types/';
    if (parameters !== null && parameters !== undefined) {
      url2 = url2 + encodeURIComponent(parameters.type);
    }
    url2 = url2 + '/versions';
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    if (parameters !== null && parameters !== undefined && parameters.filterExpression !== null && parameters.filterExpression !== undefined) {
      queryParameters.push(parameters.filterExpression);
    }
    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['Content-Type'] = 'application/json';
    
    // 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 = { resources: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var resourcesArray = responseDoc;
          if (resourcesArray !== null && resourcesArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < resourcesArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var resourcesValue = resourcesArray[loweredIndex1];
              var virtualMachineImageResourceInstance = {};
              result.resources.push(virtualMachineImageResourceInstance);
              
              var idValue = resourcesValue['id'];
              if (idValue !== null && idValue !== undefined) {
                var idInstance = idValue;
                virtualMachineImageResourceInstance.id = idInstance;
              }
              
              var nameValue = resourcesValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                virtualMachineImageResourceInstance.name = nameInstance;
              }
              
              var locationValue = resourcesValue['location'];
              if (locationValue !== null && locationValue !== undefined) {
                var locationInstance = locationValue;
                virtualMachineImageResourceInstance.location = locationInstance;
              }
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return VirtualMachineExtensionImageOperations;
})();

var VirtualMachineExtensionOperations = ( /** @lends VirtualMachineExtensionOperations */ function() {
  /**
   * @class
   * Operations for managing the virtual machine extensions in compute
   * management.
   * __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 operation to create or update the extension.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} vmName The name of the virtual machine where the extension
   * should be create or updated.
   * 
   * @param {VirtualMachineExtension} extensionParameters Parameters supplied
   * to the Create Virtual Machine Extension operation.
   * 
   * @param {string} [extensionParameters.publisher] Gets or sets the name of
   * the extension handler publisher.
   * 
   * @param {string} [extensionParameters.extensionType] Gets or sets the type
   * of the extension handler.
   * 
   * @param {string} [extensionParameters.typeHandlerVersion] Gets or sets the
   * type version of the extension handler.
   * 
   * @param {boolean} [extensionParameters.autoUpgradeMinorVersion] Gets or
   * sets whether the extension handler should be automatically upgraded
   * across minor versions.
   * 
   * @param {string} [extensionParameters.settings] Gets or sets Json formatted
   * public settings for the extension.
   * 
   * @param {string} [extensionParameters.protectedSettings] Gets or sets Json
   * formatted protected settings for the extension.
   * 
   * @param {string} [extensionParameters.provisioningState] Gets or sets the
   * provisioning state, which only appears in the response.
   * 
   * @param {VirtualMachineExtensionInstanceView}
   * [extensionParameters.instanceView] Gets or sets the virtual machine
   * extension instance view.
   * 
   * @param {string} [extensionParameters.instanceView.name] Gets or sets the
   * virtual machine extension name.
   * 
   * @param {string} [extensionParameters.instanceView.extensionType] Gets or
   * sets the full type of the extension handler which includes both publisher
   * and type.
   * 
   * @param {string} [extensionParameters.instanceView.typeHandlerVersion] Gets
   * or sets the type version of the extension handler.
   * 
   * @param {array} [extensionParameters.instanceView.subStatuses] Gets or sets
   * the resource status information.
   * 
   * @param {array} [extensionParameters.instanceView.statuses] Gets or sets
   * the resource status information.
   * 
   * @param {string} [extensionParameters.id] Gets or sets the ID of the
   * resource.
   * 
   * @param {string} [extensionParameters.name] Gets or sets the name of the
   * resource.
   * 
   * @param {string} [extensionParameters.type] Gets or sets the type of the
   * resource.
   * 
   * @param {string} extensionParameters.location Gets or sets the location of
   * the resource.
   * 
   * @param {object} [extensionParameters.tags] Gets or sets the tags attached
   * to the resource.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineExtensionOperations.prototype.beginCreatingOrUpdating = function(resourceGroupName, vmName, extensionParameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (vmName === null || vmName === undefined) {
      return callback(new Error('vmName cannot be null.'));
    }
    if (extensionParameters === null || extensionParameters === undefined) {
      return callback(new Error('extensionParameters cannot be null.'));
    }
    if (extensionParameters.location === null || extensionParameters.location === undefined) {
      return callback(new Error('extensionParameters.location cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/';
    url2 = url2 + 'virtualMachines';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(vmName);
    url2 = url2 + '/extensions/';
    if (extensionParameters.name !== null && extensionParameters.name !== undefined) {
      url2 = url2 + encodeURIComponent(extensionParameters.name);
    }
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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/json';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var virtualMachineExtensionJsonValue = {};
    requestDoc = virtualMachineExtensionJsonValue;
    
    var propertiesValue = {};
    virtualMachineExtensionJsonValue['properties'] = propertiesValue;
    
    if (extensionParameters.publisher !== null && extensionParameters.publisher !== undefined) {
      propertiesValue['publisher'] = extensionParameters.publisher;
    }
    
    if (extensionParameters.extensionType !== null && extensionParameters.extensionType !== undefined) {
      propertiesValue['type'] = extensionParameters.extensionType;
    }
    
    if (extensionParameters.typeHandlerVersion !== null && extensionParameters.typeHandlerVersion !== undefined) {
      propertiesValue['typeHandlerVersion'] = extensionParameters.typeHandlerVersion;
    }
    
    if (extensionParameters.autoUpgradeMinorVersion !== null && extensionParameters.autoUpgradeMinorVersion !== undefined) {
      propertiesValue['autoUpgradeMinorVersion'] = extensionParameters.autoUpgradeMinorVersion;
    }
    
    if (extensionParameters.settings !== null && extensionParameters.settings !== undefined) {
      propertiesValue['settings'] = extensionParameters.settings;
    }
    
    if (extensionParameters.protectedSettings !== null && extensionParameters.protectedSettings !== undefined) {
      propertiesValue['protectedSettings'] = extensionParameters.protectedSettings;
    }
    
    if (extensionParameters.provisioningState !== null && extensionParameters.provisioningState !== undefined) {
      propertiesValue['provisioningState'] = extensionParameters.provisioningState;
    }
    
    if (extensionParameters.instanceView !== null && extensionParameters.instanceView !== undefined) {
      var instanceViewValue = {};
      propertiesValue['instanceView'] = instanceViewValue;
      
      if (extensionParameters.instanceView.name !== null && extensionParameters.instanceView.name !== undefined) {
        instanceViewValue['name'] = extensionParameters.instanceView.name;
      }
      
      if (extensionParameters.instanceView.extensionType !== null && extensionParameters.instanceView.extensionType !== undefined) {
        instanceViewValue['type'] = extensionParameters.instanceView.extensionType;
      }
      
      if (extensionParameters.instanceView.typeHandlerVersion !== null && extensionParameters.instanceView.typeHandlerVersion !== undefined) {
        instanceViewValue['typeHandlerVersion'] = extensionParameters.instanceView.typeHandlerVersion;
      }
      
      if (extensionParameters.instanceView.subStatuses !== null && extensionParameters.instanceView.subStatuses !== undefined) {
        var substatusesArray = [];
        for (var loweredIndex1 = 0; loweredIndex1 < extensionParameters.instanceView.subStatuses.length; loweredIndex1 = loweredIndex1 + 1) {
          var substatusesItem = extensionParameters.instanceView.subStatuses[loweredIndex1];
          var instanceViewStatusValue = {};
          substatusesArray.push(instanceViewStatusValue);
          
          if (substatusesItem.code !== null && substatusesItem.code !== undefined) {
            instanceViewStatusValue['code'] = substatusesItem.code;
          }
          
          if (substatusesItem.level !== null && substatusesItem.level !== undefined) {
            instanceViewStatusValue['level'] = substatusesItem.level;
          }
          
          if (substatusesItem.displayStatus !== null && substatusesItem.displayStatus !== undefined) {
            instanceViewStatusValue['displayStatus'] = substatusesItem.displayStatus;
          }
          
          if (substatusesItem.message !== null && substatusesItem.message !== undefined) {
            instanceViewStatusValue['message'] = substatusesItem.message;
          }
          
          if (substatusesItem.time !== null && substatusesItem.time !== undefined) {
            instanceViewStatusValue['time'] = substatusesItem.time;
          }
        }
        instanceViewValue['substatuses'] = substatusesArray;
      }
      
      if (extensionParameters.instanceView.statuses !== null && extensionParameters.instanceView.statuses !== undefined) {
        var statusesArray = [];
        for (var loweredIndex2 = 0; loweredIndex2 < extensionParameters.instanceView.statuses.length; loweredIndex2 = loweredIndex2 + 1) {
          var statusesItem = extensionParameters.instanceView.statuses[loweredIndex2];
          var instanceViewStatusValue2 = {};
          statusesArray.push(instanceViewStatusValue2);
          
          if (statusesItem.code !== null && statusesItem.code !== undefined) {
            instanceViewStatusValue2['code'] = statusesItem.code;
          }
          
          if (statusesItem.level !== null && statusesItem.level !== undefined) {
            instanceViewStatusValue2['level'] = statusesItem.level;
          }
          
          if (statusesItem.displayStatus !== null && statusesItem.displayStatus !== undefined) {
            instanceViewStatusValue2['displayStatus'] = statusesItem.displayStatus;
          }
          
          if (statusesItem.message !== null && statusesItem.message !== undefined) {
            instanceViewStatusValue2['message'] = statusesItem.message;
          }
          
          if (statusesItem.time !== null && statusesItem.time !== undefined) {
            instanceViewStatusValue2['time'] = statusesItem.time;
          }
        }
        instanceViewValue['statuses'] = statusesArray;
      }
    }
    
    if (extensionParameters.id !== null && extensionParameters.id !== undefined) {
      virtualMachineExtensionJsonValue['id'] = extensionParameters.id;
    }
    
    if (extensionParameters.name !== null && extensionParameters.name !== undefined) {
      virtualMachineExtensionJsonValue['name'] = extensionParameters.name;
    }
    
    if (extensionParameters.type !== null && extensionParameters.type !== undefined) {
      virtualMachineExtensionJsonValue['type'] = extensionParameters.type;
    }
    
    virtualMachineExtensionJsonValue['location'] = extensionParameters.location;
    
    if (extensionParameters.tags !== null && extensionParameters.tags !== undefined) {
      var tagsDictionary = {};
      for (var tagsKey in extensionParameters.tags) {
        var tagsValue = extensionParameters.tags[tagsKey];
        tagsDictionary[tagsKey] = tagsValue;
      }
      virtualMachineExtensionJsonValue['tags'] = tagsDictionary;
    }
    
    requestContent = JSON.stringify(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 && statusCode !== 201) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200 || statusCode === 201) {
        var responseContent = body;
        result = {};
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var virtualMachineExtensionInstance = { tags: {} };
          result.virtualMachineExtension = virtualMachineExtensionInstance;
          
          var propertiesValue2 = responseDoc['properties'];
          if (propertiesValue2 !== null && propertiesValue2 !== undefined) {
            var publisherValue = propertiesValue2['publisher'];
            if (publisherValue !== null && publisherValue !== undefined) {
              var publisherInstance = publisherValue;
              virtualMachineExtensionInstance.publisher = publisherInstance;
            }
            
            var typeValue = propertiesValue2['type'];
            if (typeValue !== null && typeValue !== undefined) {
              var typeInstance = typeValue;
              virtualMachineExtensionInstance.extensionType = typeInstance;
            }
            
            var typeHandlerVersionValue = propertiesValue2['typeHandlerVersion'];
            if (typeHandlerVersionValue !== null && typeHandlerVersionValue !== undefined) {
              var typeHandlerVersionInstance = typeHandlerVersionValue;
              virtualMachineExtensionInstance.typeHandlerVersion = typeHandlerVersionInstance;
            }
            
            var autoUpgradeMinorVersionValue = propertiesValue2['autoUpgradeMinorVersion'];
            if (autoUpgradeMinorVersionValue !== null && autoUpgradeMinorVersionValue !== undefined) {
              var autoUpgradeMinorVersionInstance = autoUpgradeMinorVersionValue;
              virtualMachineExtensionInstance.autoUpgradeMinorVersion = autoUpgradeMinorVersionInstance;
            }
            
            var settingsValue = propertiesValue2['settings'];
            if (settingsValue !== null && settingsValue !== undefined) {
              var settingsInstance = settingsValue;
              virtualMachineExtensionInstance.settings = settingsInstance;
            }
            
            var protectedSettingsValue = propertiesValue2['protectedSettings'];
            if (protectedSettingsValue !== null && protectedSettingsValue !== undefined) {
              var protectedSettingsInstance = protectedSettingsValue;
              virtualMachineExtensionInstance.protectedSettings = protectedSettingsInstance;
            }
            
            var provisioningStateValue = propertiesValue2['provisioningState'];
            if (provisioningStateValue !== null && provisioningStateValue !== undefined) {
              var provisioningStateInstance = provisioningStateValue;
              virtualMachineExtensionInstance.provisioningState = provisioningStateInstance;
            }
            
            var instanceViewValue2 = propertiesValue2['instanceView'];
            if (instanceViewValue2 !== null && instanceViewValue2 !== undefined) {
              var instanceViewInstance = { statuses: [], subStatuses: [] };
              virtualMachineExtensionInstance.instanceView = instanceViewInstance;
              
              var nameValue = instanceViewValue2['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                instanceViewInstance.name = nameInstance;
              }
              
              var typeValue2 = instanceViewValue2['type'];
              if (typeValue2 !== null && typeValue2 !== undefined) {
                var typeInstance2 = typeValue2;
                instanceViewInstance.extensionType = typeInstance2;
              }
              
              var typeHandlerVersionValue2 = instanceViewValue2['typeHandlerVersion'];
              if (typeHandlerVersionValue2 !== null && typeHandlerVersionValue2 !== undefined) {
                var typeHandlerVersionInstance2 = typeHandlerVersionValue2;
                instanceViewInstance.typeHandlerVersion = typeHandlerVersionInstance2;
              }
              
              var substatusesArray2 = instanceViewValue2['substatuses'];
              if (substatusesArray2 !== null && substatusesArray2 !== undefined) {
                for (var loweredIndex3 = 0; loweredIndex3 < substatusesArray2.length; loweredIndex3 = loweredIndex3 + 1) {
                  var substatusesValue = substatusesArray2[loweredIndex3];
                  var instanceViewStatusInstance = {};
                  instanceViewInstance.subStatuses.push(instanceViewStatusInstance);
                  
                  var codeValue = substatusesValue['code'];
                  if (codeValue !== null && codeValue !== undefined) {
                    var codeInstance = codeValue;
                    instanceViewStatusInstance.code = codeInstance;
                  }
                  
                  var levelValue = substatusesValue['level'];
                  if (levelValue !== null && levelValue !== undefined) {
                    var levelInstance = levelValue;
                    instanceViewStatusInstance.level = levelInstance;
                  }
                  
                  var displayStatusValue = substatusesValue['displayStatus'];
                  if (displayStatusValue !== null && displayStatusValue !== undefined) {
                    var displayStatusInstance = displayStatusValue;
                    instanceViewStatusInstance.displayStatus = displayStatusInstance;
                  }
                  
                  var messageValue = substatusesValue['message'];
                  if (messageValue !== null && messageValue !== undefined) {
                    var messageInstance = messageValue;
                    instanceViewStatusInstance.message = messageInstance;
                  }
                  
                  var timeValue = substatusesValue['time'];
                  if (timeValue !== null && timeValue !== undefined) {
                    var timeInstance = timeValue;
                    instanceViewStatusInstance.time = timeInstance;
                  }
                }
              }
              
              var statusesArray2 = instanceViewValue2['statuses'];
              if (statusesArray2 !== null && statusesArray2 !== undefined) {
                for (var loweredIndex4 = 0; loweredIndex4 < statusesArray2.length; loweredIndex4 = loweredIndex4 + 1) {
                  var statusesValue = statusesArray2[loweredIndex4];
                  var instanceViewStatusInstance2 = {};
                  instanceViewInstance.statuses.push(instanceViewStatusInstance2);
                  
                  var codeValue2 = statusesValue['code'];
                  if (codeValue2 !== null && codeValue2 !== undefined) {
                    var codeInstance2 = codeValue2;
                    instanceViewStatusInstance2.code = codeInstance2;
                  }
                  
                  var levelValue2 = statusesValue['level'];
                  if (levelValue2 !== null && levelValue2 !== undefined) {
                    var levelInstance2 = levelValue2;
                    instanceViewStatusInstance2.level = levelInstance2;
                  }
                  
                  var displayStatusValue2 = statusesValue['displayStatus'];
                  if (displayStatusValue2 !== null && displayStatusValue2 !== undefined) {
                    var displayStatusInstance2 = displayStatusValue2;
                    instanceViewStatusInstance2.displayStatus = displayStatusInstance2;
                  }
                  
                  var messageValue2 = statusesValue['message'];
                  if (messageValue2 !== null && messageValue2 !== undefined) {
                    var messageInstance2 = messageValue2;
                    instanceViewStatusInstance2.message = messageInstance2;
                  }
                  
                  var timeValue2 = statusesValue['time'];
                  if (timeValue2 !== null && timeValue2 !== undefined) {
                    var timeInstance2 = timeValue2;
                    instanceViewStatusInstance2.time = timeInstance2;
                  }
                }
              }
            }
          }
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            virtualMachineExtensionInstance.id = idInstance;
          }
          
          var nameValue2 = responseDoc['name'];
          if (nameValue2 !== null && nameValue2 !== undefined) {
            var nameInstance2 = nameValue2;
            virtualMachineExtensionInstance.name = nameInstance2;
          }
          
          var typeValue3 = responseDoc['type'];
          if (typeValue3 !== null && typeValue3 !== undefined) {
            var typeInstance3 = typeValue3;
            virtualMachineExtensionInstance.type = typeInstance3;
          }
          
          var locationValue = responseDoc['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            virtualMachineExtensionInstance.location = locationInstance;
          }
          
          var tagsSequenceElement = responseDoc['tags'];
          if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
            for (var property in tagsSequenceElement) {
              var tagsKey2 = property;
              var tagsValue2 = tagsSequenceElement[property];
              virtualMachineExtensionInstance.tags[tagsKey2] = tagsValue2;
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.azureAsyncOperation = response.headers['azure-asyncoperation'];
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The operation to delete the extension.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} vmName The name of the virtual machine where the extension
   * should be deleted.
   * 
   * @param {string} vmExtensionName The name of the virtual machine extension.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineExtensionOperations.prototype.beginDeleting = function(resourceGroupName, vmName, vmExtensionName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (vmName === null || vmName === undefined) {
      return callback(new Error('vmName cannot be null.'));
    }
    if (vmExtensionName === null || vmExtensionName === undefined) {
      return callback(new Error('vmExtensionName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/';
    url2 = url2 + 'virtualMachines';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(vmName);
    url2 = url2 + '/extensions/';
    url2 = url2 + encodeURIComponent(vmExtensionName);
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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['Content-Type'] = 'application/json';
    
    // 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 && statusCode !== 204) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.azureAsyncOperation = response.headers['azure-asyncoperation'];
      result.requestId = response.headers['x-ms-request-id'];
      if (statusCode === 409) {
        result.status = OperationStatus.Failed;
      }
      if (statusCode === 200) {
        result.status = OperationStatus.Succeeded;
      }
      if (statusCode === 204) {
        result.status = OperationStatus.Succeeded;
      }
      
      return callback(null, result);
    });
  };
  
  /**
   * The operation to create or update the extension.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} vmName The name of the virtual machine where the extension
   * should be create or updated.
   * 
   * @param {VirtualMachineExtension} extensionParameters Parameters supplied
   * to the Create Virtual Machine Extension operation.
   * 
   * @param {string} [extensionParameters.publisher] Gets or sets the name of
   * the extension handler publisher.
   * 
   * @param {string} [extensionParameters.extensionType] Gets or sets the type
   * of the extension handler.
   * 
   * @param {string} [extensionParameters.typeHandlerVersion] Gets or sets the
   * type version of the extension handler.
   * 
   * @param {boolean} [extensionParameters.autoUpgradeMinorVersion] Gets or
   * sets whether the extension handler should be automatically upgraded
   * across minor versions.
   * 
   * @param {string} [extensionParameters.settings] Gets or sets Json formatted
   * public settings for the extension.
   * 
   * @param {string} [extensionParameters.protectedSettings] Gets or sets Json
   * formatted protected settings for the extension.
   * 
   * @param {string} [extensionParameters.provisioningState] Gets or sets the
   * provisioning state, which only appears in the response.
   * 
   * @param {VirtualMachineExtensionInstanceView}
   * [extensionParameters.instanceView] Gets or sets the virtual machine
   * extension instance view.
   * 
   * @param {string} [extensionParameters.instanceView.name] Gets or sets the
   * virtual machine extension name.
   * 
   * @param {string} [extensionParameters.instanceView.extensionType] Gets or
   * sets the full type of the extension handler which includes both publisher
   * and type.
   * 
   * @param {string} [extensionParameters.instanceView.typeHandlerVersion] Gets
   * or sets the type version of the extension handler.
   * 
   * @param {array} [extensionParameters.instanceView.subStatuses] Gets or sets
   * the resource status information.
   * 
   * @param {array} [extensionParameters.instanceView.statuses] Gets or sets
   * the resource status information.
   * 
   * @param {string} [extensionParameters.id] Gets or sets the ID of the
   * resource.
   * 
   * @param {string} [extensionParameters.name] Gets or sets the name of the
   * resource.
   * 
   * @param {string} [extensionParameters.type] Gets or sets the type of the
   * resource.
   * 
   * @param {string} extensionParameters.location Gets or sets the location of
   * the resource.
   * 
   * @param {object} [extensionParameters.tags] Gets or sets the tags attached
   * to the resource.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineExtensionOperations.prototype.createOrUpdate = function(resourceGroupName, vmName, extensionParameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachineExtensions.beginCreatingOrUpdating(resourceGroupName, vmName, extensionParameters, 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.getLongRunningOperationStatus(result.azureAsyncOperation, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} vmName The name of the virtual machine where the extension
   * should be deleted.
   * 
   * @param {string} vmExtensionName The name of the virtual machine extension.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineExtensionOperations.prototype.deleteMethod = function(resourceGroupName, vmName, vmExtensionName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachineExtensions.beginDeleting(resourceGroupName, vmName, vmExtensionName, 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.getDeleteOperationStatus(result.azureAsyncOperation, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The operation to get the extension.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} vmName The name of the virtual machine containing the
   * extension.
   * 
   * @param {string} vmExtensionName The name of the virtual machine extension.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineExtensionOperations.prototype.get = function(resourceGroupName, vmName, vmExtensionName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (vmName === null || vmName === undefined) {
      return callback(new Error('vmName cannot be null.'));
    }
    if (vmExtensionName === null || vmExtensionName === undefined) {
      return callback(new Error('vmExtensionName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/';
    url2 = url2 + 'virtualMachines';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(vmName);
    url2 = url2 + '/extensions/';
    url2 = url2 + encodeURIComponent(vmExtensionName);
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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['Content-Type'] = 'application/json';
    
    // 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 responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var virtualMachineExtensionInstance = { tags: {} };
          result.virtualMachineExtension = virtualMachineExtensionInstance;
          
          var propertiesValue = responseDoc['properties'];
          if (propertiesValue !== null && propertiesValue !== undefined) {
            var publisherValue = propertiesValue['publisher'];
            if (publisherValue !== null && publisherValue !== undefined) {
              var publisherInstance = publisherValue;
              virtualMachineExtensionInstance.publisher = publisherInstance;
            }
            
            var typeValue = propertiesValue['type'];
            if (typeValue !== null && typeValue !== undefined) {
              var typeInstance = typeValue;
              virtualMachineExtensionInstance.extensionType = typeInstance;
            }
            
            var typeHandlerVersionValue = propertiesValue['typeHandlerVersion'];
            if (typeHandlerVersionValue !== null && typeHandlerVersionValue !== undefined) {
              var typeHandlerVersionInstance = typeHandlerVersionValue;
              virtualMachineExtensionInstance.typeHandlerVersion = typeHandlerVersionInstance;
            }
            
            var autoUpgradeMinorVersionValue = propertiesValue['autoUpgradeMinorVersion'];
            if (autoUpgradeMinorVersionValue !== null && autoUpgradeMinorVersionValue !== undefined) {
              var autoUpgradeMinorVersionInstance = autoUpgradeMinorVersionValue;
              virtualMachineExtensionInstance.autoUpgradeMinorVersion = autoUpgradeMinorVersionInstance;
            }
            
            var settingsValue = propertiesValue['settings'];
            if (settingsValue !== null && settingsValue !== undefined) {
              var settingsInstance = settingsValue;
              virtualMachineExtensionInstance.settings = settingsInstance;
            }
            
            var protectedSettingsValue = propertiesValue['protectedSettings'];
            if (protectedSettingsValue !== null && protectedSettingsValue !== undefined) {
              var protectedSettingsInstance = protectedSettingsValue;
              virtualMachineExtensionInstance.protectedSettings = protectedSettingsInstance;
            }
            
            var provisioningStateValue = propertiesValue['provisioningState'];
            if (provisioningStateValue !== null && provisioningStateValue !== undefined) {
              var provisioningStateInstance = provisioningStateValue;
              virtualMachineExtensionInstance.provisioningState = provisioningStateInstance;
            }
            
            var instanceViewValue = propertiesValue['instanceView'];
            if (instanceViewValue !== null && instanceViewValue !== undefined) {
              var instanceViewInstance = { statuses: [], subStatuses: [] };
              virtualMachineExtensionInstance.instanceView = instanceViewInstance;
              
              var nameValue = instanceViewValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                instanceViewInstance.name = nameInstance;
              }
              
              var typeValue2 = instanceViewValue['type'];
              if (typeValue2 !== null && typeValue2 !== undefined) {
                var typeInstance2 = typeValue2;
                instanceViewInstance.extensionType = typeInstance2;
              }
              
              var typeHandlerVersionValue2 = instanceViewValue['typeHandlerVersion'];
              if (typeHandlerVersionValue2 !== null && typeHandlerVersionValue2 !== undefined) {
                var typeHandlerVersionInstance2 = typeHandlerVersionValue2;
                instanceViewInstance.typeHandlerVersion = typeHandlerVersionInstance2;
              }
              
              var substatusesArray = instanceViewValue['substatuses'];
              if (substatusesArray !== null && substatusesArray !== undefined) {
                for (var loweredIndex1 = 0; loweredIndex1 < substatusesArray.length; loweredIndex1 = loweredIndex1 + 1) {
                  var substatusesValue = substatusesArray[loweredIndex1];
                  var instanceViewStatusInstance = {};
                  instanceViewInstance.subStatuses.push(instanceViewStatusInstance);
                  
                  var codeValue = substatusesValue['code'];
                  if (codeValue !== null && codeValue !== undefined) {
                    var codeInstance = codeValue;
                    instanceViewStatusInstance.code = codeInstance;
                  }
                  
                  var levelValue = substatusesValue['level'];
                  if (levelValue !== null && levelValue !== undefined) {
                    var levelInstance = levelValue;
                    instanceViewStatusInstance.level = levelInstance;
                  }
                  
                  var displayStatusValue = substatusesValue['displayStatus'];
                  if (displayStatusValue !== null && displayStatusValue !== undefined) {
                    var displayStatusInstance = displayStatusValue;
                    instanceViewStatusInstance.displayStatus = displayStatusInstance;
                  }
                  
                  var messageValue = substatusesValue['message'];
                  if (messageValue !== null && messageValue !== undefined) {
                    var messageInstance = messageValue;
                    instanceViewStatusInstance.message = messageInstance;
                  }
                  
                  var timeValue = substatusesValue['time'];
                  if (timeValue !== null && timeValue !== undefined) {
                    var timeInstance = timeValue;
                    instanceViewStatusInstance.time = timeInstance;
                  }
                }
              }
              
              var statusesArray = instanceViewValue['statuses'];
              if (statusesArray !== null && statusesArray !== undefined) {
                for (var loweredIndex2 = 0; loweredIndex2 < statusesArray.length; loweredIndex2 = loweredIndex2 + 1) {
                  var statusesValue = statusesArray[loweredIndex2];
                  var instanceViewStatusInstance2 = {};
                  instanceViewInstance.statuses.push(instanceViewStatusInstance2);
                  
                  var codeValue2 = statusesValue['code'];
                  if (codeValue2 !== null && codeValue2 !== undefined) {
                    var codeInstance2 = codeValue2;
                    instanceViewStatusInstance2.code = codeInstance2;
                  }
                  
                  var levelValue2 = statusesValue['level'];
                  if (levelValue2 !== null && levelValue2 !== undefined) {
                    var levelInstance2 = levelValue2;
                    instanceViewStatusInstance2.level = levelInstance2;
                  }
                  
                  var displayStatusValue2 = statusesValue['displayStatus'];
                  if (displayStatusValue2 !== null && displayStatusValue2 !== undefined) {
                    var displayStatusInstance2 = displayStatusValue2;
                    instanceViewStatusInstance2.displayStatus = displayStatusInstance2;
                  }
                  
                  var messageValue2 = statusesValue['message'];
                  if (messageValue2 !== null && messageValue2 !== undefined) {
                    var messageInstance2 = messageValue2;
                    instanceViewStatusInstance2.message = messageInstance2;
                  }
                  
                  var timeValue2 = statusesValue['time'];
                  if (timeValue2 !== null && timeValue2 !== undefined) {
                    var timeInstance2 = timeValue2;
                    instanceViewStatusInstance2.time = timeInstance2;
                  }
                }
              }
            }
          }
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            virtualMachineExtensionInstance.id = idInstance;
          }
          
          var nameValue2 = responseDoc['name'];
          if (nameValue2 !== null && nameValue2 !== undefined) {
            var nameInstance2 = nameValue2;
            virtualMachineExtensionInstance.name = nameInstance2;
          }
          
          var typeValue3 = responseDoc['type'];
          if (typeValue3 !== null && typeValue3 !== undefined) {
            var typeInstance3 = typeValue3;
            virtualMachineExtensionInstance.type = typeInstance3;
          }
          
          var locationValue = responseDoc['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            virtualMachineExtensionInstance.location = locationInstance;
          }
          
          var tagsSequenceElement = responseDoc['tags'];
          if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
            for (var property in tagsSequenceElement) {
              var tagsKey = property;
              var tagsValue = tagsSequenceElement[property];
              virtualMachineExtensionInstance.tags[tagsKey] = tagsValue;
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The operation to get an extension along with its instance view.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} vmName The name of the virtual machine containing the
   * extension.
   * 
   * @param {string} vmExtensionName The name of the virtual machine extension.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineExtensionOperations.prototype.getWithInstanceView = function(resourceGroupName, vmName, vmExtensionName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (vmName === null || vmName === undefined) {
      return callback(new Error('vmName cannot be null.'));
    }
    if (vmExtensionName === null || vmExtensionName === undefined) {
      return callback(new Error('vmExtensionName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/';
    url2 = url2 + 'virtualMachines';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(vmName);
    url2 = url2 + '/extensions/';
    url2 = url2 + encodeURIComponent(vmExtensionName);
    var queryParameters = [];
    queryParameters.push('$expand=instanceView');
    queryParameters.push('api-version=2015-06-15');
    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
    
    // 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 responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var virtualMachineExtensionInstance = { tags: {} };
          result.virtualMachineExtension = virtualMachineExtensionInstance;
          
          var propertiesValue = responseDoc['properties'];
          if (propertiesValue !== null && propertiesValue !== undefined) {
            var publisherValue = propertiesValue['publisher'];
            if (publisherValue !== null && publisherValue !== undefined) {
              var publisherInstance = publisherValue;
              virtualMachineExtensionInstance.publisher = publisherInstance;
            }
            
            var typeValue = propertiesValue['type'];
            if (typeValue !== null && typeValue !== undefined) {
              var typeInstance = typeValue;
              virtualMachineExtensionInstance.extensionType = typeInstance;
            }
            
            var typeHandlerVersionValue = propertiesValue['typeHandlerVersion'];
            if (typeHandlerVersionValue !== null && typeHandlerVersionValue !== undefined) {
              var typeHandlerVersionInstance = typeHandlerVersionValue;
              virtualMachineExtensionInstance.typeHandlerVersion = typeHandlerVersionInstance;
            }
            
            var autoUpgradeMinorVersionValue = propertiesValue['autoUpgradeMinorVersion'];
            if (autoUpgradeMinorVersionValue !== null && autoUpgradeMinorVersionValue !== undefined) {
              var autoUpgradeMinorVersionInstance = autoUpgradeMinorVersionValue;
              virtualMachineExtensionInstance.autoUpgradeMinorVersion = autoUpgradeMinorVersionInstance;
            }
            
            var settingsValue = propertiesValue['settings'];
            if (settingsValue !== null && settingsValue !== undefined) {
              var settingsInstance = settingsValue;
              virtualMachineExtensionInstance.settings = settingsInstance;
            }
            
            var protectedSettingsValue = propertiesValue['protectedSettings'];
            if (protectedSettingsValue !== null && protectedSettingsValue !== undefined) {
              var protectedSettingsInstance = protectedSettingsValue;
              virtualMachineExtensionInstance.protectedSettings = protectedSettingsInstance;
            }
            
            var provisioningStateValue = propertiesValue['provisioningState'];
            if (provisioningStateValue !== null && provisioningStateValue !== undefined) {
              var provisioningStateInstance = provisioningStateValue;
              virtualMachineExtensionInstance.provisioningState = provisioningStateInstance;
            }
            
            var instanceViewValue = propertiesValue['instanceView'];
            if (instanceViewValue !== null && instanceViewValue !== undefined) {
              var instanceViewInstance = { statuses: [], subStatuses: [] };
              virtualMachineExtensionInstance.instanceView = instanceViewInstance;
              
              var nameValue = instanceViewValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                instanceViewInstance.name = nameInstance;
              }
              
              var typeValue2 = instanceViewValue['type'];
              if (typeValue2 !== null && typeValue2 !== undefined) {
                var typeInstance2 = typeValue2;
                instanceViewInstance.extensionType = typeInstance2;
              }
              
              var typeHandlerVersionValue2 = instanceViewValue['typeHandlerVersion'];
              if (typeHandlerVersionValue2 !== null && typeHandlerVersionValue2 !== undefined) {
                var typeHandlerVersionInstance2 = typeHandlerVersionValue2;
                instanceViewInstance.typeHandlerVersion = typeHandlerVersionInstance2;
              }
              
              var substatusesArray = instanceViewValue['substatuses'];
              if (substatusesArray !== null && substatusesArray !== undefined) {
                for (var loweredIndex1 = 0; loweredIndex1 < substatusesArray.length; loweredIndex1 = loweredIndex1 + 1) {
                  var substatusesValue = substatusesArray[loweredIndex1];
                  var instanceViewStatusInstance = {};
                  instanceViewInstance.subStatuses.push(instanceViewStatusInstance);
                  
                  var codeValue = substatusesValue['code'];
                  if (codeValue !== null && codeValue !== undefined) {
                    var codeInstance = codeValue;
                    instanceViewStatusInstance.code = codeInstance;
                  }
                  
                  var levelValue = substatusesValue['level'];
                  if (levelValue !== null && levelValue !== undefined) {
                    var levelInstance = levelValue;
                    instanceViewStatusInstance.level = levelInstance;
                  }
                  
                  var displayStatusValue = substatusesValue['displayStatus'];
                  if (displayStatusValue !== null && displayStatusValue !== undefined) {
                    var displayStatusInstance = displayStatusValue;
                    instanceViewStatusInstance.displayStatus = displayStatusInstance;
                  }
                  
                  var messageValue = substatusesValue['message'];
                  if (messageValue !== null && messageValue !== undefined) {
                    var messageInstance = messageValue;
                    instanceViewStatusInstance.message = messageInstance;
                  }
                  
                  var timeValue = substatusesValue['time'];
                  if (timeValue !== null && timeValue !== undefined) {
                    var timeInstance = timeValue;
                    instanceViewStatusInstance.time = timeInstance;
                  }
                }
              }
              
              var statusesArray = instanceViewValue['statuses'];
              if (statusesArray !== null && statusesArray !== undefined) {
                for (var loweredIndex2 = 0; loweredIndex2 < statusesArray.length; loweredIndex2 = loweredIndex2 + 1) {
                  var statusesValue = statusesArray[loweredIndex2];
                  var instanceViewStatusInstance2 = {};
                  instanceViewInstance.statuses.push(instanceViewStatusInstance2);
                  
                  var codeValue2 = statusesValue['code'];
                  if (codeValue2 !== null && codeValue2 !== undefined) {
                    var codeInstance2 = codeValue2;
                    instanceViewStatusInstance2.code = codeInstance2;
                  }
                  
                  var levelValue2 = statusesValue['level'];
                  if (levelValue2 !== null && levelValue2 !== undefined) {
                    var levelInstance2 = levelValue2;
                    instanceViewStatusInstance2.level = levelInstance2;
                  }
                  
                  var displayStatusValue2 = statusesValue['displayStatus'];
                  if (displayStatusValue2 !== null && displayStatusValue2 !== undefined) {
                    var displayStatusInstance2 = displayStatusValue2;
                    instanceViewStatusInstance2.displayStatus = displayStatusInstance2;
                  }
                  
                  var messageValue2 = statusesValue['message'];
                  if (messageValue2 !== null && messageValue2 !== undefined) {
                    var messageInstance2 = messageValue2;
                    instanceViewStatusInstance2.message = messageInstance2;
                  }
                  
                  var timeValue2 = statusesValue['time'];
                  if (timeValue2 !== null && timeValue2 !== undefined) {
                    var timeInstance2 = timeValue2;
                    instanceViewStatusInstance2.time = timeInstance2;
                  }
                }
              }
            }
          }
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            virtualMachineExtensionInstance.id = idInstance;
          }
          
          var nameValue2 = responseDoc['name'];
          if (nameValue2 !== null && nameValue2 !== undefined) {
            var nameInstance2 = nameValue2;
            virtualMachineExtensionInstance.name = nameInstance2;
          }
          
          var typeValue3 = responseDoc['type'];
          if (typeValue3 !== null && typeValue3 !== undefined) {
            var typeInstance3 = typeValue3;
            virtualMachineExtensionInstance.type = typeInstance3;
          }
          
          var locationValue = responseDoc['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            virtualMachineExtensionInstance.location = locationInstance;
          }
          
          var tagsSequenceElement = responseDoc['tags'];
          if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
            for (var property in tagsSequenceElement) {
              var tagsKey = property;
              var tagsValue = tagsSequenceElement[property];
              virtualMachineExtensionInstance.tags[tagsKey] = tagsValue;
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return VirtualMachineExtensionOperations;
})();

var VirtualMachineImageOperations = ( /** @lends VirtualMachineImageOperations */ function() {
  /**
   * @class
   * Operations for managing the virtual machine images in compute management.
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [ComputeManagementClient] {@link
   * ComputeManagementClient~ComputeManagementClient}.
   * See [virtualMachineImages] {@link
   * ComputeManagementClient~ComputeManagementClient#virtualMachineImages}.
   * Initializes a new instance of the VirtualMachineImageOperations class.
   * @constructor
   * 
   * @param {ComputeManagementClient} client Reference to the service client.
   */
  function VirtualMachineImageOperations(client) {
    this.client = client;
  }
  
  /**
   * Gets a virtual machine image.
   * 
   * @param {VirtualMachineImageGetParameters} [parametersOrCallback]
   * 
   * @param {string} [parametersOrCallback.version] Unique version number that
   * distinguish each monthly release of this product. The allowed characters
   * are digit and period.Format: <MajorVersion>.<MinorVersion>Example: 1.0.0
   * or 1.1.0
   * 
   * @param {string} [parametersOrCallback.skus] A distinct identifier for an
   * item in image name. For example: DataCenter or Enterprise
   * 
   * @param {string} [parametersOrCallback.offer] Unique identifier to
   * distinguish an image. The vmImageName must be unique within publisher’s
   * namespace. Example: WindowsServer2012
   * 
   * @param {string} [parametersOrCallback.publisherName] Publisher identifier.
   * For example: Microsoft.Windows or Canonical.
   * 
   * @param {string} [parametersOrCallback.location] Location of the PIR, used
   * for orchestration and required by CSM to direct request to appropriate
   * PIR region. Example: westus, eastus.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineImageOperations.prototype.get = function(parametersOrCallback, callback) {
    var parameters = parametersOrCallback;
    if (_.isFunction(parameters)) {
      callback = parameters;
      parameters = null;
    }
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (parameters !== null && parameters !== undefined) {
      if (parameters.location === null || parameters.location === undefined) {
        return callback(new Error('parameters.location cannot be null.'));
      }
      if (parameters.offer === null || parameters.offer === undefined) {
        return callback(new Error('parameters.offer cannot be null.'));
      }
      if (parameters.publisherName === null || parameters.publisherName === undefined) {
        return callback(new Error('parameters.publisherName cannot be null.'));
      }
      if (parameters.skus === null || parameters.skus === undefined) {
        return callback(new Error('parameters.skus 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 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/locations/';
    if (parameters !== null && parameters !== undefined) {
      url2 = url2 + encodeURIComponent(parameters.location);
    }
    url2 = url2 + '/publishers/';
    if (parameters !== null && parameters !== undefined) {
      url2 = url2 + encodeURIComponent(parameters.publisherName);
    }
    url2 = url2 + '/artifacttypes/vmimage/offers/';
    if (parameters !== null && parameters !== undefined) {
      url2 = url2 + encodeURIComponent(parameters.offer);
    }
    url2 = url2 + '/skus/';
    if (parameters !== null && parameters !== undefined) {
      url2 = url2 + encodeURIComponent(parameters.skus);
    }
    url2 = url2 + '/versions/';
    if (parameters !== null && parameters !== undefined) {
      url2 = url2 + encodeURIComponent(parameters.version);
    }
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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['Content-Type'] = 'application/json';
    
    // 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 responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var virtualMachineImageInstance = { dataDiskImages: [] };
          result.virtualMachineImage = virtualMachineImageInstance;
          
          var propertiesValue = responseDoc['properties'];
          if (propertiesValue !== null && propertiesValue !== undefined) {
            var planValue = propertiesValue['plan'];
            if (planValue !== null && planValue !== undefined) {
              var planInstance = {};
              virtualMachineImageInstance.purchasePlan = planInstance;
              
              var publisherValue = planValue['publisher'];
              if (publisherValue !== null && publisherValue !== undefined) {
                var publisherInstance = publisherValue;
                planInstance.publisher = publisherInstance;
              }
              
              var nameValue = planValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                planInstance.name = nameInstance;
              }
              
              var productValue = planValue['product'];
              if (productValue !== null && productValue !== undefined) {
                var productInstance = productValue;
                planInstance.product = productInstance;
              }
            }
            
            var osDiskImageValue = propertiesValue['osDiskImage'];
            if (osDiskImageValue !== null && osDiskImageValue !== undefined) {
              var osDiskImageInstance = {};
              virtualMachineImageInstance.oSDiskImage = osDiskImageInstance;
              
              var operatingSystemValue = osDiskImageValue['operatingSystem'];
              if (operatingSystemValue !== null && operatingSystemValue !== undefined) {
                var operatingSystemInstance = operatingSystemValue;
                osDiskImageInstance.operatingSystem = operatingSystemInstance;
              }
            }
            
            var dataDiskImagesArray = propertiesValue['dataDiskImages'];
            if (dataDiskImagesArray !== null && dataDiskImagesArray !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < dataDiskImagesArray.length; loweredIndex1 = loweredIndex1 + 1) {
                var dataDiskImagesValue = dataDiskImagesArray[loweredIndex1];
                var dataDiskImageInstance = {};
                virtualMachineImageInstance.dataDiskImages.push(dataDiskImageInstance);
                
                var lunValue = dataDiskImagesValue['lun'];
                if (lunValue !== null && lunValue !== undefined) {
                  var lunInstance = lunValue;
                  dataDiskImageInstance.lun = lunInstance;
                }
              }
            }
          }
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            virtualMachineImageInstance.id = idInstance;
          }
          
          var nameValue2 = responseDoc['name'];
          if (nameValue2 !== null && nameValue2 !== undefined) {
            var nameInstance2 = nameValue2;
            virtualMachineImageInstance.name = nameInstance2;
          }
          
          var locationValue = responseDoc['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            virtualMachineImageInstance.location = locationInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets a list of virtual machine images.
   * 
   * @param {VirtualMachineImageListParameters} [parametersOrCallback]
   * 
   * @param {string} [parametersOrCallback.filterExpression] ODAta filter
   * expression.https://msdn.microsoft.com/en-us/library/hh169248(v=nav.70).aspxSupported
   * operatives: -eq -startswith Examples:    To list the all version that
   * begin with 1.0 $filter=startswith(name, ‘1.0’)    To get the latest
   * version $filter= name eq ‘latest’
   * 
   * @param {string} [parametersOrCallback.skus] A distinct identifier for an
   * item in image name. For example: DataCenter or Enterprise
   * 
   * @param {string} [parametersOrCallback.offer] Unique identifier to
   * distinguish an image. The vmImageName must be unique within publisher’s
   * namespace. Example: WindowsServer2012
   * 
   * @param {string} [parametersOrCallback.publisherName] Publisher identifier.
   * For example: Microsoft.Windows or Canonical.
   * 
   * @param {string} [parametersOrCallback.location] Location of the PIR, used
   * for orchestration and required by CSM to direct request to appropriate
   * PIR region. Example: westus, eastus.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineImageOperations.prototype.list = function(parametersOrCallback, callback) {
    var parameters = parametersOrCallback;
    if (_.isFunction(parameters)) {
      callback = parameters;
      parameters = null;
    }
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (parameters !== null && parameters !== undefined) {
      if (parameters.location === null || parameters.location === undefined) {
        return callback(new Error('parameters.location cannot be null.'));
      }
      if (parameters.offer === null || parameters.offer === undefined) {
        return callback(new Error('parameters.offer cannot be null.'));
      }
      if (parameters.publisherName === null || parameters.publisherName === undefined) {
        return callback(new Error('parameters.publisherName cannot be null.'));
      }
      if (parameters.skus === null || parameters.skus === undefined) {
        return callback(new Error('parameters.skus cannot be null.'));
      }
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/locations/';
    if (parameters !== null && parameters !== undefined) {
      url2 = url2 + encodeURIComponent(parameters.location);
    }
    url2 = url2 + '/publishers/';
    if (parameters !== null && parameters !== undefined) {
      url2 = url2 + encodeURIComponent(parameters.publisherName);
    }
    url2 = url2 + '/artifacttypes/vmimage/offers/';
    if (parameters !== null && parameters !== undefined) {
      url2 = url2 + encodeURIComponent(parameters.offer);
    }
    url2 = url2 + '/skus/';
    if (parameters !== null && parameters !== undefined) {
      url2 = url2 + encodeURIComponent(parameters.skus);
    }
    url2 = url2 + '/versions';
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    if (parameters !== null && parameters !== undefined && parameters.filterExpression !== null && parameters.filterExpression !== undefined) {
      queryParameters.push(parameters.filterExpression);
    }
    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['Content-Type'] = 'application/json';
    
    // 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 = { resources: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var resourcesArray = responseDoc;
          if (resourcesArray !== null && resourcesArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < resourcesArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var resourcesValue = resourcesArray[loweredIndex1];
              var virtualMachineImageResourceInstance = {};
              result.resources.push(virtualMachineImageResourceInstance);
              
              var idValue = resourcesValue['id'];
              if (idValue !== null && idValue !== undefined) {
                var idInstance = idValue;
                virtualMachineImageResourceInstance.id = idInstance;
              }
              
              var nameValue = resourcesValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                virtualMachineImageResourceInstance.name = nameInstance;
              }
              
              var locationValue = resourcesValue['location'];
              if (locationValue !== null && locationValue !== undefined) {
                var locationInstance = locationValue;
                virtualMachineImageResourceInstance.location = locationInstance;
              }
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets a list of virtual machine image offers.
   * 
   * @param {VirtualMachineImageListOffersParameters} [parametersOrCallback]
   * 
   * @param {string} [parametersOrCallback.publisherName] Publisher identifier.
   * For example: Microsoft.Windows or Canonical.
   * 
   * @param {string} [parametersOrCallback.location] Location of the PIR, used
   * for orchestration and required by CSM to direct request to appropriate
   * PIR region. Example: westus, eastus.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineImageOperations.prototype.listOffers = function(parametersOrCallback, callback) {
    var parameters = parametersOrCallback;
    if (_.isFunction(parameters)) {
      callback = parameters;
      parameters = null;
    }
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (parameters !== null && parameters !== undefined) {
      if (parameters.location === null || parameters.location === undefined) {
        return callback(new Error('parameters.location cannot be null.'));
      }
      if (parameters.publisherName === null || parameters.publisherName === undefined) {
        return callback(new Error('parameters.publisherName cannot be null.'));
      }
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/locations/';
    if (parameters !== null && parameters !== undefined) {
      url2 = url2 + encodeURIComponent(parameters.location);
    }
    url2 = url2 + '/publishers/';
    if (parameters !== null && parameters !== undefined) {
      url2 = url2 + encodeURIComponent(parameters.publisherName);
    }
    url2 = url2 + '/artifacttypes/vmimage/offers';
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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['Content-Type'] = 'application/json';
    
    // 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 = { resources: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var resourcesArray = responseDoc;
          if (resourcesArray !== null && resourcesArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < resourcesArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var resourcesValue = resourcesArray[loweredIndex1];
              var virtualMachineImageResourceInstance = {};
              result.resources.push(virtualMachineImageResourceInstance);
              
              var idValue = resourcesValue['id'];
              if (idValue !== null && idValue !== undefined) {
                var idInstance = idValue;
                virtualMachineImageResourceInstance.id = idInstance;
              }
              
              var nameValue = resourcesValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                virtualMachineImageResourceInstance.name = nameInstance;
              }
              
              var locationValue = resourcesValue['location'];
              if (locationValue !== null && locationValue !== undefined) {
                var locationInstance = locationValue;
                virtualMachineImageResourceInstance.location = locationInstance;
              }
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets a list of virtual machine image publishers.
   * 
   * @param {VirtualMachineImageListPublishersParameters} [parametersOrCallback]
   * 
   * @param {string} [parametersOrCallback.location] Location of the PIR, used
   * for orchestration and required by CSM to direct request to appropriate
   * PIR region. Example: westus, eastus.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineImageOperations.prototype.listPublishers = function(parametersOrCallback, callback) {
    var parameters = parametersOrCallback;
    if (_.isFunction(parameters)) {
      callback = parameters;
      parameters = null;
    }
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (parameters !== null && parameters !== undefined) {
      if (parameters.location === null || parameters.location === undefined) {
        return callback(new Error('parameters.location cannot be null.'));
      }
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/locations/';
    if (parameters !== null && parameters !== undefined) {
      url2 = url2 + encodeURIComponent(parameters.location);
    }
    url2 = url2 + '/publishers';
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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['Content-Type'] = 'application/json';
    
    // 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 = { resources: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var resourcesArray = responseDoc;
          if (resourcesArray !== null && resourcesArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < resourcesArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var resourcesValue = resourcesArray[loweredIndex1];
              var virtualMachineImageResourceInstance = {};
              result.resources.push(virtualMachineImageResourceInstance);
              
              var idValue = resourcesValue['id'];
              if (idValue !== null && idValue !== undefined) {
                var idInstance = idValue;
                virtualMachineImageResourceInstance.id = idInstance;
              }
              
              var nameValue = resourcesValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                virtualMachineImageResourceInstance.name = nameInstance;
              }
              
              var locationValue = resourcesValue['location'];
              if (locationValue !== null && locationValue !== undefined) {
                var locationInstance = locationValue;
                virtualMachineImageResourceInstance.location = locationInstance;
              }
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets a list of virtual machine image skus.
   * 
   * @param {VirtualMachineImageListSkusParameters} [parametersOrCallback]
   * 
   * @param {string} [parametersOrCallback.offer] Unique identifier to
   * distinguish an image. The vmImageName must be unique within publisher’s
   * namespace. Example: WindowsServer2012
   * 
   * @param {string} [parametersOrCallback.publisherName] Publisher identifier.
   * For example: Microsoft.Windows or Canonical.
   * 
   * @param {string} [parametersOrCallback.location] Location of the PIR, used
   * for orchestration and required by CSM to direct request to appropriate
   * PIR region. Example: westus, eastus.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineImageOperations.prototype.listSkus = function(parametersOrCallback, callback) {
    var parameters = parametersOrCallback;
    if (_.isFunction(parameters)) {
      callback = parameters;
      parameters = null;
    }
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (parameters !== null && parameters !== undefined) {
      if (parameters.location === null || parameters.location === undefined) {
        return callback(new Error('parameters.location cannot be null.'));
      }
      if (parameters.offer === null || parameters.offer === undefined) {
        return callback(new Error('parameters.offer cannot be null.'));
      }
      if (parameters.publisherName === null || parameters.publisherName === undefined) {
        return callback(new Error('parameters.publisherName cannot be null.'));
      }
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/locations/';
    if (parameters !== null && parameters !== undefined) {
      url2 = url2 + encodeURIComponent(parameters.location);
    }
    url2 = url2 + '/publishers/';
    if (parameters !== null && parameters !== undefined) {
      url2 = url2 + encodeURIComponent(parameters.publisherName);
    }
    url2 = url2 + '/artifacttypes/vmimage/offers/';
    if (parameters !== null && parameters !== undefined) {
      url2 = url2 + encodeURIComponent(parameters.offer);
    }
    url2 = url2 + '/skus';
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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['Content-Type'] = 'application/json';
    
    // 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 = { resources: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var resourcesArray = responseDoc;
          if (resourcesArray !== null && resourcesArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < resourcesArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var resourcesValue = resourcesArray[loweredIndex1];
              var virtualMachineImageResourceInstance = {};
              result.resources.push(virtualMachineImageResourceInstance);
              
              var idValue = resourcesValue['id'];
              if (idValue !== null && idValue !== undefined) {
                var idInstance = idValue;
                virtualMachineImageResourceInstance.id = idInstance;
              }
              
              var nameValue = resourcesValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                virtualMachineImageResourceInstance.name = nameInstance;
              }
              
              var locationValue = resourcesValue['location'];
              if (locationValue !== null && locationValue !== undefined) {
                var locationInstance = locationValue;
                virtualMachineImageResourceInstance.location = locationInstance;
              }
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return VirtualMachineImageOperations;
})();

var VirtualMachineOperations = ( /** @lends VirtualMachineOperations */ function() {
  /**
   * @class
   * Operations for managing the virtual machines in compute management.
   * __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;
  }
  
  /**
   * Captures the VM by copying VirtualHardDisks of the VM and outputs a
   * template that can be used to create similar VMs.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} vmName The name of the virtual machine.
   * 
   * @param {VirtualMachineCaptureParameters} parameters Parameters supplied to
   * the Capture Virtual Machine operation.
   * 
   * @param {string} parameters.virtualHardDiskNamePrefix Gets or sets the
   * captured VirtualHardDisk's name prefix.
   * 
   * @param {string} parameters.destinationContainerName Gets or sets the
   * destination container name.
   * 
   * @param {boolean} parameters.overwrite Gets or sets whether it overwrites
   * destination VirtualHardDisk if true, in case of conflict.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.beginCapturing = function(resourceGroupName, vmName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (vmName === null || vmName === undefined) {
      return callback(new Error('vmName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.destinationContainerName === null || parameters.destinationContainerName === undefined) {
      return callback(new Error('parameters.destinationContainerName cannot be null.'));
    }
    if (parameters.overwrite === null || parameters.overwrite === undefined) {
      return callback(new Error('parameters.overwrite cannot be null.'));
    }
    if (parameters.virtualHardDiskNamePrefix === null || parameters.virtualHardDiskNamePrefix === undefined) {
      return callback(new Error('parameters.virtualHardDiskNamePrefix cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/';
    url2 = url2 + 'virtualMachines';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(vmName);
    url2 = url2 + '/capture';
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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/json';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var virtualMachineCaptureParametersValue = {};
    requestDoc = virtualMachineCaptureParametersValue;
    
    virtualMachineCaptureParametersValue['vhdPrefix'] = parameters.virtualHardDiskNamePrefix;
    
    virtualMachineCaptureParametersValue['destinationContainerName'] = parameters.destinationContainerName;
    
    virtualMachineCaptureParametersValue['overwriteVhds'] = parameters.overwrite;
    
    requestContent = JSON.stringify(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.azureAsyncOperation = response.headers['azure-asyncoperation'];
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The operation to create or update a virtual machine.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {VirtualMachine} parameters Parameters supplied to the Create
   * Virtual Machine operation.
   * 
   * @param {Plan} [parameters.plan] Gets or sets the purchase plan when
   * deploying virtual machine from VM Marketplace images.
   * 
   * @param {string} [parameters.plan.name] Gets or sets the plan ID.
   * 
   * @param {string} [parameters.plan.publisher] Gets or sets the publisher ID.
   * 
   * @param {string} [parameters.plan.product] Gets or sets the offer ID.
   * 
   * @param {string} [parameters.plan.promotionCode] Gets or sets the promotion
   * code.
   * 
   * @param {HardwareProfile} [parameters.hardwareProfile] Gets or sets the
   * hardware profile.
   * 
   * @param {string} [parameters.hardwareProfile.virtualMachineSize] The
   * virtual machine size name.
   * 
   * @param {StorageProfile} [parameters.storageProfile] Gets or sets the
   * storage profile.
   * 
   * @param {ImageReference} [parameters.storageProfile.imageReference] Gets or
   * sets the image reference.
   * 
   * @param {string} [parameters.storageProfile.imageReference.publisher] Gets
   * or sets the image publisher.
   * 
   * @param {string} [parameters.storageProfile.imageReference.offer] Gets or
   * sets the image offer.
   * 
   * @param {string} [parameters.storageProfile.imageReference.sku] Gets or
   * sets the image sku.
   * 
   * @param {string} [parameters.storageProfile.imageReference.version] Gets or
   * sets the image version. The allowed formats are Major.Minor.Build or
   * 'latest'. Major, Minor and Build being decimal numbers. Specify 'latest'
   * to use the latest version of image.
   * 
   * @param {OSDisk} [parameters.storageProfile.oSDisk] Gets or sets the OS
   * disk.
   * 
   * @param {string} [parameters.storageProfile.oSDisk.operatingSystemType]
   * Gets or sets the Operating System type.
   * 
   * @param {DiskEncryptionSettings}
   * [parameters.storageProfile.oSDisk.encryptionSettings] Gets or sets the
   * disk encryption settings.
   * 
   * @param {KeyVaultSecretReference}
   * [parameters.storageProfile.oSDisk.encryptionSettings.diskEncryptionKey]
   * Gets or sets the disk encryption key which is a KeyVault Secret.
   * 
   * @param {string}
   * [parameters.storageProfile.oSDisk.encryptionSettings.diskEncryptionKey.secretUrl]
   * Gets or sets the URL referencing a secret in a Key Vault.
   * 
   * @param {SourceVaultReference}
   * [parameters.storageProfile.oSDisk.encryptionSettings.diskEncryptionKey.sourceVault]
   * Gets or sets the Relative URL of the Key Vault containing the secret.
   * 
   * @param {string}
   * [parameters.storageProfile.oSDisk.encryptionSettings.diskEncryptionKey.sourceVault.referenceUri]
   * Gets or sets the relative URL in the previous Service Management API's
   * namespace. For Example:
   * /subscriptions/{SubcriptionId}/resourceGroups/{ResourceGroupName}/...
   * 
   * @param {KeyVaultKeyReference}
   * [parameters.storageProfile.oSDisk.encryptionSettings.keyEncryptionKey]
   * Gets or sets the key encryption key which is KeyVault Key.
   * 
   * @param {string}
   * [parameters.storageProfile.oSDisk.encryptionSettings.keyEncryptionKey.keyUrl]
   * Gets or sets the URL referencing a key in a Key Vault.
   * 
   * @param {SourceVaultReference}
   * [parameters.storageProfile.oSDisk.encryptionSettings.keyEncryptionKey.sourceVault]
   * Gets or sets the Relative URL of the Key Vault containing the key
   * 
   * @param {string}
   * [parameters.storageProfile.oSDisk.encryptionSettings.keyEncryptionKey.sourceVault.referenceUri]
   * Gets or sets the relative URL in the previous Service Management API's
   * namespace. For Example:
   * /subscriptions/{SubcriptionId}/resourceGroups/{ResourceGroupName}/...
   * 
   * @param {string} [parameters.storageProfile.oSDisk.name] Gets or sets the
   * disk name.
   * 
   * @param {VirtualHardDisk}
   * [parameters.storageProfile.oSDisk.virtualHardDisk] Gets or sets the
   * Virtual Hard Disk.
   * 
   * @param {string} [parameters.storageProfile.oSDisk.virtualHardDisk.uri]
   * Gets or sets the virtual hard disk's uri. It should be a valid Uri to a
   * virtual hard disk.
   * 
   * @param {VirtualHardDisk} [parameters.storageProfile.oSDisk.sourceImage]
   * Gets or sets the Source User Image VirtualHardDisk. This VirtualHardDisk
   * will be copied before using it to attach to the Virtual Machine.If
   * SourceImage is provided, the destination VirtualHardDisk should not exist.
   * 
   * @param {string} [parameters.storageProfile.oSDisk.sourceImage.uri] Gets or
   * sets the virtual hard disk's uri. It should be a valid Uri to a virtual
   * hard disk.
   * 
   * @param {string} [parameters.storageProfile.oSDisk.caching] Gets or sets
   * the caching type.
   * 
   * @param {string} [parameters.storageProfile.oSDisk.createOption] Gets or
   * sets the create option.
   * 
   * @param {number} [parameters.storageProfile.oSDisk.diskSizeGB] Gets or sets
   * the initial disk size in GB for blank data disks, and the new desired
   * size for existing OS and Data disks.
   * 
   * @param {array} [parameters.storageProfile.dataDisks] Gets or sets the data
   * disks.
   * 
   * @param {OSProfile} [parameters.oSProfile] Gets or sets the OS profile.
   * 
   * @param {string} [parameters.oSProfile.computerName] Gets or sets the
   * computer name.
   * 
   * @param {string} [parameters.oSProfile.adminUsername] Gets or sets the
   * admin user name.
   * 
   * @param {string} [parameters.oSProfile.adminPassword] Gets or sets the
   * admin user password.
   * 
   * @param {string} [parameters.oSProfile.customData] Gets or sets a base-64
   * encoded string of custom data.
   * 
   * @param {WindowsConfiguration} [parameters.oSProfile.windowsConfiguration]
   * Gets or sets the Windows Configuration of the OS profile.
   * 
   * @param {boolean}
   * [parameters.oSProfile.windowsConfiguration.provisionVMAgent] Gets or sets
   * whether VM Agent should be provisioned on the Virtual Machine.
   * 
   * @param {boolean}
   * [parameters.oSProfile.windowsConfiguration.enableAutomaticUpdates] Gets
   * or sets whether Windows updates are automatically installed on the VM
   * 
   * @param {string} [parameters.oSProfile.windowsConfiguration.timeZone] Gets
   * or sets the Time Zone of the VM
   * 
   * @param {array}
   * [parameters.oSProfile.windowsConfiguration.additionalUnattendContents]
   * Gets or sets the additional base-64 encoded XML formatted information
   * that can be included in the Unattend.xml file.
   * 
   * @param {WinRMConfiguration}
   * [parameters.oSProfile.windowsConfiguration.winRMConfiguration] Gets or
   * sets the Windows Remote Management configuration of the VM
   * 
   * @param {array}
   * [parameters.oSProfile.windowsConfiguration.winRMConfiguration.listeners]
   * Gets or sets the list of Windows Remote Management listeners
   * 
   * @param {LinuxConfiguration} [parameters.oSProfile.linuxConfiguration] Gets
   * or sets the Linux Configuration of the OS profile.
   * 
   * @param {boolean}
   * [parameters.oSProfile.linuxConfiguration.disablePasswordAuthentication]
   * Gets or sets whether Authentication using user name and password is
   * allowed or not
   * 
   * @param {SshConfiguration}
   * [parameters.oSProfile.linuxConfiguration.sshConfiguration] Gets or sets
   * the SSH configuration for linux VMs
   * 
   * @param {array}
   * [parameters.oSProfile.linuxConfiguration.sshConfiguration.publicKeys]
   * Gets or sets the list of SSH public keys used to authenticate with linux
   * based VMs
   * 
   * @param {array} [parameters.oSProfile.secrets] Gets or sets the List of
   * certificates for addition to the VM.
   * 
   * @param {NetworkProfile} [parameters.networkProfile] Gets or sets the
   * network profile.
   * 
   * @param {array} [parameters.networkProfile.networkInterfaces] Gets or sets
   * the network interfaces.
   * 
   * @param {DiagnosticsProfile} [parameters.diagnosticsProfile] Gets or sets
   * the diagnostics profile.
   * 
   * @param {BootDiagnostics} [parameters.diagnosticsProfile.bootDiagnostics]
   * Gets or sets the boot diagnostics.
   * 
   * @param {boolean} [parameters.diagnosticsProfile.bootDiagnostics.enabled]
   * Gets or sets whether VM Agent should be provisioned on the Virtual
   * Machine.
   * 
   * @param {string} [parameters.diagnosticsProfile.bootDiagnostics.storageUri]
   * Gets or sets the boot diagnostics storage Uri. It should be a valid Uri
   * 
   * @param {AvailabilitySetReference} [parameters.availabilitySetReference]
   * Gets or sets the reference Id of the availailbity set to which this
   * virtual machine belongs.
   * 
   * @param {string} [parameters.availabilitySetReference.referenceUri] Gets or
   * sets the relative URL in the previous Service Management API's namespace.
   * For Example:
   * /subscriptions/{SubcriptionId}/resourceGroups/{ResourceGroupName}/...
   * 
   * @param {string} [parameters.provisioningState] Gets or sets the
   * provisioning state, which only appears in the response.
   * 
   * @param {VirtualMachineInstanceView} [parameters.instanceView] Gets the
   * virtual machine instance view.
   * 
   * @param {number} [parameters.instanceView.platformUpdateDomain] Gets or
   * sets the Update Domain count.
   * 
   * @param {number} [parameters.instanceView.platformFaultDomain] Gets or sets
   * the Fault Domain count.
   * 
   * @param {string} [parameters.instanceView.remoteDesktopThumbprint] Gets or
   * sets the Remote desktop certificate thumbprint.
   * 
   * @param {VirtualMachineAgentInstanceView} [parameters.instanceView.vMAgent]
   * Gets or sets the VM Agent running on the virtual machine.
   * 
   * @param {string} [parameters.instanceView.vMAgent.vMAgentVersion] Gets or
   * sets the VM Agent full version.
   * 
   * @param {array} [parameters.instanceView.vMAgent.extensionHandlers] Gets or
   * sets the virtual machine extension handler instance view.
   * 
   * @param {array} [parameters.instanceView.vMAgent.statuses] Gets or sets the
   * resource status information.
   * 
   * @param {array} [parameters.instanceView.disks] Gets or sets the the disks
   * information.
   * 
   * @param {array} [parameters.instanceView.extensions] Gets or sets the
   * extensions information.
   * 
   * @param {BootDiagnosticsInstanceView}
   * [parameters.instanceView.bootDiagnostics] Gets or sets the boot
   * diagnostics.
   * 
   * @param {string}
   * [parameters.instanceView.bootDiagnostics.consoleScreenshotBlobUri] Gets
   * or sets the console screenshot blob Uri.
   * 
   * @param {string}
   * [parameters.instanceView.bootDiagnostics.serialConsoleLogBlobUri] Gets or
   * sets the Linux serial console log blob Uri.
   * 
   * @param {array} [parameters.instanceView.statuses] Gets or sets the
   * resource status information.
   * 
   * @param {array} [parameters.extensions] Gets the virtual machine child
   * extension resources.
   * 
   * @param {string} [parameters.id] Gets or sets the ID of the resource.
   * 
   * @param {string} [parameters.name] Gets or sets the name of the resource.
   * 
   * @param {string} [parameters.type] Gets or sets the type of the resource.
   * 
   * @param {string} parameters.location Gets or sets the location of the
   * resource.
   * 
   * @param {object} [parameters.tags] Gets or sets the tags attached to the
   * resource.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.beginCreatingOrUpdating = function(resourceGroupName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.extensions !== null && parameters.extensions !== undefined) {
      for (var loweredIndex1 = 0; loweredIndex1 < parameters.extensions.length; loweredIndex1 = loweredIndex1 + 1) {
        var extensionsParameterItem = parameters.extensions[loweredIndex1];
        if (extensionsParameterItem.location === null || extensionsParameterItem.location === undefined) {
          return callback(new Error('parameters.extensions.location cannot be null.'));
        }
      }
    }
    if (parameters.location === null || parameters.location === undefined) {
      return callback(new Error('parameters.location cannot be null.'));
    }
    if (parameters.storageProfile !== null && parameters.storageProfile !== undefined) {
      if (parameters.storageProfile.dataDisks !== null && parameters.storageProfile.dataDisks !== undefined) {
        for (var loweredIndex2 = 0; loweredIndex2 < parameters.storageProfile.dataDisks.length; loweredIndex2 = loweredIndex2 + 1) {
          var dataDisksParameterItem = parameters.storageProfile.dataDisks[loweredIndex2];
          if (dataDisksParameterItem.createOption === null || dataDisksParameterItem.createOption === undefined) {
            return callback(new Error('parameters.storageProfile.dataDisks.createOption cannot be null.'));
          }
          if (dataDisksParameterItem.lun === null || dataDisksParameterItem.lun === undefined) {
            return callback(new Error('parameters.storageProfile.dataDisks.lun cannot be null.'));
          }
          if (dataDisksParameterItem.name === null || dataDisksParameterItem.name === undefined) {
            return callback(new Error('parameters.storageProfile.dataDisks.name cannot be null.'));
          }
          if (dataDisksParameterItem.virtualHardDisk === null || dataDisksParameterItem.virtualHardDisk === undefined) {
            return callback(new Error('parameters.storageProfile.dataDisks.virtualHardDisk cannot be null.'));
          }
        }
      }
      if (parameters.storageProfile.oSDisk !== null && parameters.storageProfile.oSDisk !== undefined) {
        if (parameters.storageProfile.oSDisk.createOption === null || parameters.storageProfile.oSDisk.createOption === undefined) {
          return callback(new Error('parameters.storageProfile.oSDisk.createOption cannot be null.'));
        }
        if (parameters.storageProfile.oSDisk.encryptionSettings !== null && parameters.storageProfile.oSDisk.encryptionSettings !== undefined) {
          if (parameters.storageProfile.oSDisk.encryptionSettings.diskEncryptionKey === null || parameters.storageProfile.oSDisk.encryptionSettings.diskEncryptionKey === undefined) {
            return callback(new Error('parameters.storageProfile.oSDisk.encryptionSettings.diskEncryptionKey cannot be null.'));
          }
          if (parameters.storageProfile.oSDisk.encryptionSettings.diskEncryptionKey.secretUrl === null || parameters.storageProfile.oSDisk.encryptionSettings.diskEncryptionKey.secretUrl === undefined) {
            return callback(new Error('parameters.storageProfile.oSDisk.encryptionSettings.diskEncryptionKey.secretUrl cannot be null.'));
          }
          if (parameters.storageProfile.oSDisk.encryptionSettings.diskEncryptionKey.sourceVault === null || parameters.storageProfile.oSDisk.encryptionSettings.diskEncryptionKey.sourceVault === undefined) {
            return callback(new Error('parameters.storageProfile.oSDisk.encryptionSettings.diskEncryptionKey.sourceVault cannot be null.'));
          }
          if (parameters.storageProfile.oSDisk.encryptionSettings.keyEncryptionKey !== null && parameters.storageProfile.oSDisk.encryptionSettings.keyEncryptionKey !== undefined) {
            if (parameters.storageProfile.oSDisk.encryptionSettings.keyEncryptionKey.keyUrl === null || parameters.storageProfile.oSDisk.encryptionSettings.keyEncryptionKey.keyUrl === undefined) {
              return callback(new Error('parameters.storageProfile.oSDisk.encryptionSettings.keyEncryptionKey.keyUrl cannot be null.'));
            }
            if (parameters.storageProfile.oSDisk.encryptionSettings.keyEncryptionKey.sourceVault === null || parameters.storageProfile.oSDisk.encryptionSettings.keyEncryptionKey.sourceVault === undefined) {
              return callback(new Error('parameters.storageProfile.oSDisk.encryptionSettings.keyEncryptionKey.sourceVault cannot be null.'));
            }
          }
        }
        if (parameters.storageProfile.oSDisk.name === null || parameters.storageProfile.oSDisk.name === undefined) {
          return callback(new Error('parameters.storageProfile.oSDisk.name cannot be null.'));
        }
        if (parameters.storageProfile.oSDisk.virtualHardDisk === null || parameters.storageProfile.oSDisk.virtualHardDisk === undefined) {
          return callback(new Error('parameters.storageProfile.oSDisk.virtualHardDisk cannot be null.'));
        }
      }
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/';
    url2 = url2 + 'virtualMachines';
    url2 = url2 + '/';
    if (parameters.name !== null && parameters.name !== undefined) {
      url2 = url2 + encodeURIComponent(parameters.name);
    }
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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/json';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var virtualMachineJsonValue = {};
    requestDoc = virtualMachineJsonValue;
    
    if (parameters.plan !== null && parameters.plan !== undefined) {
      var planValue = {};
      virtualMachineJsonValue['plan'] = planValue;
      
      if (parameters.plan.name !== null && parameters.plan.name !== undefined) {
        planValue['name'] = parameters.plan.name;
      }
      
      if (parameters.plan.publisher !== null && parameters.plan.publisher !== undefined) {
        planValue['publisher'] = parameters.plan.publisher;
      }
      
      if (parameters.plan.product !== null && parameters.plan.product !== undefined) {
        planValue['product'] = parameters.plan.product;
      }
      
      if (parameters.plan.promotionCode !== null && parameters.plan.promotionCode !== undefined) {
        planValue['promotionCode'] = parameters.plan.promotionCode;
      }
    }
    
    var propertiesValue = {};
    virtualMachineJsonValue['properties'] = propertiesValue;
    
    if (parameters.hardwareProfile !== null && parameters.hardwareProfile !== undefined) {
      var hardwareProfileValue = {};
      propertiesValue['hardwareProfile'] = hardwareProfileValue;
      
      if (parameters.hardwareProfile.virtualMachineSize !== null && parameters.hardwareProfile.virtualMachineSize !== undefined) {
        hardwareProfileValue['vmSize'] = parameters.hardwareProfile.virtualMachineSize;
      }
    }
    
    if (parameters.storageProfile !== null && parameters.storageProfile !== undefined) {
      var storageProfileValue = {};
      propertiesValue['storageProfile'] = storageProfileValue;
      
      if (parameters.storageProfile.imageReference !== null && parameters.storageProfile.imageReference !== undefined) {
        var imageReferenceValue = {};
        storageProfileValue['imageReference'] = imageReferenceValue;
        
        if (parameters.storageProfile.imageReference.publisher !== null && parameters.storageProfile.imageReference.publisher !== undefined) {
          imageReferenceValue['publisher'] = parameters.storageProfile.imageReference.publisher;
        }
        
        if (parameters.storageProfile.imageReference.offer !== null && parameters.storageProfile.imageReference.offer !== undefined) {
          imageReferenceValue['offer'] = parameters.storageProfile.imageReference.offer;
        }
        
        if (parameters.storageProfile.imageReference.sku !== null && parameters.storageProfile.imageReference.sku !== undefined) {
          imageReferenceValue['sku'] = parameters.storageProfile.imageReference.sku;
        }
        
        if (parameters.storageProfile.imageReference.version !== null && parameters.storageProfile.imageReference.version !== undefined) {
          imageReferenceValue['version'] = parameters.storageProfile.imageReference.version;
        }
      }
      
      if (parameters.storageProfile.oSDisk !== null && parameters.storageProfile.oSDisk !== undefined) {
        var osDiskValue = {};
        storageProfileValue['osDisk'] = osDiskValue;
        
        if (parameters.storageProfile.oSDisk.operatingSystemType !== null && parameters.storageProfile.oSDisk.operatingSystemType !== undefined) {
          osDiskValue['osType'] = parameters.storageProfile.oSDisk.operatingSystemType;
        }
        
        if (parameters.storageProfile.oSDisk.encryptionSettings !== null && parameters.storageProfile.oSDisk.encryptionSettings !== undefined) {
          var encryptionSettingsValue = {};
          osDiskValue['encryptionSettings'] = encryptionSettingsValue;
          
          var diskEncryptionKeyValue = {};
          encryptionSettingsValue['diskEncryptionKey'] = diskEncryptionKeyValue;
          
          diskEncryptionKeyValue['secretUrl'] = parameters.storageProfile.oSDisk.encryptionSettings.diskEncryptionKey.secretUrl;
          
          var sourceVaultValue = {};
          diskEncryptionKeyValue['sourceVault'] = sourceVaultValue;
          
          if (parameters.storageProfile.oSDisk.encryptionSettings.diskEncryptionKey.sourceVault.referenceUri !== null && parameters.storageProfile.oSDisk.encryptionSettings.diskEncryptionKey.sourceVault.referenceUri !== undefined) {
            sourceVaultValue['id'] = parameters.storageProfile.oSDisk.encryptionSettings.diskEncryptionKey.sourceVault.referenceUri;
          }
          
          if (parameters.storageProfile.oSDisk.encryptionSettings.keyEncryptionKey !== null && parameters.storageProfile.oSDisk.encryptionSettings.keyEncryptionKey !== undefined) {
            var keyEncryptionKeyValue = {};
            encryptionSettingsValue['keyEncryptionKey'] = keyEncryptionKeyValue;
            
            keyEncryptionKeyValue['keyUrl'] = parameters.storageProfile.oSDisk.encryptionSettings.keyEncryptionKey.keyUrl;
            
            var sourceVaultValue2 = {};
            keyEncryptionKeyValue['sourceVault'] = sourceVaultValue2;
            
            if (parameters.storageProfile.oSDisk.encryptionSettings.keyEncryptionKey.sourceVault.referenceUri !== null && parameters.storageProfile.oSDisk.encryptionSettings.keyEncryptionKey.sourceVault.referenceUri !== undefined) {
              sourceVaultValue2['id'] = parameters.storageProfile.oSDisk.encryptionSettings.keyEncryptionKey.sourceVault.referenceUri;
            }
          }
        }
        
        osDiskValue['name'] = parameters.storageProfile.oSDisk.name;
        
        var vhdValue = {};
        osDiskValue['vhd'] = vhdValue;
        
        if (parameters.storageProfile.oSDisk.virtualHardDisk.uri !== null && parameters.storageProfile.oSDisk.virtualHardDisk.uri !== undefined) {
          vhdValue['uri'] = parameters.storageProfile.oSDisk.virtualHardDisk.uri;
        }
        
        if (parameters.storageProfile.oSDisk.sourceImage !== null && parameters.storageProfile.oSDisk.sourceImage !== undefined) {
          var imageValue = {};
          osDiskValue['image'] = imageValue;
          
          if (parameters.storageProfile.oSDisk.sourceImage.uri !== null && parameters.storageProfile.oSDisk.sourceImage.uri !== undefined) {
            imageValue['uri'] = parameters.storageProfile.oSDisk.sourceImage.uri;
          }
        }
        
        if (parameters.storageProfile.oSDisk.caching !== null && parameters.storageProfile.oSDisk.caching !== undefined) {
          osDiskValue['caching'] = parameters.storageProfile.oSDisk.caching;
        }
        
        osDiskValue['createOption'] = parameters.storageProfile.oSDisk.createOption;
        
        if (parameters.storageProfile.oSDisk.diskSizeGB !== null && parameters.storageProfile.oSDisk.diskSizeGB !== undefined) {
          osDiskValue['diskSizeGB'] = parameters.storageProfile.oSDisk.diskSizeGB;
        }
      }
      
      if (parameters.storageProfile.dataDisks !== null && parameters.storageProfile.dataDisks !== undefined) {
        var dataDisksArray = [];
        for (var loweredIndex3 = 0; loweredIndex3 < parameters.storageProfile.dataDisks.length; loweredIndex3 = loweredIndex3 + 1) {
          var dataDisksItem = parameters.storageProfile.dataDisks[loweredIndex3];
          var dataDiskValue = {};
          dataDisksArray.push(dataDiskValue);
          
          dataDiskValue['lun'] = dataDisksItem.lun;
          
          dataDiskValue['name'] = dataDisksItem.name;
          
          var vhdValue2 = {};
          dataDiskValue['vhd'] = vhdValue2;
          
          if (dataDisksItem.virtualHardDisk.uri !== null && dataDisksItem.virtualHardDisk.uri !== undefined) {
            vhdValue2['uri'] = dataDisksItem.virtualHardDisk.uri;
          }
          
          if (dataDisksItem.sourceImage !== null && dataDisksItem.sourceImage !== undefined) {
            var imageValue2 = {};
            dataDiskValue['image'] = imageValue2;
            
            if (dataDisksItem.sourceImage.uri !== null && dataDisksItem.sourceImage.uri !== undefined) {
              imageValue2['uri'] = dataDisksItem.sourceImage.uri;
            }
          }
          
          if (dataDisksItem.caching !== null && dataDisksItem.caching !== undefined) {
            dataDiskValue['caching'] = dataDisksItem.caching;
          }
          
          dataDiskValue['createOption'] = dataDisksItem.createOption;
          
          if (dataDisksItem.diskSizeGB !== null && dataDisksItem.diskSizeGB !== undefined) {
            dataDiskValue['diskSizeGB'] = dataDisksItem.diskSizeGB;
          }
        }
        storageProfileValue['dataDisks'] = dataDisksArray;
      }
    }
    
    if (parameters.oSProfile !== null && parameters.oSProfile !== undefined) {
      var osProfileValue = {};
      propertiesValue['osProfile'] = osProfileValue;
      
      if (parameters.oSProfile.computerName !== null && parameters.oSProfile.computerName !== undefined) {
        osProfileValue['computerName'] = parameters.oSProfile.computerName;
      }
      
      if (parameters.oSProfile.adminUsername !== null && parameters.oSProfile.adminUsername !== undefined) {
        osProfileValue['adminUsername'] = parameters.oSProfile.adminUsername;
      }
      
      if (parameters.oSProfile.adminPassword !== null && parameters.oSProfile.adminPassword !== undefined) {
        osProfileValue['adminPassword'] = parameters.oSProfile.adminPassword;
      }
      
      if (parameters.oSProfile.customData !== null && parameters.oSProfile.customData !== undefined) {
        osProfileValue['customData'] = parameters.oSProfile.customData;
      }
      
      if (parameters.oSProfile.windowsConfiguration !== null && parameters.oSProfile.windowsConfiguration !== undefined) {
        var windowsConfigurationValue = {};
        osProfileValue['windowsConfiguration'] = windowsConfigurationValue;
        
        if (parameters.oSProfile.windowsConfiguration.provisionVMAgent !== null && parameters.oSProfile.windowsConfiguration.provisionVMAgent !== undefined) {
          windowsConfigurationValue['provisionVMAgent'] = parameters.oSProfile.windowsConfiguration.provisionVMAgent;
        }
        
        if (parameters.oSProfile.windowsConfiguration.enableAutomaticUpdates !== null && parameters.oSProfile.windowsConfiguration.enableAutomaticUpdates !== undefined) {
          windowsConfigurationValue['enableAutomaticUpdates'] = parameters.oSProfile.windowsConfiguration.enableAutomaticUpdates;
        }
        
        if (parameters.oSProfile.windowsConfiguration.timeZone !== null && parameters.oSProfile.windowsConfiguration.timeZone !== undefined) {
          windowsConfigurationValue['timeZone'] = parameters.oSProfile.windowsConfiguration.timeZone;
        }
        
        if (parameters.oSProfile.windowsConfiguration.additionalUnattendContents !== null && parameters.oSProfile.windowsConfiguration.additionalUnattendContents !== undefined) {
          var additionalUnattendContentArray = [];
          for (var loweredIndex4 = 0; loweredIndex4 < parameters.oSProfile.windowsConfiguration.additionalUnattendContents.length; loweredIndex4 = loweredIndex4 + 1) {
            var additionalUnattendContentItem = parameters.oSProfile.windowsConfiguration.additionalUnattendContents[loweredIndex4];
            var additionalUnattendContentValue = {};
            additionalUnattendContentArray.push(additionalUnattendContentValue);
            
            if (additionalUnattendContentItem.passName !== null && additionalUnattendContentItem.passName !== undefined) {
              additionalUnattendContentValue['passName'] = additionalUnattendContentItem.passName;
            }
            
            if (additionalUnattendContentItem.componentName !== null && additionalUnattendContentItem.componentName !== undefined) {
              additionalUnattendContentValue['componentName'] = additionalUnattendContentItem.componentName;
            }
            
            if (additionalUnattendContentItem.settingName !== null && additionalUnattendContentItem.settingName !== undefined) {
              additionalUnattendContentValue['settingName'] = additionalUnattendContentItem.settingName;
            }
            
            if (additionalUnattendContentItem.content !== null && additionalUnattendContentItem.content !== undefined) {
              additionalUnattendContentValue['content'] = additionalUnattendContentItem.content;
            }
          }
          windowsConfigurationValue['additionalUnattendContent'] = additionalUnattendContentArray;
        }
        
        if (parameters.oSProfile.windowsConfiguration.winRMConfiguration !== null && parameters.oSProfile.windowsConfiguration.winRMConfiguration !== undefined) {
          var winRMValue = {};
          windowsConfigurationValue['winRM'] = winRMValue;
          
          if (parameters.oSProfile.windowsConfiguration.winRMConfiguration.listeners !== null && parameters.oSProfile.windowsConfiguration.winRMConfiguration.listeners !== undefined) {
            var listenersArray = [];
            for (var loweredIndex5 = 0; loweredIndex5 < parameters.oSProfile.windowsConfiguration.winRMConfiguration.listeners.length; loweredIndex5 = loweredIndex5 + 1) {
              var listenersItem = parameters.oSProfile.windowsConfiguration.winRMConfiguration.listeners[loweredIndex5];
              var winRMListenerValue = {};
              listenersArray.push(winRMListenerValue);
              
              if (listenersItem.protocol !== null && listenersItem.protocol !== undefined) {
                winRMListenerValue['protocol'] = listenersItem.protocol;
              }
              
              if (listenersItem.certificateUrl !== null && listenersItem.certificateUrl !== undefined) {
                winRMListenerValue['certificateUrl'] = listenersItem.certificateUrl;
              }
            }
            winRMValue['listeners'] = listenersArray;
          }
        }
      }
      
      if (parameters.oSProfile.linuxConfiguration !== null && parameters.oSProfile.linuxConfiguration !== undefined) {
        var linuxConfigurationValue = {};
        osProfileValue['linuxConfiguration'] = linuxConfigurationValue;
        
        if (parameters.oSProfile.linuxConfiguration.disablePasswordAuthentication !== null && parameters.oSProfile.linuxConfiguration.disablePasswordAuthentication !== undefined) {
          linuxConfigurationValue['disablePasswordAuthentication'] = parameters.oSProfile.linuxConfiguration.disablePasswordAuthentication;
        }
        
        if (parameters.oSProfile.linuxConfiguration.sshConfiguration !== null && parameters.oSProfile.linuxConfiguration.sshConfiguration !== undefined) {
          var sshValue = {};
          linuxConfigurationValue['ssh'] = sshValue;
          
          if (parameters.oSProfile.linuxConfiguration.sshConfiguration.publicKeys !== null && parameters.oSProfile.linuxConfiguration.sshConfiguration.publicKeys !== undefined) {
            var publicKeysArray = [];
            for (var loweredIndex6 = 0; loweredIndex6 < parameters.oSProfile.linuxConfiguration.sshConfiguration.publicKeys.length; loweredIndex6 = loweredIndex6 + 1) {
              var publicKeysItem = parameters.oSProfile.linuxConfiguration.sshConfiguration.publicKeys[loweredIndex6];
              var sshPublicKeyValue = {};
              publicKeysArray.push(sshPublicKeyValue);
              
              if (publicKeysItem.path !== null && publicKeysItem.path !== undefined) {
                sshPublicKeyValue['path'] = publicKeysItem.path;
              }
              
              if (publicKeysItem.keyData !== null && publicKeysItem.keyData !== undefined) {
                sshPublicKeyValue['keyData'] = publicKeysItem.keyData;
              }
            }
            sshValue['publicKeys'] = publicKeysArray;
          }
        }
      }
      
      if (parameters.oSProfile.secrets !== null && parameters.oSProfile.secrets !== undefined) {
        var secretsArray = [];
        for (var loweredIndex7 = 0; loweredIndex7 < parameters.oSProfile.secrets.length; loweredIndex7 = loweredIndex7 + 1) {
          var secretsItem = parameters.oSProfile.secrets[loweredIndex7];
          var vaultSecretGroupValue = {};
          secretsArray.push(vaultSecretGroupValue);
          
          if (secretsItem.sourceVault !== null && secretsItem.sourceVault !== undefined) {
            var sourceVaultValue3 = {};
            vaultSecretGroupValue['sourceVault'] = sourceVaultValue3;
            
            if (secretsItem.sourceVault.referenceUri !== null && secretsItem.sourceVault.referenceUri !== undefined) {
              sourceVaultValue3['id'] = secretsItem.sourceVault.referenceUri;
            }
          }
          
          if (secretsItem.vaultCertificates !== null && secretsItem.vaultCertificates !== undefined) {
            var vaultCertificatesArray = [];
            for (var loweredIndex8 = 0; loweredIndex8 < secretsItem.vaultCertificates.length; loweredIndex8 = loweredIndex8 + 1) {
              var vaultCertificatesItem = secretsItem.vaultCertificates[loweredIndex8];
              var vaultCertificateValue = {};
              vaultCertificatesArray.push(vaultCertificateValue);
              
              if (vaultCertificatesItem.certificateUrl !== null && vaultCertificatesItem.certificateUrl !== undefined) {
                vaultCertificateValue['certificateUrl'] = vaultCertificatesItem.certificateUrl;
              }
              
              if (vaultCertificatesItem.certificateStore !== null && vaultCertificatesItem.certificateStore !== undefined) {
                vaultCertificateValue['certificateStore'] = vaultCertificatesItem.certificateStore;
              }
            }
            vaultSecretGroupValue['vaultCertificates'] = vaultCertificatesArray;
          }
        }
        osProfileValue['secrets'] = secretsArray;
      }
    }
    
    if (parameters.networkProfile !== null && parameters.networkProfile !== undefined) {
      var networkProfileValue = {};
      propertiesValue['networkProfile'] = networkProfileValue;
      
      if (parameters.networkProfile.networkInterfaces !== null && parameters.networkProfile.networkInterfaces !== undefined) {
        var networkInterfacesArray = [];
        for (var loweredIndex9 = 0; loweredIndex9 < parameters.networkProfile.networkInterfaces.length; loweredIndex9 = loweredIndex9 + 1) {
          var networkInterfacesItem = parameters.networkProfile.networkInterfaces[loweredIndex9];
          var networkInterfaceReferenceJsonValue = {};
          networkInterfacesArray.push(networkInterfaceReferenceJsonValue);
          
          var propertiesValue2 = {};
          networkInterfaceReferenceJsonValue['properties'] = propertiesValue2;
          
          if (networkInterfacesItem.primary !== null && networkInterfacesItem.primary !== undefined) {
            propertiesValue2['primary'] = networkInterfacesItem.primary;
          }
          
          if (networkInterfacesItem.referenceUri !== null && networkInterfacesItem.referenceUri !== undefined) {
            networkInterfaceReferenceJsonValue['id'] = networkInterfacesItem.referenceUri;
          }
        }
        networkProfileValue['networkInterfaces'] = networkInterfacesArray;
      }
    }
    
    if (parameters.diagnosticsProfile !== null && parameters.diagnosticsProfile !== undefined) {
      var diagnosticsProfileValue = {};
      propertiesValue['diagnosticsProfile'] = diagnosticsProfileValue;
      
      if (parameters.diagnosticsProfile.bootDiagnostics !== null && parameters.diagnosticsProfile.bootDiagnostics !== undefined) {
        var bootDiagnosticsValue = {};
        diagnosticsProfileValue['bootDiagnostics'] = bootDiagnosticsValue;
        
        if (parameters.diagnosticsProfile.bootDiagnostics.enabled !== null && parameters.diagnosticsProfile.bootDiagnostics.enabled !== undefined) {
          bootDiagnosticsValue['enabled'] = parameters.diagnosticsProfile.bootDiagnostics.enabled;
        }
        
        if (parameters.diagnosticsProfile.bootDiagnostics.storageUri !== null && parameters.diagnosticsProfile.bootDiagnostics.storageUri !== undefined) {
          bootDiagnosticsValue['storageUri'] = parameters.diagnosticsProfile.bootDiagnostics.storageUri;
        }
      }
    }
    
    if (parameters.availabilitySetReference !== null && parameters.availabilitySetReference !== undefined) {
      var availabilitySetValue = {};
      propertiesValue['availabilitySet'] = availabilitySetValue;
      
      if (parameters.availabilitySetReference.referenceUri !== null && parameters.availabilitySetReference.referenceUri !== undefined) {
        availabilitySetValue['id'] = parameters.availabilitySetReference.referenceUri;
      }
    }
    
    if (parameters.provisioningState !== null && parameters.provisioningState !== undefined) {
      propertiesValue['provisioningState'] = parameters.provisioningState;
    }
    
    if (parameters.instanceView !== null && parameters.instanceView !== undefined) {
      var instanceViewValue = {};
      propertiesValue['instanceView'] = instanceViewValue;
      
      if (parameters.instanceView.platformUpdateDomain !== null && parameters.instanceView.platformUpdateDomain !== undefined) {
        instanceViewValue['platformUpdateDomain'] = parameters.instanceView.platformUpdateDomain;
      }
      
      if (parameters.instanceView.platformFaultDomain !== null && parameters.instanceView.platformFaultDomain !== undefined) {
        instanceViewValue['platformFaultDomain'] = parameters.instanceView.platformFaultDomain;
      }
      
      if (parameters.instanceView.remoteDesktopThumbprint !== null && parameters.instanceView.remoteDesktopThumbprint !== undefined) {
        instanceViewValue['rdpThumbPrint'] = parameters.instanceView.remoteDesktopThumbprint;
      }
      
      if (parameters.instanceView.vMAgent !== null && parameters.instanceView.vMAgent !== undefined) {
        var vmAgentValue = {};
        instanceViewValue['vmAgent'] = vmAgentValue;
        
        if (parameters.instanceView.vMAgent.vMAgentVersion !== null && parameters.instanceView.vMAgent.vMAgentVersion !== undefined) {
          vmAgentValue['vmAgentVersion'] = parameters.instanceView.vMAgent.vMAgentVersion;
        }
        
        if (parameters.instanceView.vMAgent.extensionHandlers !== null && parameters.instanceView.vMAgent.extensionHandlers !== undefined) {
          var extensionHandlersArray = [];
          for (var loweredIndex10 = 0; loweredIndex10 < parameters.instanceView.vMAgent.extensionHandlers.length; loweredIndex10 = loweredIndex10 + 1) {
            var extensionHandlersItem = parameters.instanceView.vMAgent.extensionHandlers[loweredIndex10];
            var virtualMachineExtensionHandlerInstanceViewValue = {};
            extensionHandlersArray.push(virtualMachineExtensionHandlerInstanceViewValue);
            
            if (extensionHandlersItem.type !== null && extensionHandlersItem.type !== undefined) {
              virtualMachineExtensionHandlerInstanceViewValue['type'] = extensionHandlersItem.type;
            }
            
            if (extensionHandlersItem.typeHandlerVersion !== null && extensionHandlersItem.typeHandlerVersion !== undefined) {
              virtualMachineExtensionHandlerInstanceViewValue['typeHandlerVersion'] = extensionHandlersItem.typeHandlerVersion;
            }
            
            if (extensionHandlersItem.status !== null && extensionHandlersItem.status !== undefined) {
              var statusValue = {};
              virtualMachineExtensionHandlerInstanceViewValue['status'] = statusValue;
              
              if (extensionHandlersItem.status.code !== null && extensionHandlersItem.status.code !== undefined) {
                statusValue['code'] = extensionHandlersItem.status.code;
              }
              
              if (extensionHandlersItem.status.level !== null && extensionHandlersItem.status.level !== undefined) {
                statusValue['level'] = extensionHandlersItem.status.level;
              }
              
              if (extensionHandlersItem.status.displayStatus !== null && extensionHandlersItem.status.displayStatus !== undefined) {
                statusValue['displayStatus'] = extensionHandlersItem.status.displayStatus;
              }
              
              if (extensionHandlersItem.status.message !== null && extensionHandlersItem.status.message !== undefined) {
                statusValue['message'] = extensionHandlersItem.status.message;
              }
              
              if (extensionHandlersItem.status.time !== null && extensionHandlersItem.status.time !== undefined) {
                statusValue['time'] = extensionHandlersItem.status.time;
              }
            }
          }
          vmAgentValue['extensionHandlers'] = extensionHandlersArray;
        }
        
        if (parameters.instanceView.vMAgent.statuses !== null && parameters.instanceView.vMAgent.statuses !== undefined) {
          var statusesArray = [];
          for (var loweredIndex11 = 0; loweredIndex11 < parameters.instanceView.vMAgent.statuses.length; loweredIndex11 = loweredIndex11 + 1) {
            var statusesItem = parameters.instanceView.vMAgent.statuses[loweredIndex11];
            var instanceViewStatusValue = {};
            statusesArray.push(instanceViewStatusValue);
            
            if (statusesItem.code !== null && statusesItem.code !== undefined) {
              instanceViewStatusValue['code'] = statusesItem.code;
            }
            
            if (statusesItem.level !== null && statusesItem.level !== undefined) {
              instanceViewStatusValue['level'] = statusesItem.level;
            }
            
            if (statusesItem.displayStatus !== null && statusesItem.displayStatus !== undefined) {
              instanceViewStatusValue['displayStatus'] = statusesItem.displayStatus;
            }
            
            if (statusesItem.message !== null && statusesItem.message !== undefined) {
              instanceViewStatusValue['message'] = statusesItem.message;
            }
            
            if (statusesItem.time !== null && statusesItem.time !== undefined) {
              instanceViewStatusValue['time'] = statusesItem.time;
            }
          }
          vmAgentValue['statuses'] = statusesArray;
        }
      }
      
      if (parameters.instanceView.disks !== null && parameters.instanceView.disks !== undefined) {
        var disksArray = [];
        for (var loweredIndex12 = 0; loweredIndex12 < parameters.instanceView.disks.length; loweredIndex12 = loweredIndex12 + 1) {
          var disksItem = parameters.instanceView.disks[loweredIndex12];
          var diskInstanceViewValue = {};
          disksArray.push(diskInstanceViewValue);
          
          if (disksItem.name !== null && disksItem.name !== undefined) {
            diskInstanceViewValue['name'] = disksItem.name;
          }
          
          if (disksItem.statuses !== null && disksItem.statuses !== undefined) {
            var statusesArray2 = [];
            for (var loweredIndex13 = 0; loweredIndex13 < disksItem.statuses.length; loweredIndex13 = loweredIndex13 + 1) {
              var statusesItem2 = disksItem.statuses[loweredIndex13];
              var instanceViewStatusValue2 = {};
              statusesArray2.push(instanceViewStatusValue2);
              
              if (statusesItem2.code !== null && statusesItem2.code !== undefined) {
                instanceViewStatusValue2['code'] = statusesItem2.code;
              }
              
              if (statusesItem2.level !== null && statusesItem2.level !== undefined) {
                instanceViewStatusValue2['level'] = statusesItem2.level;
              }
              
              if (statusesItem2.displayStatus !== null && statusesItem2.displayStatus !== undefined) {
                instanceViewStatusValue2['displayStatus'] = statusesItem2.displayStatus;
              }
              
              if (statusesItem2.message !== null && statusesItem2.message !== undefined) {
                instanceViewStatusValue2['message'] = statusesItem2.message;
              }
              
              if (statusesItem2.time !== null && statusesItem2.time !== undefined) {
                instanceViewStatusValue2['time'] = statusesItem2.time;
              }
            }
            diskInstanceViewValue['statuses'] = statusesArray2;
          }
        }
        instanceViewValue['disks'] = disksArray;
      }
      
      if (parameters.instanceView.extensions !== null && parameters.instanceView.extensions !== undefined) {
        var extensionsArray = [];
        for (var loweredIndex14 = 0; loweredIndex14 < parameters.instanceView.extensions.length; loweredIndex14 = loweredIndex14 + 1) {
          var extensionsItem = parameters.instanceView.extensions[loweredIndex14];
          var virtualMachineExtensionInstanceViewValue = {};
          extensionsArray.push(virtualMachineExtensionInstanceViewValue);
          
          if (extensionsItem.name !== null && extensionsItem.name !== undefined) {
            virtualMachineExtensionInstanceViewValue['name'] = extensionsItem.name;
          }
          
          if (extensionsItem.extensionType !== null && extensionsItem.extensionType !== undefined) {
            virtualMachineExtensionInstanceViewValue['type'] = extensionsItem.extensionType;
          }
          
          if (extensionsItem.typeHandlerVersion !== null && extensionsItem.typeHandlerVersion !== undefined) {
            virtualMachineExtensionInstanceViewValue['typeHandlerVersion'] = extensionsItem.typeHandlerVersion;
          }
          
          if (extensionsItem.subStatuses !== null && extensionsItem.subStatuses !== undefined) {
            var substatusesArray = [];
            for (var loweredIndex15 = 0; loweredIndex15 < extensionsItem.subStatuses.length; loweredIndex15 = loweredIndex15 + 1) {
              var substatusesItem = extensionsItem.subStatuses[loweredIndex15];
              var instanceViewStatusValue3 = {};
              substatusesArray.push(instanceViewStatusValue3);
              
              if (substatusesItem.code !== null && substatusesItem.code !== undefined) {
                instanceViewStatusValue3['code'] = substatusesItem.code;
              }
              
              if (substatusesItem.level !== null && substatusesItem.level !== undefined) {
                instanceViewStatusValue3['level'] = substatusesItem.level;
              }
              
              if (substatusesItem.displayStatus !== null && substatusesItem.displayStatus !== undefined) {
                instanceViewStatusValue3['displayStatus'] = substatusesItem.displayStatus;
              }
              
              if (substatusesItem.message !== null && substatusesItem.message !== undefined) {
                instanceViewStatusValue3['message'] = substatusesItem.message;
              }
              
              if (substatusesItem.time !== null && substatusesItem.time !== undefined) {
                instanceViewStatusValue3['time'] = substatusesItem.time;
              }
            }
            virtualMachineExtensionInstanceViewValue['substatuses'] = substatusesArray;
          }
          
          if (extensionsItem.statuses !== null && extensionsItem.statuses !== undefined) {
            var statusesArray3 = [];
            for (var loweredIndex16 = 0; loweredIndex16 < extensionsItem.statuses.length; loweredIndex16 = loweredIndex16 + 1) {
              var statusesItem3 = extensionsItem.statuses[loweredIndex16];
              var instanceViewStatusValue4 = {};
              statusesArray3.push(instanceViewStatusValue4);
              
              if (statusesItem3.code !== null && statusesItem3.code !== undefined) {
                instanceViewStatusValue4['code'] = statusesItem3.code;
              }
              
              if (statusesItem3.level !== null && statusesItem3.level !== undefined) {
                instanceViewStatusValue4['level'] = statusesItem3.level;
              }
              
              if (statusesItem3.displayStatus !== null && statusesItem3.displayStatus !== undefined) {
                instanceViewStatusValue4['displayStatus'] = statusesItem3.displayStatus;
              }
              
              if (statusesItem3.message !== null && statusesItem3.message !== undefined) {
                instanceViewStatusValue4['message'] = statusesItem3.message;
              }
              
              if (statusesItem3.time !== null && statusesItem3.time !== undefined) {
                instanceViewStatusValue4['time'] = statusesItem3.time;
              }
            }
            virtualMachineExtensionInstanceViewValue['statuses'] = statusesArray3;
          }
        }
        instanceViewValue['extensions'] = extensionsArray;
      }
      
      if (parameters.instanceView.bootDiagnostics !== null && parameters.instanceView.bootDiagnostics !== undefined) {
        var bootDiagnosticsValue2 = {};
        instanceViewValue['bootDiagnostics'] = bootDiagnosticsValue2;
        
        if (parameters.instanceView.bootDiagnostics.consoleScreenshotBlobUri !== null && parameters.instanceView.bootDiagnostics.consoleScreenshotBlobUri !== undefined) {
          bootDiagnosticsValue2['consoleScreenshotBlobUri'] = parameters.instanceView.bootDiagnostics.consoleScreenshotBlobUri;
        }
        
        if (parameters.instanceView.bootDiagnostics.serialConsoleLogBlobUri !== null && parameters.instanceView.bootDiagnostics.serialConsoleLogBlobUri !== undefined) {
          bootDiagnosticsValue2['serialConsoleLogBlobUri'] = parameters.instanceView.bootDiagnostics.serialConsoleLogBlobUri;
        }
      }
      
      if (parameters.instanceView.statuses !== null && parameters.instanceView.statuses !== undefined) {
        var statusesArray4 = [];
        for (var loweredIndex17 = 0; loweredIndex17 < parameters.instanceView.statuses.length; loweredIndex17 = loweredIndex17 + 1) {
          var statusesItem4 = parameters.instanceView.statuses[loweredIndex17];
          var instanceViewStatusValue5 = {};
          statusesArray4.push(instanceViewStatusValue5);
          
          if (statusesItem4.code !== null && statusesItem4.code !== undefined) {
            instanceViewStatusValue5['code'] = statusesItem4.code;
          }
          
          if (statusesItem4.level !== null && statusesItem4.level !== undefined) {
            instanceViewStatusValue5['level'] = statusesItem4.level;
          }
          
          if (statusesItem4.displayStatus !== null && statusesItem4.displayStatus !== undefined) {
            instanceViewStatusValue5['displayStatus'] = statusesItem4.displayStatus;
          }
          
          if (statusesItem4.message !== null && statusesItem4.message !== undefined) {
            instanceViewStatusValue5['message'] = statusesItem4.message;
          }
          
          if (statusesItem4.time !== null && statusesItem4.time !== undefined) {
            instanceViewStatusValue5['time'] = statusesItem4.time;
          }
        }
        instanceViewValue['statuses'] = statusesArray4;
      }
    }
    
    if (parameters.extensions !== null && parameters.extensions !== undefined) {
      var resourcesArray = [];
      for (var loweredIndex18 = 0; loweredIndex18 < parameters.extensions.length; loweredIndex18 = loweredIndex18 + 1) {
        var resourcesItem = parameters.extensions[loweredIndex18];
        var virtualMachineExtensionJsonValue = {};
        resourcesArray.push(virtualMachineExtensionJsonValue);
        
        var propertiesValue3 = {};
        virtualMachineExtensionJsonValue['properties'] = propertiesValue3;
        
        if (resourcesItem.publisher !== null && resourcesItem.publisher !== undefined) {
          propertiesValue3['publisher'] = resourcesItem.publisher;
        }
        
        if (resourcesItem.extensionType !== null && resourcesItem.extensionType !== undefined) {
          propertiesValue3['type'] = resourcesItem.extensionType;
        }
        
        if (resourcesItem.typeHandlerVersion !== null && resourcesItem.typeHandlerVersion !== undefined) {
          propertiesValue3['typeHandlerVersion'] = resourcesItem.typeHandlerVersion;
        }
        
        if (resourcesItem.autoUpgradeMinorVersion !== null && resourcesItem.autoUpgradeMinorVersion !== undefined) {
          propertiesValue3['autoUpgradeMinorVersion'] = resourcesItem.autoUpgradeMinorVersion;
        }
        
        if (resourcesItem.settings !== null && resourcesItem.settings !== undefined) {
          propertiesValue3['settings'] = resourcesItem.settings;
        }
        
        if (resourcesItem.protectedSettings !== null && resourcesItem.protectedSettings !== undefined) {
          propertiesValue3['protectedSettings'] = resourcesItem.protectedSettings;
        }
        
        if (resourcesItem.provisioningState !== null && resourcesItem.provisioningState !== undefined) {
          propertiesValue3['provisioningState'] = resourcesItem.provisioningState;
        }
        
        if (resourcesItem.instanceView !== null && resourcesItem.instanceView !== undefined) {
          var instanceViewValue2 = {};
          propertiesValue3['instanceView'] = instanceViewValue2;
          
          if (resourcesItem.instanceView.name !== null && resourcesItem.instanceView.name !== undefined) {
            instanceViewValue2['name'] = resourcesItem.instanceView.name;
          }
          
          if (resourcesItem.instanceView.extensionType !== null && resourcesItem.instanceView.extensionType !== undefined) {
            instanceViewValue2['type'] = resourcesItem.instanceView.extensionType;
          }
          
          if (resourcesItem.instanceView.typeHandlerVersion !== null && resourcesItem.instanceView.typeHandlerVersion !== undefined) {
            instanceViewValue2['typeHandlerVersion'] = resourcesItem.instanceView.typeHandlerVersion;
          }
          
          if (resourcesItem.instanceView.subStatuses !== null && resourcesItem.instanceView.subStatuses !== undefined) {
            var substatusesArray2 = [];
            for (var loweredIndex19 = 0; loweredIndex19 < resourcesItem.instanceView.subStatuses.length; loweredIndex19 = loweredIndex19 + 1) {
              var substatusesItem2 = resourcesItem.instanceView.subStatuses[loweredIndex19];
              var instanceViewStatusValue6 = {};
              substatusesArray2.push(instanceViewStatusValue6);
              
              if (substatusesItem2.code !== null && substatusesItem2.code !== undefined) {
                instanceViewStatusValue6['code'] = substatusesItem2.code;
              }
              
              if (substatusesItem2.level !== null && substatusesItem2.level !== undefined) {
                instanceViewStatusValue6['level'] = substatusesItem2.level;
              }
              
              if (substatusesItem2.displayStatus !== null && substatusesItem2.displayStatus !== undefined) {
                instanceViewStatusValue6['displayStatus'] = substatusesItem2.displayStatus;
              }
              
              if (substatusesItem2.message !== null && substatusesItem2.message !== undefined) {
                instanceViewStatusValue6['message'] = substatusesItem2.message;
              }
              
              if (substatusesItem2.time !== null && substatusesItem2.time !== undefined) {
                instanceViewStatusValue6['time'] = substatusesItem2.time;
              }
            }
            instanceViewValue2['substatuses'] = substatusesArray2;
          }
          
          if (resourcesItem.instanceView.statuses !== null && resourcesItem.instanceView.statuses !== undefined) {
            var statusesArray5 = [];
            for (var loweredIndex20 = 0; loweredIndex20 < resourcesItem.instanceView.statuses.length; loweredIndex20 = loweredIndex20 + 1) {
              var statusesItem5 = resourcesItem.instanceView.statuses[loweredIndex20];
              var instanceViewStatusValue7 = {};
              statusesArray5.push(instanceViewStatusValue7);
              
              if (statusesItem5.code !== null && statusesItem5.code !== undefined) {
                instanceViewStatusValue7['code'] = statusesItem5.code;
              }
              
              if (statusesItem5.level !== null && statusesItem5.level !== undefined) {
                instanceViewStatusValue7['level'] = statusesItem5.level;
              }
              
              if (statusesItem5.displayStatus !== null && statusesItem5.displayStatus !== undefined) {
                instanceViewStatusValue7['displayStatus'] = statusesItem5.displayStatus;
              }
              
              if (statusesItem5.message !== null && statusesItem5.message !== undefined) {
                instanceViewStatusValue7['message'] = statusesItem5.message;
              }
              
              if (statusesItem5.time !== null && statusesItem5.time !== undefined) {
                instanceViewStatusValue7['time'] = statusesItem5.time;
              }
            }
            instanceViewValue2['statuses'] = statusesArray5;
          }
        }
        
        if (resourcesItem.id !== null && resourcesItem.id !== undefined) {
          virtualMachineExtensionJsonValue['id'] = resourcesItem.id;
        }
        
        if (resourcesItem.name !== null && resourcesItem.name !== undefined) {
          virtualMachineExtensionJsonValue['name'] = resourcesItem.name;
        }
        
        if (resourcesItem.type !== null && resourcesItem.type !== undefined) {
          virtualMachineExtensionJsonValue['type'] = resourcesItem.type;
        }
        
        virtualMachineExtensionJsonValue['location'] = resourcesItem.location;
        
        if (resourcesItem.tags !== null && resourcesItem.tags !== undefined) {
          var tagsDictionary = {};
          for (var tagsKey in resourcesItem.tags) {
            var tagsValue = resourcesItem.tags[tagsKey];
            tagsDictionary[tagsKey] = tagsValue;
          }
          virtualMachineExtensionJsonValue['tags'] = tagsDictionary;
        }
      }
      virtualMachineJsonValue['resources'] = resourcesArray;
    }
    
    if (parameters.id !== null && parameters.id !== undefined) {
      virtualMachineJsonValue['id'] = parameters.id;
    }
    
    if (parameters.name !== null && parameters.name !== undefined) {
      virtualMachineJsonValue['name'] = parameters.name;
    }
    
    if (parameters.type !== null && parameters.type !== undefined) {
      virtualMachineJsonValue['type'] = parameters.type;
    }
    
    virtualMachineJsonValue['location'] = parameters.location;
    
    if (parameters.tags !== null && parameters.tags !== undefined) {
      var tagsDictionary2 = {};
      for (var tagsKey2 in parameters.tags) {
        var tagsValue2 = parameters.tags[tagsKey2];
        tagsDictionary2[tagsKey2] = tagsValue2;
      }
      virtualMachineJsonValue['tags'] = tagsDictionary2;
    }
    
    requestContent = JSON.stringify(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 && statusCode !== 201) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200 || statusCode === 201) {
        var responseContent = body;
        result = {};
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var virtualMachineInstance = { extensions: [], tags: {} };
          result.virtualMachine = virtualMachineInstance;
          
          var planValue2 = responseDoc['plan'];
          if (planValue2 !== null && planValue2 !== undefined) {
            var planInstance = {};
            virtualMachineInstance.plan = planInstance;
            
            var nameValue = planValue2['name'];
            if (nameValue !== null && nameValue !== undefined) {
              var nameInstance = nameValue;
              planInstance.name = nameInstance;
            }
            
            var publisherValue = planValue2['publisher'];
            if (publisherValue !== null && publisherValue !== undefined) {
              var publisherInstance = publisherValue;
              planInstance.publisher = publisherInstance;
            }
            
            var productValue = planValue2['product'];
            if (productValue !== null && productValue !== undefined) {
              var productInstance = productValue;
              planInstance.product = productInstance;
            }
            
            var promotionCodeValue = planValue2['promotionCode'];
            if (promotionCodeValue !== null && promotionCodeValue !== undefined) {
              var promotionCodeInstance = promotionCodeValue;
              planInstance.promotionCode = promotionCodeInstance;
            }
          }
          
          var propertiesValue4 = responseDoc['properties'];
          if (propertiesValue4 !== null && propertiesValue4 !== undefined) {
            var hardwareProfileValue2 = propertiesValue4['hardwareProfile'];
            if (hardwareProfileValue2 !== null && hardwareProfileValue2 !== undefined) {
              var hardwareProfileInstance = {};
              virtualMachineInstance.hardwareProfile = hardwareProfileInstance;
              
              var vmSizeValue = hardwareProfileValue2['vmSize'];
              if (vmSizeValue !== null && vmSizeValue !== undefined) {
                var vmSizeInstance = vmSizeValue;
                hardwareProfileInstance.virtualMachineSize = vmSizeInstance;
              }
            }
            
            var storageProfileValue2 = propertiesValue4['storageProfile'];
            if (storageProfileValue2 !== null && storageProfileValue2 !== undefined) {
              var storageProfileInstance = { dataDisks: [] };
              virtualMachineInstance.storageProfile = storageProfileInstance;
              
              var imageReferenceValue2 = storageProfileValue2['imageReference'];
              if (imageReferenceValue2 !== null && imageReferenceValue2 !== undefined) {
                var imageReferenceInstance = {};
                storageProfileInstance.imageReference = imageReferenceInstance;
                
                var publisherValue2 = imageReferenceValue2['publisher'];
                if (publisherValue2 !== null && publisherValue2 !== undefined) {
                  var publisherInstance2 = publisherValue2;
                  imageReferenceInstance.publisher = publisherInstance2;
                }
                
                var offerValue = imageReferenceValue2['offer'];
                if (offerValue !== null && offerValue !== undefined) {
                  var offerInstance = offerValue;
                  imageReferenceInstance.offer = offerInstance;
                }
                
                var skuValue = imageReferenceValue2['sku'];
                if (skuValue !== null && skuValue !== undefined) {
                  var skuInstance = skuValue;
                  imageReferenceInstance.sku = skuInstance;
                }
                
                var versionValue = imageReferenceValue2['version'];
                if (versionValue !== null && versionValue !== undefined) {
                  var versionInstance = versionValue;
                  imageReferenceInstance.version = versionInstance;
                }
              }
              
              var osDiskValue2 = storageProfileValue2['osDisk'];
              if (osDiskValue2 !== null && osDiskValue2 !== undefined) {
                var osDiskInstance = {};
                storageProfileInstance.oSDisk = osDiskInstance;
                
                var osTypeValue = osDiskValue2['osType'];
                if (osTypeValue !== null && osTypeValue !== undefined) {
                  var osTypeInstance = osTypeValue;
                  osDiskInstance.operatingSystemType = osTypeInstance;
                }
                
                var encryptionSettingsValue2 = osDiskValue2['encryptionSettings'];
                if (encryptionSettingsValue2 !== null && encryptionSettingsValue2 !== undefined) {
                  var encryptionSettingsInstance = {};
                  osDiskInstance.encryptionSettings = encryptionSettingsInstance;
                  
                  var diskEncryptionKeyValue2 = encryptionSettingsValue2['diskEncryptionKey'];
                  if (diskEncryptionKeyValue2 !== null && diskEncryptionKeyValue2 !== undefined) {
                    var diskEncryptionKeyInstance = {};
                    encryptionSettingsInstance.diskEncryptionKey = diskEncryptionKeyInstance;
                    
                    var secretUrlValue = diskEncryptionKeyValue2['secretUrl'];
                    if (secretUrlValue !== null && secretUrlValue !== undefined) {
                      var secretUrlInstance = secretUrlValue;
                      diskEncryptionKeyInstance.secretUrl = secretUrlInstance;
                    }
                    
                    var sourceVaultValue4 = diskEncryptionKeyValue2['sourceVault'];
                    if (sourceVaultValue4 !== null && sourceVaultValue4 !== undefined) {
                      var sourceVaultInstance = {};
                      diskEncryptionKeyInstance.sourceVault = sourceVaultInstance;
                      
                      var idValue = sourceVaultValue4['id'];
                      if (idValue !== null && idValue !== undefined) {
                        var idInstance = idValue;
                        sourceVaultInstance.referenceUri = idInstance;
                      }
                    }
                  }
                  
                  var keyEncryptionKeyValue2 = encryptionSettingsValue2['keyEncryptionKey'];
                  if (keyEncryptionKeyValue2 !== null && keyEncryptionKeyValue2 !== undefined) {
                    var keyEncryptionKeyInstance = {};
                    encryptionSettingsInstance.keyEncryptionKey = keyEncryptionKeyInstance;
                    
                    var keyUrlValue = keyEncryptionKeyValue2['keyUrl'];
                    if (keyUrlValue !== null && keyUrlValue !== undefined) {
                      var keyUrlInstance = keyUrlValue;
                      keyEncryptionKeyInstance.keyUrl = keyUrlInstance;
                    }
                    
                    var sourceVaultValue5 = keyEncryptionKeyValue2['sourceVault'];
                    if (sourceVaultValue5 !== null && sourceVaultValue5 !== undefined) {
                      var sourceVaultInstance2 = {};
                      keyEncryptionKeyInstance.sourceVault = sourceVaultInstance2;
                      
                      var idValue2 = sourceVaultValue5['id'];
                      if (idValue2 !== null && idValue2 !== undefined) {
                        var idInstance2 = idValue2;
                        sourceVaultInstance2.referenceUri = idInstance2;
                      }
                    }
                  }
                }
                
                var nameValue2 = osDiskValue2['name'];
                if (nameValue2 !== null && nameValue2 !== undefined) {
                  var nameInstance2 = nameValue2;
                  osDiskInstance.name = nameInstance2;
                }
                
                var vhdValue3 = osDiskValue2['vhd'];
                if (vhdValue3 !== null && vhdValue3 !== undefined) {
                  var vhdInstance = {};
                  osDiskInstance.virtualHardDisk = vhdInstance;
                  
                  var uriValue = vhdValue3['uri'];
                  if (uriValue !== null && uriValue !== undefined) {
                    var uriInstance = uriValue;
                    vhdInstance.uri = uriInstance;
                  }
                }
                
                var imageValue3 = osDiskValue2['image'];
                if (imageValue3 !== null && imageValue3 !== undefined) {
                  var imageInstance = {};
                  osDiskInstance.sourceImage = imageInstance;
                  
                  var uriValue2 = imageValue3['uri'];
                  if (uriValue2 !== null && uriValue2 !== undefined) {
                    var uriInstance2 = uriValue2;
                    imageInstance.uri = uriInstance2;
                  }
                }
                
                var cachingValue = osDiskValue2['caching'];
                if (cachingValue !== null && cachingValue !== undefined) {
                  var cachingInstance = cachingValue;
                  osDiskInstance.caching = cachingInstance;
                }
                
                var createOptionValue = osDiskValue2['createOption'];
                if (createOptionValue !== null && createOptionValue !== undefined) {
                  var createOptionInstance = createOptionValue;
                  osDiskInstance.createOption = createOptionInstance;
                }
                
                var diskSizeGBValue = osDiskValue2['diskSizeGB'];
                if (diskSizeGBValue !== null && diskSizeGBValue !== undefined) {
                  var diskSizeGBInstance = diskSizeGBValue;
                  osDiskInstance.diskSizeGB = diskSizeGBInstance;
                }
              }
              
              var dataDisksArray2 = storageProfileValue2['dataDisks'];
              if (dataDisksArray2 !== null && dataDisksArray2 !== undefined) {
                for (var loweredIndex21 = 0; loweredIndex21 < dataDisksArray2.length; loweredIndex21 = loweredIndex21 + 1) {
                  var dataDisksValue = dataDisksArray2[loweredIndex21];
                  var dataDiskInstance = {};
                  storageProfileInstance.dataDisks.push(dataDiskInstance);
                  
                  var lunValue = dataDisksValue['lun'];
                  if (lunValue !== null && lunValue !== undefined) {
                    var lunInstance = lunValue;
                    dataDiskInstance.lun = lunInstance;
                  }
                  
                  var nameValue3 = dataDisksValue['name'];
                  if (nameValue3 !== null && nameValue3 !== undefined) {
                    var nameInstance3 = nameValue3;
                    dataDiskInstance.name = nameInstance3;
                  }
                  
                  var vhdValue4 = dataDisksValue['vhd'];
                  if (vhdValue4 !== null && vhdValue4 !== undefined) {
                    var vhdInstance2 = {};
                    dataDiskInstance.virtualHardDisk = vhdInstance2;
                    
                    var uriValue3 = vhdValue4['uri'];
                    if (uriValue3 !== null && uriValue3 !== undefined) {
                      var uriInstance3 = uriValue3;
                      vhdInstance2.uri = uriInstance3;
                    }
                  }
                  
                  var imageValue4 = dataDisksValue['image'];
                  if (imageValue4 !== null && imageValue4 !== undefined) {
                    var imageInstance2 = {};
                    dataDiskInstance.sourceImage = imageInstance2;
                    
                    var uriValue4 = imageValue4['uri'];
                    if (uriValue4 !== null && uriValue4 !== undefined) {
                      var uriInstance4 = uriValue4;
                      imageInstance2.uri = uriInstance4;
                    }
                  }
                  
                  var cachingValue2 = dataDisksValue['caching'];
                  if (cachingValue2 !== null && cachingValue2 !== undefined) {
                    var cachingInstance2 = cachingValue2;
                    dataDiskInstance.caching = cachingInstance2;
                  }
                  
                  var createOptionValue2 = dataDisksValue['createOption'];
                  if (createOptionValue2 !== null && createOptionValue2 !== undefined) {
                    var createOptionInstance2 = createOptionValue2;
                    dataDiskInstance.createOption = createOptionInstance2;
                  }
                  
                  var diskSizeGBValue2 = dataDisksValue['diskSizeGB'];
                  if (diskSizeGBValue2 !== null && diskSizeGBValue2 !== undefined) {
                    var diskSizeGBInstance2 = diskSizeGBValue2;
                    dataDiskInstance.diskSizeGB = diskSizeGBInstance2;
                  }
                }
              }
            }
            
            var osProfileValue2 = propertiesValue4['osProfile'];
            if (osProfileValue2 !== null && osProfileValue2 !== undefined) {
              var osProfileInstance = { secrets: [] };
              virtualMachineInstance.oSProfile = osProfileInstance;
              
              var computerNameValue = osProfileValue2['computerName'];
              if (computerNameValue !== null && computerNameValue !== undefined) {
                var computerNameInstance = computerNameValue;
                osProfileInstance.computerName = computerNameInstance;
              }
              
              var adminUsernameValue = osProfileValue2['adminUsername'];
              if (adminUsernameValue !== null && adminUsernameValue !== undefined) {
                var adminUsernameInstance = adminUsernameValue;
                osProfileInstance.adminUsername = adminUsernameInstance;
              }
              
              var adminPasswordValue = osProfileValue2['adminPassword'];
              if (adminPasswordValue !== null && adminPasswordValue !== undefined) {
                var adminPasswordInstance = adminPasswordValue;
                osProfileInstance.adminPassword = adminPasswordInstance;
              }
              
              var customDataValue = osProfileValue2['customData'];
              if (customDataValue !== null && customDataValue !== undefined) {
                var customDataInstance = customDataValue;
                osProfileInstance.customData = customDataInstance;
              }
              
              var windowsConfigurationValue2 = osProfileValue2['windowsConfiguration'];
              if (windowsConfigurationValue2 !== null && windowsConfigurationValue2 !== undefined) {
                var windowsConfigurationInstance = { additionalUnattendContents: [] };
                osProfileInstance.windowsConfiguration = windowsConfigurationInstance;
                
                var provisionVMAgentValue = windowsConfigurationValue2['provisionVMAgent'];
                if (provisionVMAgentValue !== null && provisionVMAgentValue !== undefined) {
                  var provisionVMAgentInstance = provisionVMAgentValue;
                  windowsConfigurationInstance.provisionVMAgent = provisionVMAgentInstance;
                }
                
                var enableAutomaticUpdatesValue = windowsConfigurationValue2['enableAutomaticUpdates'];
                if (enableAutomaticUpdatesValue !== null && enableAutomaticUpdatesValue !== undefined) {
                  var enableAutomaticUpdatesInstance = enableAutomaticUpdatesValue;
                  windowsConfigurationInstance.enableAutomaticUpdates = enableAutomaticUpdatesInstance;
                }
                
                var timeZoneValue = windowsConfigurationValue2['timeZone'];
                if (timeZoneValue !== null && timeZoneValue !== undefined) {
                  var timeZoneInstance = timeZoneValue;
                  windowsConfigurationInstance.timeZone = timeZoneInstance;
                }
                
                var additionalUnattendContentArray2 = windowsConfigurationValue2['additionalUnattendContent'];
                if (additionalUnattendContentArray2 !== null && additionalUnattendContentArray2 !== undefined) {
                  for (var loweredIndex22 = 0; loweredIndex22 < additionalUnattendContentArray2.length; loweredIndex22 = loweredIndex22 + 1) {
                    var additionalUnattendContentValue2 = additionalUnattendContentArray2[loweredIndex22];
                    var additionalUnattendContentInstance = {};
                    windowsConfigurationInstance.additionalUnattendContents.push(additionalUnattendContentInstance);
                    
                    var passNameValue = additionalUnattendContentValue2['passName'];
                    if (passNameValue !== null && passNameValue !== undefined) {
                      var passNameInstance = passNameValue;
                      additionalUnattendContentInstance.passName = passNameInstance;
                    }
                    
                    var componentNameValue = additionalUnattendContentValue2['componentName'];
                    if (componentNameValue !== null && componentNameValue !== undefined) {
                      var componentNameInstance = componentNameValue;
                      additionalUnattendContentInstance.componentName = componentNameInstance;
                    }
                    
                    var settingNameValue = additionalUnattendContentValue2['settingName'];
                    if (settingNameValue !== null && settingNameValue !== undefined) {
                      var settingNameInstance = settingNameValue;
                      additionalUnattendContentInstance.settingName = settingNameInstance;
                    }
                    
                    var contentValue = additionalUnattendContentValue2['content'];
                    if (contentValue !== null && contentValue !== undefined) {
                      var contentInstance = contentValue;
                      additionalUnattendContentInstance.content = contentInstance;
                    }
                  }
                }
                
                var winRMValue2 = windowsConfigurationValue2['winRM'];
                if (winRMValue2 !== null && winRMValue2 !== undefined) {
                  var winRMInstance = { listeners: [] };
                  windowsConfigurationInstance.winRMConfiguration = winRMInstance;
                  
                  var listenersArray2 = winRMValue2['listeners'];
                  if (listenersArray2 !== null && listenersArray2 !== undefined) {
                    for (var loweredIndex23 = 0; loweredIndex23 < listenersArray2.length; loweredIndex23 = loweredIndex23 + 1) {
                      var listenersValue = listenersArray2[loweredIndex23];
                      var winRMListenerInstance = {};
                      winRMInstance.listeners.push(winRMListenerInstance);
                      
                      var protocolValue = listenersValue['protocol'];
                      if (protocolValue !== null && protocolValue !== undefined) {
                        var protocolInstance = protocolValue;
                        winRMListenerInstance.protocol = protocolInstance;
                      }
                      
                      var certificateUrlValue = listenersValue['certificateUrl'];
                      if (certificateUrlValue !== null && certificateUrlValue !== undefined) {
                        var certificateUrlInstance = certificateUrlValue;
                        winRMListenerInstance.certificateUrl = certificateUrlInstance;
                      }
                    }
                  }
                }
              }
              
              var linuxConfigurationValue2 = osProfileValue2['linuxConfiguration'];
              if (linuxConfigurationValue2 !== null && linuxConfigurationValue2 !== undefined) {
                var linuxConfigurationInstance = {};
                osProfileInstance.linuxConfiguration = linuxConfigurationInstance;
                
                var disablePasswordAuthenticationValue = linuxConfigurationValue2['disablePasswordAuthentication'];
                if (disablePasswordAuthenticationValue !== null && disablePasswordAuthenticationValue !== undefined) {
                  var disablePasswordAuthenticationInstance = disablePasswordAuthenticationValue;
                  linuxConfigurationInstance.disablePasswordAuthentication = disablePasswordAuthenticationInstance;
                }
                
                var sshValue2 = linuxConfigurationValue2['ssh'];
                if (sshValue2 !== null && sshValue2 !== undefined) {
                  var sshInstance = { publicKeys: [] };
                  linuxConfigurationInstance.sshConfiguration = sshInstance;
                  
                  var publicKeysArray2 = sshValue2['publicKeys'];
                  if (publicKeysArray2 !== null && publicKeysArray2 !== undefined) {
                    for (var loweredIndex24 = 0; loweredIndex24 < publicKeysArray2.length; loweredIndex24 = loweredIndex24 + 1) {
                      var publicKeysValue = publicKeysArray2[loweredIndex24];
                      var sshPublicKeyInstance = {};
                      sshInstance.publicKeys.push(sshPublicKeyInstance);
                      
                      var pathValue = publicKeysValue['path'];
                      if (pathValue !== null && pathValue !== undefined) {
                        var pathInstance = pathValue;
                        sshPublicKeyInstance.path = pathInstance;
                      }
                      
                      var keyDataValue = publicKeysValue['keyData'];
                      if (keyDataValue !== null && keyDataValue !== undefined) {
                        var keyDataInstance = keyDataValue;
                        sshPublicKeyInstance.keyData = keyDataInstance;
                      }
                    }
                  }
                }
              }
              
              var secretsArray2 = osProfileValue2['secrets'];
              if (secretsArray2 !== null && secretsArray2 !== undefined) {
                for (var loweredIndex25 = 0; loweredIndex25 < secretsArray2.length; loweredIndex25 = loweredIndex25 + 1) {
                  var secretsValue = secretsArray2[loweredIndex25];
                  var vaultSecretGroupInstance = { vaultCertificates: [] };
                  osProfileInstance.secrets.push(vaultSecretGroupInstance);
                  
                  var sourceVaultValue6 = secretsValue['sourceVault'];
                  if (sourceVaultValue6 !== null && sourceVaultValue6 !== undefined) {
                    var sourceVaultInstance3 = {};
                    vaultSecretGroupInstance.sourceVault = sourceVaultInstance3;
                    
                    var idValue3 = sourceVaultValue6['id'];
                    if (idValue3 !== null && idValue3 !== undefined) {
                      var idInstance3 = idValue3;
                      sourceVaultInstance3.referenceUri = idInstance3;
                    }
                  }
                  
                  var vaultCertificatesArray2 = secretsValue['vaultCertificates'];
                  if (vaultCertificatesArray2 !== null && vaultCertificatesArray2 !== undefined) {
                    for (var loweredIndex26 = 0; loweredIndex26 < vaultCertificatesArray2.length; loweredIndex26 = loweredIndex26 + 1) {
                      var vaultCertificatesValue = vaultCertificatesArray2[loweredIndex26];
                      var vaultCertificateInstance = {};
                      vaultSecretGroupInstance.vaultCertificates.push(vaultCertificateInstance);
                      
                      var certificateUrlValue2 = vaultCertificatesValue['certificateUrl'];
                      if (certificateUrlValue2 !== null && certificateUrlValue2 !== undefined) {
                        var certificateUrlInstance2 = certificateUrlValue2;
                        vaultCertificateInstance.certificateUrl = certificateUrlInstance2;
                      }
                      
                      var certificateStoreValue = vaultCertificatesValue['certificateStore'];
                      if (certificateStoreValue !== null && certificateStoreValue !== undefined) {
                        var certificateStoreInstance = certificateStoreValue;
                        vaultCertificateInstance.certificateStore = certificateStoreInstance;
                      }
                    }
                  }
                }
              }
            }
            
            var networkProfileValue2 = propertiesValue4['networkProfile'];
            if (networkProfileValue2 !== null && networkProfileValue2 !== undefined) {
              var networkProfileInstance = { networkInterfaces: [] };
              virtualMachineInstance.networkProfile = networkProfileInstance;
              
              var networkInterfacesArray2 = networkProfileValue2['networkInterfaces'];
              if (networkInterfacesArray2 !== null && networkInterfacesArray2 !== undefined) {
                for (var loweredIndex27 = 0; loweredIndex27 < networkInterfacesArray2.length; loweredIndex27 = loweredIndex27 + 1) {
                  var networkInterfacesValue = networkInterfacesArray2[loweredIndex27];
                  var networkInterfaceReferenceJsonInstance = {};
                  networkProfileInstance.networkInterfaces.push(networkInterfaceReferenceJsonInstance);
                  
                  var propertiesValue5 = networkInterfacesValue['properties'];
                  if (propertiesValue5 !== null && propertiesValue5 !== undefined) {
                    var primaryValue = propertiesValue5['primary'];
                    if (primaryValue !== null && primaryValue !== undefined) {
                      var primaryInstance = primaryValue;
                      networkInterfaceReferenceJsonInstance.primary = primaryInstance;
                    }
                  }
                  
                  var idValue4 = networkInterfacesValue['id'];
                  if (idValue4 !== null && idValue4 !== undefined) {
                    var idInstance4 = idValue4;
                    networkInterfaceReferenceJsonInstance.referenceUri = idInstance4;
                  }
                }
              }
            }
            
            var diagnosticsProfileValue2 = propertiesValue4['diagnosticsProfile'];
            if (diagnosticsProfileValue2 !== null && diagnosticsProfileValue2 !== undefined) {
              var diagnosticsProfileInstance = {};
              virtualMachineInstance.diagnosticsProfile = diagnosticsProfileInstance;
              
              var bootDiagnosticsValue3 = diagnosticsProfileValue2['bootDiagnostics'];
              if (bootDiagnosticsValue3 !== null && bootDiagnosticsValue3 !== undefined) {
                var bootDiagnosticsInstance = {};
                diagnosticsProfileInstance.bootDiagnostics = bootDiagnosticsInstance;
                
                var enabledValue = bootDiagnosticsValue3['enabled'];
                if (enabledValue !== null && enabledValue !== undefined) {
                  var enabledInstance = enabledValue;
                  bootDiagnosticsInstance.enabled = enabledInstance;
                }
                
                var storageUriValue = bootDiagnosticsValue3['storageUri'];
                if (storageUriValue !== null && storageUriValue !== undefined) {
                  var storageUriInstance = storageUriValue;
                  bootDiagnosticsInstance.storageUri = storageUriInstance;
                }
              }
            }
            
            var availabilitySetValue2 = propertiesValue4['availabilitySet'];
            if (availabilitySetValue2 !== null && availabilitySetValue2 !== undefined) {
              var availabilitySetInstance = {};
              virtualMachineInstance.availabilitySetReference = availabilitySetInstance;
              
              var idValue5 = availabilitySetValue2['id'];
              if (idValue5 !== null && idValue5 !== undefined) {
                var idInstance5 = idValue5;
                availabilitySetInstance.referenceUri = idInstance5;
              }
            }
            
            var provisioningStateValue = propertiesValue4['provisioningState'];
            if (provisioningStateValue !== null && provisioningStateValue !== undefined) {
              var provisioningStateInstance = provisioningStateValue;
              virtualMachineInstance.provisioningState = provisioningStateInstance;
            }
            
            var instanceViewValue3 = propertiesValue4['instanceView'];
            if (instanceViewValue3 !== null && instanceViewValue3 !== undefined) {
              var instanceViewInstance = { disks: [], extensions: [], statuses: [] };
              virtualMachineInstance.instanceView = instanceViewInstance;
              
              var platformUpdateDomainValue = instanceViewValue3['platformUpdateDomain'];
              if (platformUpdateDomainValue !== null && platformUpdateDomainValue !== undefined) {
                var platformUpdateDomainInstance = platformUpdateDomainValue;
                instanceViewInstance.platformUpdateDomain = platformUpdateDomainInstance;
              }
              
              var platformFaultDomainValue = instanceViewValue3['platformFaultDomain'];
              if (platformFaultDomainValue !== null && platformFaultDomainValue !== undefined) {
                var platformFaultDomainInstance = platformFaultDomainValue;
                instanceViewInstance.platformFaultDomain = platformFaultDomainInstance;
              }
              
              var rdpThumbPrintValue = instanceViewValue3['rdpThumbPrint'];
              if (rdpThumbPrintValue !== null && rdpThumbPrintValue !== undefined) {
                var rdpThumbPrintInstance = rdpThumbPrintValue;
                instanceViewInstance.remoteDesktopThumbprint = rdpThumbPrintInstance;
              }
              
              var vmAgentValue2 = instanceViewValue3['vmAgent'];
              if (vmAgentValue2 !== null && vmAgentValue2 !== undefined) {
                var vmAgentInstance = { extensionHandlers: [], statuses: [] };
                instanceViewInstance.vMAgent = vmAgentInstance;
                
                var vmAgentVersionValue = vmAgentValue2['vmAgentVersion'];
                if (vmAgentVersionValue !== null && vmAgentVersionValue !== undefined) {
                  var vmAgentVersionInstance = vmAgentVersionValue;
                  vmAgentInstance.vMAgentVersion = vmAgentVersionInstance;
                }
                
                var extensionHandlersArray2 = vmAgentValue2['extensionHandlers'];
                if (extensionHandlersArray2 !== null && extensionHandlersArray2 !== undefined) {
                  for (var loweredIndex28 = 0; loweredIndex28 < extensionHandlersArray2.length; loweredIndex28 = loweredIndex28 + 1) {
                    var extensionHandlersValue = extensionHandlersArray2[loweredIndex28];
                    var virtualMachineExtensionHandlerInstanceViewInstance = {};
                    vmAgentInstance.extensionHandlers.push(virtualMachineExtensionHandlerInstanceViewInstance);
                    
                    var typeValue = extensionHandlersValue['type'];
                    if (typeValue !== null && typeValue !== undefined) {
                      var typeInstance = typeValue;
                      virtualMachineExtensionHandlerInstanceViewInstance.type = typeInstance;
                    }
                    
                    var typeHandlerVersionValue = extensionHandlersValue['typeHandlerVersion'];
                    if (typeHandlerVersionValue !== null && typeHandlerVersionValue !== undefined) {
                      var typeHandlerVersionInstance = typeHandlerVersionValue;
                      virtualMachineExtensionHandlerInstanceViewInstance.typeHandlerVersion = typeHandlerVersionInstance;
                    }
                    
                    var statusValue2 = extensionHandlersValue['status'];
                    if (statusValue2 !== null && statusValue2 !== undefined) {
                      var statusInstance = {};
                      virtualMachineExtensionHandlerInstanceViewInstance.status = statusInstance;
                      
                      var codeValue = statusValue2['code'];
                      if (codeValue !== null && codeValue !== undefined) {
                        var codeInstance = codeValue;
                        statusInstance.code = codeInstance;
                      }
                      
                      var levelValue = statusValue2['level'];
                      if (levelValue !== null && levelValue !== undefined) {
                        var levelInstance = levelValue;
                        statusInstance.level = levelInstance;
                      }
                      
                      var displayStatusValue = statusValue2['displayStatus'];
                      if (displayStatusValue !== null && displayStatusValue !== undefined) {
                        var displayStatusInstance = displayStatusValue;
                        statusInstance.displayStatus = displayStatusInstance;
                      }
                      
                      var messageValue = statusValue2['message'];
                      if (messageValue !== null && messageValue !== undefined) {
                        var messageInstance = messageValue;
                        statusInstance.message = messageInstance;
                      }
                      
                      var timeValue = statusValue2['time'];
                      if (timeValue !== null && timeValue !== undefined) {
                        var timeInstance = timeValue;
                        statusInstance.time = timeInstance;
                      }
                    }
                  }
                }
                
                var statusesArray6 = vmAgentValue2['statuses'];
                if (statusesArray6 !== null && statusesArray6 !== undefined) {
                  for (var loweredIndex29 = 0; loweredIndex29 < statusesArray6.length; loweredIndex29 = loweredIndex29 + 1) {
                    var statusesValue = statusesArray6[loweredIndex29];
                    var instanceViewStatusInstance = {};
                    vmAgentInstance.statuses.push(instanceViewStatusInstance);
                    
                    var codeValue2 = statusesValue['code'];
                    if (codeValue2 !== null && codeValue2 !== undefined) {
                      var codeInstance2 = codeValue2;
                      instanceViewStatusInstance.code = codeInstance2;
                    }
                    
                    var levelValue2 = statusesValue['level'];
                    if (levelValue2 !== null && levelValue2 !== undefined) {
                      var levelInstance2 = levelValue2;
                      instanceViewStatusInstance.level = levelInstance2;
                    }
                    
                    var displayStatusValue2 = statusesValue['displayStatus'];
                    if (displayStatusValue2 !== null && displayStatusValue2 !== undefined) {
                      var displayStatusInstance2 = displayStatusValue2;
                      instanceViewStatusInstance.displayStatus = displayStatusInstance2;
                    }
                    
                    var messageValue2 = statusesValue['message'];
                    if (messageValue2 !== null && messageValue2 !== undefined) {
                      var messageInstance2 = messageValue2;
                      instanceViewStatusInstance.message = messageInstance2;
                    }
                    
                    var timeValue2 = statusesValue['time'];
                    if (timeValue2 !== null && timeValue2 !== undefined) {
                      var timeInstance2 = timeValue2;
                      instanceViewStatusInstance.time = timeInstance2;
                    }
                  }
                }
              }
              
              var disksArray2 = instanceViewValue3['disks'];
              if (disksArray2 !== null && disksArray2 !== undefined) {
                for (var loweredIndex30 = 0; loweredIndex30 < disksArray2.length; loweredIndex30 = loweredIndex30 + 1) {
                  var disksValue = disksArray2[loweredIndex30];
                  var diskInstanceViewInstance = { statuses: [] };
                  instanceViewInstance.disks.push(diskInstanceViewInstance);
                  
                  var nameValue4 = disksValue['name'];
                  if (nameValue4 !== null && nameValue4 !== undefined) {
                    var nameInstance4 = nameValue4;
                    diskInstanceViewInstance.name = nameInstance4;
                  }
                  
                  var statusesArray7 = disksValue['statuses'];
                  if (statusesArray7 !== null && statusesArray7 !== undefined) {
                    for (var loweredIndex31 = 0; loweredIndex31 < statusesArray7.length; loweredIndex31 = loweredIndex31 + 1) {
                      var statusesValue2 = statusesArray7[loweredIndex31];
                      var instanceViewStatusInstance2 = {};
                      diskInstanceViewInstance.statuses.push(instanceViewStatusInstance2);
                      
                      var codeValue3 = statusesValue2['code'];
                      if (codeValue3 !== null && codeValue3 !== undefined) {
                        var codeInstance3 = codeValue3;
                        instanceViewStatusInstance2.code = codeInstance3;
                      }
                      
                      var levelValue3 = statusesValue2['level'];
                      if (levelValue3 !== null && levelValue3 !== undefined) {
                        var levelInstance3 = levelValue3;
                        instanceViewStatusInstance2.level = levelInstance3;
                      }
                      
                      var displayStatusValue3 = statusesValue2['displayStatus'];
                      if (displayStatusValue3 !== null && displayStatusValue3 !== undefined) {
                        var displayStatusInstance3 = displayStatusValue3;
                        instanceViewStatusInstance2.displayStatus = displayStatusInstance3;
                      }
                      
                      var messageValue3 = statusesValue2['message'];
                      if (messageValue3 !== null && messageValue3 !== undefined) {
                        var messageInstance3 = messageValue3;
                        instanceViewStatusInstance2.message = messageInstance3;
                      }
                      
                      var timeValue3 = statusesValue2['time'];
                      if (timeValue3 !== null && timeValue3 !== undefined) {
                        var timeInstance3 = timeValue3;
                        instanceViewStatusInstance2.time = timeInstance3;
                      }
                    }
                  }
                }
              }
              
              var extensionsArray2 = instanceViewValue3['extensions'];
              if (extensionsArray2 !== null && extensionsArray2 !== undefined) {
                for (var loweredIndex32 = 0; loweredIndex32 < extensionsArray2.length; loweredIndex32 = loweredIndex32 + 1) {
                  var extensionsValue = extensionsArray2[loweredIndex32];
                  var virtualMachineExtensionInstanceViewInstance = { statuses: [], subStatuses: [] };
                  instanceViewInstance.extensions.push(virtualMachineExtensionInstanceViewInstance);
                  
                  var nameValue5 = extensionsValue['name'];
                  if (nameValue5 !== null && nameValue5 !== undefined) {
                    var nameInstance5 = nameValue5;
                    virtualMachineExtensionInstanceViewInstance.name = nameInstance5;
                  }
                  
                  var typeValue2 = extensionsValue['type'];
                  if (typeValue2 !== null && typeValue2 !== undefined) {
                    var typeInstance2 = typeValue2;
                    virtualMachineExtensionInstanceViewInstance.extensionType = typeInstance2;
                  }
                  
                  var typeHandlerVersionValue2 = extensionsValue['typeHandlerVersion'];
                  if (typeHandlerVersionValue2 !== null && typeHandlerVersionValue2 !== undefined) {
                    var typeHandlerVersionInstance2 = typeHandlerVersionValue2;
                    virtualMachineExtensionInstanceViewInstance.typeHandlerVersion = typeHandlerVersionInstance2;
                  }
                  
                  var substatusesArray3 = extensionsValue['substatuses'];
                  if (substatusesArray3 !== null && substatusesArray3 !== undefined) {
                    for (var loweredIndex33 = 0; loweredIndex33 < substatusesArray3.length; loweredIndex33 = loweredIndex33 + 1) {
                      var substatusesValue = substatusesArray3[loweredIndex33];
                      var instanceViewStatusInstance3 = {};
                      virtualMachineExtensionInstanceViewInstance.subStatuses.push(instanceViewStatusInstance3);
                      
                      var codeValue4 = substatusesValue['code'];
                      if (codeValue4 !== null && codeValue4 !== undefined) {
                        var codeInstance4 = codeValue4;
                        instanceViewStatusInstance3.code = codeInstance4;
                      }
                      
                      var levelValue4 = substatusesValue['level'];
                      if (levelValue4 !== null && levelValue4 !== undefined) {
                        var levelInstance4 = levelValue4;
                        instanceViewStatusInstance3.level = levelInstance4;
                      }
                      
                      var displayStatusValue4 = substatusesValue['displayStatus'];
                      if (displayStatusValue4 !== null && displayStatusValue4 !== undefined) {
                        var displayStatusInstance4 = displayStatusValue4;
                        instanceViewStatusInstance3.displayStatus = displayStatusInstance4;
                      }
                      
                      var messageValue4 = substatusesValue['message'];
                      if (messageValue4 !== null && messageValue4 !== undefined) {
                        var messageInstance4 = messageValue4;
                        instanceViewStatusInstance3.message = messageInstance4;
                      }
                      
                      var timeValue4 = substatusesValue['time'];
                      if (timeValue4 !== null && timeValue4 !== undefined) {
                        var timeInstance4 = timeValue4;
                        instanceViewStatusInstance3.time = timeInstance4;
                      }
                    }
                  }
                  
                  var statusesArray8 = extensionsValue['statuses'];
                  if (statusesArray8 !== null && statusesArray8 !== undefined) {
                    for (var loweredIndex34 = 0; loweredIndex34 < statusesArray8.length; loweredIndex34 = loweredIndex34 + 1) {
                      var statusesValue3 = statusesArray8[loweredIndex34];
                      var instanceViewStatusInstance4 = {};
                      virtualMachineExtensionInstanceViewInstance.statuses.push(instanceViewStatusInstance4);
                      
                      var codeValue5 = statusesValue3['code'];
                      if (codeValue5 !== null && codeValue5 !== undefined) {
                        var codeInstance5 = codeValue5;
                        instanceViewStatusInstance4.code = codeInstance5;
                      }
                      
                      var levelValue5 = statusesValue3['level'];
                      if (levelValue5 !== null && levelValue5 !== undefined) {
                        var levelInstance5 = levelValue5;
                        instanceViewStatusInstance4.level = levelInstance5;
                      }
                      
                      var displayStatusValue5 = statusesValue3['displayStatus'];
                      if (displayStatusValue5 !== null && displayStatusValue5 !== undefined) {
                        var displayStatusInstance5 = displayStatusValue5;
                        instanceViewStatusInstance4.displayStatus = displayStatusInstance5;
                      }
                      
                      var messageValue5 = statusesValue3['message'];
                      if (messageValue5 !== null && messageValue5 !== undefined) {
                        var messageInstance5 = messageValue5;
                        instanceViewStatusInstance4.message = messageInstance5;
                      }
                      
                      var timeValue5 = statusesValue3['time'];
                      if (timeValue5 !== null && timeValue5 !== undefined) {
                        var timeInstance5 = timeValue5;
                        instanceViewStatusInstance4.time = timeInstance5;
                      }
                    }
                  }
                }
              }
              
              var bootDiagnosticsValue4 = instanceViewValue3['bootDiagnostics'];
              if (bootDiagnosticsValue4 !== null && bootDiagnosticsValue4 !== undefined) {
                var bootDiagnosticsInstance2 = {};
                instanceViewInstance.bootDiagnostics = bootDiagnosticsInstance2;
                
                var consoleScreenshotBlobUriValue = bootDiagnosticsValue4['consoleScreenshotBlobUri'];
                if (consoleScreenshotBlobUriValue !== null && consoleScreenshotBlobUriValue !== undefined) {
                  var consoleScreenshotBlobUriInstance = consoleScreenshotBlobUriValue;
                  bootDiagnosticsInstance2.consoleScreenshotBlobUri = consoleScreenshotBlobUriInstance;
                }
                
                var serialConsoleLogBlobUriValue = bootDiagnosticsValue4['serialConsoleLogBlobUri'];
                if (serialConsoleLogBlobUriValue !== null && serialConsoleLogBlobUriValue !== undefined) {
                  var serialConsoleLogBlobUriInstance = serialConsoleLogBlobUriValue;
                  bootDiagnosticsInstance2.serialConsoleLogBlobUri = serialConsoleLogBlobUriInstance;
                }
              }
              
              var statusesArray9 = instanceViewValue3['statuses'];
              if (statusesArray9 !== null && statusesArray9 !== undefined) {
                for (var loweredIndex35 = 0; loweredIndex35 < statusesArray9.length; loweredIndex35 = loweredIndex35 + 1) {
                  var statusesValue4 = statusesArray9[loweredIndex35];
                  var instanceViewStatusInstance5 = {};
                  instanceViewInstance.statuses.push(instanceViewStatusInstance5);
                  
                  var codeValue6 = statusesValue4['code'];
                  if (codeValue6 !== null && codeValue6 !== undefined) {
                    var codeInstance6 = codeValue6;
                    instanceViewStatusInstance5.code = codeInstance6;
                  }
                  
                  var levelValue6 = statusesValue4['level'];
                  if (levelValue6 !== null && levelValue6 !== undefined) {
                    var levelInstance6 = levelValue6;
                    instanceViewStatusInstance5.level = levelInstance6;
                  }
                  
                  var displayStatusValue6 = statusesValue4['displayStatus'];
                  if (displayStatusValue6 !== null && displayStatusValue6 !== undefined) {
                    var displayStatusInstance6 = displayStatusValue6;
                    instanceViewStatusInstance5.displayStatus = displayStatusInstance6;
                  }
                  
                  var messageValue6 = statusesValue4['message'];
                  if (messageValue6 !== null && messageValue6 !== undefined) {
                    var messageInstance6 = messageValue6;
                    instanceViewStatusInstance5.message = messageInstance6;
                  }
                  
                  var timeValue6 = statusesValue4['time'];
                  if (timeValue6 !== null && timeValue6 !== undefined) {
                    var timeInstance6 = timeValue6;
                    instanceViewStatusInstance5.time = timeInstance6;
                  }
                }
              }
            }
          }
          
          var resourcesArray2 = responseDoc['resources'];
          if (resourcesArray2 !== null && resourcesArray2 !== undefined) {
            virtualMachineInstance.extensions = [];
            for (var loweredIndex36 = 0; loweredIndex36 < resourcesArray2.length; loweredIndex36 = loweredIndex36 + 1) {
              var resourcesValue = resourcesArray2[loweredIndex36];
              var virtualMachineExtensionJsonInstance = { tags: {} };
              virtualMachineInstance.extensions.push(virtualMachineExtensionJsonInstance);
              
              var propertiesValue6 = resourcesValue['properties'];
              if (propertiesValue6 !== null && propertiesValue6 !== undefined) {
                var publisherValue3 = propertiesValue6['publisher'];
                if (publisherValue3 !== null && publisherValue3 !== undefined) {
                  var publisherInstance3 = publisherValue3;
                  virtualMachineExtensionJsonInstance.publisher = publisherInstance3;
                }
                
                var typeValue3 = propertiesValue6['type'];
                if (typeValue3 !== null && typeValue3 !== undefined) {
                  var typeInstance3 = typeValue3;
                  virtualMachineExtensionJsonInstance.extensionType = typeInstance3;
                }
                
                var typeHandlerVersionValue3 = propertiesValue6['typeHandlerVersion'];
                if (typeHandlerVersionValue3 !== null && typeHandlerVersionValue3 !== undefined) {
                  var typeHandlerVersionInstance3 = typeHandlerVersionValue3;
                  virtualMachineExtensionJsonInstance.typeHandlerVersion = typeHandlerVersionInstance3;
                }
                
                var autoUpgradeMinorVersionValue = propertiesValue6['autoUpgradeMinorVersion'];
                if (autoUpgradeMinorVersionValue !== null && autoUpgradeMinorVersionValue !== undefined) {
                  var autoUpgradeMinorVersionInstance = autoUpgradeMinorVersionValue;
                  virtualMachineExtensionJsonInstance.autoUpgradeMinorVersion = autoUpgradeMinorVersionInstance;
                }
                
                var settingsValue = propertiesValue6['settings'];
                if (settingsValue !== null && settingsValue !== undefined) {
                  var settingsInstance = settingsValue;
                  virtualMachineExtensionJsonInstance.settings = settingsInstance;
                }
                
                var protectedSettingsValue = propertiesValue6['protectedSettings'];
                if (protectedSettingsValue !== null && protectedSettingsValue !== undefined) {
                  var protectedSettingsInstance = protectedSettingsValue;
                  virtualMachineExtensionJsonInstance.protectedSettings = protectedSettingsInstance;
                }
                
                var provisioningStateValue2 = propertiesValue6['provisioningState'];
                if (provisioningStateValue2 !== null && provisioningStateValue2 !== undefined) {
                  var provisioningStateInstance2 = provisioningStateValue2;
                  virtualMachineExtensionJsonInstance.provisioningState = provisioningStateInstance2;
                }
                
                var instanceViewValue4 = propertiesValue6['instanceView'];
                if (instanceViewValue4 !== null && instanceViewValue4 !== undefined) {
                  var instanceViewInstance2 = { statuses: [], subStatuses: [] };
                  virtualMachineExtensionJsonInstance.instanceView = instanceViewInstance2;
                  
                  var nameValue6 = instanceViewValue4['name'];
                  if (nameValue6 !== null && nameValue6 !== undefined) {
                    var nameInstance6 = nameValue6;
                    instanceViewInstance2.name = nameInstance6;
                  }
                  
                  var typeValue4 = instanceViewValue4['type'];
                  if (typeValue4 !== null && typeValue4 !== undefined) {
                    var typeInstance4 = typeValue4;
                    instanceViewInstance2.extensionType = typeInstance4;
                  }
                  
                  var typeHandlerVersionValue4 = instanceViewValue4['typeHandlerVersion'];
                  if (typeHandlerVersionValue4 !== null && typeHandlerVersionValue4 !== undefined) {
                    var typeHandlerVersionInstance4 = typeHandlerVersionValue4;
                    instanceViewInstance2.typeHandlerVersion = typeHandlerVersionInstance4;
                  }
                  
                  var substatusesArray4 = instanceViewValue4['substatuses'];
                  if (substatusesArray4 !== null && substatusesArray4 !== undefined) {
                    for (var loweredIndex37 = 0; loweredIndex37 < substatusesArray4.length; loweredIndex37 = loweredIndex37 + 1) {
                      var substatusesValue2 = substatusesArray4[loweredIndex37];
                      var instanceViewStatusInstance6 = {};
                      instanceViewInstance2.subStatuses.push(instanceViewStatusInstance6);
                      
                      var codeValue7 = substatusesValue2['code'];
                      if (codeValue7 !== null && codeValue7 !== undefined) {
                        var codeInstance7 = codeValue7;
                        instanceViewStatusInstance6.code = codeInstance7;
                      }
                      
                      var levelValue7 = substatusesValue2['level'];
                      if (levelValue7 !== null && levelValue7 !== undefined) {
                        var levelInstance7 = levelValue7;
                        instanceViewStatusInstance6.level = levelInstance7;
                      }
                      
                      var displayStatusValue7 = substatusesValue2['displayStatus'];
                      if (displayStatusValue7 !== null && displayStatusValue7 !== undefined) {
                        var displayStatusInstance7 = displayStatusValue7;
                        instanceViewStatusInstance6.displayStatus = displayStatusInstance7;
                      }
                      
                      var messageValue7 = substatusesValue2['message'];
                      if (messageValue7 !== null && messageValue7 !== undefined) {
                        var messageInstance7 = messageValue7;
                        instanceViewStatusInstance6.message = messageInstance7;
                      }
                      
                      var timeValue7 = substatusesValue2['time'];
                      if (timeValue7 !== null && timeValue7 !== undefined) {
                        var timeInstance7 = timeValue7;
                        instanceViewStatusInstance6.time = timeInstance7;
                      }
                    }
                  }
                  
                  var statusesArray10 = instanceViewValue4['statuses'];
                  if (statusesArray10 !== null && statusesArray10 !== undefined) {
                    for (var loweredIndex38 = 0; loweredIndex38 < statusesArray10.length; loweredIndex38 = loweredIndex38 + 1) {
                      var statusesValue5 = statusesArray10[loweredIndex38];
                      var instanceViewStatusInstance7 = {};
                      instanceViewInstance2.statuses.push(instanceViewStatusInstance7);
                      
                      var codeValue8 = statusesValue5['code'];
                      if (codeValue8 !== null && codeValue8 !== undefined) {
                        var codeInstance8 = codeValue8;
                        instanceViewStatusInstance7.code = codeInstance8;
                      }
                      
                      var levelValue8 = statusesValue5['level'];
                      if (levelValue8 !== null && levelValue8 !== undefined) {
                        var levelInstance8 = levelValue8;
                        instanceViewStatusInstance7.level = levelInstance8;
                      }
                      
                      var displayStatusValue8 = statusesValue5['displayStatus'];
                      if (displayStatusValue8 !== null && displayStatusValue8 !== undefined) {
                        var displayStatusInstance8 = displayStatusValue8;
                        instanceViewStatusInstance7.displayStatus = displayStatusInstance8;
                      }
                      
                      var messageValue8 = statusesValue5['message'];
                      if (messageValue8 !== null && messageValue8 !== undefined) {
                        var messageInstance8 = messageValue8;
                        instanceViewStatusInstance7.message = messageInstance8;
                      }
                      
                      var timeValue8 = statusesValue5['time'];
                      if (timeValue8 !== null && timeValue8 !== undefined) {
                        var timeInstance8 = timeValue8;
                        instanceViewStatusInstance7.time = timeInstance8;
                      }
                    }
                  }
                }
              }
              
              var idValue6 = resourcesValue['id'];
              if (idValue6 !== null && idValue6 !== undefined) {
                var idInstance6 = idValue6;
                virtualMachineExtensionJsonInstance.id = idInstance6;
              }
              
              var nameValue7 = resourcesValue['name'];
              if (nameValue7 !== null && nameValue7 !== undefined) {
                var nameInstance7 = nameValue7;
                virtualMachineExtensionJsonInstance.name = nameInstance7;
              }
              
              var typeValue5 = resourcesValue['type'];
              if (typeValue5 !== null && typeValue5 !== undefined) {
                var typeInstance5 = typeValue5;
                virtualMachineExtensionJsonInstance.type = typeInstance5;
              }
              
              var locationValue = resourcesValue['location'];
              if (locationValue !== null && locationValue !== undefined) {
                var locationInstance = locationValue;
                virtualMachineExtensionJsonInstance.location = locationInstance;
              }
              
              var tagsSequenceElement = resourcesValue['tags'];
              if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
                for (var property in tagsSequenceElement) {
                  var tagsKey3 = property;
                  var tagsValue3 = tagsSequenceElement[property];
                  virtualMachineExtensionJsonInstance.tags[tagsKey3] = tagsValue3;
                }
              }
            }
          }
          
          var idValue7 = responseDoc['id'];
          if (idValue7 !== null && idValue7 !== undefined) {
            var idInstance7 = idValue7;
            virtualMachineInstance.id = idInstance7;
          }
          
          var nameValue8 = responseDoc['name'];
          if (nameValue8 !== null && nameValue8 !== undefined) {
            var nameInstance8 = nameValue8;
            virtualMachineInstance.name = nameInstance8;
          }
          
          var typeValue6 = responseDoc['type'];
          if (typeValue6 !== null && typeValue6 !== undefined) {
            var typeInstance6 = typeValue6;
            virtualMachineInstance.type = typeInstance6;
          }
          
          var locationValue2 = responseDoc['location'];
          if (locationValue2 !== null && locationValue2 !== undefined) {
            var locationInstance2 = locationValue2;
            virtualMachineInstance.location = locationInstance2;
          }
          
          var tagsSequenceElement2 = responseDoc['tags'];
          if (tagsSequenceElement2 !== null && tagsSequenceElement2 !== undefined) {
            for (var property2 in tagsSequenceElement2) {
              var tagsKey4 = property2;
              var tagsValue4 = tagsSequenceElement2[property2];
              virtualMachineInstance.tags[tagsKey4] = tagsValue4;
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.azureAsyncOperation = response.headers['azure-asyncoperation'];
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Shuts down the Virtual Machine and releases the compute resources. You are
   * not billed for the compute resources that this Virtual Machine uses.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} vmName The name of the virtual machine.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.beginDeallocating = function(resourceGroupName, vmName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (vmName === null || vmName === undefined) {
      return callback(new Error('vmName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/';
    url2 = url2 + 'virtualMachines';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(vmName);
    url2 = url2 + '/deallocate';
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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
    
    // 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.azureAsyncOperation = response.headers['azure-asyncoperation'];
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The operation to delete a virtual machine.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} vmName The name of the virtual machine.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.beginDeleting = function(resourceGroupName, vmName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (vmName === null || vmName === undefined) {
      return callback(new Error('vmName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/';
    url2 = url2 + 'virtualMachines';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(vmName);
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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['Content-Type'] = 'application/json';
    
    // 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 && statusCode !== 204) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.azureAsyncOperation = response.headers['azure-asyncoperation'];
      result.requestId = response.headers['x-ms-request-id'];
      if (statusCode === 409) {
        result.status = OperationStatus.Failed;
      }
      if (statusCode === 204) {
        result.status = OperationStatus.Succeeded;
      }
      if (statusCode === 200) {
        result.status = OperationStatus.Succeeded;
      }
      
      return callback(null, result);
    });
  };
  
  /**
   * The operation to power off (stop) a virtual machine.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} vmName The name of the virtual machine.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.beginPoweringOff = function(resourceGroupName, vmName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (vmName === null || vmName === undefined) {
      return callback(new Error('vmName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/';
    url2 = url2 + 'virtualMachines';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(vmName);
    url2 = url2 + '/powerOff';
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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
    
    // 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.azureAsyncOperation = response.headers['azure-asyncoperation'];
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The operation to restart a virtual machine.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} vmName The name of the virtual machine.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.beginRestarting = function(resourceGroupName, vmName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (vmName === null || vmName === undefined) {
      return callback(new Error('vmName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/';
    url2 = url2 + 'virtualMachines';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(vmName);
    url2 = url2 + '/restart';
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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
    
    // 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.azureAsyncOperation = response.headers['azure-asyncoperation'];
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The operation to start a virtual machine.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} vmName The name of the virtual machine.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.beginStarting = function(resourceGroupName, vmName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (vmName === null || vmName === undefined) {
      return callback(new Error('vmName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/';
    url2 = url2 + 'virtualMachines';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(vmName);
    url2 = url2 + '/start';
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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
    
    // 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.azureAsyncOperation = response.headers['azure-asyncoperation'];
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Captures the VM by copying VirtualHardDisks of the VM and outputs a
   * template that can be used to create similar VMs.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} vmName The name of the virtual machine.
   * 
   * @param {VirtualMachineCaptureParameters} parameters Parameters supplied to
   * the Capture Virtual Machine operation.
   * 
   * @param {string} parameters.virtualHardDiskNamePrefix Gets or sets the
   * captured VirtualHardDisk's name prefix.
   * 
   * @param {string} parameters.destinationContainerName Gets or sets the
   * destination container name.
   * 
   * @param {boolean} parameters.overwrite Gets or sets whether it overwrites
   * destination VirtualHardDisk if true, in case of conflict.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.capture = function(resourceGroupName, vmName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachines.beginCapturing(resourceGroupName, vmName, 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.getLongRunningOperationStatus(result.azureAsyncOperation, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The operation to create or update a virtual machine.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {VirtualMachine} parameters Parameters supplied to the Create
   * Virtual Machine operation.
   * 
   * @param {Plan} [parameters.plan] Gets or sets the purchase plan when
   * deploying virtual machine from VM Marketplace images.
   * 
   * @param {string} [parameters.plan.name] Gets or sets the plan ID.
   * 
   * @param {string} [parameters.plan.publisher] Gets or sets the publisher ID.
   * 
   * @param {string} [parameters.plan.product] Gets or sets the offer ID.
   * 
   * @param {string} [parameters.plan.promotionCode] Gets or sets the promotion
   * code.
   * 
   * @param {HardwareProfile} [parameters.hardwareProfile] Gets or sets the
   * hardware profile.
   * 
   * @param {string} [parameters.hardwareProfile.virtualMachineSize] The
   * virtual machine size name.
   * 
   * @param {StorageProfile} [parameters.storageProfile] Gets or sets the
   * storage profile.
   * 
   * @param {ImageReference} [parameters.storageProfile.imageReference] Gets or
   * sets the image reference.
   * 
   * @param {string} [parameters.storageProfile.imageReference.publisher] Gets
   * or sets the image publisher.
   * 
   * @param {string} [parameters.storageProfile.imageReference.offer] Gets or
   * sets the image offer.
   * 
   * @param {string} [parameters.storageProfile.imageReference.sku] Gets or
   * sets the image sku.
   * 
   * @param {string} [parameters.storageProfile.imageReference.version] Gets or
   * sets the image version. The allowed formats are Major.Minor.Build or
   * 'latest'. Major, Minor and Build being decimal numbers. Specify 'latest'
   * to use the latest version of image.
   * 
   * @param {OSDisk} [parameters.storageProfile.oSDisk] Gets or sets the OS
   * disk.
   * 
   * @param {string} [parameters.storageProfile.oSDisk.operatingSystemType]
   * Gets or sets the Operating System type.
   * 
   * @param {DiskEncryptionSettings}
   * [parameters.storageProfile.oSDisk.encryptionSettings] Gets or sets the
   * disk encryption settings.
   * 
   * @param {KeyVaultSecretReference}
   * [parameters.storageProfile.oSDisk.encryptionSettings.diskEncryptionKey]
   * Gets or sets the disk encryption key which is a KeyVault Secret.
   * 
   * @param {string}
   * [parameters.storageProfile.oSDisk.encryptionSettings.diskEncryptionKey.secretUrl]
   * Gets or sets the URL referencing a secret in a Key Vault.
   * 
   * @param {SourceVaultReference}
   * [parameters.storageProfile.oSDisk.encryptionSettings.diskEncryptionKey.sourceVault]
   * Gets or sets the Relative URL of the Key Vault containing the secret.
   * 
   * @param {string}
   * [parameters.storageProfile.oSDisk.encryptionSettings.diskEncryptionKey.sourceVault.referenceUri]
   * Gets or sets the relative URL in the previous Service Management API's
   * namespace. For Example:
   * /subscriptions/{SubcriptionId}/resourceGroups/{ResourceGroupName}/...
   * 
   * @param {KeyVaultKeyReference}
   * [parameters.storageProfile.oSDisk.encryptionSettings.keyEncryptionKey]
   * Gets or sets the key encryption key which is KeyVault Key.
   * 
   * @param {string}
   * [parameters.storageProfile.oSDisk.encryptionSettings.keyEncryptionKey.keyUrl]
   * Gets or sets the URL referencing a key in a Key Vault.
   * 
   * @param {SourceVaultReference}
   * [parameters.storageProfile.oSDisk.encryptionSettings.keyEncryptionKey.sourceVault]
   * Gets or sets the Relative URL of the Key Vault containing the key
   * 
   * @param {string}
   * [parameters.storageProfile.oSDisk.encryptionSettings.keyEncryptionKey.sourceVault.referenceUri]
   * Gets or sets the relative URL in the previous Service Management API's
   * namespace. For Example:
   * /subscriptions/{SubcriptionId}/resourceGroups/{ResourceGroupName}/...
   * 
   * @param {string} [parameters.storageProfile.oSDisk.name] Gets or sets the
   * disk name.
   * 
   * @param {VirtualHardDisk}
   * [parameters.storageProfile.oSDisk.virtualHardDisk] Gets or sets the
   * Virtual Hard Disk.
   * 
   * @param {string} [parameters.storageProfile.oSDisk.virtualHardDisk.uri]
   * Gets or sets the virtual hard disk's uri. It should be a valid Uri to a
   * virtual hard disk.
   * 
   * @param {VirtualHardDisk} [parameters.storageProfile.oSDisk.sourceImage]
   * Gets or sets the Source User Image VirtualHardDisk. This VirtualHardDisk
   * will be copied before using it to attach to the Virtual Machine.If
   * SourceImage is provided, the destination VirtualHardDisk should not exist.
   * 
   * @param {string} [parameters.storageProfile.oSDisk.sourceImage.uri] Gets or
   * sets the virtual hard disk's uri. It should be a valid Uri to a virtual
   * hard disk.
   * 
   * @param {string} [parameters.storageProfile.oSDisk.caching] Gets or sets
   * the caching type.
   * 
   * @param {string} [parameters.storageProfile.oSDisk.createOption] Gets or
   * sets the create option.
   * 
   * @param {number} [parameters.storageProfile.oSDisk.diskSizeGB] Gets or sets
   * the initial disk size in GB for blank data disks, and the new desired
   * size for existing OS and Data disks.
   * 
   * @param {array} [parameters.storageProfile.dataDisks] Gets or sets the data
   * disks.
   * 
   * @param {OSProfile} [parameters.oSProfile] Gets or sets the OS profile.
   * 
   * @param {string} [parameters.oSProfile.computerName] Gets or sets the
   * computer name.
   * 
   * @param {string} [parameters.oSProfile.adminUsername] Gets or sets the
   * admin user name.
   * 
   * @param {string} [parameters.oSProfile.adminPassword] Gets or sets the
   * admin user password.
   * 
   * @param {string} [parameters.oSProfile.customData] Gets or sets a base-64
   * encoded string of custom data.
   * 
   * @param {WindowsConfiguration} [parameters.oSProfile.windowsConfiguration]
   * Gets or sets the Windows Configuration of the OS profile.
   * 
   * @param {boolean}
   * [parameters.oSProfile.windowsConfiguration.provisionVMAgent] Gets or sets
   * whether VM Agent should be provisioned on the Virtual Machine.
   * 
   * @param {boolean}
   * [parameters.oSProfile.windowsConfiguration.enableAutomaticUpdates] Gets
   * or sets whether Windows updates are automatically installed on the VM
   * 
   * @param {string} [parameters.oSProfile.windowsConfiguration.timeZone] Gets
   * or sets the Time Zone of the VM
   * 
   * @param {array}
   * [parameters.oSProfile.windowsConfiguration.additionalUnattendContents]
   * Gets or sets the additional base-64 encoded XML formatted information
   * that can be included in the Unattend.xml file.
   * 
   * @param {WinRMConfiguration}
   * [parameters.oSProfile.windowsConfiguration.winRMConfiguration] Gets or
   * sets the Windows Remote Management configuration of the VM
   * 
   * @param {array}
   * [parameters.oSProfile.windowsConfiguration.winRMConfiguration.listeners]
   * Gets or sets the list of Windows Remote Management listeners
   * 
   * @param {LinuxConfiguration} [parameters.oSProfile.linuxConfiguration] Gets
   * or sets the Linux Configuration of the OS profile.
   * 
   * @param {boolean}
   * [parameters.oSProfile.linuxConfiguration.disablePasswordAuthentication]
   * Gets or sets whether Authentication using user name and password is
   * allowed or not
   * 
   * @param {SshConfiguration}
   * [parameters.oSProfile.linuxConfiguration.sshConfiguration] Gets or sets
   * the SSH configuration for linux VMs
   * 
   * @param {array}
   * [parameters.oSProfile.linuxConfiguration.sshConfiguration.publicKeys]
   * Gets or sets the list of SSH public keys used to authenticate with linux
   * based VMs
   * 
   * @param {array} [parameters.oSProfile.secrets] Gets or sets the List of
   * certificates for addition to the VM.
   * 
   * @param {NetworkProfile} [parameters.networkProfile] Gets or sets the
   * network profile.
   * 
   * @param {array} [parameters.networkProfile.networkInterfaces] Gets or sets
   * the network interfaces.
   * 
   * @param {DiagnosticsProfile} [parameters.diagnosticsProfile] Gets or sets
   * the diagnostics profile.
   * 
   * @param {BootDiagnostics} [parameters.diagnosticsProfile.bootDiagnostics]
   * Gets or sets the boot diagnostics.
   * 
   * @param {boolean} [parameters.diagnosticsProfile.bootDiagnostics.enabled]
   * Gets or sets whether VM Agent should be provisioned on the Virtual
   * Machine.
   * 
   * @param {string} [parameters.diagnosticsProfile.bootDiagnostics.storageUri]
   * Gets or sets the boot diagnostics storage Uri. It should be a valid Uri
   * 
   * @param {AvailabilitySetReference} [parameters.availabilitySetReference]
   * Gets or sets the reference Id of the availailbity set to which this
   * virtual machine belongs.
   * 
   * @param {string} [parameters.availabilitySetReference.referenceUri] Gets or
   * sets the relative URL in the previous Service Management API's namespace.
   * For Example:
   * /subscriptions/{SubcriptionId}/resourceGroups/{ResourceGroupName}/...
   * 
   * @param {string} [parameters.provisioningState] Gets or sets the
   * provisioning state, which only appears in the response.
   * 
   * @param {VirtualMachineInstanceView} [parameters.instanceView] Gets the
   * virtual machine instance view.
   * 
   * @param {number} [parameters.instanceView.platformUpdateDomain] Gets or
   * sets the Update Domain count.
   * 
   * @param {number} [parameters.instanceView.platformFaultDomain] Gets or sets
   * the Fault Domain count.
   * 
   * @param {string} [parameters.instanceView.remoteDesktopThumbprint] Gets or
   * sets the Remote desktop certificate thumbprint.
   * 
   * @param {VirtualMachineAgentInstanceView} [parameters.instanceView.vMAgent]
   * Gets or sets the VM Agent running on the virtual machine.
   * 
   * @param {string} [parameters.instanceView.vMAgent.vMAgentVersion] Gets or
   * sets the VM Agent full version.
   * 
   * @param {array} [parameters.instanceView.vMAgent.extensionHandlers] Gets or
   * sets the virtual machine extension handler instance view.
   * 
   * @param {array} [parameters.instanceView.vMAgent.statuses] Gets or sets the
   * resource status information.
   * 
   * @param {array} [parameters.instanceView.disks] Gets or sets the the disks
   * information.
   * 
   * @param {array} [parameters.instanceView.extensions] Gets or sets the
   * extensions information.
   * 
   * @param {BootDiagnosticsInstanceView}
   * [parameters.instanceView.bootDiagnostics] Gets or sets the boot
   * diagnostics.
   * 
   * @param {string}
   * [parameters.instanceView.bootDiagnostics.consoleScreenshotBlobUri] Gets
   * or sets the console screenshot blob Uri.
   * 
   * @param {string}
   * [parameters.instanceView.bootDiagnostics.serialConsoleLogBlobUri] Gets or
   * sets the Linux serial console log blob Uri.
   * 
   * @param {array} [parameters.instanceView.statuses] Gets or sets the
   * resource status information.
   * 
   * @param {array} [parameters.extensions] Gets the virtual machine child
   * extension resources.
   * 
   * @param {string} [parameters.id] Gets or sets the ID of the resource.
   * 
   * @param {string} [parameters.name] Gets or sets the name of the resource.
   * 
   * @param {string} [parameters.type] Gets or sets the type of the resource.
   * 
   * @param {string} parameters.location Gets or sets the location of the
   * resource.
   * 
   * @param {object} [parameters.tags] Gets or sets the tags attached to the
   * resource.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.createOrUpdate = function(resourceGroupName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachines.beginCreatingOrUpdating(resourceGroupName, 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.getLongRunningOperationStatus(result.azureAsyncOperation, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * Shuts down the Virtual Machine and releases the compute resources. You are
   * not billed for the compute resources that this Virtual Machine uses.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} vmName The name of the virtual machine.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.deallocate = function(resourceGroupName, vmName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachines.beginDeallocating(resourceGroupName, vmName, 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.getLongRunningOperationStatus(result.azureAsyncOperation, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The operation to delete a virtual machine.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} vmName The name of the virtual machine.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.deleteMethod = function(resourceGroupName, vmName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachines.beginDeleting(resourceGroupName, vmName, 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.getDeleteOperationStatus(result.azureAsyncOperation, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * Sets the state of the VM as Generalized.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} vmName The name of the virtual machine.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.generalize = function(resourceGroupName, vmName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (vmName === null || vmName === undefined) {
      return callback(new Error('vmName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/';
    url2 = url2 + 'virtualMachines';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(vmName);
    url2 = url2 + '/generalize';
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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/json';
    
    // 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 operation to get a virtual machine.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} vmName The name of the virtual machine.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.get = function(resourceGroupName, vmName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (vmName === null || vmName === undefined) {
      return callback(new Error('vmName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/';
    url2 = url2 + 'virtualMachines';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(vmName);
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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['Content-Type'] = 'application/json';
    
    // 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 responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var virtualMachineInstance = { extensions: [], tags: {} };
          result.virtualMachine = virtualMachineInstance;
          
          var planValue = responseDoc['plan'];
          if (planValue !== null && planValue !== undefined) {
            var planInstance = {};
            virtualMachineInstance.plan = planInstance;
            
            var nameValue = planValue['name'];
            if (nameValue !== null && nameValue !== undefined) {
              var nameInstance = nameValue;
              planInstance.name = nameInstance;
            }
            
            var publisherValue = planValue['publisher'];
            if (publisherValue !== null && publisherValue !== undefined) {
              var publisherInstance = publisherValue;
              planInstance.publisher = publisherInstance;
            }
            
            var productValue = planValue['product'];
            if (productValue !== null && productValue !== undefined) {
              var productInstance = productValue;
              planInstance.product = productInstance;
            }
            
            var promotionCodeValue = planValue['promotionCode'];
            if (promotionCodeValue !== null && promotionCodeValue !== undefined) {
              var promotionCodeInstance = promotionCodeValue;
              planInstance.promotionCode = promotionCodeInstance;
            }
          }
          
          var propertiesValue = responseDoc['properties'];
          if (propertiesValue !== null && propertiesValue !== undefined) {
            var hardwareProfileValue = propertiesValue['hardwareProfile'];
            if (hardwareProfileValue !== null && hardwareProfileValue !== undefined) {
              var hardwareProfileInstance = {};
              virtualMachineInstance.hardwareProfile = hardwareProfileInstance;
              
              var vmSizeValue = hardwareProfileValue['vmSize'];
              if (vmSizeValue !== null && vmSizeValue !== undefined) {
                var vmSizeInstance = vmSizeValue;
                hardwareProfileInstance.virtualMachineSize = vmSizeInstance;
              }
            }
            
            var storageProfileValue = propertiesValue['storageProfile'];
            if (storageProfileValue !== null && storageProfileValue !== undefined) {
              var storageProfileInstance = { dataDisks: [] };
              virtualMachineInstance.storageProfile = storageProfileInstance;
              
              var imageReferenceValue = storageProfileValue['imageReference'];
              if (imageReferenceValue !== null && imageReferenceValue !== undefined) {
                var imageReferenceInstance = {};
                storageProfileInstance.imageReference = imageReferenceInstance;
                
                var publisherValue2 = imageReferenceValue['publisher'];
                if (publisherValue2 !== null && publisherValue2 !== undefined) {
                  var publisherInstance2 = publisherValue2;
                  imageReferenceInstance.publisher = publisherInstance2;
                }
                
                var offerValue = imageReferenceValue['offer'];
                if (offerValue !== null && offerValue !== undefined) {
                  var offerInstance = offerValue;
                  imageReferenceInstance.offer = offerInstance;
                }
                
                var skuValue = imageReferenceValue['sku'];
                if (skuValue !== null && skuValue !== undefined) {
                  var skuInstance = skuValue;
                  imageReferenceInstance.sku = skuInstance;
                }
                
                var versionValue = imageReferenceValue['version'];
                if (versionValue !== null && versionValue !== undefined) {
                  var versionInstance = versionValue;
                  imageReferenceInstance.version = versionInstance;
                }
              }
              
              var osDiskValue = storageProfileValue['osDisk'];
              if (osDiskValue !== null && osDiskValue !== undefined) {
                var osDiskInstance = {};
                storageProfileInstance.oSDisk = osDiskInstance;
                
                var osTypeValue = osDiskValue['osType'];
                if (osTypeValue !== null && osTypeValue !== undefined) {
                  var osTypeInstance = osTypeValue;
                  osDiskInstance.operatingSystemType = osTypeInstance;
                }
                
                var encryptionSettingsValue = osDiskValue['encryptionSettings'];
                if (encryptionSettingsValue !== null && encryptionSettingsValue !== undefined) {
                  var encryptionSettingsInstance = {};
                  osDiskInstance.encryptionSettings = encryptionSettingsInstance;
                  
                  var diskEncryptionKeyValue = encryptionSettingsValue['diskEncryptionKey'];
                  if (diskEncryptionKeyValue !== null && diskEncryptionKeyValue !== undefined) {
                    var diskEncryptionKeyInstance = {};
                    encryptionSettingsInstance.diskEncryptionKey = diskEncryptionKeyInstance;
                    
                    var secretUrlValue = diskEncryptionKeyValue['secretUrl'];
                    if (secretUrlValue !== null && secretUrlValue !== undefined) {
                      var secretUrlInstance = secretUrlValue;
                      diskEncryptionKeyInstance.secretUrl = secretUrlInstance;
                    }
                    
                    var sourceVaultValue = diskEncryptionKeyValue['sourceVault'];
                    if (sourceVaultValue !== null && sourceVaultValue !== undefined) {
                      var sourceVaultInstance = {};
                      diskEncryptionKeyInstance.sourceVault = sourceVaultInstance;
                      
                      var idValue = sourceVaultValue['id'];
                      if (idValue !== null && idValue !== undefined) {
                        var idInstance = idValue;
                        sourceVaultInstance.referenceUri = idInstance;
                      }
                    }
                  }
                  
                  var keyEncryptionKeyValue = encryptionSettingsValue['keyEncryptionKey'];
                  if (keyEncryptionKeyValue !== null && keyEncryptionKeyValue !== undefined) {
                    var keyEncryptionKeyInstance = {};
                    encryptionSettingsInstance.keyEncryptionKey = keyEncryptionKeyInstance;
                    
                    var keyUrlValue = keyEncryptionKeyValue['keyUrl'];
                    if (keyUrlValue !== null && keyUrlValue !== undefined) {
                      var keyUrlInstance = keyUrlValue;
                      keyEncryptionKeyInstance.keyUrl = keyUrlInstance;
                    }
                    
                    var sourceVaultValue2 = keyEncryptionKeyValue['sourceVault'];
                    if (sourceVaultValue2 !== null && sourceVaultValue2 !== undefined) {
                      var sourceVaultInstance2 = {};
                      keyEncryptionKeyInstance.sourceVault = sourceVaultInstance2;
                      
                      var idValue2 = sourceVaultValue2['id'];
                      if (idValue2 !== null && idValue2 !== undefined) {
                        var idInstance2 = idValue2;
                        sourceVaultInstance2.referenceUri = idInstance2;
                      }
                    }
                  }
                }
                
                var nameValue2 = osDiskValue['name'];
                if (nameValue2 !== null && nameValue2 !== undefined) {
                  var nameInstance2 = nameValue2;
                  osDiskInstance.name = nameInstance2;
                }
                
                var vhdValue = osDiskValue['vhd'];
                if (vhdValue !== null && vhdValue !== undefined) {
                  var vhdInstance = {};
                  osDiskInstance.virtualHardDisk = vhdInstance;
                  
                  var uriValue = vhdValue['uri'];
                  if (uriValue !== null && uriValue !== undefined) {
                    var uriInstance = uriValue;
                    vhdInstance.uri = uriInstance;
                  }
                }
                
                var imageValue = osDiskValue['image'];
                if (imageValue !== null && imageValue !== undefined) {
                  var imageInstance = {};
                  osDiskInstance.sourceImage = imageInstance;
                  
                  var uriValue2 = imageValue['uri'];
                  if (uriValue2 !== null && uriValue2 !== undefined) {
                    var uriInstance2 = uriValue2;
                    imageInstance.uri = uriInstance2;
                  }
                }
                
                var cachingValue = osDiskValue['caching'];
                if (cachingValue !== null && cachingValue !== undefined) {
                  var cachingInstance = cachingValue;
                  osDiskInstance.caching = cachingInstance;
                }
                
                var createOptionValue = osDiskValue['createOption'];
                if (createOptionValue !== null && createOptionValue !== undefined) {
                  var createOptionInstance = createOptionValue;
                  osDiskInstance.createOption = createOptionInstance;
                }
                
                var diskSizeGBValue = osDiskValue['diskSizeGB'];
                if (diskSizeGBValue !== null && diskSizeGBValue !== undefined) {
                  var diskSizeGBInstance = diskSizeGBValue;
                  osDiskInstance.diskSizeGB = diskSizeGBInstance;
                }
              }
              
              var dataDisksArray = storageProfileValue['dataDisks'];
              if (dataDisksArray !== null && dataDisksArray !== undefined) {
                for (var loweredIndex1 = 0; loweredIndex1 < dataDisksArray.length; loweredIndex1 = loweredIndex1 + 1) {
                  var dataDisksValue = dataDisksArray[loweredIndex1];
                  var dataDiskInstance = {};
                  storageProfileInstance.dataDisks.push(dataDiskInstance);
                  
                  var lunValue = dataDisksValue['lun'];
                  if (lunValue !== null && lunValue !== undefined) {
                    var lunInstance = lunValue;
                    dataDiskInstance.lun = lunInstance;
                  }
                  
                  var nameValue3 = dataDisksValue['name'];
                  if (nameValue3 !== null && nameValue3 !== undefined) {
                    var nameInstance3 = nameValue3;
                    dataDiskInstance.name = nameInstance3;
                  }
                  
                  var vhdValue2 = dataDisksValue['vhd'];
                  if (vhdValue2 !== null && vhdValue2 !== undefined) {
                    var vhdInstance2 = {};
                    dataDiskInstance.virtualHardDisk = vhdInstance2;
                    
                    var uriValue3 = vhdValue2['uri'];
                    if (uriValue3 !== null && uriValue3 !== undefined) {
                      var uriInstance3 = uriValue3;
                      vhdInstance2.uri = uriInstance3;
                    }
                  }
                  
                  var imageValue2 = dataDisksValue['image'];
                  if (imageValue2 !== null && imageValue2 !== undefined) {
                    var imageInstance2 = {};
                    dataDiskInstance.sourceImage = imageInstance2;
                    
                    var uriValue4 = imageValue2['uri'];
                    if (uriValue4 !== null && uriValue4 !== undefined) {
                      var uriInstance4 = uriValue4;
                      imageInstance2.uri = uriInstance4;
                    }
                  }
                  
                  var cachingValue2 = dataDisksValue['caching'];
                  if (cachingValue2 !== null && cachingValue2 !== undefined) {
                    var cachingInstance2 = cachingValue2;
                    dataDiskInstance.caching = cachingInstance2;
                  }
                  
                  var createOptionValue2 = dataDisksValue['createOption'];
                  if (createOptionValue2 !== null && createOptionValue2 !== undefined) {
                    var createOptionInstance2 = createOptionValue2;
                    dataDiskInstance.createOption = createOptionInstance2;
                  }
                  
                  var diskSizeGBValue2 = dataDisksValue['diskSizeGB'];
                  if (diskSizeGBValue2 !== null && diskSizeGBValue2 !== undefined) {
                    var diskSizeGBInstance2 = diskSizeGBValue2;
                    dataDiskInstance.diskSizeGB = diskSizeGBInstance2;
                  }
                }
              }
            }
            
            var osProfileValue = propertiesValue['osProfile'];
            if (osProfileValue !== null && osProfileValue !== undefined) {
              var osProfileInstance = { secrets: [] };
              virtualMachineInstance.oSProfile = osProfileInstance;
              
              var computerNameValue = osProfileValue['computerName'];
              if (computerNameValue !== null && computerNameValue !== undefined) {
                var computerNameInstance = computerNameValue;
                osProfileInstance.computerName = computerNameInstance;
              }
              
              var adminUsernameValue = osProfileValue['adminUsername'];
              if (adminUsernameValue !== null && adminUsernameValue !== undefined) {
                var adminUsernameInstance = adminUsernameValue;
                osProfileInstance.adminUsername = adminUsernameInstance;
              }
              
              var adminPasswordValue = osProfileValue['adminPassword'];
              if (adminPasswordValue !== null && adminPasswordValue !== undefined) {
                var adminPasswordInstance = adminPasswordValue;
                osProfileInstance.adminPassword = adminPasswordInstance;
              }
              
              var customDataValue = osProfileValue['customData'];
              if (customDataValue !== null && customDataValue !== undefined) {
                var customDataInstance = customDataValue;
                osProfileInstance.customData = customDataInstance;
              }
              
              var windowsConfigurationValue = osProfileValue['windowsConfiguration'];
              if (windowsConfigurationValue !== null && windowsConfigurationValue !== undefined) {
                var windowsConfigurationInstance = { additionalUnattendContents: [] };
                osProfileInstance.windowsConfiguration = windowsConfigurationInstance;
                
                var provisionVMAgentValue = windowsConfigurationValue['provisionVMAgent'];
                if (provisionVMAgentValue !== null && provisionVMAgentValue !== undefined) {
                  var provisionVMAgentInstance = provisionVMAgentValue;
                  windowsConfigurationInstance.provisionVMAgent = provisionVMAgentInstance;
                }
                
                var enableAutomaticUpdatesValue = windowsConfigurationValue['enableAutomaticUpdates'];
                if (enableAutomaticUpdatesValue !== null && enableAutomaticUpdatesValue !== undefined) {
                  var enableAutomaticUpdatesInstance = enableAutomaticUpdatesValue;
                  windowsConfigurationInstance.enableAutomaticUpdates = enableAutomaticUpdatesInstance;
                }
                
                var timeZoneValue = windowsConfigurationValue['timeZone'];
                if (timeZoneValue !== null && timeZoneValue !== undefined) {
                  var timeZoneInstance = timeZoneValue;
                  windowsConfigurationInstance.timeZone = timeZoneInstance;
                }
                
                var additionalUnattendContentArray = windowsConfigurationValue['additionalUnattendContent'];
                if (additionalUnattendContentArray !== null && additionalUnattendContentArray !== undefined) {
                  for (var loweredIndex2 = 0; loweredIndex2 < additionalUnattendContentArray.length; loweredIndex2 = loweredIndex2 + 1) {
                    var additionalUnattendContentValue = additionalUnattendContentArray[loweredIndex2];
                    var additionalUnattendContentInstance = {};
                    windowsConfigurationInstance.additionalUnattendContents.push(additionalUnattendContentInstance);
                    
                    var passNameValue = additionalUnattendContentValue['passName'];
                    if (passNameValue !== null && passNameValue !== undefined) {
                      var passNameInstance = passNameValue;
                      additionalUnattendContentInstance.passName = passNameInstance;
                    }
                    
                    var componentNameValue = additionalUnattendContentValue['componentName'];
                    if (componentNameValue !== null && componentNameValue !== undefined) {
                      var componentNameInstance = componentNameValue;
                      additionalUnattendContentInstance.componentName = componentNameInstance;
                    }
                    
                    var settingNameValue = additionalUnattendContentValue['settingName'];
                    if (settingNameValue !== null && settingNameValue !== undefined) {
                      var settingNameInstance = settingNameValue;
                      additionalUnattendContentInstance.settingName = settingNameInstance;
                    }
                    
                    var contentValue = additionalUnattendContentValue['content'];
                    if (contentValue !== null && contentValue !== undefined) {
                      var contentInstance = contentValue;
                      additionalUnattendContentInstance.content = contentInstance;
                    }
                  }
                }
                
                var winRMValue = windowsConfigurationValue['winRM'];
                if (winRMValue !== null && winRMValue !== undefined) {
                  var winRMInstance = { listeners: [] };
                  windowsConfigurationInstance.winRMConfiguration = winRMInstance;
                  
                  var listenersArray = winRMValue['listeners'];
                  if (listenersArray !== null && listenersArray !== undefined) {
                    for (var loweredIndex3 = 0; loweredIndex3 < listenersArray.length; loweredIndex3 = loweredIndex3 + 1) {
                      var listenersValue = listenersArray[loweredIndex3];
                      var winRMListenerInstance = {};
                      winRMInstance.listeners.push(winRMListenerInstance);
                      
                      var protocolValue = listenersValue['protocol'];
                      if (protocolValue !== null && protocolValue !== undefined) {
                        var protocolInstance = protocolValue;
                        winRMListenerInstance.protocol = protocolInstance;
                      }
                      
                      var certificateUrlValue = listenersValue['certificateUrl'];
                      if (certificateUrlValue !== null && certificateUrlValue !== undefined) {
                        var certificateUrlInstance = certificateUrlValue;
                        winRMListenerInstance.certificateUrl = certificateUrlInstance;
                      }
                    }
                  }
                }
              }
              
              var linuxConfigurationValue = osProfileValue['linuxConfiguration'];
              if (linuxConfigurationValue !== null && linuxConfigurationValue !== undefined) {
                var linuxConfigurationInstance = {};
                osProfileInstance.linuxConfiguration = linuxConfigurationInstance;
                
                var disablePasswordAuthenticationValue = linuxConfigurationValue['disablePasswordAuthentication'];
                if (disablePasswordAuthenticationValue !== null && disablePasswordAuthenticationValue !== undefined) {
                  var disablePasswordAuthenticationInstance = disablePasswordAuthenticationValue;
                  linuxConfigurationInstance.disablePasswordAuthentication = disablePasswordAuthenticationInstance;
                }
                
                var sshValue = linuxConfigurationValue['ssh'];
                if (sshValue !== null && sshValue !== undefined) {
                  var sshInstance = { publicKeys: [] };
                  linuxConfigurationInstance.sshConfiguration = sshInstance;
                  
                  var publicKeysArray = sshValue['publicKeys'];
                  if (publicKeysArray !== null && publicKeysArray !== undefined) {
                    for (var loweredIndex4 = 0; loweredIndex4 < publicKeysArray.length; loweredIndex4 = loweredIndex4 + 1) {
                      var publicKeysValue = publicKeysArray[loweredIndex4];
                      var sshPublicKeyInstance = {};
                      sshInstance.publicKeys.push(sshPublicKeyInstance);
                      
                      var pathValue = publicKeysValue['path'];
                      if (pathValue !== null && pathValue !== undefined) {
                        var pathInstance = pathValue;
                        sshPublicKeyInstance.path = pathInstance;
                      }
                      
                      var keyDataValue = publicKeysValue['keyData'];
                      if (keyDataValue !== null && keyDataValue !== undefined) {
                        var keyDataInstance = keyDataValue;
                        sshPublicKeyInstance.keyData = keyDataInstance;
                      }
                    }
                  }
                }
              }
              
              var secretsArray = osProfileValue['secrets'];
              if (secretsArray !== null && secretsArray !== undefined) {
                for (var loweredIndex5 = 0; loweredIndex5 < secretsArray.length; loweredIndex5 = loweredIndex5 + 1) {
                  var secretsValue = secretsArray[loweredIndex5];
                  var vaultSecretGroupInstance = { vaultCertificates: [] };
                  osProfileInstance.secrets.push(vaultSecretGroupInstance);
                  
                  var sourceVaultValue3 = secretsValue['sourceVault'];
                  if (sourceVaultValue3 !== null && sourceVaultValue3 !== undefined) {
                    var sourceVaultInstance3 = {};
                    vaultSecretGroupInstance.sourceVault = sourceVaultInstance3;
                    
                    var idValue3 = sourceVaultValue3['id'];
                    if (idValue3 !== null && idValue3 !== undefined) {
                      var idInstance3 = idValue3;
                      sourceVaultInstance3.referenceUri = idInstance3;
                    }
                  }
                  
                  var vaultCertificatesArray = secretsValue['vaultCertificates'];
                  if (vaultCertificatesArray !== null && vaultCertificatesArray !== undefined) {
                    for (var loweredIndex6 = 0; loweredIndex6 < vaultCertificatesArray.length; loweredIndex6 = loweredIndex6 + 1) {
                      var vaultCertificatesValue = vaultCertificatesArray[loweredIndex6];
                      var vaultCertificateInstance = {};
                      vaultSecretGroupInstance.vaultCertificates.push(vaultCertificateInstance);
                      
                      var certificateUrlValue2 = vaultCertificatesValue['certificateUrl'];
                      if (certificateUrlValue2 !== null && certificateUrlValue2 !== undefined) {
                        var certificateUrlInstance2 = certificateUrlValue2;
                        vaultCertificateInstance.certificateUrl = certificateUrlInstance2;
                      }
                      
                      var certificateStoreValue = vaultCertificatesValue['certificateStore'];
                      if (certificateStoreValue !== null && certificateStoreValue !== undefined) {
                        var certificateStoreInstance = certificateStoreValue;
                        vaultCertificateInstance.certificateStore = certificateStoreInstance;
                      }
                    }
                  }
                }
              }
            }
            
            var networkProfileValue = propertiesValue['networkProfile'];
            if (networkProfileValue !== null && networkProfileValue !== undefined) {
              var networkProfileInstance = { networkInterfaces: [] };
              virtualMachineInstance.networkProfile = networkProfileInstance;
              
              var networkInterfacesArray = networkProfileValue['networkInterfaces'];
              if (networkInterfacesArray !== null && networkInterfacesArray !== undefined) {
                for (var loweredIndex7 = 0; loweredIndex7 < networkInterfacesArray.length; loweredIndex7 = loweredIndex7 + 1) {
                  var networkInterfacesValue = networkInterfacesArray[loweredIndex7];
                  var networkInterfaceReferenceJsonInstance = {};
                  networkProfileInstance.networkInterfaces.push(networkInterfaceReferenceJsonInstance);
                  
                  var propertiesValue2 = networkInterfacesValue['properties'];
                  if (propertiesValue2 !== null && propertiesValue2 !== undefined) {
                    var primaryValue = propertiesValue2['primary'];
                    if (primaryValue !== null && primaryValue !== undefined) {
                      var primaryInstance = primaryValue;
                      networkInterfaceReferenceJsonInstance.primary = primaryInstance;
                    }
                  }
                  
                  var idValue4 = networkInterfacesValue['id'];
                  if (idValue4 !== null && idValue4 !== undefined) {
                    var idInstance4 = idValue4;
                    networkInterfaceReferenceJsonInstance.referenceUri = idInstance4;
                  }
                }
              }
            }
            
            var diagnosticsProfileValue = propertiesValue['diagnosticsProfile'];
            if (diagnosticsProfileValue !== null && diagnosticsProfileValue !== undefined) {
              var diagnosticsProfileInstance = {};
              virtualMachineInstance.diagnosticsProfile = diagnosticsProfileInstance;
              
              var bootDiagnosticsValue = diagnosticsProfileValue['bootDiagnostics'];
              if (bootDiagnosticsValue !== null && bootDiagnosticsValue !== undefined) {
                var bootDiagnosticsInstance = {};
                diagnosticsProfileInstance.bootDiagnostics = bootDiagnosticsInstance;
                
                var enabledValue = bootDiagnosticsValue['enabled'];
                if (enabledValue !== null && enabledValue !== undefined) {
                  var enabledInstance = enabledValue;
                  bootDiagnosticsInstance.enabled = enabledInstance;
                }
                
                var storageUriValue = bootDiagnosticsValue['storageUri'];
                if (storageUriValue !== null && storageUriValue !== undefined) {
                  var storageUriInstance = storageUriValue;
                  bootDiagnosticsInstance.storageUri = storageUriInstance;
                }
              }
            }
            
            var availabilitySetValue = propertiesValue['availabilitySet'];
            if (availabilitySetValue !== null && availabilitySetValue !== undefined) {
              var availabilitySetInstance = {};
              virtualMachineInstance.availabilitySetReference = availabilitySetInstance;
              
              var idValue5 = availabilitySetValue['id'];
              if (idValue5 !== null && idValue5 !== undefined) {
                var idInstance5 = idValue5;
                availabilitySetInstance.referenceUri = idInstance5;
              }
            }
            
            var provisioningStateValue = propertiesValue['provisioningState'];
            if (provisioningStateValue !== null && provisioningStateValue !== undefined) {
              var provisioningStateInstance = provisioningStateValue;
              virtualMachineInstance.provisioningState = provisioningStateInstance;
            }
            
            var instanceViewValue = propertiesValue['instanceView'];
            if (instanceViewValue !== null && instanceViewValue !== undefined) {
              var instanceViewInstance = { disks: [], extensions: [], statuses: [] };
              virtualMachineInstance.instanceView = instanceViewInstance;
              
              var platformUpdateDomainValue = instanceViewValue['platformUpdateDomain'];
              if (platformUpdateDomainValue !== null && platformUpdateDomainValue !== undefined) {
                var platformUpdateDomainInstance = platformUpdateDomainValue;
                instanceViewInstance.platformUpdateDomain = platformUpdateDomainInstance;
              }
              
              var platformFaultDomainValue = instanceViewValue['platformFaultDomain'];
              if (platformFaultDomainValue !== null && platformFaultDomainValue !== undefined) {
                var platformFaultDomainInstance = platformFaultDomainValue;
                instanceViewInstance.platformFaultDomain = platformFaultDomainInstance;
              }
              
              var rdpThumbPrintValue = instanceViewValue['rdpThumbPrint'];
              if (rdpThumbPrintValue !== null && rdpThumbPrintValue !== undefined) {
                var rdpThumbPrintInstance = rdpThumbPrintValue;
                instanceViewInstance.remoteDesktopThumbprint = rdpThumbPrintInstance;
              }
              
              var vmAgentValue = instanceViewValue['vmAgent'];
              if (vmAgentValue !== null && vmAgentValue !== undefined) {
                var vmAgentInstance = { extensionHandlers: [], statuses: [] };
                instanceViewInstance.vMAgent = vmAgentInstance;
                
                var vmAgentVersionValue = vmAgentValue['vmAgentVersion'];
                if (vmAgentVersionValue !== null && vmAgentVersionValue !== undefined) {
                  var vmAgentVersionInstance = vmAgentVersionValue;
                  vmAgentInstance.vMAgentVersion = vmAgentVersionInstance;
                }
                
                var extensionHandlersArray = vmAgentValue['extensionHandlers'];
                if (extensionHandlersArray !== null && extensionHandlersArray !== undefined) {
                  for (var loweredIndex8 = 0; loweredIndex8 < extensionHandlersArray.length; loweredIndex8 = loweredIndex8 + 1) {
                    var extensionHandlersValue = extensionHandlersArray[loweredIndex8];
                    var virtualMachineExtensionHandlerInstanceViewInstance = {};
                    vmAgentInstance.extensionHandlers.push(virtualMachineExtensionHandlerInstanceViewInstance);
                    
                    var typeValue = extensionHandlersValue['type'];
                    if (typeValue !== null && typeValue !== undefined) {
                      var typeInstance = typeValue;
                      virtualMachineExtensionHandlerInstanceViewInstance.type = typeInstance;
                    }
                    
                    var typeHandlerVersionValue = extensionHandlersValue['typeHandlerVersion'];
                    if (typeHandlerVersionValue !== null && typeHandlerVersionValue !== undefined) {
                      var typeHandlerVersionInstance = typeHandlerVersionValue;
                      virtualMachineExtensionHandlerInstanceViewInstance.typeHandlerVersion = typeHandlerVersionInstance;
                    }
                    
                    var statusValue = extensionHandlersValue['status'];
                    if (statusValue !== null && statusValue !== undefined) {
                      var statusInstance = {};
                      virtualMachineExtensionHandlerInstanceViewInstance.status = statusInstance;
                      
                      var codeValue = statusValue['code'];
                      if (codeValue !== null && codeValue !== undefined) {
                        var codeInstance = codeValue;
                        statusInstance.code = codeInstance;
                      }
                      
                      var levelValue = statusValue['level'];
                      if (levelValue !== null && levelValue !== undefined) {
                        var levelInstance = levelValue;
                        statusInstance.level = levelInstance;
                      }
                      
                      var displayStatusValue = statusValue['displayStatus'];
                      if (displayStatusValue !== null && displayStatusValue !== undefined) {
                        var displayStatusInstance = displayStatusValue;
                        statusInstance.displayStatus = displayStatusInstance;
                      }
                      
                      var messageValue = statusValue['message'];
                      if (messageValue !== null && messageValue !== undefined) {
                        var messageInstance = messageValue;
                        statusInstance.message = messageInstance;
                      }
                      
                      var timeValue = statusValue['time'];
                      if (timeValue !== null && timeValue !== undefined) {
                        var timeInstance = timeValue;
                        statusInstance.time = timeInstance;
                      }
                    }
                  }
                }
                
                var statusesArray = vmAgentValue['statuses'];
                if (statusesArray !== null && statusesArray !== undefined) {
                  for (var loweredIndex9 = 0; loweredIndex9 < statusesArray.length; loweredIndex9 = loweredIndex9 + 1) {
                    var statusesValue = statusesArray[loweredIndex9];
                    var instanceViewStatusInstance = {};
                    vmAgentInstance.statuses.push(instanceViewStatusInstance);
                    
                    var codeValue2 = statusesValue['code'];
                    if (codeValue2 !== null && codeValue2 !== undefined) {
                      var codeInstance2 = codeValue2;
                      instanceViewStatusInstance.code = codeInstance2;
                    }
                    
                    var levelValue2 = statusesValue['level'];
                    if (levelValue2 !== null && levelValue2 !== undefined) {
                      var levelInstance2 = levelValue2;
                      instanceViewStatusInstance.level = levelInstance2;
                    }
                    
                    var displayStatusValue2 = statusesValue['displayStatus'];
                    if (displayStatusValue2 !== null && displayStatusValue2 !== undefined) {
                      var displayStatusInstance2 = displayStatusValue2;
                      instanceViewStatusInstance.displayStatus = displayStatusInstance2;
                    }
                    
                    var messageValue2 = statusesValue['message'];
                    if (messageValue2 !== null && messageValue2 !== undefined) {
                      var messageInstance2 = messageValue2;
                      instanceViewStatusInstance.message = messageInstance2;
                    }
                    
                    var timeValue2 = statusesValue['time'];
                    if (timeValue2 !== null && timeValue2 !== undefined) {
                      var timeInstance2 = timeValue2;
                      instanceViewStatusInstance.time = timeInstance2;
                    }
                  }
                }
              }
              
              var disksArray = instanceViewValue['disks'];
              if (disksArray !== null && disksArray !== undefined) {
                for (var loweredIndex10 = 0; loweredIndex10 < disksArray.length; loweredIndex10 = loweredIndex10 + 1) {
                  var disksValue = disksArray[loweredIndex10];
                  var diskInstanceViewInstance = { statuses: [] };
                  instanceViewInstance.disks.push(diskInstanceViewInstance);
                  
                  var nameValue4 = disksValue['name'];
                  if (nameValue4 !== null && nameValue4 !== undefined) {
                    var nameInstance4 = nameValue4;
                    diskInstanceViewInstance.name = nameInstance4;
                  }
                  
                  var statusesArray2 = disksValue['statuses'];
                  if (statusesArray2 !== null && statusesArray2 !== undefined) {
                    for (var loweredIndex11 = 0; loweredIndex11 < statusesArray2.length; loweredIndex11 = loweredIndex11 + 1) {
                      var statusesValue2 = statusesArray2[loweredIndex11];
                      var instanceViewStatusInstance2 = {};
                      diskInstanceViewInstance.statuses.push(instanceViewStatusInstance2);
                      
                      var codeValue3 = statusesValue2['code'];
                      if (codeValue3 !== null && codeValue3 !== undefined) {
                        var codeInstance3 = codeValue3;
                        instanceViewStatusInstance2.code = codeInstance3;
                      }
                      
                      var levelValue3 = statusesValue2['level'];
                      if (levelValue3 !== null && levelValue3 !== undefined) {
                        var levelInstance3 = levelValue3;
                        instanceViewStatusInstance2.level = levelInstance3;
                      }
                      
                      var displayStatusValue3 = statusesValue2['displayStatus'];
                      if (displayStatusValue3 !== null && displayStatusValue3 !== undefined) {
                        var displayStatusInstance3 = displayStatusValue3;
                        instanceViewStatusInstance2.displayStatus = displayStatusInstance3;
                      }
                      
                      var messageValue3 = statusesValue2['message'];
                      if (messageValue3 !== null && messageValue3 !== undefined) {
                        var messageInstance3 = messageValue3;
                        instanceViewStatusInstance2.message = messageInstance3;
                      }
                      
                      var timeValue3 = statusesValue2['time'];
                      if (timeValue3 !== null && timeValue3 !== undefined) {
                        var timeInstance3 = timeValue3;
                        instanceViewStatusInstance2.time = timeInstance3;
                      }
                    }
                  }
                }
              }
              
              var extensionsArray = instanceViewValue['extensions'];
              if (extensionsArray !== null && extensionsArray !== undefined) {
                for (var loweredIndex12 = 0; loweredIndex12 < extensionsArray.length; loweredIndex12 = loweredIndex12 + 1) {
                  var extensionsValue = extensionsArray[loweredIndex12];
                  var virtualMachineExtensionInstanceViewInstance = { statuses: [], subStatuses: [] };
                  instanceViewInstance.extensions.push(virtualMachineExtensionInstanceViewInstance);
                  
                  var nameValue5 = extensionsValue['name'];
                  if (nameValue5 !== null && nameValue5 !== undefined) {
                    var nameInstance5 = nameValue5;
                    virtualMachineExtensionInstanceViewInstance.name = nameInstance5;
                  }
                  
                  var typeValue2 = extensionsValue['type'];
                  if (typeValue2 !== null && typeValue2 !== undefined) {
                    var typeInstance2 = typeValue2;
                    virtualMachineExtensionInstanceViewInstance.extensionType = typeInstance2;
                  }
                  
                  var typeHandlerVersionValue2 = extensionsValue['typeHandlerVersion'];
                  if (typeHandlerVersionValue2 !== null && typeHandlerVersionValue2 !== undefined) {
                    var typeHandlerVersionInstance2 = typeHandlerVersionValue2;
                    virtualMachineExtensionInstanceViewInstance.typeHandlerVersion = typeHandlerVersionInstance2;
                  }
                  
                  var substatusesArray = extensionsValue['substatuses'];
                  if (substatusesArray !== null && substatusesArray !== undefined) {
                    for (var loweredIndex13 = 0; loweredIndex13 < substatusesArray.length; loweredIndex13 = loweredIndex13 + 1) {
                      var substatusesValue = substatusesArray[loweredIndex13];
                      var instanceViewStatusInstance3 = {};
                      virtualMachineExtensionInstanceViewInstance.subStatuses.push(instanceViewStatusInstance3);
                      
                      var codeValue4 = substatusesValue['code'];
                      if (codeValue4 !== null && codeValue4 !== undefined) {
                        var codeInstance4 = codeValue4;
                        instanceViewStatusInstance3.code = codeInstance4;
                      }
                      
                      var levelValue4 = substatusesValue['level'];
                      if (levelValue4 !== null && levelValue4 !== undefined) {
                        var levelInstance4 = levelValue4;
                        instanceViewStatusInstance3.level = levelInstance4;
                      }
                      
                      var displayStatusValue4 = substatusesValue['displayStatus'];
                      if (displayStatusValue4 !== null && displayStatusValue4 !== undefined) {
                        var displayStatusInstance4 = displayStatusValue4;
                        instanceViewStatusInstance3.displayStatus = displayStatusInstance4;
                      }
                      
                      var messageValue4 = substatusesValue['message'];
                      if (messageValue4 !== null && messageValue4 !== undefined) {
                        var messageInstance4 = messageValue4;
                        instanceViewStatusInstance3.message = messageInstance4;
                      }
                      
                      var timeValue4 = substatusesValue['time'];
                      if (timeValue4 !== null && timeValue4 !== undefined) {
                        var timeInstance4 = timeValue4;
                        instanceViewStatusInstance3.time = timeInstance4;
                      }
                    }
                  }
                  
                  var statusesArray3 = extensionsValue['statuses'];
                  if (statusesArray3 !== null && statusesArray3 !== undefined) {
                    for (var loweredIndex14 = 0; loweredIndex14 < statusesArray3.length; loweredIndex14 = loweredIndex14 + 1) {
                      var statusesValue3 = statusesArray3[loweredIndex14];
                      var instanceViewStatusInstance4 = {};
                      virtualMachineExtensionInstanceViewInstance.statuses.push(instanceViewStatusInstance4);
                      
                      var codeValue5 = statusesValue3['code'];
                      if (codeValue5 !== null && codeValue5 !== undefined) {
                        var codeInstance5 = codeValue5;
                        instanceViewStatusInstance4.code = codeInstance5;
                      }
                      
                      var levelValue5 = statusesValue3['level'];
                      if (levelValue5 !== null && levelValue5 !== undefined) {
                        var levelInstance5 = levelValue5;
                        instanceViewStatusInstance4.level = levelInstance5;
                      }
                      
                      var displayStatusValue5 = statusesValue3['displayStatus'];
                      if (displayStatusValue5 !== null && displayStatusValue5 !== undefined) {
                        var displayStatusInstance5 = displayStatusValue5;
                        instanceViewStatusInstance4.displayStatus = displayStatusInstance5;
                      }
                      
                      var messageValue5 = statusesValue3['message'];
                      if (messageValue5 !== null && messageValue5 !== undefined) {
                        var messageInstance5 = messageValue5;
                        instanceViewStatusInstance4.message = messageInstance5;
                      }
                      
                      var timeValue5 = statusesValue3['time'];
                      if (timeValue5 !== null && timeValue5 !== undefined) {
                        var timeInstance5 = timeValue5;
                        instanceViewStatusInstance4.time = timeInstance5;
                      }
                    }
                  }
                }
              }
              
              var bootDiagnosticsValue2 = instanceViewValue['bootDiagnostics'];
              if (bootDiagnosticsValue2 !== null && bootDiagnosticsValue2 !== undefined) {
                var bootDiagnosticsInstance2 = {};
                instanceViewInstance.bootDiagnostics = bootDiagnosticsInstance2;
                
                var consoleScreenshotBlobUriValue = bootDiagnosticsValue2['consoleScreenshotBlobUri'];
                if (consoleScreenshotBlobUriValue !== null && consoleScreenshotBlobUriValue !== undefined) {
                  var consoleScreenshotBlobUriInstance = consoleScreenshotBlobUriValue;
                  bootDiagnosticsInstance2.consoleScreenshotBlobUri = consoleScreenshotBlobUriInstance;
                }
                
                var serialConsoleLogBlobUriValue = bootDiagnosticsValue2['serialConsoleLogBlobUri'];
                if (serialConsoleLogBlobUriValue !== null && serialConsoleLogBlobUriValue !== undefined) {
                  var serialConsoleLogBlobUriInstance = serialConsoleLogBlobUriValue;
                  bootDiagnosticsInstance2.serialConsoleLogBlobUri = serialConsoleLogBlobUriInstance;
                }
              }
              
              var statusesArray4 = instanceViewValue['statuses'];
              if (statusesArray4 !== null && statusesArray4 !== undefined) {
                for (var loweredIndex15 = 0; loweredIndex15 < statusesArray4.length; loweredIndex15 = loweredIndex15 + 1) {
                  var statusesValue4 = statusesArray4[loweredIndex15];
                  var instanceViewStatusInstance5 = {};
                  instanceViewInstance.statuses.push(instanceViewStatusInstance5);
                  
                  var codeValue6 = statusesValue4['code'];
                  if (codeValue6 !== null && codeValue6 !== undefined) {
                    var codeInstance6 = codeValue6;
                    instanceViewStatusInstance5.code = codeInstance6;
                  }
                  
                  var levelValue6 = statusesValue4['level'];
                  if (levelValue6 !== null && levelValue6 !== undefined) {
                    var levelInstance6 = levelValue6;
                    instanceViewStatusInstance5.level = levelInstance6;
                  }
                  
                  var displayStatusValue6 = statusesValue4['displayStatus'];
                  if (displayStatusValue6 !== null && displayStatusValue6 !== undefined) {
                    var displayStatusInstance6 = displayStatusValue6;
                    instanceViewStatusInstance5.displayStatus = displayStatusInstance6;
                  }
                  
                  var messageValue6 = statusesValue4['message'];
                  if (messageValue6 !== null && messageValue6 !== undefined) {
                    var messageInstance6 = messageValue6;
                    instanceViewStatusInstance5.message = messageInstance6;
                  }
                  
                  var timeValue6 = statusesValue4['time'];
                  if (timeValue6 !== null && timeValue6 !== undefined) {
                    var timeInstance6 = timeValue6;
                    instanceViewStatusInstance5.time = timeInstance6;
                  }
                }
              }
            }
          }
          
          var resourcesArray = responseDoc['resources'];
          if (resourcesArray !== null && resourcesArray !== undefined) {
            virtualMachineInstance.extensions = [];
            for (var loweredIndex16 = 0; loweredIndex16 < resourcesArray.length; loweredIndex16 = loweredIndex16 + 1) {
              var resourcesValue = resourcesArray[loweredIndex16];
              var virtualMachineExtensionJsonInstance = { tags: {} };
              virtualMachineInstance.extensions.push(virtualMachineExtensionJsonInstance);
              
              var propertiesValue3 = resourcesValue['properties'];
              if (propertiesValue3 !== null && propertiesValue3 !== undefined) {
                var publisherValue3 = propertiesValue3['publisher'];
                if (publisherValue3 !== null && publisherValue3 !== undefined) {
                  var publisherInstance3 = publisherValue3;
                  virtualMachineExtensionJsonInstance.publisher = publisherInstance3;
                }
                
                var typeValue3 = propertiesValue3['type'];
                if (typeValue3 !== null && typeValue3 !== undefined) {
                  var typeInstance3 = typeValue3;
                  virtualMachineExtensionJsonInstance.extensionType = typeInstance3;
                }
                
                var typeHandlerVersionValue3 = propertiesValue3['typeHandlerVersion'];
                if (typeHandlerVersionValue3 !== null && typeHandlerVersionValue3 !== undefined) {
                  var typeHandlerVersionInstance3 = typeHandlerVersionValue3;
                  virtualMachineExtensionJsonInstance.typeHandlerVersion = typeHandlerVersionInstance3;
                }
                
                var autoUpgradeMinorVersionValue = propertiesValue3['autoUpgradeMinorVersion'];
                if (autoUpgradeMinorVersionValue !== null && autoUpgradeMinorVersionValue !== undefined) {
                  var autoUpgradeMinorVersionInstance = autoUpgradeMinorVersionValue;
                  virtualMachineExtensionJsonInstance.autoUpgradeMinorVersion = autoUpgradeMinorVersionInstance;
                }
                
                var settingsValue = propertiesValue3['settings'];
                if (settingsValue !== null && settingsValue !== undefined) {
                  var settingsInstance = settingsValue;
                  virtualMachineExtensionJsonInstance.settings = settingsInstance;
                }
                
                var protectedSettingsValue = propertiesValue3['protectedSettings'];
                if (protectedSettingsValue !== null && protectedSettingsValue !== undefined) {
                  var protectedSettingsInstance = protectedSettingsValue;
                  virtualMachineExtensionJsonInstance.protectedSettings = protectedSettingsInstance;
                }
                
                var provisioningStateValue2 = propertiesValue3['provisioningState'];
                if (provisioningStateValue2 !== null && provisioningStateValue2 !== undefined) {
                  var provisioningStateInstance2 = provisioningStateValue2;
                  virtualMachineExtensionJsonInstance.provisioningState = provisioningStateInstance2;
                }
                
                var instanceViewValue2 = propertiesValue3['instanceView'];
                if (instanceViewValue2 !== null && instanceViewValue2 !== undefined) {
                  var instanceViewInstance2 = { statuses: [], subStatuses: [] };
                  virtualMachineExtensionJsonInstance.instanceView = instanceViewInstance2;
                  
                  var nameValue6 = instanceViewValue2['name'];
                  if (nameValue6 !== null && nameValue6 !== undefined) {
                    var nameInstance6 = nameValue6;
                    instanceViewInstance2.name = nameInstance6;
                  }
                  
                  var typeValue4 = instanceViewValue2['type'];
                  if (typeValue4 !== null && typeValue4 !== undefined) {
                    var typeInstance4 = typeValue4;
                    instanceViewInstance2.extensionType = typeInstance4;
                  }
                  
                  var typeHandlerVersionValue4 = instanceViewValue2['typeHandlerVersion'];
                  if (typeHandlerVersionValue4 !== null && typeHandlerVersionValue4 !== undefined) {
                    var typeHandlerVersionInstance4 = typeHandlerVersionValue4;
                    instanceViewInstance2.typeHandlerVersion = typeHandlerVersionInstance4;
                  }
                  
                  var substatusesArray2 = instanceViewValue2['substatuses'];
                  if (substatusesArray2 !== null && substatusesArray2 !== undefined) {
                    for (var loweredIndex17 = 0; loweredIndex17 < substatusesArray2.length; loweredIndex17 = loweredIndex17 + 1) {
                      var substatusesValue2 = substatusesArray2[loweredIndex17];
                      var instanceViewStatusInstance6 = {};
                      instanceViewInstance2.subStatuses.push(instanceViewStatusInstance6);
                      
                      var codeValue7 = substatusesValue2['code'];
                      if (codeValue7 !== null && codeValue7 !== undefined) {
                        var codeInstance7 = codeValue7;
                        instanceViewStatusInstance6.code = codeInstance7;
                      }
                      
                      var levelValue7 = substatusesValue2['level'];
                      if (levelValue7 !== null && levelValue7 !== undefined) {
                        var levelInstance7 = levelValue7;
                        instanceViewStatusInstance6.level = levelInstance7;
                      }
                      
                      var displayStatusValue7 = substatusesValue2['displayStatus'];
                      if (displayStatusValue7 !== null && displayStatusValue7 !== undefined) {
                        var displayStatusInstance7 = displayStatusValue7;
                        instanceViewStatusInstance6.displayStatus = displayStatusInstance7;
                      }
                      
                      var messageValue7 = substatusesValue2['message'];
                      if (messageValue7 !== null && messageValue7 !== undefined) {
                        var messageInstance7 = messageValue7;
                        instanceViewStatusInstance6.message = messageInstance7;
                      }
                      
                      var timeValue7 = substatusesValue2['time'];
                      if (timeValue7 !== null && timeValue7 !== undefined) {
                        var timeInstance7 = timeValue7;
                        instanceViewStatusInstance6.time = timeInstance7;
                      }
                    }
                  }
                  
                  var statusesArray5 = instanceViewValue2['statuses'];
                  if (statusesArray5 !== null && statusesArray5 !== undefined) {
                    for (var loweredIndex18 = 0; loweredIndex18 < statusesArray5.length; loweredIndex18 = loweredIndex18 + 1) {
                      var statusesValue5 = statusesArray5[loweredIndex18];
                      var instanceViewStatusInstance7 = {};
                      instanceViewInstance2.statuses.push(instanceViewStatusInstance7);
                      
                      var codeValue8 = statusesValue5['code'];
                      if (codeValue8 !== null && codeValue8 !== undefined) {
                        var codeInstance8 = codeValue8;
                        instanceViewStatusInstance7.code = codeInstance8;
                      }
                      
                      var levelValue8 = statusesValue5['level'];
                      if (levelValue8 !== null && levelValue8 !== undefined) {
                        var levelInstance8 = levelValue8;
                        instanceViewStatusInstance7.level = levelInstance8;
                      }
                      
                      var displayStatusValue8 = statusesValue5['displayStatus'];
                      if (displayStatusValue8 !== null && displayStatusValue8 !== undefined) {
                        var displayStatusInstance8 = displayStatusValue8;
                        instanceViewStatusInstance7.displayStatus = displayStatusInstance8;
                      }
                      
                      var messageValue8 = statusesValue5['message'];
                      if (messageValue8 !== null && messageValue8 !== undefined) {
                        var messageInstance8 = messageValue8;
                        instanceViewStatusInstance7.message = messageInstance8;
                      }
                      
                      var timeValue8 = statusesValue5['time'];
                      if (timeValue8 !== null && timeValue8 !== undefined) {
                        var timeInstance8 = timeValue8;
                        instanceViewStatusInstance7.time = timeInstance8;
                      }
                    }
                  }
                }
              }
              
              var idValue6 = resourcesValue['id'];
              if (idValue6 !== null && idValue6 !== undefined) {
                var idInstance6 = idValue6;
                virtualMachineExtensionJsonInstance.id = idInstance6;
              }
              
              var nameValue7 = resourcesValue['name'];
              if (nameValue7 !== null && nameValue7 !== undefined) {
                var nameInstance7 = nameValue7;
                virtualMachineExtensionJsonInstance.name = nameInstance7;
              }
              
              var typeValue5 = resourcesValue['type'];
              if (typeValue5 !== null && typeValue5 !== undefined) {
                var typeInstance5 = typeValue5;
                virtualMachineExtensionJsonInstance.type = typeInstance5;
              }
              
              var locationValue = resourcesValue['location'];
              if (locationValue !== null && locationValue !== undefined) {
                var locationInstance = locationValue;
                virtualMachineExtensionJsonInstance.location = locationInstance;
              }
              
              var tagsSequenceElement = resourcesValue['tags'];
              if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
                for (var property in tagsSequenceElement) {
                  var tagsKey = property;
                  var tagsValue = tagsSequenceElement[property];
                  virtualMachineExtensionJsonInstance.tags[tagsKey] = tagsValue;
                }
              }
            }
          }
          
          var idValue7 = responseDoc['id'];
          if (idValue7 !== null && idValue7 !== undefined) {
            var idInstance7 = idValue7;
            virtualMachineInstance.id = idInstance7;
          }
          
          var nameValue8 = responseDoc['name'];
          if (nameValue8 !== null && nameValue8 !== undefined) {
            var nameInstance8 = nameValue8;
            virtualMachineInstance.name = nameInstance8;
          }
          
          var typeValue6 = responseDoc['type'];
          if (typeValue6 !== null && typeValue6 !== undefined) {
            var typeInstance6 = typeValue6;
            virtualMachineInstance.type = typeInstance6;
          }
          
          var locationValue2 = responseDoc['location'];
          if (locationValue2 !== null && locationValue2 !== undefined) {
            var locationInstance2 = locationValue2;
            virtualMachineInstance.location = locationInstance2;
          }
          
          var tagsSequenceElement2 = responseDoc['tags'];
          if (tagsSequenceElement2 !== null && tagsSequenceElement2 !== undefined) {
            for (var property2 in tagsSequenceElement2) {
              var tagsKey2 = property2;
              var tagsValue2 = tagsSequenceElement2[property2];
              virtualMachineInstance.tags[tagsKey2] = tagsValue2;
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The operation to get a virtual machine along with its instance view.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} vmName The name of the virtual machine.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.getWithInstanceView = function(resourceGroupName, vmName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (vmName === null || vmName === undefined) {
      return callback(new Error('vmName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/';
    url2 = url2 + 'virtualMachines';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(vmName);
    var queryParameters = [];
    queryParameters.push('$expand=instanceView');
    queryParameters.push('api-version=2015-06-15');
    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
    
    // 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 responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var virtualMachineInstance = { extensions: [], tags: {} };
          result.virtualMachine = virtualMachineInstance;
          
          var planValue = responseDoc['plan'];
          if (planValue !== null && planValue !== undefined) {
            var planInstance = {};
            virtualMachineInstance.plan = planInstance;
            
            var nameValue = planValue['name'];
            if (nameValue !== null && nameValue !== undefined) {
              var nameInstance = nameValue;
              planInstance.name = nameInstance;
            }
            
            var publisherValue = planValue['publisher'];
            if (publisherValue !== null && publisherValue !== undefined) {
              var publisherInstance = publisherValue;
              planInstance.publisher = publisherInstance;
            }
            
            var productValue = planValue['product'];
            if (productValue !== null && productValue !== undefined) {
              var productInstance = productValue;
              planInstance.product = productInstance;
            }
            
            var promotionCodeValue = planValue['promotionCode'];
            if (promotionCodeValue !== null && promotionCodeValue !== undefined) {
              var promotionCodeInstance = promotionCodeValue;
              planInstance.promotionCode = promotionCodeInstance;
            }
          }
          
          var propertiesValue = responseDoc['properties'];
          if (propertiesValue !== null && propertiesValue !== undefined) {
            var hardwareProfileValue = propertiesValue['hardwareProfile'];
            if (hardwareProfileValue !== null && hardwareProfileValue !== undefined) {
              var hardwareProfileInstance = {};
              virtualMachineInstance.hardwareProfile = hardwareProfileInstance;
              
              var vmSizeValue = hardwareProfileValue['vmSize'];
              if (vmSizeValue !== null && vmSizeValue !== undefined) {
                var vmSizeInstance = vmSizeValue;
                hardwareProfileInstance.virtualMachineSize = vmSizeInstance;
              }
            }
            
            var storageProfileValue = propertiesValue['storageProfile'];
            if (storageProfileValue !== null && storageProfileValue !== undefined) {
              var storageProfileInstance = { dataDisks: [] };
              virtualMachineInstance.storageProfile = storageProfileInstance;
              
              var imageReferenceValue = storageProfileValue['imageReference'];
              if (imageReferenceValue !== null && imageReferenceValue !== undefined) {
                var imageReferenceInstance = {};
                storageProfileInstance.imageReference = imageReferenceInstance;
                
                var publisherValue2 = imageReferenceValue['publisher'];
                if (publisherValue2 !== null && publisherValue2 !== undefined) {
                  var publisherInstance2 = publisherValue2;
                  imageReferenceInstance.publisher = publisherInstance2;
                }
                
                var offerValue = imageReferenceValue['offer'];
                if (offerValue !== null && offerValue !== undefined) {
                  var offerInstance = offerValue;
                  imageReferenceInstance.offer = offerInstance;
                }
                
                var skuValue = imageReferenceValue['sku'];
                if (skuValue !== null && skuValue !== undefined) {
                  var skuInstance = skuValue;
                  imageReferenceInstance.sku = skuInstance;
                }
                
                var versionValue = imageReferenceValue['version'];
                if (versionValue !== null && versionValue !== undefined) {
                  var versionInstance = versionValue;
                  imageReferenceInstance.version = versionInstance;
                }
              }
              
              var osDiskValue = storageProfileValue['osDisk'];
              if (osDiskValue !== null && osDiskValue !== undefined) {
                var osDiskInstance = {};
                storageProfileInstance.oSDisk = osDiskInstance;
                
                var osTypeValue = osDiskValue['osType'];
                if (osTypeValue !== null && osTypeValue !== undefined) {
                  var osTypeInstance = osTypeValue;
                  osDiskInstance.operatingSystemType = osTypeInstance;
                }
                
                var encryptionSettingsValue = osDiskValue['encryptionSettings'];
                if (encryptionSettingsValue !== null && encryptionSettingsValue !== undefined) {
                  var encryptionSettingsInstance = {};
                  osDiskInstance.encryptionSettings = encryptionSettingsInstance;
                  
                  var diskEncryptionKeyValue = encryptionSettingsValue['diskEncryptionKey'];
                  if (diskEncryptionKeyValue !== null && diskEncryptionKeyValue !== undefined) {
                    var diskEncryptionKeyInstance = {};
                    encryptionSettingsInstance.diskEncryptionKey = diskEncryptionKeyInstance;
                    
                    var secretUrlValue = diskEncryptionKeyValue['secretUrl'];
                    if (secretUrlValue !== null && secretUrlValue !== undefined) {
                      var secretUrlInstance = secretUrlValue;
                      diskEncryptionKeyInstance.secretUrl = secretUrlInstance;
                    }
                    
                    var sourceVaultValue = diskEncryptionKeyValue['sourceVault'];
                    if (sourceVaultValue !== null && sourceVaultValue !== undefined) {
                      var sourceVaultInstance = {};
                      diskEncryptionKeyInstance.sourceVault = sourceVaultInstance;
                      
                      var idValue = sourceVaultValue['id'];
                      if (idValue !== null && idValue !== undefined) {
                        var idInstance = idValue;
                        sourceVaultInstance.referenceUri = idInstance;
                      }
                    }
                  }
                  
                  var keyEncryptionKeyValue = encryptionSettingsValue['keyEncryptionKey'];
                  if (keyEncryptionKeyValue !== null && keyEncryptionKeyValue !== undefined) {
                    var keyEncryptionKeyInstance = {};
                    encryptionSettingsInstance.keyEncryptionKey = keyEncryptionKeyInstance;
                    
                    var keyUrlValue = keyEncryptionKeyValue['keyUrl'];
                    if (keyUrlValue !== null && keyUrlValue !== undefined) {
                      var keyUrlInstance = keyUrlValue;
                      keyEncryptionKeyInstance.keyUrl = keyUrlInstance;
                    }
                    
                    var sourceVaultValue2 = keyEncryptionKeyValue['sourceVault'];
                    if (sourceVaultValue2 !== null && sourceVaultValue2 !== undefined) {
                      var sourceVaultInstance2 = {};
                      keyEncryptionKeyInstance.sourceVault = sourceVaultInstance2;
                      
                      var idValue2 = sourceVaultValue2['id'];
                      if (idValue2 !== null && idValue2 !== undefined) {
                        var idInstance2 = idValue2;
                        sourceVaultInstance2.referenceUri = idInstance2;
                      }
                    }
                  }
                }
                
                var nameValue2 = osDiskValue['name'];
                if (nameValue2 !== null && nameValue2 !== undefined) {
                  var nameInstance2 = nameValue2;
                  osDiskInstance.name = nameInstance2;
                }
                
                var vhdValue = osDiskValue['vhd'];
                if (vhdValue !== null && vhdValue !== undefined) {
                  var vhdInstance = {};
                  osDiskInstance.virtualHardDisk = vhdInstance;
                  
                  var uriValue = vhdValue['uri'];
                  if (uriValue !== null && uriValue !== undefined) {
                    var uriInstance = uriValue;
                    vhdInstance.uri = uriInstance;
                  }
                }
                
                var imageValue = osDiskValue['image'];
                if (imageValue !== null && imageValue !== undefined) {
                  var imageInstance = {};
                  osDiskInstance.sourceImage = imageInstance;
                  
                  var uriValue2 = imageValue['uri'];
                  if (uriValue2 !== null && uriValue2 !== undefined) {
                    var uriInstance2 = uriValue2;
                    imageInstance.uri = uriInstance2;
                  }
                }
                
                var cachingValue = osDiskValue['caching'];
                if (cachingValue !== null && cachingValue !== undefined) {
                  var cachingInstance = cachingValue;
                  osDiskInstance.caching = cachingInstance;
                }
                
                var createOptionValue = osDiskValue['createOption'];
                if (createOptionValue !== null && createOptionValue !== undefined) {
                  var createOptionInstance = createOptionValue;
                  osDiskInstance.createOption = createOptionInstance;
                }
                
                var diskSizeGBValue = osDiskValue['diskSizeGB'];
                if (diskSizeGBValue !== null && diskSizeGBValue !== undefined) {
                  var diskSizeGBInstance = diskSizeGBValue;
                  osDiskInstance.diskSizeGB = diskSizeGBInstance;
                }
              }
              
              var dataDisksArray = storageProfileValue['dataDisks'];
              if (dataDisksArray !== null && dataDisksArray !== undefined) {
                for (var loweredIndex1 = 0; loweredIndex1 < dataDisksArray.length; loweredIndex1 = loweredIndex1 + 1) {
                  var dataDisksValue = dataDisksArray[loweredIndex1];
                  var dataDiskInstance = {};
                  storageProfileInstance.dataDisks.push(dataDiskInstance);
                  
                  var lunValue = dataDisksValue['lun'];
                  if (lunValue !== null && lunValue !== undefined) {
                    var lunInstance = lunValue;
                    dataDiskInstance.lun = lunInstance;
                  }
                  
                  var nameValue3 = dataDisksValue['name'];
                  if (nameValue3 !== null && nameValue3 !== undefined) {
                    var nameInstance3 = nameValue3;
                    dataDiskInstance.name = nameInstance3;
                  }
                  
                  var vhdValue2 = dataDisksValue['vhd'];
                  if (vhdValue2 !== null && vhdValue2 !== undefined) {
                    var vhdInstance2 = {};
                    dataDiskInstance.virtualHardDisk = vhdInstance2;
                    
                    var uriValue3 = vhdValue2['uri'];
                    if (uriValue3 !== null && uriValue3 !== undefined) {
                      var uriInstance3 = uriValue3;
                      vhdInstance2.uri = uriInstance3;
                    }
                  }
                  
                  var imageValue2 = dataDisksValue['image'];
                  if (imageValue2 !== null && imageValue2 !== undefined) {
                    var imageInstance2 = {};
                    dataDiskInstance.sourceImage = imageInstance2;
                    
                    var uriValue4 = imageValue2['uri'];
                    if (uriValue4 !== null && uriValue4 !== undefined) {
                      var uriInstance4 = uriValue4;
                      imageInstance2.uri = uriInstance4;
                    }
                  }
                  
                  var cachingValue2 = dataDisksValue['caching'];
                  if (cachingValue2 !== null && cachingValue2 !== undefined) {
                    var cachingInstance2 = cachingValue2;
                    dataDiskInstance.caching = cachingInstance2;
                  }
                  
                  var createOptionValue2 = dataDisksValue['createOption'];
                  if (createOptionValue2 !== null && createOptionValue2 !== undefined) {
                    var createOptionInstance2 = createOptionValue2;
                    dataDiskInstance.createOption = createOptionInstance2;
                  }
                  
                  var diskSizeGBValue2 = dataDisksValue['diskSizeGB'];
                  if (diskSizeGBValue2 !== null && diskSizeGBValue2 !== undefined) {
                    var diskSizeGBInstance2 = diskSizeGBValue2;
                    dataDiskInstance.diskSizeGB = diskSizeGBInstance2;
                  }
                }
              }
            }
            
            var osProfileValue = propertiesValue['osProfile'];
            if (osProfileValue !== null && osProfileValue !== undefined) {
              var osProfileInstance = { secrets: [] };
              virtualMachineInstance.oSProfile = osProfileInstance;
              
              var computerNameValue = osProfileValue['computerName'];
              if (computerNameValue !== null && computerNameValue !== undefined) {
                var computerNameInstance = computerNameValue;
                osProfileInstance.computerName = computerNameInstance;
              }
              
              var adminUsernameValue = osProfileValue['adminUsername'];
              if (adminUsernameValue !== null && adminUsernameValue !== undefined) {
                var adminUsernameInstance = adminUsernameValue;
                osProfileInstance.adminUsername = adminUsernameInstance;
              }
              
              var adminPasswordValue = osProfileValue['adminPassword'];
              if (adminPasswordValue !== null && adminPasswordValue !== undefined) {
                var adminPasswordInstance = adminPasswordValue;
                osProfileInstance.adminPassword = adminPasswordInstance;
              }
              
              var customDataValue = osProfileValue['customData'];
              if (customDataValue !== null && customDataValue !== undefined) {
                var customDataInstance = customDataValue;
                osProfileInstance.customData = customDataInstance;
              }
              
              var windowsConfigurationValue = osProfileValue['windowsConfiguration'];
              if (windowsConfigurationValue !== null && windowsConfigurationValue !== undefined) {
                var windowsConfigurationInstance = { additionalUnattendContents: [] };
                osProfileInstance.windowsConfiguration = windowsConfigurationInstance;
                
                var provisionVMAgentValue = windowsConfigurationValue['provisionVMAgent'];
                if (provisionVMAgentValue !== null && provisionVMAgentValue !== undefined) {
                  var provisionVMAgentInstance = provisionVMAgentValue;
                  windowsConfigurationInstance.provisionVMAgent = provisionVMAgentInstance;
                }
                
                var enableAutomaticUpdatesValue = windowsConfigurationValue['enableAutomaticUpdates'];
                if (enableAutomaticUpdatesValue !== null && enableAutomaticUpdatesValue !== undefined) {
                  var enableAutomaticUpdatesInstance = enableAutomaticUpdatesValue;
                  windowsConfigurationInstance.enableAutomaticUpdates = enableAutomaticUpdatesInstance;
                }
                
                var timeZoneValue = windowsConfigurationValue['timeZone'];
                if (timeZoneValue !== null && timeZoneValue !== undefined) {
                  var timeZoneInstance = timeZoneValue;
                  windowsConfigurationInstance.timeZone = timeZoneInstance;
                }
                
                var additionalUnattendContentArray = windowsConfigurationValue['additionalUnattendContent'];
                if (additionalUnattendContentArray !== null && additionalUnattendContentArray !== undefined) {
                  for (var loweredIndex2 = 0; loweredIndex2 < additionalUnattendContentArray.length; loweredIndex2 = loweredIndex2 + 1) {
                    var additionalUnattendContentValue = additionalUnattendContentArray[loweredIndex2];
                    var additionalUnattendContentInstance = {};
                    windowsConfigurationInstance.additionalUnattendContents.push(additionalUnattendContentInstance);
                    
                    var passNameValue = additionalUnattendContentValue['passName'];
                    if (passNameValue !== null && passNameValue !== undefined) {
                      var passNameInstance = passNameValue;
                      additionalUnattendContentInstance.passName = passNameInstance;
                    }
                    
                    var componentNameValue = additionalUnattendContentValue['componentName'];
                    if (componentNameValue !== null && componentNameValue !== undefined) {
                      var componentNameInstance = componentNameValue;
                      additionalUnattendContentInstance.componentName = componentNameInstance;
                    }
                    
                    var settingNameValue = additionalUnattendContentValue['settingName'];
                    if (settingNameValue !== null && settingNameValue !== undefined) {
                      var settingNameInstance = settingNameValue;
                      additionalUnattendContentInstance.settingName = settingNameInstance;
                    }
                    
                    var contentValue = additionalUnattendContentValue['content'];
                    if (contentValue !== null && contentValue !== undefined) {
                      var contentInstance = contentValue;
                      additionalUnattendContentInstance.content = contentInstance;
                    }
                  }
                }
                
                var winRMValue = windowsConfigurationValue['winRM'];
                if (winRMValue !== null && winRMValue !== undefined) {
                  var winRMInstance = { listeners: [] };
                  windowsConfigurationInstance.winRMConfiguration = winRMInstance;
                  
                  var listenersArray = winRMValue['listeners'];
                  if (listenersArray !== null && listenersArray !== undefined) {
                    for (var loweredIndex3 = 0; loweredIndex3 < listenersArray.length; loweredIndex3 = loweredIndex3 + 1) {
                      var listenersValue = listenersArray[loweredIndex3];
                      var winRMListenerInstance = {};
                      winRMInstance.listeners.push(winRMListenerInstance);
                      
                      var protocolValue = listenersValue['protocol'];
                      if (protocolValue !== null && protocolValue !== undefined) {
                        var protocolInstance = protocolValue;
                        winRMListenerInstance.protocol = protocolInstance;
                      }
                      
                      var certificateUrlValue = listenersValue['certificateUrl'];
                      if (certificateUrlValue !== null && certificateUrlValue !== undefined) {
                        var certificateUrlInstance = certificateUrlValue;
                        winRMListenerInstance.certificateUrl = certificateUrlInstance;
                      }
                    }
                  }
                }
              }
              
              var linuxConfigurationValue = osProfileValue['linuxConfiguration'];
              if (linuxConfigurationValue !== null && linuxConfigurationValue !== undefined) {
                var linuxConfigurationInstance = {};
                osProfileInstance.linuxConfiguration = linuxConfigurationInstance;
                
                var disablePasswordAuthenticationValue = linuxConfigurationValue['disablePasswordAuthentication'];
                if (disablePasswordAuthenticationValue !== null && disablePasswordAuthenticationValue !== undefined) {
                  var disablePasswordAuthenticationInstance = disablePasswordAuthenticationValue;
                  linuxConfigurationInstance.disablePasswordAuthentication = disablePasswordAuthenticationInstance;
                }
                
                var sshValue = linuxConfigurationValue['ssh'];
                if (sshValue !== null && sshValue !== undefined) {
                  var sshInstance = { publicKeys: [] };
                  linuxConfigurationInstance.sshConfiguration = sshInstance;
                  
                  var publicKeysArray = sshValue['publicKeys'];
                  if (publicKeysArray !== null && publicKeysArray !== undefined) {
                    for (var loweredIndex4 = 0; loweredIndex4 < publicKeysArray.length; loweredIndex4 = loweredIndex4 + 1) {
                      var publicKeysValue = publicKeysArray[loweredIndex4];
                      var sshPublicKeyInstance = {};
                      sshInstance.publicKeys.push(sshPublicKeyInstance);
                      
                      var pathValue = publicKeysValue['path'];
                      if (pathValue !== null && pathValue !== undefined) {
                        var pathInstance = pathValue;
                        sshPublicKeyInstance.path = pathInstance;
                      }
                      
                      var keyDataValue = publicKeysValue['keyData'];
                      if (keyDataValue !== null && keyDataValue !== undefined) {
                        var keyDataInstance = keyDataValue;
                        sshPublicKeyInstance.keyData = keyDataInstance;
                      }
                    }
                  }
                }
              }
              
              var secretsArray = osProfileValue['secrets'];
              if (secretsArray !== null && secretsArray !== undefined) {
                for (var loweredIndex5 = 0; loweredIndex5 < secretsArray.length; loweredIndex5 = loweredIndex5 + 1) {
                  var secretsValue = secretsArray[loweredIndex5];
                  var vaultSecretGroupInstance = { vaultCertificates: [] };
                  osProfileInstance.secrets.push(vaultSecretGroupInstance);
                  
                  var sourceVaultValue3 = secretsValue['sourceVault'];
                  if (sourceVaultValue3 !== null && sourceVaultValue3 !== undefined) {
                    var sourceVaultInstance3 = {};
                    vaultSecretGroupInstance.sourceVault = sourceVaultInstance3;
                    
                    var idValue3 = sourceVaultValue3['id'];
                    if (idValue3 !== null && idValue3 !== undefined) {
                      var idInstance3 = idValue3;
                      sourceVaultInstance3.referenceUri = idInstance3;
                    }
                  }
                  
                  var vaultCertificatesArray = secretsValue['vaultCertificates'];
                  if (vaultCertificatesArray !== null && vaultCertificatesArray !== undefined) {
                    for (var loweredIndex6 = 0; loweredIndex6 < vaultCertificatesArray.length; loweredIndex6 = loweredIndex6 + 1) {
                      var vaultCertificatesValue = vaultCertificatesArray[loweredIndex6];
                      var vaultCertificateInstance = {};
                      vaultSecretGroupInstance.vaultCertificates.push(vaultCertificateInstance);
                      
                      var certificateUrlValue2 = vaultCertificatesValue['certificateUrl'];
                      if (certificateUrlValue2 !== null && certificateUrlValue2 !== undefined) {
                        var certificateUrlInstance2 = certificateUrlValue2;
                        vaultCertificateInstance.certificateUrl = certificateUrlInstance2;
                      }
                      
                      var certificateStoreValue = vaultCertificatesValue['certificateStore'];
                      if (certificateStoreValue !== null && certificateStoreValue !== undefined) {
                        var certificateStoreInstance = certificateStoreValue;
                        vaultCertificateInstance.certificateStore = certificateStoreInstance;
                      }
                    }
                  }
                }
              }
            }
            
            var networkProfileValue = propertiesValue['networkProfile'];
            if (networkProfileValue !== null && networkProfileValue !== undefined) {
              var networkProfileInstance = { networkInterfaces: [] };
              virtualMachineInstance.networkProfile = networkProfileInstance;
              
              var networkInterfacesArray = networkProfileValue['networkInterfaces'];
              if (networkInterfacesArray !== null && networkInterfacesArray !== undefined) {
                for (var loweredIndex7 = 0; loweredIndex7 < networkInterfacesArray.length; loweredIndex7 = loweredIndex7 + 1) {
                  var networkInterfacesValue = networkInterfacesArray[loweredIndex7];
                  var networkInterfaceReferenceJsonInstance = {};
                  networkProfileInstance.networkInterfaces.push(networkInterfaceReferenceJsonInstance);
                  
                  var propertiesValue2 = networkInterfacesValue['properties'];
                  if (propertiesValue2 !== null && propertiesValue2 !== undefined) {
                    var primaryValue = propertiesValue2['primary'];
                    if (primaryValue !== null && primaryValue !== undefined) {
                      var primaryInstance = primaryValue;
                      networkInterfaceReferenceJsonInstance.primary = primaryInstance;
                    }
                  }
                  
                  var idValue4 = networkInterfacesValue['id'];
                  if (idValue4 !== null && idValue4 !== undefined) {
                    var idInstance4 = idValue4;
                    networkInterfaceReferenceJsonInstance.referenceUri = idInstance4;
                  }
                }
              }
            }
            
            var diagnosticsProfileValue = propertiesValue['diagnosticsProfile'];
            if (diagnosticsProfileValue !== null && diagnosticsProfileValue !== undefined) {
              var diagnosticsProfileInstance = {};
              virtualMachineInstance.diagnosticsProfile = diagnosticsProfileInstance;
              
              var bootDiagnosticsValue = diagnosticsProfileValue['bootDiagnostics'];
              if (bootDiagnosticsValue !== null && bootDiagnosticsValue !== undefined) {
                var bootDiagnosticsInstance = {};
                diagnosticsProfileInstance.bootDiagnostics = bootDiagnosticsInstance;
                
                var enabledValue = bootDiagnosticsValue['enabled'];
                if (enabledValue !== null && enabledValue !== undefined) {
                  var enabledInstance = enabledValue;
                  bootDiagnosticsInstance.enabled = enabledInstance;
                }
                
                var storageUriValue = bootDiagnosticsValue['storageUri'];
                if (storageUriValue !== null && storageUriValue !== undefined) {
                  var storageUriInstance = storageUriValue;
                  bootDiagnosticsInstance.storageUri = storageUriInstance;
                }
              }
            }
            
            var availabilitySetValue = propertiesValue['availabilitySet'];
            if (availabilitySetValue !== null && availabilitySetValue !== undefined) {
              var availabilitySetInstance = {};
              virtualMachineInstance.availabilitySetReference = availabilitySetInstance;
              
              var idValue5 = availabilitySetValue['id'];
              if (idValue5 !== null && idValue5 !== undefined) {
                var idInstance5 = idValue5;
                availabilitySetInstance.referenceUri = idInstance5;
              }
            }
            
            var provisioningStateValue = propertiesValue['provisioningState'];
            if (provisioningStateValue !== null && provisioningStateValue !== undefined) {
              var provisioningStateInstance = provisioningStateValue;
              virtualMachineInstance.provisioningState = provisioningStateInstance;
            }
            
            var instanceViewValue = propertiesValue['instanceView'];
            if (instanceViewValue !== null && instanceViewValue !== undefined) {
              var instanceViewInstance = { disks: [], extensions: [], statuses: [] };
              virtualMachineInstance.instanceView = instanceViewInstance;
              
              var platformUpdateDomainValue = instanceViewValue['platformUpdateDomain'];
              if (platformUpdateDomainValue !== null && platformUpdateDomainValue !== undefined) {
                var platformUpdateDomainInstance = platformUpdateDomainValue;
                instanceViewInstance.platformUpdateDomain = platformUpdateDomainInstance;
              }
              
              var platformFaultDomainValue = instanceViewValue['platformFaultDomain'];
              if (platformFaultDomainValue !== null && platformFaultDomainValue !== undefined) {
                var platformFaultDomainInstance = platformFaultDomainValue;
                instanceViewInstance.platformFaultDomain = platformFaultDomainInstance;
              }
              
              var rdpThumbPrintValue = instanceViewValue['rdpThumbPrint'];
              if (rdpThumbPrintValue !== null && rdpThumbPrintValue !== undefined) {
                var rdpThumbPrintInstance = rdpThumbPrintValue;
                instanceViewInstance.remoteDesktopThumbprint = rdpThumbPrintInstance;
              }
              
              var vmAgentValue = instanceViewValue['vmAgent'];
              if (vmAgentValue !== null && vmAgentValue !== undefined) {
                var vmAgentInstance = { extensionHandlers: [], statuses: [] };
                instanceViewInstance.vMAgent = vmAgentInstance;
                
                var vmAgentVersionValue = vmAgentValue['vmAgentVersion'];
                if (vmAgentVersionValue !== null && vmAgentVersionValue !== undefined) {
                  var vmAgentVersionInstance = vmAgentVersionValue;
                  vmAgentInstance.vMAgentVersion = vmAgentVersionInstance;
                }
                
                var extensionHandlersArray = vmAgentValue['extensionHandlers'];
                if (extensionHandlersArray !== null && extensionHandlersArray !== undefined) {
                  for (var loweredIndex8 = 0; loweredIndex8 < extensionHandlersArray.length; loweredIndex8 = loweredIndex8 + 1) {
                    var extensionHandlersValue = extensionHandlersArray[loweredIndex8];
                    var virtualMachineExtensionHandlerInstanceViewInstance = {};
                    vmAgentInstance.extensionHandlers.push(virtualMachineExtensionHandlerInstanceViewInstance);
                    
                    var typeValue = extensionHandlersValue['type'];
                    if (typeValue !== null && typeValue !== undefined) {
                      var typeInstance = typeValue;
                      virtualMachineExtensionHandlerInstanceViewInstance.type = typeInstance;
                    }
                    
                    var typeHandlerVersionValue = extensionHandlersValue['typeHandlerVersion'];
                    if (typeHandlerVersionValue !== null && typeHandlerVersionValue !== undefined) {
                      var typeHandlerVersionInstance = typeHandlerVersionValue;
                      virtualMachineExtensionHandlerInstanceViewInstance.typeHandlerVersion = typeHandlerVersionInstance;
                    }
                    
                    var statusValue = extensionHandlersValue['status'];
                    if (statusValue !== null && statusValue !== undefined) {
                      var statusInstance = {};
                      virtualMachineExtensionHandlerInstanceViewInstance.status = statusInstance;
                      
                      var codeValue = statusValue['code'];
                      if (codeValue !== null && codeValue !== undefined) {
                        var codeInstance = codeValue;
                        statusInstance.code = codeInstance;
                      }
                      
                      var levelValue = statusValue['level'];
                      if (levelValue !== null && levelValue !== undefined) {
                        var levelInstance = levelValue;
                        statusInstance.level = levelInstance;
                      }
                      
                      var displayStatusValue = statusValue['displayStatus'];
                      if (displayStatusValue !== null && displayStatusValue !== undefined) {
                        var displayStatusInstance = displayStatusValue;
                        statusInstance.displayStatus = displayStatusInstance;
                      }
                      
                      var messageValue = statusValue['message'];
                      if (messageValue !== null && messageValue !== undefined) {
                        var messageInstance = messageValue;
                        statusInstance.message = messageInstance;
                      }
                      
                      var timeValue = statusValue['time'];
                      if (timeValue !== null && timeValue !== undefined) {
                        var timeInstance = timeValue;
                        statusInstance.time = timeInstance;
                      }
                    }
                  }
                }
                
                var statusesArray = vmAgentValue['statuses'];
                if (statusesArray !== null && statusesArray !== undefined) {
                  for (var loweredIndex9 = 0; loweredIndex9 < statusesArray.length; loweredIndex9 = loweredIndex9 + 1) {
                    var statusesValue = statusesArray[loweredIndex9];
                    var instanceViewStatusInstance = {};
                    vmAgentInstance.statuses.push(instanceViewStatusInstance);
                    
                    var codeValue2 = statusesValue['code'];
                    if (codeValue2 !== null && codeValue2 !== undefined) {
                      var codeInstance2 = codeValue2;
                      instanceViewStatusInstance.code = codeInstance2;
                    }
                    
                    var levelValue2 = statusesValue['level'];
                    if (levelValue2 !== null && levelValue2 !== undefined) {
                      var levelInstance2 = levelValue2;
                      instanceViewStatusInstance.level = levelInstance2;
                    }
                    
                    var displayStatusValue2 = statusesValue['displayStatus'];
                    if (displayStatusValue2 !== null && displayStatusValue2 !== undefined) {
                      var displayStatusInstance2 = displayStatusValue2;
                      instanceViewStatusInstance.displayStatus = displayStatusInstance2;
                    }
                    
                    var messageValue2 = statusesValue['message'];
                    if (messageValue2 !== null && messageValue2 !== undefined) {
                      var messageInstance2 = messageValue2;
                      instanceViewStatusInstance.message = messageInstance2;
                    }
                    
                    var timeValue2 = statusesValue['time'];
                    if (timeValue2 !== null && timeValue2 !== undefined) {
                      var timeInstance2 = timeValue2;
                      instanceViewStatusInstance.time = timeInstance2;
                    }
                  }
                }
              }
              
              var disksArray = instanceViewValue['disks'];
              if (disksArray !== null && disksArray !== undefined) {
                for (var loweredIndex10 = 0; loweredIndex10 < disksArray.length; loweredIndex10 = loweredIndex10 + 1) {
                  var disksValue = disksArray[loweredIndex10];
                  var diskInstanceViewInstance = { statuses: [] };
                  instanceViewInstance.disks.push(diskInstanceViewInstance);
                  
                  var nameValue4 = disksValue['name'];
                  if (nameValue4 !== null && nameValue4 !== undefined) {
                    var nameInstance4 = nameValue4;
                    diskInstanceViewInstance.name = nameInstance4;
                  }
                  
                  var statusesArray2 = disksValue['statuses'];
                  if (statusesArray2 !== null && statusesArray2 !== undefined) {
                    for (var loweredIndex11 = 0; loweredIndex11 < statusesArray2.length; loweredIndex11 = loweredIndex11 + 1) {
                      var statusesValue2 = statusesArray2[loweredIndex11];
                      var instanceViewStatusInstance2 = {};
                      diskInstanceViewInstance.statuses.push(instanceViewStatusInstance2);
                      
                      var codeValue3 = statusesValue2['code'];
                      if (codeValue3 !== null && codeValue3 !== undefined) {
                        var codeInstance3 = codeValue3;
                        instanceViewStatusInstance2.code = codeInstance3;
                      }
                      
                      var levelValue3 = statusesValue2['level'];
                      if (levelValue3 !== null && levelValue3 !== undefined) {
                        var levelInstance3 = levelValue3;
                        instanceViewStatusInstance2.level = levelInstance3;
                      }
                      
                      var displayStatusValue3 = statusesValue2['displayStatus'];
                      if (displayStatusValue3 !== null && displayStatusValue3 !== undefined) {
                        var displayStatusInstance3 = displayStatusValue3;
                        instanceViewStatusInstance2.displayStatus = displayStatusInstance3;
                      }
                      
                      var messageValue3 = statusesValue2['message'];
                      if (messageValue3 !== null && messageValue3 !== undefined) {
                        var messageInstance3 = messageValue3;
                        instanceViewStatusInstance2.message = messageInstance3;
                      }
                      
                      var timeValue3 = statusesValue2['time'];
                      if (timeValue3 !== null && timeValue3 !== undefined) {
                        var timeInstance3 = timeValue3;
                        instanceViewStatusInstance2.time = timeInstance3;
                      }
                    }
                  }
                }
              }
              
              var extensionsArray = instanceViewValue['extensions'];
              if (extensionsArray !== null && extensionsArray !== undefined) {
                for (var loweredIndex12 = 0; loweredIndex12 < extensionsArray.length; loweredIndex12 = loweredIndex12 + 1) {
                  var extensionsValue = extensionsArray[loweredIndex12];
                  var virtualMachineExtensionInstanceViewInstance = { statuses: [], subStatuses: [] };
                  instanceViewInstance.extensions.push(virtualMachineExtensionInstanceViewInstance);
                  
                  var nameValue5 = extensionsValue['name'];
                  if (nameValue5 !== null && nameValue5 !== undefined) {
                    var nameInstance5 = nameValue5;
                    virtualMachineExtensionInstanceViewInstance.name = nameInstance5;
                  }
                  
                  var typeValue2 = extensionsValue['type'];
                  if (typeValue2 !== null && typeValue2 !== undefined) {
                    var typeInstance2 = typeValue2;
                    virtualMachineExtensionInstanceViewInstance.extensionType = typeInstance2;
                  }
                  
                  var typeHandlerVersionValue2 = extensionsValue['typeHandlerVersion'];
                  if (typeHandlerVersionValue2 !== null && typeHandlerVersionValue2 !== undefined) {
                    var typeHandlerVersionInstance2 = typeHandlerVersionValue2;
                    virtualMachineExtensionInstanceViewInstance.typeHandlerVersion = typeHandlerVersionInstance2;
                  }
                  
                  var substatusesArray = extensionsValue['substatuses'];
                  if (substatusesArray !== null && substatusesArray !== undefined) {
                    for (var loweredIndex13 = 0; loweredIndex13 < substatusesArray.length; loweredIndex13 = loweredIndex13 + 1) {
                      var substatusesValue = substatusesArray[loweredIndex13];
                      var instanceViewStatusInstance3 = {};
                      virtualMachineExtensionInstanceViewInstance.subStatuses.push(instanceViewStatusInstance3);
                      
                      var codeValue4 = substatusesValue['code'];
                      if (codeValue4 !== null && codeValue4 !== undefined) {
                        var codeInstance4 = codeValue4;
                        instanceViewStatusInstance3.code = codeInstance4;
                      }
                      
                      var levelValue4 = substatusesValue['level'];
                      if (levelValue4 !== null && levelValue4 !== undefined) {
                        var levelInstance4 = levelValue4;
                        instanceViewStatusInstance3.level = levelInstance4;
                      }
                      
                      var displayStatusValue4 = substatusesValue['displayStatus'];
                      if (displayStatusValue4 !== null && displayStatusValue4 !== undefined) {
                        var displayStatusInstance4 = displayStatusValue4;
                        instanceViewStatusInstance3.displayStatus = displayStatusInstance4;
                      }
                      
                      var messageValue4 = substatusesValue['message'];
                      if (messageValue4 !== null && messageValue4 !== undefined) {
                        var messageInstance4 = messageValue4;
                        instanceViewStatusInstance3.message = messageInstance4;
                      }
                      
                      var timeValue4 = substatusesValue['time'];
                      if (timeValue4 !== null && timeValue4 !== undefined) {
                        var timeInstance4 = timeValue4;
                        instanceViewStatusInstance3.time = timeInstance4;
                      }
                    }
                  }
                  
                  var statusesArray3 = extensionsValue['statuses'];
                  if (statusesArray3 !== null && statusesArray3 !== undefined) {
                    for (var loweredIndex14 = 0; loweredIndex14 < statusesArray3.length; loweredIndex14 = loweredIndex14 + 1) {
                      var statusesValue3 = statusesArray3[loweredIndex14];
                      var instanceViewStatusInstance4 = {};
                      virtualMachineExtensionInstanceViewInstance.statuses.push(instanceViewStatusInstance4);
                      
                      var codeValue5 = statusesValue3['code'];
                      if (codeValue5 !== null && codeValue5 !== undefined) {
                        var codeInstance5 = codeValue5;
                        instanceViewStatusInstance4.code = codeInstance5;
                      }
                      
                      var levelValue5 = statusesValue3['level'];
                      if (levelValue5 !== null && levelValue5 !== undefined) {
                        var levelInstance5 = levelValue5;
                        instanceViewStatusInstance4.level = levelInstance5;
                      }
                      
                      var displayStatusValue5 = statusesValue3['displayStatus'];
                      if (displayStatusValue5 !== null && displayStatusValue5 !== undefined) {
                        var displayStatusInstance5 = displayStatusValue5;
                        instanceViewStatusInstance4.displayStatus = displayStatusInstance5;
                      }
                      
                      var messageValue5 = statusesValue3['message'];
                      if (messageValue5 !== null && messageValue5 !== undefined) {
                        var messageInstance5 = messageValue5;
                        instanceViewStatusInstance4.message = messageInstance5;
                      }
                      
                      var timeValue5 = statusesValue3['time'];
                      if (timeValue5 !== null && timeValue5 !== undefined) {
                        var timeInstance5 = timeValue5;
                        instanceViewStatusInstance4.time = timeInstance5;
                      }
                    }
                  }
                }
              }
              
              var bootDiagnosticsValue2 = instanceViewValue['bootDiagnostics'];
              if (bootDiagnosticsValue2 !== null && bootDiagnosticsValue2 !== undefined) {
                var bootDiagnosticsInstance2 = {};
                instanceViewInstance.bootDiagnostics = bootDiagnosticsInstance2;
                
                var consoleScreenshotBlobUriValue = bootDiagnosticsValue2['consoleScreenshotBlobUri'];
                if (consoleScreenshotBlobUriValue !== null && consoleScreenshotBlobUriValue !== undefined) {
                  var consoleScreenshotBlobUriInstance = consoleScreenshotBlobUriValue;
                  bootDiagnosticsInstance2.consoleScreenshotBlobUri = consoleScreenshotBlobUriInstance;
                }
                
                var serialConsoleLogBlobUriValue = bootDiagnosticsValue2['serialConsoleLogBlobUri'];
                if (serialConsoleLogBlobUriValue !== null && serialConsoleLogBlobUriValue !== undefined) {
                  var serialConsoleLogBlobUriInstance = serialConsoleLogBlobUriValue;
                  bootDiagnosticsInstance2.serialConsoleLogBlobUri = serialConsoleLogBlobUriInstance;
                }
              }
              
              var statusesArray4 = instanceViewValue['statuses'];
              if (statusesArray4 !== null && statusesArray4 !== undefined) {
                for (var loweredIndex15 = 0; loweredIndex15 < statusesArray4.length; loweredIndex15 = loweredIndex15 + 1) {
                  var statusesValue4 = statusesArray4[loweredIndex15];
                  var instanceViewStatusInstance5 = {};
                  instanceViewInstance.statuses.push(instanceViewStatusInstance5);
                  
                  var codeValue6 = statusesValue4['code'];
                  if (codeValue6 !== null && codeValue6 !== undefined) {
                    var codeInstance6 = codeValue6;
                    instanceViewStatusInstance5.code = codeInstance6;
                  }
                  
                  var levelValue6 = statusesValue4['level'];
                  if (levelValue6 !== null && levelValue6 !== undefined) {
                    var levelInstance6 = levelValue6;
                    instanceViewStatusInstance5.level = levelInstance6;
                  }
                  
                  var displayStatusValue6 = statusesValue4['displayStatus'];
                  if (displayStatusValue6 !== null && displayStatusValue6 !== undefined) {
                    var displayStatusInstance6 = displayStatusValue6;
                    instanceViewStatusInstance5.displayStatus = displayStatusInstance6;
                  }
                  
                  var messageValue6 = statusesValue4['message'];
                  if (messageValue6 !== null && messageValue6 !== undefined) {
                    var messageInstance6 = messageValue6;
                    instanceViewStatusInstance5.message = messageInstance6;
                  }
                  
                  var timeValue6 = statusesValue4['time'];
                  if (timeValue6 !== null && timeValue6 !== undefined) {
                    var timeInstance6 = timeValue6;
                    instanceViewStatusInstance5.time = timeInstance6;
                  }
                }
              }
            }
          }
          
          var resourcesArray = responseDoc['resources'];
          if (resourcesArray !== null && resourcesArray !== undefined) {
            virtualMachineInstance.extensions = [];
            for (var loweredIndex16 = 0; loweredIndex16 < resourcesArray.length; loweredIndex16 = loweredIndex16 + 1) {
              var resourcesValue = resourcesArray[loweredIndex16];
              var virtualMachineExtensionJsonInstance = { tags: {} };
              virtualMachineInstance.extensions.push(virtualMachineExtensionJsonInstance);
              
              var propertiesValue3 = resourcesValue['properties'];
              if (propertiesValue3 !== null && propertiesValue3 !== undefined) {
                var publisherValue3 = propertiesValue3['publisher'];
                if (publisherValue3 !== null && publisherValue3 !== undefined) {
                  var publisherInstance3 = publisherValue3;
                  virtualMachineExtensionJsonInstance.publisher = publisherInstance3;
                }
                
                var typeValue3 = propertiesValue3['type'];
                if (typeValue3 !== null && typeValue3 !== undefined) {
                  var typeInstance3 = typeValue3;
                  virtualMachineExtensionJsonInstance.extensionType = typeInstance3;
                }
                
                var typeHandlerVersionValue3 = propertiesValue3['typeHandlerVersion'];
                if (typeHandlerVersionValue3 !== null && typeHandlerVersionValue3 !== undefined) {
                  var typeHandlerVersionInstance3 = typeHandlerVersionValue3;
                  virtualMachineExtensionJsonInstance.typeHandlerVersion = typeHandlerVersionInstance3;
                }
                
                var autoUpgradeMinorVersionValue = propertiesValue3['autoUpgradeMinorVersion'];
                if (autoUpgradeMinorVersionValue !== null && autoUpgradeMinorVersionValue !== undefined) {
                  var autoUpgradeMinorVersionInstance = autoUpgradeMinorVersionValue;
                  virtualMachineExtensionJsonInstance.autoUpgradeMinorVersion = autoUpgradeMinorVersionInstance;
                }
                
                var settingsValue = propertiesValue3['settings'];
                if (settingsValue !== null && settingsValue !== undefined) {
                  var settingsInstance = settingsValue;
                  virtualMachineExtensionJsonInstance.settings = settingsInstance;
                }
                
                var protectedSettingsValue = propertiesValue3['protectedSettings'];
                if (protectedSettingsValue !== null && protectedSettingsValue !== undefined) {
                  var protectedSettingsInstance = protectedSettingsValue;
                  virtualMachineExtensionJsonInstance.protectedSettings = protectedSettingsInstance;
                }
                
                var provisioningStateValue2 = propertiesValue3['provisioningState'];
                if (provisioningStateValue2 !== null && provisioningStateValue2 !== undefined) {
                  var provisioningStateInstance2 = provisioningStateValue2;
                  virtualMachineExtensionJsonInstance.provisioningState = provisioningStateInstance2;
                }
                
                var instanceViewValue2 = propertiesValue3['instanceView'];
                if (instanceViewValue2 !== null && instanceViewValue2 !== undefined) {
                  var instanceViewInstance2 = { statuses: [], subStatuses: [] };
                  virtualMachineExtensionJsonInstance.instanceView = instanceViewInstance2;
                  
                  var nameValue6 = instanceViewValue2['name'];
                  if (nameValue6 !== null && nameValue6 !== undefined) {
                    var nameInstance6 = nameValue6;
                    instanceViewInstance2.name = nameInstance6;
                  }
                  
                  var typeValue4 = instanceViewValue2['type'];
                  if (typeValue4 !== null && typeValue4 !== undefined) {
                    var typeInstance4 = typeValue4;
                    instanceViewInstance2.extensionType = typeInstance4;
                  }
                  
                  var typeHandlerVersionValue4 = instanceViewValue2['typeHandlerVersion'];
                  if (typeHandlerVersionValue4 !== null && typeHandlerVersionValue4 !== undefined) {
                    var typeHandlerVersionInstance4 = typeHandlerVersionValue4;
                    instanceViewInstance2.typeHandlerVersion = typeHandlerVersionInstance4;
                  }
                  
                  var substatusesArray2 = instanceViewValue2['substatuses'];
                  if (substatusesArray2 !== null && substatusesArray2 !== undefined) {
                    for (var loweredIndex17 = 0; loweredIndex17 < substatusesArray2.length; loweredIndex17 = loweredIndex17 + 1) {
                      var substatusesValue2 = substatusesArray2[loweredIndex17];
                      var instanceViewStatusInstance6 = {};
                      instanceViewInstance2.subStatuses.push(instanceViewStatusInstance6);
                      
                      var codeValue7 = substatusesValue2['code'];
                      if (codeValue7 !== null && codeValue7 !== undefined) {
                        var codeInstance7 = codeValue7;
                        instanceViewStatusInstance6.code = codeInstance7;
                      }
                      
                      var levelValue7 = substatusesValue2['level'];
                      if (levelValue7 !== null && levelValue7 !== undefined) {
                        var levelInstance7 = levelValue7;
                        instanceViewStatusInstance6.level = levelInstance7;
                      }
                      
                      var displayStatusValue7 = substatusesValue2['displayStatus'];
                      if (displayStatusValue7 !== null && displayStatusValue7 !== undefined) {
                        var displayStatusInstance7 = displayStatusValue7;
                        instanceViewStatusInstance6.displayStatus = displayStatusInstance7;
                      }
                      
                      var messageValue7 = substatusesValue2['message'];
                      if (messageValue7 !== null && messageValue7 !== undefined) {
                        var messageInstance7 = messageValue7;
                        instanceViewStatusInstance6.message = messageInstance7;
                      }
                      
                      var timeValue7 = substatusesValue2['time'];
                      if (timeValue7 !== null && timeValue7 !== undefined) {
                        var timeInstance7 = timeValue7;
                        instanceViewStatusInstance6.time = timeInstance7;
                      }
                    }
                  }
                  
                  var statusesArray5 = instanceViewValue2['statuses'];
                  if (statusesArray5 !== null && statusesArray5 !== undefined) {
                    for (var loweredIndex18 = 0; loweredIndex18 < statusesArray5.length; loweredIndex18 = loweredIndex18 + 1) {
                      var statusesValue5 = statusesArray5[loweredIndex18];
                      var instanceViewStatusInstance7 = {};
                      instanceViewInstance2.statuses.push(instanceViewStatusInstance7);
                      
                      var codeValue8 = statusesValue5['code'];
                      if (codeValue8 !== null && codeValue8 !== undefined) {
                        var codeInstance8 = codeValue8;
                        instanceViewStatusInstance7.code = codeInstance8;
                      }
                      
                      var levelValue8 = statusesValue5['level'];
                      if (levelValue8 !== null && levelValue8 !== undefined) {
                        var levelInstance8 = levelValue8;
                        instanceViewStatusInstance7.level = levelInstance8;
                      }
                      
                      var displayStatusValue8 = statusesValue5['displayStatus'];
                      if (displayStatusValue8 !== null && displayStatusValue8 !== undefined) {
                        var displayStatusInstance8 = displayStatusValue8;
                        instanceViewStatusInstance7.displayStatus = displayStatusInstance8;
                      }
                      
                      var messageValue8 = statusesValue5['message'];
                      if (messageValue8 !== null && messageValue8 !== undefined) {
                        var messageInstance8 = messageValue8;
                        instanceViewStatusInstance7.message = messageInstance8;
                      }
                      
                      var timeValue8 = statusesValue5['time'];
                      if (timeValue8 !== null && timeValue8 !== undefined) {
                        var timeInstance8 = timeValue8;
                        instanceViewStatusInstance7.time = timeInstance8;
                      }
                    }
                  }
                }
              }
              
              var idValue6 = resourcesValue['id'];
              if (idValue6 !== null && idValue6 !== undefined) {
                var idInstance6 = idValue6;
                virtualMachineExtensionJsonInstance.id = idInstance6;
              }
              
              var nameValue7 = resourcesValue['name'];
              if (nameValue7 !== null && nameValue7 !== undefined) {
                var nameInstance7 = nameValue7;
                virtualMachineExtensionJsonInstance.name = nameInstance7;
              }
              
              var typeValue5 = resourcesValue['type'];
              if (typeValue5 !== null && typeValue5 !== undefined) {
                var typeInstance5 = typeValue5;
                virtualMachineExtensionJsonInstance.type = typeInstance5;
              }
              
              var locationValue = resourcesValue['location'];
              if (locationValue !== null && locationValue !== undefined) {
                var locationInstance = locationValue;
                virtualMachineExtensionJsonInstance.location = locationInstance;
              }
              
              var tagsSequenceElement = resourcesValue['tags'];
              if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
                for (var property in tagsSequenceElement) {
                  var tagsKey = property;
                  var tagsValue = tagsSequenceElement[property];
                  virtualMachineExtensionJsonInstance.tags[tagsKey] = tagsValue;
                }
              }
            }
          }
          
          var idValue7 = responseDoc['id'];
          if (idValue7 !== null && idValue7 !== undefined) {
            var idInstance7 = idValue7;
            virtualMachineInstance.id = idInstance7;
          }
          
          var nameValue8 = responseDoc['name'];
          if (nameValue8 !== null && nameValue8 !== undefined) {
            var nameInstance8 = nameValue8;
            virtualMachineInstance.name = nameInstance8;
          }
          
          var typeValue6 = responseDoc['type'];
          if (typeValue6 !== null && typeValue6 !== undefined) {
            var typeInstance6 = typeValue6;
            virtualMachineInstance.type = typeInstance6;
          }
          
          var locationValue2 = responseDoc['location'];
          if (locationValue2 !== null && locationValue2 !== undefined) {
            var locationInstance2 = locationValue2;
            virtualMachineInstance.location = locationInstance2;
          }
          
          var tagsSequenceElement2 = responseDoc['tags'];
          if (tagsSequenceElement2 !== null && tagsSequenceElement2 !== undefined) {
            for (var property2 in tagsSequenceElement2) {
              var tagsKey2 = property2;
              var tagsValue2 = tagsSequenceElement2[property2];
              virtualMachineInstance.tags[tagsKey2] = tagsValue2;
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The operation to list virtual machines under a resource group.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.list = function(resourceGroupName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/';
    url2 = url2 + 'virtualMachines';
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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['Content-Type'] = 'application/json';
    
    // 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 = { virtualMachines: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var valueArray = responseDoc['value'];
          if (valueArray !== null && valueArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var valueValue = valueArray[loweredIndex1];
              var virtualMachineJsonInstance = { extensions: [], tags: {} };
              result.virtualMachines.push(virtualMachineJsonInstance);
              
              var planValue = valueValue['plan'];
              if (planValue !== null && planValue !== undefined) {
                var planInstance = {};
                virtualMachineJsonInstance.plan = planInstance;
                
                var nameValue = planValue['name'];
                if (nameValue !== null && nameValue !== undefined) {
                  var nameInstance = nameValue;
                  planInstance.name = nameInstance;
                }
                
                var publisherValue = planValue['publisher'];
                if (publisherValue !== null && publisherValue !== undefined) {
                  var publisherInstance = publisherValue;
                  planInstance.publisher = publisherInstance;
                }
                
                var productValue = planValue['product'];
                if (productValue !== null && productValue !== undefined) {
                  var productInstance = productValue;
                  planInstance.product = productInstance;
                }
                
                var promotionCodeValue = planValue['promotionCode'];
                if (promotionCodeValue !== null && promotionCodeValue !== undefined) {
                  var promotionCodeInstance = promotionCodeValue;
                  planInstance.promotionCode = promotionCodeInstance;
                }
              }
              
              var propertiesValue = valueValue['properties'];
              if (propertiesValue !== null && propertiesValue !== undefined) {
                var hardwareProfileValue = propertiesValue['hardwareProfile'];
                if (hardwareProfileValue !== null && hardwareProfileValue !== undefined) {
                  var hardwareProfileInstance = {};
                  virtualMachineJsonInstance.hardwareProfile = hardwareProfileInstance;
                  
                  var vmSizeValue = hardwareProfileValue['vmSize'];
                  if (vmSizeValue !== null && vmSizeValue !== undefined) {
                    var vmSizeInstance = vmSizeValue;
                    hardwareProfileInstance.virtualMachineSize = vmSizeInstance;
                  }
                }
                
                var storageProfileValue = propertiesValue['storageProfile'];
                if (storageProfileValue !== null && storageProfileValue !== undefined) {
                  var storageProfileInstance = { dataDisks: [] };
                  virtualMachineJsonInstance.storageProfile = storageProfileInstance;
                  
                  var imageReferenceValue = storageProfileValue['imageReference'];
                  if (imageReferenceValue !== null && imageReferenceValue !== undefined) {
                    var imageReferenceInstance = {};
                    storageProfileInstance.imageReference = imageReferenceInstance;
                    
                    var publisherValue2 = imageReferenceValue['publisher'];
                    if (publisherValue2 !== null && publisherValue2 !== undefined) {
                      var publisherInstance2 = publisherValue2;
                      imageReferenceInstance.publisher = publisherInstance2;
                    }
                    
                    var offerValue = imageReferenceValue['offer'];
                    if (offerValue !== null && offerValue !== undefined) {
                      var offerInstance = offerValue;
                      imageReferenceInstance.offer = offerInstance;
                    }
                    
                    var skuValue = imageReferenceValue['sku'];
                    if (skuValue !== null && skuValue !== undefined) {
                      var skuInstance = skuValue;
                      imageReferenceInstance.sku = skuInstance;
                    }
                    
                    var versionValue = imageReferenceValue['version'];
                    if (versionValue !== null && versionValue !== undefined) {
                      var versionInstance = versionValue;
                      imageReferenceInstance.version = versionInstance;
                    }
                  }
                  
                  var osDiskValue = storageProfileValue['osDisk'];
                  if (osDiskValue !== null && osDiskValue !== undefined) {
                    var osDiskInstance = {};
                    storageProfileInstance.oSDisk = osDiskInstance;
                    
                    var osTypeValue = osDiskValue['osType'];
                    if (osTypeValue !== null && osTypeValue !== undefined) {
                      var osTypeInstance = osTypeValue;
                      osDiskInstance.operatingSystemType = osTypeInstance;
                    }
                    
                    var encryptionSettingsValue = osDiskValue['encryptionSettings'];
                    if (encryptionSettingsValue !== null && encryptionSettingsValue !== undefined) {
                      var encryptionSettingsInstance = {};
                      osDiskInstance.encryptionSettings = encryptionSettingsInstance;
                      
                      var diskEncryptionKeyValue = encryptionSettingsValue['diskEncryptionKey'];
                      if (diskEncryptionKeyValue !== null && diskEncryptionKeyValue !== undefined) {
                        var diskEncryptionKeyInstance = {};
                        encryptionSettingsInstance.diskEncryptionKey = diskEncryptionKeyInstance;
                        
                        var secretUrlValue = diskEncryptionKeyValue['secretUrl'];
                        if (secretUrlValue !== null && secretUrlValue !== undefined) {
                          var secretUrlInstance = secretUrlValue;
                          diskEncryptionKeyInstance.secretUrl = secretUrlInstance;
                        }
                        
                        var sourceVaultValue = diskEncryptionKeyValue['sourceVault'];
                        if (sourceVaultValue !== null && sourceVaultValue !== undefined) {
                          var sourceVaultInstance = {};
                          diskEncryptionKeyInstance.sourceVault = sourceVaultInstance;
                          
                          var idValue = sourceVaultValue['id'];
                          if (idValue !== null && idValue !== undefined) {
                            var idInstance = idValue;
                            sourceVaultInstance.referenceUri = idInstance;
                          }
                        }
                      }
                      
                      var keyEncryptionKeyValue = encryptionSettingsValue['keyEncryptionKey'];
                      if (keyEncryptionKeyValue !== null && keyEncryptionKeyValue !== undefined) {
                        var keyEncryptionKeyInstance = {};
                        encryptionSettingsInstance.keyEncryptionKey = keyEncryptionKeyInstance;
                        
                        var keyUrlValue = keyEncryptionKeyValue['keyUrl'];
                        if (keyUrlValue !== null && keyUrlValue !== undefined) {
                          var keyUrlInstance = keyUrlValue;
                          keyEncryptionKeyInstance.keyUrl = keyUrlInstance;
                        }
                        
                        var sourceVaultValue2 = keyEncryptionKeyValue['sourceVault'];
                        if (sourceVaultValue2 !== null && sourceVaultValue2 !== undefined) {
                          var sourceVaultInstance2 = {};
                          keyEncryptionKeyInstance.sourceVault = sourceVaultInstance2;
                          
                          var idValue2 = sourceVaultValue2['id'];
                          if (idValue2 !== null && idValue2 !== undefined) {
                            var idInstance2 = idValue2;
                            sourceVaultInstance2.referenceUri = idInstance2;
                          }
                        }
                      }
                    }
                    
                    var nameValue2 = osDiskValue['name'];
                    if (nameValue2 !== null && nameValue2 !== undefined) {
                      var nameInstance2 = nameValue2;
                      osDiskInstance.name = nameInstance2;
                    }
                    
                    var vhdValue = osDiskValue['vhd'];
                    if (vhdValue !== null && vhdValue !== undefined) {
                      var vhdInstance = {};
                      osDiskInstance.virtualHardDisk = vhdInstance;
                      
                      var uriValue = vhdValue['uri'];
                      if (uriValue !== null && uriValue !== undefined) {
                        var uriInstance = uriValue;
                        vhdInstance.uri = uriInstance;
                      }
                    }
                    
                    var imageValue = osDiskValue['image'];
                    if (imageValue !== null && imageValue !== undefined) {
                      var imageInstance = {};
                      osDiskInstance.sourceImage = imageInstance;
                      
                      var uriValue2 = imageValue['uri'];
                      if (uriValue2 !== null && uriValue2 !== undefined) {
                        var uriInstance2 = uriValue2;
                        imageInstance.uri = uriInstance2;
                      }
                    }
                    
                    var cachingValue = osDiskValue['caching'];
                    if (cachingValue !== null && cachingValue !== undefined) {
                      var cachingInstance = cachingValue;
                      osDiskInstance.caching = cachingInstance;
                    }
                    
                    var createOptionValue = osDiskValue['createOption'];
                    if (createOptionValue !== null && createOptionValue !== undefined) {
                      var createOptionInstance = createOptionValue;
                      osDiskInstance.createOption = createOptionInstance;
                    }
                    
                    var diskSizeGBValue = osDiskValue['diskSizeGB'];
                    if (diskSizeGBValue !== null && diskSizeGBValue !== undefined) {
                      var diskSizeGBInstance = diskSizeGBValue;
                      osDiskInstance.diskSizeGB = diskSizeGBInstance;
                    }
                  }
                  
                  var dataDisksArray = storageProfileValue['dataDisks'];
                  if (dataDisksArray !== null && dataDisksArray !== undefined) {
                    for (var loweredIndex2 = 0; loweredIndex2 < dataDisksArray.length; loweredIndex2 = loweredIndex2 + 1) {
                      var dataDisksValue = dataDisksArray[loweredIndex2];
                      var dataDiskInstance = {};
                      storageProfileInstance.dataDisks.push(dataDiskInstance);
                      
                      var lunValue = dataDisksValue['lun'];
                      if (lunValue !== null && lunValue !== undefined) {
                        var lunInstance = lunValue;
                        dataDiskInstance.lun = lunInstance;
                      }
                      
                      var nameValue3 = dataDisksValue['name'];
                      if (nameValue3 !== null && nameValue3 !== undefined) {
                        var nameInstance3 = nameValue3;
                        dataDiskInstance.name = nameInstance3;
                      }
                      
                      var vhdValue2 = dataDisksValue['vhd'];
                      if (vhdValue2 !== null && vhdValue2 !== undefined) {
                        var vhdInstance2 = {};
                        dataDiskInstance.virtualHardDisk = vhdInstance2;
                        
                        var uriValue3 = vhdValue2['uri'];
                        if (uriValue3 !== null && uriValue3 !== undefined) {
                          var uriInstance3 = uriValue3;
                          vhdInstance2.uri = uriInstance3;
                        }
                      }
                      
                      var imageValue2 = dataDisksValue['image'];
                      if (imageValue2 !== null && imageValue2 !== undefined) {
                        var imageInstance2 = {};
                        dataDiskInstance.sourceImage = imageInstance2;
                        
                        var uriValue4 = imageValue2['uri'];
                        if (uriValue4 !== null && uriValue4 !== undefined) {
                          var uriInstance4 = uriValue4;
                          imageInstance2.uri = uriInstance4;
                        }
                      }
                      
                      var cachingValue2 = dataDisksValue['caching'];
                      if (cachingValue2 !== null && cachingValue2 !== undefined) {
                        var cachingInstance2 = cachingValue2;
                        dataDiskInstance.caching = cachingInstance2;
                      }
                      
                      var createOptionValue2 = dataDisksValue['createOption'];
                      if (createOptionValue2 !== null && createOptionValue2 !== undefined) {
                        var createOptionInstance2 = createOptionValue2;
                        dataDiskInstance.createOption = createOptionInstance2;
                      }
                      
                      var diskSizeGBValue2 = dataDisksValue['diskSizeGB'];
                      if (diskSizeGBValue2 !== null && diskSizeGBValue2 !== undefined) {
                        var diskSizeGBInstance2 = diskSizeGBValue2;
                        dataDiskInstance.diskSizeGB = diskSizeGBInstance2;
                      }
                    }
                  }
                }
                
                var osProfileValue = propertiesValue['osProfile'];
                if (osProfileValue !== null && osProfileValue !== undefined) {
                  var osProfileInstance = { secrets: [] };
                  virtualMachineJsonInstance.oSProfile = osProfileInstance;
                  
                  var computerNameValue = osProfileValue['computerName'];
                  if (computerNameValue !== null && computerNameValue !== undefined) {
                    var computerNameInstance = computerNameValue;
                    osProfileInstance.computerName = computerNameInstance;
                  }
                  
                  var adminUsernameValue = osProfileValue['adminUsername'];
                  if (adminUsernameValue !== null && adminUsernameValue !== undefined) {
                    var adminUsernameInstance = adminUsernameValue;
                    osProfileInstance.adminUsername = adminUsernameInstance;
                  }
                  
                  var adminPasswordValue = osProfileValue['adminPassword'];
                  if (adminPasswordValue !== null && adminPasswordValue !== undefined) {
                    var adminPasswordInstance = adminPasswordValue;
                    osProfileInstance.adminPassword = adminPasswordInstance;
                  }
                  
                  var customDataValue = osProfileValue['customData'];
                  if (customDataValue !== null && customDataValue !== undefined) {
                    var customDataInstance = customDataValue;
                    osProfileInstance.customData = customDataInstance;
                  }
                  
                  var windowsConfigurationValue = osProfileValue['windowsConfiguration'];
                  if (windowsConfigurationValue !== null && windowsConfigurationValue !== undefined) {
                    var windowsConfigurationInstance = { additionalUnattendContents: [] };
                    osProfileInstance.windowsConfiguration = windowsConfigurationInstance;
                    
                    var provisionVMAgentValue = windowsConfigurationValue['provisionVMAgent'];
                    if (provisionVMAgentValue !== null && provisionVMAgentValue !== undefined) {
                      var provisionVMAgentInstance = provisionVMAgentValue;
                      windowsConfigurationInstance.provisionVMAgent = provisionVMAgentInstance;
                    }
                    
                    var enableAutomaticUpdatesValue = windowsConfigurationValue['enableAutomaticUpdates'];
                    if (enableAutomaticUpdatesValue !== null && enableAutomaticUpdatesValue !== undefined) {
                      var enableAutomaticUpdatesInstance = enableAutomaticUpdatesValue;
                      windowsConfigurationInstance.enableAutomaticUpdates = enableAutomaticUpdatesInstance;
                    }
                    
                    var timeZoneValue = windowsConfigurationValue['timeZone'];
                    if (timeZoneValue !== null && timeZoneValue !== undefined) {
                      var timeZoneInstance = timeZoneValue;
                      windowsConfigurationInstance.timeZone = timeZoneInstance;
                    }
                    
                    var additionalUnattendContentArray = windowsConfigurationValue['additionalUnattendContent'];
                    if (additionalUnattendContentArray !== null && additionalUnattendContentArray !== undefined) {
                      for (var loweredIndex3 = 0; loweredIndex3 < additionalUnattendContentArray.length; loweredIndex3 = loweredIndex3 + 1) {
                        var additionalUnattendContentValue = additionalUnattendContentArray[loweredIndex3];
                        var additionalUnattendContentInstance = {};
                        windowsConfigurationInstance.additionalUnattendContents.push(additionalUnattendContentInstance);
                        
                        var passNameValue = additionalUnattendContentValue['passName'];
                        if (passNameValue !== null && passNameValue !== undefined) {
                          var passNameInstance = passNameValue;
                          additionalUnattendContentInstance.passName = passNameInstance;
                        }
                        
                        var componentNameValue = additionalUnattendContentValue['componentName'];
                        if (componentNameValue !== null && componentNameValue !== undefined) {
                          var componentNameInstance = componentNameValue;
                          additionalUnattendContentInstance.componentName = componentNameInstance;
                        }
                        
                        var settingNameValue = additionalUnattendContentValue['settingName'];
                        if (settingNameValue !== null && settingNameValue !== undefined) {
                          var settingNameInstance = settingNameValue;
                          additionalUnattendContentInstance.settingName = settingNameInstance;
                        }
                        
                        var contentValue = additionalUnattendContentValue['content'];
                        if (contentValue !== null && contentValue !== undefined) {
                          var contentInstance = contentValue;
                          additionalUnattendContentInstance.content = contentInstance;
                        }
                      }
                    }
                    
                    var winRMValue = windowsConfigurationValue['winRM'];
                    if (winRMValue !== null && winRMValue !== undefined) {
                      var winRMInstance = { listeners: [] };
                      windowsConfigurationInstance.winRMConfiguration = winRMInstance;
                      
                      var listenersArray = winRMValue['listeners'];
                      if (listenersArray !== null && listenersArray !== undefined) {
                        for (var loweredIndex4 = 0; loweredIndex4 < listenersArray.length; loweredIndex4 = loweredIndex4 + 1) {
                          var listenersValue = listenersArray[loweredIndex4];
                          var winRMListenerInstance = {};
                          winRMInstance.listeners.push(winRMListenerInstance);
                          
                          var protocolValue = listenersValue['protocol'];
                          if (protocolValue !== null && protocolValue !== undefined) {
                            var protocolInstance = protocolValue;
                            winRMListenerInstance.protocol = protocolInstance;
                          }
                          
                          var certificateUrlValue = listenersValue['certificateUrl'];
                          if (certificateUrlValue !== null && certificateUrlValue !== undefined) {
                            var certificateUrlInstance = certificateUrlValue;
                            winRMListenerInstance.certificateUrl = certificateUrlInstance;
                          }
                        }
                      }
                    }
                  }
                  
                  var linuxConfigurationValue = osProfileValue['linuxConfiguration'];
                  if (linuxConfigurationValue !== null && linuxConfigurationValue !== undefined) {
                    var linuxConfigurationInstance = {};
                    osProfileInstance.linuxConfiguration = linuxConfigurationInstance;
                    
                    var disablePasswordAuthenticationValue = linuxConfigurationValue['disablePasswordAuthentication'];
                    if (disablePasswordAuthenticationValue !== null && disablePasswordAuthenticationValue !== undefined) {
                      var disablePasswordAuthenticationInstance = disablePasswordAuthenticationValue;
                      linuxConfigurationInstance.disablePasswordAuthentication = disablePasswordAuthenticationInstance;
                    }
                    
                    var sshValue = linuxConfigurationValue['ssh'];
                    if (sshValue !== null && sshValue !== undefined) {
                      var sshInstance = { publicKeys: [] };
                      linuxConfigurationInstance.sshConfiguration = sshInstance;
                      
                      var publicKeysArray = sshValue['publicKeys'];
                      if (publicKeysArray !== null && publicKeysArray !== undefined) {
                        for (var loweredIndex5 = 0; loweredIndex5 < publicKeysArray.length; loweredIndex5 = loweredIndex5 + 1) {
                          var publicKeysValue = publicKeysArray[loweredIndex5];
                          var sshPublicKeyInstance = {};
                          sshInstance.publicKeys.push(sshPublicKeyInstance);
                          
                          var pathValue = publicKeysValue['path'];
                          if (pathValue !== null && pathValue !== undefined) {
                            var pathInstance = pathValue;
                            sshPublicKeyInstance.path = pathInstance;
                          }
                          
                          var keyDataValue = publicKeysValue['keyData'];
                          if (keyDataValue !== null && keyDataValue !== undefined) {
                            var keyDataInstance = keyDataValue;
                            sshPublicKeyInstance.keyData = keyDataInstance;
                          }
                        }
                      }
                    }
                  }
                  
                  var secretsArray = osProfileValue['secrets'];
                  if (secretsArray !== null && secretsArray !== undefined) {
                    for (var loweredIndex6 = 0; loweredIndex6 < secretsArray.length; loweredIndex6 = loweredIndex6 + 1) {
                      var secretsValue = secretsArray[loweredIndex6];
                      var vaultSecretGroupInstance = { vaultCertificates: [] };
                      osProfileInstance.secrets.push(vaultSecretGroupInstance);
                      
                      var sourceVaultValue3 = secretsValue['sourceVault'];
                      if (sourceVaultValue3 !== null && sourceVaultValue3 !== undefined) {
                        var sourceVaultInstance3 = {};
                        vaultSecretGroupInstance.sourceVault = sourceVaultInstance3;
                        
                        var idValue3 = sourceVaultValue3['id'];
                        if (idValue3 !== null && idValue3 !== undefined) {
                          var idInstance3 = idValue3;
                          sourceVaultInstance3.referenceUri = idInstance3;
                        }
                      }
                      
                      var vaultCertificatesArray = secretsValue['vaultCertificates'];
                      if (vaultCertificatesArray !== null && vaultCertificatesArray !== undefined) {
                        for (var loweredIndex7 = 0; loweredIndex7 < vaultCertificatesArray.length; loweredIndex7 = loweredIndex7 + 1) {
                          var vaultCertificatesValue = vaultCertificatesArray[loweredIndex7];
                          var vaultCertificateInstance = {};
                          vaultSecretGroupInstance.vaultCertificates.push(vaultCertificateInstance);
                          
                          var certificateUrlValue2 = vaultCertificatesValue['certificateUrl'];
                          if (certificateUrlValue2 !== null && certificateUrlValue2 !== undefined) {
                            var certificateUrlInstance2 = certificateUrlValue2;
                            vaultCertificateInstance.certificateUrl = certificateUrlInstance2;
                          }
                          
                          var certificateStoreValue = vaultCertificatesValue['certificateStore'];
                          if (certificateStoreValue !== null && certificateStoreValue !== undefined) {
                            var certificateStoreInstance = certificateStoreValue;
                            vaultCertificateInstance.certificateStore = certificateStoreInstance;
                          }
                        }
                      }
                    }
                  }
                }
                
                var networkProfileValue = propertiesValue['networkProfile'];
                if (networkProfileValue !== null && networkProfileValue !== undefined) {
                  var networkProfileInstance = { networkInterfaces: [] };
                  virtualMachineJsonInstance.networkProfile = networkProfileInstance;
                  
                  var networkInterfacesArray = networkProfileValue['networkInterfaces'];
                  if (networkInterfacesArray !== null && networkInterfacesArray !== undefined) {
                    for (var loweredIndex8 = 0; loweredIndex8 < networkInterfacesArray.length; loweredIndex8 = loweredIndex8 + 1) {
                      var networkInterfacesValue = networkInterfacesArray[loweredIndex8];
                      var networkInterfaceReferenceJsonInstance = {};
                      networkProfileInstance.networkInterfaces.push(networkInterfaceReferenceJsonInstance);
                      
                      var propertiesValue2 = networkInterfacesValue['properties'];
                      if (propertiesValue2 !== null && propertiesValue2 !== undefined) {
                        var primaryValue = propertiesValue2['primary'];
                        if (primaryValue !== null && primaryValue !== undefined) {
                          var primaryInstance = primaryValue;
                          networkInterfaceReferenceJsonInstance.primary = primaryInstance;
                        }
                      }
                      
                      var idValue4 = networkInterfacesValue['id'];
                      if (idValue4 !== null && idValue4 !== undefined) {
                        var idInstance4 = idValue4;
                        networkInterfaceReferenceJsonInstance.referenceUri = idInstance4;
                      }
                    }
                  }
                }
                
                var diagnosticsProfileValue = propertiesValue['diagnosticsProfile'];
                if (diagnosticsProfileValue !== null && diagnosticsProfileValue !== undefined) {
                  var diagnosticsProfileInstance = {};
                  virtualMachineJsonInstance.diagnosticsProfile = diagnosticsProfileInstance;
                  
                  var bootDiagnosticsValue = diagnosticsProfileValue['bootDiagnostics'];
                  if (bootDiagnosticsValue !== null && bootDiagnosticsValue !== undefined) {
                    var bootDiagnosticsInstance = {};
                    diagnosticsProfileInstance.bootDiagnostics = bootDiagnosticsInstance;
                    
                    var enabledValue = bootDiagnosticsValue['enabled'];
                    if (enabledValue !== null && enabledValue !== undefined) {
                      var enabledInstance = enabledValue;
                      bootDiagnosticsInstance.enabled = enabledInstance;
                    }
                    
                    var storageUriValue = bootDiagnosticsValue['storageUri'];
                    if (storageUriValue !== null && storageUriValue !== undefined) {
                      var storageUriInstance = storageUriValue;
                      bootDiagnosticsInstance.storageUri = storageUriInstance;
                    }
                  }
                }
                
                var availabilitySetValue = propertiesValue['availabilitySet'];
                if (availabilitySetValue !== null && availabilitySetValue !== undefined) {
                  var availabilitySetInstance = {};
                  virtualMachineJsonInstance.availabilitySetReference = availabilitySetInstance;
                  
                  var idValue5 = availabilitySetValue['id'];
                  if (idValue5 !== null && idValue5 !== undefined) {
                    var idInstance5 = idValue5;
                    availabilitySetInstance.referenceUri = idInstance5;
                  }
                }
                
                var provisioningStateValue = propertiesValue['provisioningState'];
                if (provisioningStateValue !== null && provisioningStateValue !== undefined) {
                  var provisioningStateInstance = provisioningStateValue;
                  virtualMachineJsonInstance.provisioningState = provisioningStateInstance;
                }
                
                var instanceViewValue = propertiesValue['instanceView'];
                if (instanceViewValue !== null && instanceViewValue !== undefined) {
                  var instanceViewInstance = { disks: [], extensions: [], statuses: [] };
                  virtualMachineJsonInstance.instanceView = instanceViewInstance;
                  
                  var platformUpdateDomainValue = instanceViewValue['platformUpdateDomain'];
                  if (platformUpdateDomainValue !== null && platformUpdateDomainValue !== undefined) {
                    var platformUpdateDomainInstance = platformUpdateDomainValue;
                    instanceViewInstance.platformUpdateDomain = platformUpdateDomainInstance;
                  }
                  
                  var platformFaultDomainValue = instanceViewValue['platformFaultDomain'];
                  if (platformFaultDomainValue !== null && platformFaultDomainValue !== undefined) {
                    var platformFaultDomainInstance = platformFaultDomainValue;
                    instanceViewInstance.platformFaultDomain = platformFaultDomainInstance;
                  }
                  
                  var rdpThumbPrintValue = instanceViewValue['rdpThumbPrint'];
                  if (rdpThumbPrintValue !== null && rdpThumbPrintValue !== undefined) {
                    var rdpThumbPrintInstance = rdpThumbPrintValue;
                    instanceViewInstance.remoteDesktopThumbprint = rdpThumbPrintInstance;
                  }
                  
                  var vmAgentValue = instanceViewValue['vmAgent'];
                  if (vmAgentValue !== null && vmAgentValue !== undefined) {
                    var vmAgentInstance = { extensionHandlers: [], statuses: [] };
                    instanceViewInstance.vMAgent = vmAgentInstance;
                    
                    var vmAgentVersionValue = vmAgentValue['vmAgentVersion'];
                    if (vmAgentVersionValue !== null && vmAgentVersionValue !== undefined) {
                      var vmAgentVersionInstance = vmAgentVersionValue;
                      vmAgentInstance.vMAgentVersion = vmAgentVersionInstance;
                    }
                    
                    var extensionHandlersArray = vmAgentValue['extensionHandlers'];
                    if (extensionHandlersArray !== null && extensionHandlersArray !== undefined) {
                      for (var loweredIndex9 = 0; loweredIndex9 < extensionHandlersArray.length; loweredIndex9 = loweredIndex9 + 1) {
                        var extensionHandlersValue = extensionHandlersArray[loweredIndex9];
                        var virtualMachineExtensionHandlerInstanceViewInstance = {};
                        vmAgentInstance.extensionHandlers.push(virtualMachineExtensionHandlerInstanceViewInstance);
                        
                        var typeValue = extensionHandlersValue['type'];
                        if (typeValue !== null && typeValue !== undefined) {
                          var typeInstance = typeValue;
                          virtualMachineExtensionHandlerInstanceViewInstance.type = typeInstance;
                        }
                        
                        var typeHandlerVersionValue = extensionHandlersValue['typeHandlerVersion'];
                        if (typeHandlerVersionValue !== null && typeHandlerVersionValue !== undefined) {
                          var typeHandlerVersionInstance = typeHandlerVersionValue;
                          virtualMachineExtensionHandlerInstanceViewInstance.typeHandlerVersion = typeHandlerVersionInstance;
                        }
                        
                        var statusValue = extensionHandlersValue['status'];
                        if (statusValue !== null && statusValue !== undefined) {
                          var statusInstance = {};
                          virtualMachineExtensionHandlerInstanceViewInstance.status = statusInstance;
                          
                          var codeValue = statusValue['code'];
                          if (codeValue !== null && codeValue !== undefined) {
                            var codeInstance = codeValue;
                            statusInstance.code = codeInstance;
                          }
                          
                          var levelValue = statusValue['level'];
                          if (levelValue !== null && levelValue !== undefined) {
                            var levelInstance = levelValue;
                            statusInstance.level = levelInstance;
                          }
                          
                          var displayStatusValue = statusValue['displayStatus'];
                          if (displayStatusValue !== null && displayStatusValue !== undefined) {
                            var displayStatusInstance = displayStatusValue;
                            statusInstance.displayStatus = displayStatusInstance;
                          }
                          
                          var messageValue = statusValue['message'];
                          if (messageValue !== null && messageValue !== undefined) {
                            var messageInstance = messageValue;
                            statusInstance.message = messageInstance;
                          }
                          
                          var timeValue = statusValue['time'];
                          if (timeValue !== null && timeValue !== undefined) {
                            var timeInstance = timeValue;
                            statusInstance.time = timeInstance;
                          }
                        }
                      }
                    }
                    
                    var statusesArray = vmAgentValue['statuses'];
                    if (statusesArray !== null && statusesArray !== undefined) {
                      for (var loweredIndex10 = 0; loweredIndex10 < statusesArray.length; loweredIndex10 = loweredIndex10 + 1) {
                        var statusesValue = statusesArray[loweredIndex10];
                        var instanceViewStatusInstance = {};
                        vmAgentInstance.statuses.push(instanceViewStatusInstance);
                        
                        var codeValue2 = statusesValue['code'];
                        if (codeValue2 !== null && codeValue2 !== undefined) {
                          var codeInstance2 = codeValue2;
                          instanceViewStatusInstance.code = codeInstance2;
                        }
                        
                        var levelValue2 = statusesValue['level'];
                        if (levelValue2 !== null && levelValue2 !== undefined) {
                          var levelInstance2 = levelValue2;
                          instanceViewStatusInstance.level = levelInstance2;
                        }
                        
                        var displayStatusValue2 = statusesValue['displayStatus'];
                        if (displayStatusValue2 !== null && displayStatusValue2 !== undefined) {
                          var displayStatusInstance2 = displayStatusValue2;
                          instanceViewStatusInstance.displayStatus = displayStatusInstance2;
                        }
                        
                        var messageValue2 = statusesValue['message'];
                        if (messageValue2 !== null && messageValue2 !== undefined) {
                          var messageInstance2 = messageValue2;
                          instanceViewStatusInstance.message = messageInstance2;
                        }
                        
                        var timeValue2 = statusesValue['time'];
                        if (timeValue2 !== null && timeValue2 !== undefined) {
                          var timeInstance2 = timeValue2;
                          instanceViewStatusInstance.time = timeInstance2;
                        }
                      }
                    }
                  }
                  
                  var disksArray = instanceViewValue['disks'];
                  if (disksArray !== null && disksArray !== undefined) {
                    for (var loweredIndex11 = 0; loweredIndex11 < disksArray.length; loweredIndex11 = loweredIndex11 + 1) {
                      var disksValue = disksArray[loweredIndex11];
                      var diskInstanceViewInstance = { statuses: [] };
                      instanceViewInstance.disks.push(diskInstanceViewInstance);
                      
                      var nameValue4 = disksValue['name'];
                      if (nameValue4 !== null && nameValue4 !== undefined) {
                        var nameInstance4 = nameValue4;
                        diskInstanceViewInstance.name = nameInstance4;
                      }
                      
                      var statusesArray2 = disksValue['statuses'];
                      if (statusesArray2 !== null && statusesArray2 !== undefined) {
                        for (var loweredIndex12 = 0; loweredIndex12 < statusesArray2.length; loweredIndex12 = loweredIndex12 + 1) {
                          var statusesValue2 = statusesArray2[loweredIndex12];
                          var instanceViewStatusInstance2 = {};
                          diskInstanceViewInstance.statuses.push(instanceViewStatusInstance2);
                          
                          var codeValue3 = statusesValue2['code'];
                          if (codeValue3 !== null && codeValue3 !== undefined) {
                            var codeInstance3 = codeValue3;
                            instanceViewStatusInstance2.code = codeInstance3;
                          }
                          
                          var levelValue3 = statusesValue2['level'];
                          if (levelValue3 !== null && levelValue3 !== undefined) {
                            var levelInstance3 = levelValue3;
                            instanceViewStatusInstance2.level = levelInstance3;
                          }
                          
                          var displayStatusValue3 = statusesValue2['displayStatus'];
                          if (displayStatusValue3 !== null && displayStatusValue3 !== undefined) {
                            var displayStatusInstance3 = displayStatusValue3;
                            instanceViewStatusInstance2.displayStatus = displayStatusInstance3;
                          }
                          
                          var messageValue3 = statusesValue2['message'];
                          if (messageValue3 !== null && messageValue3 !== undefined) {
                            var messageInstance3 = messageValue3;
                            instanceViewStatusInstance2.message = messageInstance3;
                          }
                          
                          var timeValue3 = statusesValue2['time'];
                          if (timeValue3 !== null && timeValue3 !== undefined) {
                            var timeInstance3 = timeValue3;
                            instanceViewStatusInstance2.time = timeInstance3;
                          }
                        }
                      }
                    }
                  }
                  
                  var extensionsArray = instanceViewValue['extensions'];
                  if (extensionsArray !== null && extensionsArray !== undefined) {
                    for (var loweredIndex13 = 0; loweredIndex13 < extensionsArray.length; loweredIndex13 = loweredIndex13 + 1) {
                      var extensionsValue = extensionsArray[loweredIndex13];
                      var virtualMachineExtensionInstanceViewInstance = { statuses: [], subStatuses: [] };
                      instanceViewInstance.extensions.push(virtualMachineExtensionInstanceViewInstance);
                      
                      var nameValue5 = extensionsValue['name'];
                      if (nameValue5 !== null && nameValue5 !== undefined) {
                        var nameInstance5 = nameValue5;
                        virtualMachineExtensionInstanceViewInstance.name = nameInstance5;
                      }
                      
                      var typeValue2 = extensionsValue['type'];
                      if (typeValue2 !== null && typeValue2 !== undefined) {
                        var typeInstance2 = typeValue2;
                        virtualMachineExtensionInstanceViewInstance.extensionType = typeInstance2;
                      }
                      
                      var typeHandlerVersionValue2 = extensionsValue['typeHandlerVersion'];
                      if (typeHandlerVersionValue2 !== null && typeHandlerVersionValue2 !== undefined) {
                        var typeHandlerVersionInstance2 = typeHandlerVersionValue2;
                        virtualMachineExtensionInstanceViewInstance.typeHandlerVersion = typeHandlerVersionInstance2;
                      }
                      
                      var substatusesArray = extensionsValue['substatuses'];
                      if (substatusesArray !== null && substatusesArray !== undefined) {
                        for (var loweredIndex14 = 0; loweredIndex14 < substatusesArray.length; loweredIndex14 = loweredIndex14 + 1) {
                          var substatusesValue = substatusesArray[loweredIndex14];
                          var instanceViewStatusInstance3 = {};
                          virtualMachineExtensionInstanceViewInstance.subStatuses.push(instanceViewStatusInstance3);
                          
                          var codeValue4 = substatusesValue['code'];
                          if (codeValue4 !== null && codeValue4 !== undefined) {
                            var codeInstance4 = codeValue4;
                            instanceViewStatusInstance3.code = codeInstance4;
                          }
                          
                          var levelValue4 = substatusesValue['level'];
                          if (levelValue4 !== null && levelValue4 !== undefined) {
                            var levelInstance4 = levelValue4;
                            instanceViewStatusInstance3.level = levelInstance4;
                          }
                          
                          var displayStatusValue4 = substatusesValue['displayStatus'];
                          if (displayStatusValue4 !== null && displayStatusValue4 !== undefined) {
                            var displayStatusInstance4 = displayStatusValue4;
                            instanceViewStatusInstance3.displayStatus = displayStatusInstance4;
                          }
                          
                          var messageValue4 = substatusesValue['message'];
                          if (messageValue4 !== null && messageValue4 !== undefined) {
                            var messageInstance4 = messageValue4;
                            instanceViewStatusInstance3.message = messageInstance4;
                          }
                          
                          var timeValue4 = substatusesValue['time'];
                          if (timeValue4 !== null && timeValue4 !== undefined) {
                            var timeInstance4 = timeValue4;
                            instanceViewStatusInstance3.time = timeInstance4;
                          }
                        }
                      }
                      
                      var statusesArray3 = extensionsValue['statuses'];
                      if (statusesArray3 !== null && statusesArray3 !== undefined) {
                        for (var loweredIndex15 = 0; loweredIndex15 < statusesArray3.length; loweredIndex15 = loweredIndex15 + 1) {
                          var statusesValue3 = statusesArray3[loweredIndex15];
                          var instanceViewStatusInstance4 = {};
                          virtualMachineExtensionInstanceViewInstance.statuses.push(instanceViewStatusInstance4);
                          
                          var codeValue5 = statusesValue3['code'];
                          if (codeValue5 !== null && codeValue5 !== undefined) {
                            var codeInstance5 = codeValue5;
                            instanceViewStatusInstance4.code = codeInstance5;
                          }
                          
                          var levelValue5 = statusesValue3['level'];
                          if (levelValue5 !== null && levelValue5 !== undefined) {
                            var levelInstance5 = levelValue5;
                            instanceViewStatusInstance4.level = levelInstance5;
                          }
                          
                          var displayStatusValue5 = statusesValue3['displayStatus'];
                          if (displayStatusValue5 !== null && displayStatusValue5 !== undefined) {
                            var displayStatusInstance5 = displayStatusValue5;
                            instanceViewStatusInstance4.displayStatus = displayStatusInstance5;
                          }
                          
                          var messageValue5 = statusesValue3['message'];
                          if (messageValue5 !== null && messageValue5 !== undefined) {
                            var messageInstance5 = messageValue5;
                            instanceViewStatusInstance4.message = messageInstance5;
                          }
                          
                          var timeValue5 = statusesValue3['time'];
                          if (timeValue5 !== null && timeValue5 !== undefined) {
                            var timeInstance5 = timeValue5;
                            instanceViewStatusInstance4.time = timeInstance5;
                          }
                        }
                      }
                    }
                  }
                  
                  var bootDiagnosticsValue2 = instanceViewValue['bootDiagnostics'];
                  if (bootDiagnosticsValue2 !== null && bootDiagnosticsValue2 !== undefined) {
                    var bootDiagnosticsInstance2 = {};
                    instanceViewInstance.bootDiagnostics = bootDiagnosticsInstance2;
                    
                    var consoleScreenshotBlobUriValue = bootDiagnosticsValue2['consoleScreenshotBlobUri'];
                    if (consoleScreenshotBlobUriValue !== null && consoleScreenshotBlobUriValue !== undefined) {
                      var consoleScreenshotBlobUriInstance = consoleScreenshotBlobUriValue;
                      bootDiagnosticsInstance2.consoleScreenshotBlobUri = consoleScreenshotBlobUriInstance;
                    }
                    
                    var serialConsoleLogBlobUriValue = bootDiagnosticsValue2['serialConsoleLogBlobUri'];
                    if (serialConsoleLogBlobUriValue !== null && serialConsoleLogBlobUriValue !== undefined) {
                      var serialConsoleLogBlobUriInstance = serialConsoleLogBlobUriValue;
                      bootDiagnosticsInstance2.serialConsoleLogBlobUri = serialConsoleLogBlobUriInstance;
                    }
                  }
                  
                  var statusesArray4 = instanceViewValue['statuses'];
                  if (statusesArray4 !== null && statusesArray4 !== undefined) {
                    for (var loweredIndex16 = 0; loweredIndex16 < statusesArray4.length; loweredIndex16 = loweredIndex16 + 1) {
                      var statusesValue4 = statusesArray4[loweredIndex16];
                      var instanceViewStatusInstance5 = {};
                      instanceViewInstance.statuses.push(instanceViewStatusInstance5);
                      
                      var codeValue6 = statusesValue4['code'];
                      if (codeValue6 !== null && codeValue6 !== undefined) {
                        var codeInstance6 = codeValue6;
                        instanceViewStatusInstance5.code = codeInstance6;
                      }
                      
                      var levelValue6 = statusesValue4['level'];
                      if (levelValue6 !== null && levelValue6 !== undefined) {
                        var levelInstance6 = levelValue6;
                        instanceViewStatusInstance5.level = levelInstance6;
                      }
                      
                      var displayStatusValue6 = statusesValue4['displayStatus'];
                      if (displayStatusValue6 !== null && displayStatusValue6 !== undefined) {
                        var displayStatusInstance6 = displayStatusValue6;
                        instanceViewStatusInstance5.displayStatus = displayStatusInstance6;
                      }
                      
                      var messageValue6 = statusesValue4['message'];
                      if (messageValue6 !== null && messageValue6 !== undefined) {
                        var messageInstance6 = messageValue6;
                        instanceViewStatusInstance5.message = messageInstance6;
                      }
                      
                      var timeValue6 = statusesValue4['time'];
                      if (timeValue6 !== null && timeValue6 !== undefined) {
                        var timeInstance6 = timeValue6;
                        instanceViewStatusInstance5.time = timeInstance6;
                      }
                    }
                  }
                }
              }
              
              var resourcesArray = valueValue['resources'];
              if (resourcesArray !== null && resourcesArray !== undefined) {
                virtualMachineJsonInstance.extensions = [];
                for (var loweredIndex17 = 0; loweredIndex17 < resourcesArray.length; loweredIndex17 = loweredIndex17 + 1) {
                  var resourcesValue = resourcesArray[loweredIndex17];
                  var virtualMachineExtensionJsonInstance = { tags: {} };
                  virtualMachineJsonInstance.extensions.push(virtualMachineExtensionJsonInstance);
                  
                  var propertiesValue3 = resourcesValue['properties'];
                  if (propertiesValue3 !== null && propertiesValue3 !== undefined) {
                    var publisherValue3 = propertiesValue3['publisher'];
                    if (publisherValue3 !== null && publisherValue3 !== undefined) {
                      var publisherInstance3 = publisherValue3;
                      virtualMachineExtensionJsonInstance.publisher = publisherInstance3;
                    }
                    
                    var typeValue3 = propertiesValue3['type'];
                    if (typeValue3 !== null && typeValue3 !== undefined) {
                      var typeInstance3 = typeValue3;
                      virtualMachineExtensionJsonInstance.extensionType = typeInstance3;
                    }
                    
                    var typeHandlerVersionValue3 = propertiesValue3['typeHandlerVersion'];
                    if (typeHandlerVersionValue3 !== null && typeHandlerVersionValue3 !== undefined) {
                      var typeHandlerVersionInstance3 = typeHandlerVersionValue3;
                      virtualMachineExtensionJsonInstance.typeHandlerVersion = typeHandlerVersionInstance3;
                    }
                    
                    var autoUpgradeMinorVersionValue = propertiesValue3['autoUpgradeMinorVersion'];
                    if (autoUpgradeMinorVersionValue !== null && autoUpgradeMinorVersionValue !== undefined) {
                      var autoUpgradeMinorVersionInstance = autoUpgradeMinorVersionValue;
                      virtualMachineExtensionJsonInstance.autoUpgradeMinorVersion = autoUpgradeMinorVersionInstance;
                    }
                    
                    var settingsValue = propertiesValue3['settings'];
                    if (settingsValue !== null && settingsValue !== undefined) {
                      var settingsInstance = settingsValue;
                      virtualMachineExtensionJsonInstance.settings = settingsInstance;
                    }
                    
                    var protectedSettingsValue = propertiesValue3['protectedSettings'];
                    if (protectedSettingsValue !== null && protectedSettingsValue !== undefined) {
                      var protectedSettingsInstance = protectedSettingsValue;
                      virtualMachineExtensionJsonInstance.protectedSettings = protectedSettingsInstance;
                    }
                    
                    var provisioningStateValue2 = propertiesValue3['provisioningState'];
                    if (provisioningStateValue2 !== null && provisioningStateValue2 !== undefined) {
                      var provisioningStateInstance2 = provisioningStateValue2;
                      virtualMachineExtensionJsonInstance.provisioningState = provisioningStateInstance2;
                    }
                    
                    var instanceViewValue2 = propertiesValue3['instanceView'];
                    if (instanceViewValue2 !== null && instanceViewValue2 !== undefined) {
                      var instanceViewInstance2 = { statuses: [], subStatuses: [] };
                      virtualMachineExtensionJsonInstance.instanceView = instanceViewInstance2;
                      
                      var nameValue6 = instanceViewValue2['name'];
                      if (nameValue6 !== null && nameValue6 !== undefined) {
                        var nameInstance6 = nameValue6;
                        instanceViewInstance2.name = nameInstance6;
                      }
                      
                      var typeValue4 = instanceViewValue2['type'];
                      if (typeValue4 !== null && typeValue4 !== undefined) {
                        var typeInstance4 = typeValue4;
                        instanceViewInstance2.extensionType = typeInstance4;
                      }
                      
                      var typeHandlerVersionValue4 = instanceViewValue2['typeHandlerVersion'];
                      if (typeHandlerVersionValue4 !== null && typeHandlerVersionValue4 !== undefined) {
                        var typeHandlerVersionInstance4 = typeHandlerVersionValue4;
                        instanceViewInstance2.typeHandlerVersion = typeHandlerVersionInstance4;
                      }
                      
                      var substatusesArray2 = instanceViewValue2['substatuses'];
                      if (substatusesArray2 !== null && substatusesArray2 !== undefined) {
                        for (var loweredIndex18 = 0; loweredIndex18 < substatusesArray2.length; loweredIndex18 = loweredIndex18 + 1) {
                          var substatusesValue2 = substatusesArray2[loweredIndex18];
                          var instanceViewStatusInstance6 = {};
                          instanceViewInstance2.subStatuses.push(instanceViewStatusInstance6);
                          
                          var codeValue7 = substatusesValue2['code'];
                          if (codeValue7 !== null && codeValue7 !== undefined) {
                            var codeInstance7 = codeValue7;
                            instanceViewStatusInstance6.code = codeInstance7;
                          }
                          
                          var levelValue7 = substatusesValue2['level'];
                          if (levelValue7 !== null && levelValue7 !== undefined) {
                            var levelInstance7 = levelValue7;
                            instanceViewStatusInstance6.level = levelInstance7;
                          }
                          
                          var displayStatusValue7 = substatusesValue2['displayStatus'];
                          if (displayStatusValue7 !== null && displayStatusValue7 !== undefined) {
                            var displayStatusInstance7 = displayStatusValue7;
                            instanceViewStatusInstance6.displayStatus = displayStatusInstance7;
                          }
                          
                          var messageValue7 = substatusesValue2['message'];
                          if (messageValue7 !== null && messageValue7 !== undefined) {
                            var messageInstance7 = messageValue7;
                            instanceViewStatusInstance6.message = messageInstance7;
                          }
                          
                          var timeValue7 = substatusesValue2['time'];
                          if (timeValue7 !== null && timeValue7 !== undefined) {
                            var timeInstance7 = timeValue7;
                            instanceViewStatusInstance6.time = timeInstance7;
                          }
                        }
                      }
                      
                      var statusesArray5 = instanceViewValue2['statuses'];
                      if (statusesArray5 !== null && statusesArray5 !== undefined) {
                        for (var loweredIndex19 = 0; loweredIndex19 < statusesArray5.length; loweredIndex19 = loweredIndex19 + 1) {
                          var statusesValue5 = statusesArray5[loweredIndex19];
                          var instanceViewStatusInstance7 = {};
                          instanceViewInstance2.statuses.push(instanceViewStatusInstance7);
                          
                          var codeValue8 = statusesValue5['code'];
                          if (codeValue8 !== null && codeValue8 !== undefined) {
                            var codeInstance8 = codeValue8;
                            instanceViewStatusInstance7.code = codeInstance8;
                          }
                          
                          var levelValue8 = statusesValue5['level'];
                          if (levelValue8 !== null && levelValue8 !== undefined) {
                            var levelInstance8 = levelValue8;
                            instanceViewStatusInstance7.level = levelInstance8;
                          }
                          
                          var displayStatusValue8 = statusesValue5['displayStatus'];
                          if (displayStatusValue8 !== null && displayStatusValue8 !== undefined) {
                            var displayStatusInstance8 = displayStatusValue8;
                            instanceViewStatusInstance7.displayStatus = displayStatusInstance8;
                          }
                          
                          var messageValue8 = statusesValue5['message'];
                          if (messageValue8 !== null && messageValue8 !== undefined) {
                            var messageInstance8 = messageValue8;
                            instanceViewStatusInstance7.message = messageInstance8;
                          }
                          
                          var timeValue8 = statusesValue5['time'];
                          if (timeValue8 !== null && timeValue8 !== undefined) {
                            var timeInstance8 = timeValue8;
                            instanceViewStatusInstance7.time = timeInstance8;
                          }
                        }
                      }
                    }
                  }
                  
                  var idValue6 = resourcesValue['id'];
                  if (idValue6 !== null && idValue6 !== undefined) {
                    var idInstance6 = idValue6;
                    virtualMachineExtensionJsonInstance.id = idInstance6;
                  }
                  
                  var nameValue7 = resourcesValue['name'];
                  if (nameValue7 !== null && nameValue7 !== undefined) {
                    var nameInstance7 = nameValue7;
                    virtualMachineExtensionJsonInstance.name = nameInstance7;
                  }
                  
                  var typeValue5 = resourcesValue['type'];
                  if (typeValue5 !== null && typeValue5 !== undefined) {
                    var typeInstance5 = typeValue5;
                    virtualMachineExtensionJsonInstance.type = typeInstance5;
                  }
                  
                  var locationValue = resourcesValue['location'];
                  if (locationValue !== null && locationValue !== undefined) {
                    var locationInstance = locationValue;
                    virtualMachineExtensionJsonInstance.location = locationInstance;
                  }
                  
                  var tagsSequenceElement = resourcesValue['tags'];
                  if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
                    for (var property in tagsSequenceElement) {
                      var tagsKey = property;
                      var tagsValue = tagsSequenceElement[property];
                      virtualMachineExtensionJsonInstance.tags[tagsKey] = tagsValue;
                    }
                  }
                }
              }
              
              var idValue7 = valueValue['id'];
              if (idValue7 !== null && idValue7 !== undefined) {
                var idInstance7 = idValue7;
                virtualMachineJsonInstance.id = idInstance7;
              }
              
              var nameValue8 = valueValue['name'];
              if (nameValue8 !== null && nameValue8 !== undefined) {
                var nameInstance8 = nameValue8;
                virtualMachineJsonInstance.name = nameInstance8;
              }
              
              var typeValue6 = valueValue['type'];
              if (typeValue6 !== null && typeValue6 !== undefined) {
                var typeInstance6 = typeValue6;
                virtualMachineJsonInstance.type = typeInstance6;
              }
              
              var locationValue2 = valueValue['location'];
              if (locationValue2 !== null && locationValue2 !== undefined) {
                var locationInstance2 = locationValue2;
                virtualMachineJsonInstance.location = locationInstance2;
              }
              
              var tagsSequenceElement2 = valueValue['tags'];
              if (tagsSequenceElement2 !== null && tagsSequenceElement2 !== undefined) {
                for (var property2 in tagsSequenceElement2) {
                  var tagsKey2 = property2;
                  var tagsValue2 = tagsSequenceElement2[property2];
                  virtualMachineJsonInstance.tags[tagsKey2] = tagsValue2;
                }
              }
            }
          }
          
          var nextLinkValue = responseDoc['nextLink'];
          if (nextLinkValue !== null && nextLinkValue !== undefined) {
            var nextLinkInstance = nextLinkValue;
            result.nextLink = nextLinkInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets the list of Virtual Machines in the subscription. Use nextLink
   * property in the response to get the next page of Virtual Machines. Do
   * this till nextLink is not null to fetch all the Virtual Machines.
   * 
   * @param {ListParameters} [parametersOrCallback]
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.listAll = function(parametersOrCallback, callback) {
    var parameters = parametersOrCallback;
    if (_.isFunction(parameters)) {
      callback = parameters;
      parameters = null;
    }
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/';
    url2 = url2 + 'virtualMachines';
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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['Content-Type'] = 'application/json';
    
    // 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 = { virtualMachines: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var valueArray = responseDoc['value'];
          if (valueArray !== null && valueArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var valueValue = valueArray[loweredIndex1];
              var virtualMachineJsonInstance = { extensions: [], tags: {} };
              result.virtualMachines.push(virtualMachineJsonInstance);
              
              var planValue = valueValue['plan'];
              if (planValue !== null && planValue !== undefined) {
                var planInstance = {};
                virtualMachineJsonInstance.plan = planInstance;
                
                var nameValue = planValue['name'];
                if (nameValue !== null && nameValue !== undefined) {
                  var nameInstance = nameValue;
                  planInstance.name = nameInstance;
                }
                
                var publisherValue = planValue['publisher'];
                if (publisherValue !== null && publisherValue !== undefined) {
                  var publisherInstance = publisherValue;
                  planInstance.publisher = publisherInstance;
                }
                
                var productValue = planValue['product'];
                if (productValue !== null && productValue !== undefined) {
                  var productInstance = productValue;
                  planInstance.product = productInstance;
                }
                
                var promotionCodeValue = planValue['promotionCode'];
                if (promotionCodeValue !== null && promotionCodeValue !== undefined) {
                  var promotionCodeInstance = promotionCodeValue;
                  planInstance.promotionCode = promotionCodeInstance;
                }
              }
              
              var propertiesValue = valueValue['properties'];
              if (propertiesValue !== null && propertiesValue !== undefined) {
                var hardwareProfileValue = propertiesValue['hardwareProfile'];
                if (hardwareProfileValue !== null && hardwareProfileValue !== undefined) {
                  var hardwareProfileInstance = {};
                  virtualMachineJsonInstance.hardwareProfile = hardwareProfileInstance;
                  
                  var vmSizeValue = hardwareProfileValue['vmSize'];
                  if (vmSizeValue !== null && vmSizeValue !== undefined) {
                    var vmSizeInstance = vmSizeValue;
                    hardwareProfileInstance.virtualMachineSize = vmSizeInstance;
                  }
                }
                
                var storageProfileValue = propertiesValue['storageProfile'];
                if (storageProfileValue !== null && storageProfileValue !== undefined) {
                  var storageProfileInstance = { dataDisks: [] };
                  virtualMachineJsonInstance.storageProfile = storageProfileInstance;
                  
                  var imageReferenceValue = storageProfileValue['imageReference'];
                  if (imageReferenceValue !== null && imageReferenceValue !== undefined) {
                    var imageReferenceInstance = {};
                    storageProfileInstance.imageReference = imageReferenceInstance;
                    
                    var publisherValue2 = imageReferenceValue['publisher'];
                    if (publisherValue2 !== null && publisherValue2 !== undefined) {
                      var publisherInstance2 = publisherValue2;
                      imageReferenceInstance.publisher = publisherInstance2;
                    }
                    
                    var offerValue = imageReferenceValue['offer'];
                    if (offerValue !== null && offerValue !== undefined) {
                      var offerInstance = offerValue;
                      imageReferenceInstance.offer = offerInstance;
                    }
                    
                    var skuValue = imageReferenceValue['sku'];
                    if (skuValue !== null && skuValue !== undefined) {
                      var skuInstance = skuValue;
                      imageReferenceInstance.sku = skuInstance;
                    }
                    
                    var versionValue = imageReferenceValue['version'];
                    if (versionValue !== null && versionValue !== undefined) {
                      var versionInstance = versionValue;
                      imageReferenceInstance.version = versionInstance;
                    }
                  }
                  
                  var osDiskValue = storageProfileValue['osDisk'];
                  if (osDiskValue !== null && osDiskValue !== undefined) {
                    var osDiskInstance = {};
                    storageProfileInstance.oSDisk = osDiskInstance;
                    
                    var osTypeValue = osDiskValue['osType'];
                    if (osTypeValue !== null && osTypeValue !== undefined) {
                      var osTypeInstance = osTypeValue;
                      osDiskInstance.operatingSystemType = osTypeInstance;
                    }
                    
                    var encryptionSettingsValue = osDiskValue['encryptionSettings'];
                    if (encryptionSettingsValue !== null && encryptionSettingsValue !== undefined) {
                      var encryptionSettingsInstance = {};
                      osDiskInstance.encryptionSettings = encryptionSettingsInstance;
                      
                      var diskEncryptionKeyValue = encryptionSettingsValue['diskEncryptionKey'];
                      if (diskEncryptionKeyValue !== null && diskEncryptionKeyValue !== undefined) {
                        var diskEncryptionKeyInstance = {};
                        encryptionSettingsInstance.diskEncryptionKey = diskEncryptionKeyInstance;
                        
                        var secretUrlValue = diskEncryptionKeyValue['secretUrl'];
                        if (secretUrlValue !== null && secretUrlValue !== undefined) {
                          var secretUrlInstance = secretUrlValue;
                          diskEncryptionKeyInstance.secretUrl = secretUrlInstance;
                        }
                        
                        var sourceVaultValue = diskEncryptionKeyValue['sourceVault'];
                        if (sourceVaultValue !== null && sourceVaultValue !== undefined) {
                          var sourceVaultInstance = {};
                          diskEncryptionKeyInstance.sourceVault = sourceVaultInstance;
                          
                          var idValue = sourceVaultValue['id'];
                          if (idValue !== null && idValue !== undefined) {
                            var idInstance = idValue;
                            sourceVaultInstance.referenceUri = idInstance;
                          }
                        }
                      }
                      
                      var keyEncryptionKeyValue = encryptionSettingsValue['keyEncryptionKey'];
                      if (keyEncryptionKeyValue !== null && keyEncryptionKeyValue !== undefined) {
                        var keyEncryptionKeyInstance = {};
                        encryptionSettingsInstance.keyEncryptionKey = keyEncryptionKeyInstance;
                        
                        var keyUrlValue = keyEncryptionKeyValue['keyUrl'];
                        if (keyUrlValue !== null && keyUrlValue !== undefined) {
                          var keyUrlInstance = keyUrlValue;
                          keyEncryptionKeyInstance.keyUrl = keyUrlInstance;
                        }
                        
                        var sourceVaultValue2 = keyEncryptionKeyValue['sourceVault'];
                        if (sourceVaultValue2 !== null && sourceVaultValue2 !== undefined) {
                          var sourceVaultInstance2 = {};
                          keyEncryptionKeyInstance.sourceVault = sourceVaultInstance2;
                          
                          var idValue2 = sourceVaultValue2['id'];
                          if (idValue2 !== null && idValue2 !== undefined) {
                            var idInstance2 = idValue2;
                            sourceVaultInstance2.referenceUri = idInstance2;
                          }
                        }
                      }
                    }
                    
                    var nameValue2 = osDiskValue['name'];
                    if (nameValue2 !== null && nameValue2 !== undefined) {
                      var nameInstance2 = nameValue2;
                      osDiskInstance.name = nameInstance2;
                    }
                    
                    var vhdValue = osDiskValue['vhd'];
                    if (vhdValue !== null && vhdValue !== undefined) {
                      var vhdInstance = {};
                      osDiskInstance.virtualHardDisk = vhdInstance;
                      
                      var uriValue = vhdValue['uri'];
                      if (uriValue !== null && uriValue !== undefined) {
                        var uriInstance = uriValue;
                        vhdInstance.uri = uriInstance;
                      }
                    }
                    
                    var imageValue = osDiskValue['image'];
                    if (imageValue !== null && imageValue !== undefined) {
                      var imageInstance = {};
                      osDiskInstance.sourceImage = imageInstance;
                      
                      var uriValue2 = imageValue['uri'];
                      if (uriValue2 !== null && uriValue2 !== undefined) {
                        var uriInstance2 = uriValue2;
                        imageInstance.uri = uriInstance2;
                      }
                    }
                    
                    var cachingValue = osDiskValue['caching'];
                    if (cachingValue !== null && cachingValue !== undefined) {
                      var cachingInstance = cachingValue;
                      osDiskInstance.caching = cachingInstance;
                    }
                    
                    var createOptionValue = osDiskValue['createOption'];
                    if (createOptionValue !== null && createOptionValue !== undefined) {
                      var createOptionInstance = createOptionValue;
                      osDiskInstance.createOption = createOptionInstance;
                    }
                    
                    var diskSizeGBValue = osDiskValue['diskSizeGB'];
                    if (diskSizeGBValue !== null && diskSizeGBValue !== undefined) {
                      var diskSizeGBInstance = diskSizeGBValue;
                      osDiskInstance.diskSizeGB = diskSizeGBInstance;
                    }
                  }
                  
                  var dataDisksArray = storageProfileValue['dataDisks'];
                  if (dataDisksArray !== null && dataDisksArray !== undefined) {
                    for (var loweredIndex2 = 0; loweredIndex2 < dataDisksArray.length; loweredIndex2 = loweredIndex2 + 1) {
                      var dataDisksValue = dataDisksArray[loweredIndex2];
                      var dataDiskInstance = {};
                      storageProfileInstance.dataDisks.push(dataDiskInstance);
                      
                      var lunValue = dataDisksValue['lun'];
                      if (lunValue !== null && lunValue !== undefined) {
                        var lunInstance = lunValue;
                        dataDiskInstance.lun = lunInstance;
                      }
                      
                      var nameValue3 = dataDisksValue['name'];
                      if (nameValue3 !== null && nameValue3 !== undefined) {
                        var nameInstance3 = nameValue3;
                        dataDiskInstance.name = nameInstance3;
                      }
                      
                      var vhdValue2 = dataDisksValue['vhd'];
                      if (vhdValue2 !== null && vhdValue2 !== undefined) {
                        var vhdInstance2 = {};
                        dataDiskInstance.virtualHardDisk = vhdInstance2;
                        
                        var uriValue3 = vhdValue2['uri'];
                        if (uriValue3 !== null && uriValue3 !== undefined) {
                          var uriInstance3 = uriValue3;
                          vhdInstance2.uri = uriInstance3;
                        }
                      }
                      
                      var imageValue2 = dataDisksValue['image'];
                      if (imageValue2 !== null && imageValue2 !== undefined) {
                        var imageInstance2 = {};
                        dataDiskInstance.sourceImage = imageInstance2;
                        
                        var uriValue4 = imageValue2['uri'];
                        if (uriValue4 !== null && uriValue4 !== undefined) {
                          var uriInstance4 = uriValue4;
                          imageInstance2.uri = uriInstance4;
                        }
                      }
                      
                      var cachingValue2 = dataDisksValue['caching'];
                      if (cachingValue2 !== null && cachingValue2 !== undefined) {
                        var cachingInstance2 = cachingValue2;
                        dataDiskInstance.caching = cachingInstance2;
                      }
                      
                      var createOptionValue2 = dataDisksValue['createOption'];
                      if (createOptionValue2 !== null && createOptionValue2 !== undefined) {
                        var createOptionInstance2 = createOptionValue2;
                        dataDiskInstance.createOption = createOptionInstance2;
                      }
                      
                      var diskSizeGBValue2 = dataDisksValue['diskSizeGB'];
                      if (diskSizeGBValue2 !== null && diskSizeGBValue2 !== undefined) {
                        var diskSizeGBInstance2 = diskSizeGBValue2;
                        dataDiskInstance.diskSizeGB = diskSizeGBInstance2;
                      }
                    }
                  }
                }
                
                var osProfileValue = propertiesValue['osProfile'];
                if (osProfileValue !== null && osProfileValue !== undefined) {
                  var osProfileInstance = { secrets: [] };
                  virtualMachineJsonInstance.oSProfile = osProfileInstance;
                  
                  var computerNameValue = osProfileValue['computerName'];
                  if (computerNameValue !== null && computerNameValue !== undefined) {
                    var computerNameInstance = computerNameValue;
                    osProfileInstance.computerName = computerNameInstance;
                  }
                  
                  var adminUsernameValue = osProfileValue['adminUsername'];
                  if (adminUsernameValue !== null && adminUsernameValue !== undefined) {
                    var adminUsernameInstance = adminUsernameValue;
                    osProfileInstance.adminUsername = adminUsernameInstance;
                  }
                  
                  var adminPasswordValue = osProfileValue['adminPassword'];
                  if (adminPasswordValue !== null && adminPasswordValue !== undefined) {
                    var adminPasswordInstance = adminPasswordValue;
                    osProfileInstance.adminPassword = adminPasswordInstance;
                  }
                  
                  var customDataValue = osProfileValue['customData'];
                  if (customDataValue !== null && customDataValue !== undefined) {
                    var customDataInstance = customDataValue;
                    osProfileInstance.customData = customDataInstance;
                  }
                  
                  var windowsConfigurationValue = osProfileValue['windowsConfiguration'];
                  if (windowsConfigurationValue !== null && windowsConfigurationValue !== undefined) {
                    var windowsConfigurationInstance = { additionalUnattendContents: [] };
                    osProfileInstance.windowsConfiguration = windowsConfigurationInstance;
                    
                    var provisionVMAgentValue = windowsConfigurationValue['provisionVMAgent'];
                    if (provisionVMAgentValue !== null && provisionVMAgentValue !== undefined) {
                      var provisionVMAgentInstance = provisionVMAgentValue;
                      windowsConfigurationInstance.provisionVMAgent = provisionVMAgentInstance;
                    }
                    
                    var enableAutomaticUpdatesValue = windowsConfigurationValue['enableAutomaticUpdates'];
                    if (enableAutomaticUpdatesValue !== null && enableAutomaticUpdatesValue !== undefined) {
                      var enableAutomaticUpdatesInstance = enableAutomaticUpdatesValue;
                      windowsConfigurationInstance.enableAutomaticUpdates = enableAutomaticUpdatesInstance;
                    }
                    
                    var timeZoneValue = windowsConfigurationValue['timeZone'];
                    if (timeZoneValue !== null && timeZoneValue !== undefined) {
                      var timeZoneInstance = timeZoneValue;
                      windowsConfigurationInstance.timeZone = timeZoneInstance;
                    }
                    
                    var additionalUnattendContentArray = windowsConfigurationValue['additionalUnattendContent'];
                    if (additionalUnattendContentArray !== null && additionalUnattendContentArray !== undefined) {
                      for (var loweredIndex3 = 0; loweredIndex3 < additionalUnattendContentArray.length; loweredIndex3 = loweredIndex3 + 1) {
                        var additionalUnattendContentValue = additionalUnattendContentArray[loweredIndex3];
                        var additionalUnattendContentInstance = {};
                        windowsConfigurationInstance.additionalUnattendContents.push(additionalUnattendContentInstance);
                        
                        var passNameValue = additionalUnattendContentValue['passName'];
                        if (passNameValue !== null && passNameValue !== undefined) {
                          var passNameInstance = passNameValue;
                          additionalUnattendContentInstance.passName = passNameInstance;
                        }
                        
                        var componentNameValue = additionalUnattendContentValue['componentName'];
                        if (componentNameValue !== null && componentNameValue !== undefined) {
                          var componentNameInstance = componentNameValue;
                          additionalUnattendContentInstance.componentName = componentNameInstance;
                        }
                        
                        var settingNameValue = additionalUnattendContentValue['settingName'];
                        if (settingNameValue !== null && settingNameValue !== undefined) {
                          var settingNameInstance = settingNameValue;
                          additionalUnattendContentInstance.settingName = settingNameInstance;
                        }
                        
                        var contentValue = additionalUnattendContentValue['content'];
                        if (contentValue !== null && contentValue !== undefined) {
                          var contentInstance = contentValue;
                          additionalUnattendContentInstance.content = contentInstance;
                        }
                      }
                    }
                    
                    var winRMValue = windowsConfigurationValue['winRM'];
                    if (winRMValue !== null && winRMValue !== undefined) {
                      var winRMInstance = { listeners: [] };
                      windowsConfigurationInstance.winRMConfiguration = winRMInstance;
                      
                      var listenersArray = winRMValue['listeners'];
                      if (listenersArray !== null && listenersArray !== undefined) {
                        for (var loweredIndex4 = 0; loweredIndex4 < listenersArray.length; loweredIndex4 = loweredIndex4 + 1) {
                          var listenersValue = listenersArray[loweredIndex4];
                          var winRMListenerInstance = {};
                          winRMInstance.listeners.push(winRMListenerInstance);
                          
                          var protocolValue = listenersValue['protocol'];
                          if (protocolValue !== null && protocolValue !== undefined) {
                            var protocolInstance = protocolValue;
                            winRMListenerInstance.protocol = protocolInstance;
                          }
                          
                          var certificateUrlValue = listenersValue['certificateUrl'];
                          if (certificateUrlValue !== null && certificateUrlValue !== undefined) {
                            var certificateUrlInstance = certificateUrlValue;
                            winRMListenerInstance.certificateUrl = certificateUrlInstance;
                          }
                        }
                      }
                    }
                  }
                  
                  var linuxConfigurationValue = osProfileValue['linuxConfiguration'];
                  if (linuxConfigurationValue !== null && linuxConfigurationValue !== undefined) {
                    var linuxConfigurationInstance = {};
                    osProfileInstance.linuxConfiguration = linuxConfigurationInstance;
                    
                    var disablePasswordAuthenticationValue = linuxConfigurationValue['disablePasswordAuthentication'];
                    if (disablePasswordAuthenticationValue !== null && disablePasswordAuthenticationValue !== undefined) {
                      var disablePasswordAuthenticationInstance = disablePasswordAuthenticationValue;
                      linuxConfigurationInstance.disablePasswordAuthentication = disablePasswordAuthenticationInstance;
                    }
                    
                    var sshValue = linuxConfigurationValue['ssh'];
                    if (sshValue !== null && sshValue !== undefined) {
                      var sshInstance = { publicKeys: [] };
                      linuxConfigurationInstance.sshConfiguration = sshInstance;
                      
                      var publicKeysArray = sshValue['publicKeys'];
                      if (publicKeysArray !== null && publicKeysArray !== undefined) {
                        for (var loweredIndex5 = 0; loweredIndex5 < publicKeysArray.length; loweredIndex5 = loweredIndex5 + 1) {
                          var publicKeysValue = publicKeysArray[loweredIndex5];
                          var sshPublicKeyInstance = {};
                          sshInstance.publicKeys.push(sshPublicKeyInstance);
                          
                          var pathValue = publicKeysValue['path'];
                          if (pathValue !== null && pathValue !== undefined) {
                            var pathInstance = pathValue;
                            sshPublicKeyInstance.path = pathInstance;
                          }
                          
                          var keyDataValue = publicKeysValue['keyData'];
                          if (keyDataValue !== null && keyDataValue !== undefined) {
                            var keyDataInstance = keyDataValue;
                            sshPublicKeyInstance.keyData = keyDataInstance;
                          }
                        }
                      }
                    }
                  }
                  
                  var secretsArray = osProfileValue['secrets'];
                  if (secretsArray !== null && secretsArray !== undefined) {
                    for (var loweredIndex6 = 0; loweredIndex6 < secretsArray.length; loweredIndex6 = loweredIndex6 + 1) {
                      var secretsValue = secretsArray[loweredIndex6];
                      var vaultSecretGroupInstance = { vaultCertificates: [] };
                      osProfileInstance.secrets.push(vaultSecretGroupInstance);
                      
                      var sourceVaultValue3 = secretsValue['sourceVault'];
                      if (sourceVaultValue3 !== null && sourceVaultValue3 !== undefined) {
                        var sourceVaultInstance3 = {};
                        vaultSecretGroupInstance.sourceVault = sourceVaultInstance3;
                        
                        var idValue3 = sourceVaultValue3['id'];
                        if (idValue3 !== null && idValue3 !== undefined) {
                          var idInstance3 = idValue3;
                          sourceVaultInstance3.referenceUri = idInstance3;
                        }
                      }
                      
                      var vaultCertificatesArray = secretsValue['vaultCertificates'];
                      if (vaultCertificatesArray !== null && vaultCertificatesArray !== undefined) {
                        for (var loweredIndex7 = 0; loweredIndex7 < vaultCertificatesArray.length; loweredIndex7 = loweredIndex7 + 1) {
                          var vaultCertificatesValue = vaultCertificatesArray[loweredIndex7];
                          var vaultCertificateInstance = {};
                          vaultSecretGroupInstance.vaultCertificates.push(vaultCertificateInstance);
                          
                          var certificateUrlValue2 = vaultCertificatesValue['certificateUrl'];
                          if (certificateUrlValue2 !== null && certificateUrlValue2 !== undefined) {
                            var certificateUrlInstance2 = certificateUrlValue2;
                            vaultCertificateInstance.certificateUrl = certificateUrlInstance2;
                          }
                          
                          var certificateStoreValue = vaultCertificatesValue['certificateStore'];
                          if (certificateStoreValue !== null && certificateStoreValue !== undefined) {
                            var certificateStoreInstance = certificateStoreValue;
                            vaultCertificateInstance.certificateStore = certificateStoreInstance;
                          }
                        }
                      }
                    }
                  }
                }
                
                var networkProfileValue = propertiesValue['networkProfile'];
                if (networkProfileValue !== null && networkProfileValue !== undefined) {
                  var networkProfileInstance = { networkInterfaces: [] };
                  virtualMachineJsonInstance.networkProfile = networkProfileInstance;
                  
                  var networkInterfacesArray = networkProfileValue['networkInterfaces'];
                  if (networkInterfacesArray !== null && networkInterfacesArray !== undefined) {
                    for (var loweredIndex8 = 0; loweredIndex8 < networkInterfacesArray.length; loweredIndex8 = loweredIndex8 + 1) {
                      var networkInterfacesValue = networkInterfacesArray[loweredIndex8];
                      var networkInterfaceReferenceJsonInstance = {};
                      networkProfileInstance.networkInterfaces.push(networkInterfaceReferenceJsonInstance);
                      
                      var propertiesValue2 = networkInterfacesValue['properties'];
                      if (propertiesValue2 !== null && propertiesValue2 !== undefined) {
                        var primaryValue = propertiesValue2['primary'];
                        if (primaryValue !== null && primaryValue !== undefined) {
                          var primaryInstance = primaryValue;
                          networkInterfaceReferenceJsonInstance.primary = primaryInstance;
                        }
                      }
                      
                      var idValue4 = networkInterfacesValue['id'];
                      if (idValue4 !== null && idValue4 !== undefined) {
                        var idInstance4 = idValue4;
                        networkInterfaceReferenceJsonInstance.referenceUri = idInstance4;
                      }
                    }
                  }
                }
                
                var diagnosticsProfileValue = propertiesValue['diagnosticsProfile'];
                if (diagnosticsProfileValue !== null && diagnosticsProfileValue !== undefined) {
                  var diagnosticsProfileInstance = {};
                  virtualMachineJsonInstance.diagnosticsProfile = diagnosticsProfileInstance;
                  
                  var bootDiagnosticsValue = diagnosticsProfileValue['bootDiagnostics'];
                  if (bootDiagnosticsValue !== null && bootDiagnosticsValue !== undefined) {
                    var bootDiagnosticsInstance = {};
                    diagnosticsProfileInstance.bootDiagnostics = bootDiagnosticsInstance;
                    
                    var enabledValue = bootDiagnosticsValue['enabled'];
                    if (enabledValue !== null && enabledValue !== undefined) {
                      var enabledInstance = enabledValue;
                      bootDiagnosticsInstance.enabled = enabledInstance;
                    }
                    
                    var storageUriValue = bootDiagnosticsValue['storageUri'];
                    if (storageUriValue !== null && storageUriValue !== undefined) {
                      var storageUriInstance = storageUriValue;
                      bootDiagnosticsInstance.storageUri = storageUriInstance;
                    }
                  }
                }
                
                var availabilitySetValue = propertiesValue['availabilitySet'];
                if (availabilitySetValue !== null && availabilitySetValue !== undefined) {
                  var availabilitySetInstance = {};
                  virtualMachineJsonInstance.availabilitySetReference = availabilitySetInstance;
                  
                  var idValue5 = availabilitySetValue['id'];
                  if (idValue5 !== null && idValue5 !== undefined) {
                    var idInstance5 = idValue5;
                    availabilitySetInstance.referenceUri = idInstance5;
                  }
                }
                
                var provisioningStateValue = propertiesValue['provisioningState'];
                if (provisioningStateValue !== null && provisioningStateValue !== undefined) {
                  var provisioningStateInstance = provisioningStateValue;
                  virtualMachineJsonInstance.provisioningState = provisioningStateInstance;
                }
                
                var instanceViewValue = propertiesValue['instanceView'];
                if (instanceViewValue !== null && instanceViewValue !== undefined) {
                  var instanceViewInstance = { disks: [], extensions: [], statuses: [] };
                  virtualMachineJsonInstance.instanceView = instanceViewInstance;
                  
                  var platformUpdateDomainValue = instanceViewValue['platformUpdateDomain'];
                  if (platformUpdateDomainValue !== null && platformUpdateDomainValue !== undefined) {
                    var platformUpdateDomainInstance = platformUpdateDomainValue;
                    instanceViewInstance.platformUpdateDomain = platformUpdateDomainInstance;
                  }
                  
                  var platformFaultDomainValue = instanceViewValue['platformFaultDomain'];
                  if (platformFaultDomainValue !== null && platformFaultDomainValue !== undefined) {
                    var platformFaultDomainInstance = platformFaultDomainValue;
                    instanceViewInstance.platformFaultDomain = platformFaultDomainInstance;
                  }
                  
                  var rdpThumbPrintValue = instanceViewValue['rdpThumbPrint'];
                  if (rdpThumbPrintValue !== null && rdpThumbPrintValue !== undefined) {
                    var rdpThumbPrintInstance = rdpThumbPrintValue;
                    instanceViewInstance.remoteDesktopThumbprint = rdpThumbPrintInstance;
                  }
                  
                  var vmAgentValue = instanceViewValue['vmAgent'];
                  if (vmAgentValue !== null && vmAgentValue !== undefined) {
                    var vmAgentInstance = { extensionHandlers: [], statuses: [] };
                    instanceViewInstance.vMAgent = vmAgentInstance;
                    
                    var vmAgentVersionValue = vmAgentValue['vmAgentVersion'];
                    if (vmAgentVersionValue !== null && vmAgentVersionValue !== undefined) {
                      var vmAgentVersionInstance = vmAgentVersionValue;
                      vmAgentInstance.vMAgentVersion = vmAgentVersionInstance;
                    }
                    
                    var extensionHandlersArray = vmAgentValue['extensionHandlers'];
                    if (extensionHandlersArray !== null && extensionHandlersArray !== undefined) {
                      for (var loweredIndex9 = 0; loweredIndex9 < extensionHandlersArray.length; loweredIndex9 = loweredIndex9 + 1) {
                        var extensionHandlersValue = extensionHandlersArray[loweredIndex9];
                        var virtualMachineExtensionHandlerInstanceViewInstance = {};
                        vmAgentInstance.extensionHandlers.push(virtualMachineExtensionHandlerInstanceViewInstance);
                        
                        var typeValue = extensionHandlersValue['type'];
                        if (typeValue !== null && typeValue !== undefined) {
                          var typeInstance = typeValue;
                          virtualMachineExtensionHandlerInstanceViewInstance.type = typeInstance;
                        }
                        
                        var typeHandlerVersionValue = extensionHandlersValue['typeHandlerVersion'];
                        if (typeHandlerVersionValue !== null && typeHandlerVersionValue !== undefined) {
                          var typeHandlerVersionInstance = typeHandlerVersionValue;
                          virtualMachineExtensionHandlerInstanceViewInstance.typeHandlerVersion = typeHandlerVersionInstance;
                        }
                        
                        var statusValue = extensionHandlersValue['status'];
                        if (statusValue !== null && statusValue !== undefined) {
                          var statusInstance = {};
                          virtualMachineExtensionHandlerInstanceViewInstance.status = statusInstance;
                          
                          var codeValue = statusValue['code'];
                          if (codeValue !== null && codeValue !== undefined) {
                            var codeInstance = codeValue;
                            statusInstance.code = codeInstance;
                          }
                          
                          var levelValue = statusValue['level'];
                          if (levelValue !== null && levelValue !== undefined) {
                            var levelInstance = levelValue;
                            statusInstance.level = levelInstance;
                          }
                          
                          var displayStatusValue = statusValue['displayStatus'];
                          if (displayStatusValue !== null && displayStatusValue !== undefined) {
                            var displayStatusInstance = displayStatusValue;
                            statusInstance.displayStatus = displayStatusInstance;
                          }
                          
                          var messageValue = statusValue['message'];
                          if (messageValue !== null && messageValue !== undefined) {
                            var messageInstance = messageValue;
                            statusInstance.message = messageInstance;
                          }
                          
                          var timeValue = statusValue['time'];
                          if (timeValue !== null && timeValue !== undefined) {
                            var timeInstance = timeValue;
                            statusInstance.time = timeInstance;
                          }
                        }
                      }
                    }
                    
                    var statusesArray = vmAgentValue['statuses'];
                    if (statusesArray !== null && statusesArray !== undefined) {
                      for (var loweredIndex10 = 0; loweredIndex10 < statusesArray.length; loweredIndex10 = loweredIndex10 + 1) {
                        var statusesValue = statusesArray[loweredIndex10];
                        var instanceViewStatusInstance = {};
                        vmAgentInstance.statuses.push(instanceViewStatusInstance);
                        
                        var codeValue2 = statusesValue['code'];
                        if (codeValue2 !== null && codeValue2 !== undefined) {
                          var codeInstance2 = codeValue2;
                          instanceViewStatusInstance.code = codeInstance2;
                        }
                        
                        var levelValue2 = statusesValue['level'];
                        if (levelValue2 !== null && levelValue2 !== undefined) {
                          var levelInstance2 = levelValue2;
                          instanceViewStatusInstance.level = levelInstance2;
                        }
                        
                        var displayStatusValue2 = statusesValue['displayStatus'];
                        if (displayStatusValue2 !== null && displayStatusValue2 !== undefined) {
                          var displayStatusInstance2 = displayStatusValue2;
                          instanceViewStatusInstance.displayStatus = displayStatusInstance2;
                        }
                        
                        var messageValue2 = statusesValue['message'];
                        if (messageValue2 !== null && messageValue2 !== undefined) {
                          var messageInstance2 = messageValue2;
                          instanceViewStatusInstance.message = messageInstance2;
                        }
                        
                        var timeValue2 = statusesValue['time'];
                        if (timeValue2 !== null && timeValue2 !== undefined) {
                          var timeInstance2 = timeValue2;
                          instanceViewStatusInstance.time = timeInstance2;
                        }
                      }
                    }
                  }
                  
                  var disksArray = instanceViewValue['disks'];
                  if (disksArray !== null && disksArray !== undefined) {
                    for (var loweredIndex11 = 0; loweredIndex11 < disksArray.length; loweredIndex11 = loweredIndex11 + 1) {
                      var disksValue = disksArray[loweredIndex11];
                      var diskInstanceViewInstance = { statuses: [] };
                      instanceViewInstance.disks.push(diskInstanceViewInstance);
                      
                      var nameValue4 = disksValue['name'];
                      if (nameValue4 !== null && nameValue4 !== undefined) {
                        var nameInstance4 = nameValue4;
                        diskInstanceViewInstance.name = nameInstance4;
                      }
                      
                      var statusesArray2 = disksValue['statuses'];
                      if (statusesArray2 !== null && statusesArray2 !== undefined) {
                        for (var loweredIndex12 = 0; loweredIndex12 < statusesArray2.length; loweredIndex12 = loweredIndex12 + 1) {
                          var statusesValue2 = statusesArray2[loweredIndex12];
                          var instanceViewStatusInstance2 = {};
                          diskInstanceViewInstance.statuses.push(instanceViewStatusInstance2);
                          
                          var codeValue3 = statusesValue2['code'];
                          if (codeValue3 !== null && codeValue3 !== undefined) {
                            var codeInstance3 = codeValue3;
                            instanceViewStatusInstance2.code = codeInstance3;
                          }
                          
                          var levelValue3 = statusesValue2['level'];
                          if (levelValue3 !== null && levelValue3 !== undefined) {
                            var levelInstance3 = levelValue3;
                            instanceViewStatusInstance2.level = levelInstance3;
                          }
                          
                          var displayStatusValue3 = statusesValue2['displayStatus'];
                          if (displayStatusValue3 !== null && displayStatusValue3 !== undefined) {
                            var displayStatusInstance3 = displayStatusValue3;
                            instanceViewStatusInstance2.displayStatus = displayStatusInstance3;
                          }
                          
                          var messageValue3 = statusesValue2['message'];
                          if (messageValue3 !== null && messageValue3 !== undefined) {
                            var messageInstance3 = messageValue3;
                            instanceViewStatusInstance2.message = messageInstance3;
                          }
                          
                          var timeValue3 = statusesValue2['time'];
                          if (timeValue3 !== null && timeValue3 !== undefined) {
                            var timeInstance3 = timeValue3;
                            instanceViewStatusInstance2.time = timeInstance3;
                          }
                        }
                      }
                    }
                  }
                  
                  var extensionsArray = instanceViewValue['extensions'];
                  if (extensionsArray !== null && extensionsArray !== undefined) {
                    for (var loweredIndex13 = 0; loweredIndex13 < extensionsArray.length; loweredIndex13 = loweredIndex13 + 1) {
                      var extensionsValue = extensionsArray[loweredIndex13];
                      var virtualMachineExtensionInstanceViewInstance = { statuses: [], subStatuses: [] };
                      instanceViewInstance.extensions.push(virtualMachineExtensionInstanceViewInstance);
                      
                      var nameValue5 = extensionsValue['name'];
                      if (nameValue5 !== null && nameValue5 !== undefined) {
                        var nameInstance5 = nameValue5;
                        virtualMachineExtensionInstanceViewInstance.name = nameInstance5;
                      }
                      
                      var typeValue2 = extensionsValue['type'];
                      if (typeValue2 !== null && typeValue2 !== undefined) {
                        var typeInstance2 = typeValue2;
                        virtualMachineExtensionInstanceViewInstance.extensionType = typeInstance2;
                      }
                      
                      var typeHandlerVersionValue2 = extensionsValue['typeHandlerVersion'];
                      if (typeHandlerVersionValue2 !== null && typeHandlerVersionValue2 !== undefined) {
                        var typeHandlerVersionInstance2 = typeHandlerVersionValue2;
                        virtualMachineExtensionInstanceViewInstance.typeHandlerVersion = typeHandlerVersionInstance2;
                      }
                      
                      var substatusesArray = extensionsValue['substatuses'];
                      if (substatusesArray !== null && substatusesArray !== undefined) {
                        for (var loweredIndex14 = 0; loweredIndex14 < substatusesArray.length; loweredIndex14 = loweredIndex14 + 1) {
                          var substatusesValue = substatusesArray[loweredIndex14];
                          var instanceViewStatusInstance3 = {};
                          virtualMachineExtensionInstanceViewInstance.subStatuses.push(instanceViewStatusInstance3);
                          
                          var codeValue4 = substatusesValue['code'];
                          if (codeValue4 !== null && codeValue4 !== undefined) {
                            var codeInstance4 = codeValue4;
                            instanceViewStatusInstance3.code = codeInstance4;
                          }
                          
                          var levelValue4 = substatusesValue['level'];
                          if (levelValue4 !== null && levelValue4 !== undefined) {
                            var levelInstance4 = levelValue4;
                            instanceViewStatusInstance3.level = levelInstance4;
                          }
                          
                          var displayStatusValue4 = substatusesValue['displayStatus'];
                          if (displayStatusValue4 !== null && displayStatusValue4 !== undefined) {
                            var displayStatusInstance4 = displayStatusValue4;
                            instanceViewStatusInstance3.displayStatus = displayStatusInstance4;
                          }
                          
                          var messageValue4 = substatusesValue['message'];
                          if (messageValue4 !== null && messageValue4 !== undefined) {
                            var messageInstance4 = messageValue4;
                            instanceViewStatusInstance3.message = messageInstance4;
                          }
                          
                          var timeValue4 = substatusesValue['time'];
                          if (timeValue4 !== null && timeValue4 !== undefined) {
                            var timeInstance4 = timeValue4;
                            instanceViewStatusInstance3.time = timeInstance4;
                          }
                        }
                      }
                      
                      var statusesArray3 = extensionsValue['statuses'];
                      if (statusesArray3 !== null && statusesArray3 !== undefined) {
                        for (var loweredIndex15 = 0; loweredIndex15 < statusesArray3.length; loweredIndex15 = loweredIndex15 + 1) {
                          var statusesValue3 = statusesArray3[loweredIndex15];
                          var instanceViewStatusInstance4 = {};
                          virtualMachineExtensionInstanceViewInstance.statuses.push(instanceViewStatusInstance4);
                          
                          var codeValue5 = statusesValue3['code'];
                          if (codeValue5 !== null && codeValue5 !== undefined) {
                            var codeInstance5 = codeValue5;
                            instanceViewStatusInstance4.code = codeInstance5;
                          }
                          
                          var levelValue5 = statusesValue3['level'];
                          if (levelValue5 !== null && levelValue5 !== undefined) {
                            var levelInstance5 = levelValue5;
                            instanceViewStatusInstance4.level = levelInstance5;
                          }
                          
                          var displayStatusValue5 = statusesValue3['displayStatus'];
                          if (displayStatusValue5 !== null && displayStatusValue5 !== undefined) {
                            var displayStatusInstance5 = displayStatusValue5;
                            instanceViewStatusInstance4.displayStatus = displayStatusInstance5;
                          }
                          
                          var messageValue5 = statusesValue3['message'];
                          if (messageValue5 !== null && messageValue5 !== undefined) {
                            var messageInstance5 = messageValue5;
                            instanceViewStatusInstance4.message = messageInstance5;
                          }
                          
                          var timeValue5 = statusesValue3['time'];
                          if (timeValue5 !== null && timeValue5 !== undefined) {
                            var timeInstance5 = timeValue5;
                            instanceViewStatusInstance4.time = timeInstance5;
                          }
                        }
                      }
                    }
                  }
                  
                  var bootDiagnosticsValue2 = instanceViewValue['bootDiagnostics'];
                  if (bootDiagnosticsValue2 !== null && bootDiagnosticsValue2 !== undefined) {
                    var bootDiagnosticsInstance2 = {};
                    instanceViewInstance.bootDiagnostics = bootDiagnosticsInstance2;
                    
                    var consoleScreenshotBlobUriValue = bootDiagnosticsValue2['consoleScreenshotBlobUri'];
                    if (consoleScreenshotBlobUriValue !== null && consoleScreenshotBlobUriValue !== undefined) {
                      var consoleScreenshotBlobUriInstance = consoleScreenshotBlobUriValue;
                      bootDiagnosticsInstance2.consoleScreenshotBlobUri = consoleScreenshotBlobUriInstance;
                    }
                    
                    var serialConsoleLogBlobUriValue = bootDiagnosticsValue2['serialConsoleLogBlobUri'];
                    if (serialConsoleLogBlobUriValue !== null && serialConsoleLogBlobUriValue !== undefined) {
                      var serialConsoleLogBlobUriInstance = serialConsoleLogBlobUriValue;
                      bootDiagnosticsInstance2.serialConsoleLogBlobUri = serialConsoleLogBlobUriInstance;
                    }
                  }
                  
                  var statusesArray4 = instanceViewValue['statuses'];
                  if (statusesArray4 !== null && statusesArray4 !== undefined) {
                    for (var loweredIndex16 = 0; loweredIndex16 < statusesArray4.length; loweredIndex16 = loweredIndex16 + 1) {
                      var statusesValue4 = statusesArray4[loweredIndex16];
                      var instanceViewStatusInstance5 = {};
                      instanceViewInstance.statuses.push(instanceViewStatusInstance5);
                      
                      var codeValue6 = statusesValue4['code'];
                      if (codeValue6 !== null && codeValue6 !== undefined) {
                        var codeInstance6 = codeValue6;
                        instanceViewStatusInstance5.code = codeInstance6;
                      }
                      
                      var levelValue6 = statusesValue4['level'];
                      if (levelValue6 !== null && levelValue6 !== undefined) {
                        var levelInstance6 = levelValue6;
                        instanceViewStatusInstance5.level = levelInstance6;
                      }
                      
                      var displayStatusValue6 = statusesValue4['displayStatus'];
                      if (displayStatusValue6 !== null && displayStatusValue6 !== undefined) {
                        var displayStatusInstance6 = displayStatusValue6;
                        instanceViewStatusInstance5.displayStatus = displayStatusInstance6;
                      }
                      
                      var messageValue6 = statusesValue4['message'];
                      if (messageValue6 !== null && messageValue6 !== undefined) {
                        var messageInstance6 = messageValue6;
                        instanceViewStatusInstance5.message = messageInstance6;
                      }
                      
                      var timeValue6 = statusesValue4['time'];
                      if (timeValue6 !== null && timeValue6 !== undefined) {
                        var timeInstance6 = timeValue6;
                        instanceViewStatusInstance5.time = timeInstance6;
                      }
                    }
                  }
                }
              }
              
              var resourcesArray = valueValue['resources'];
              if (resourcesArray !== null && resourcesArray !== undefined) {
                virtualMachineJsonInstance.extensions = [];
                for (var loweredIndex17 = 0; loweredIndex17 < resourcesArray.length; loweredIndex17 = loweredIndex17 + 1) {
                  var resourcesValue = resourcesArray[loweredIndex17];
                  var virtualMachineExtensionJsonInstance = { tags: {} };
                  virtualMachineJsonInstance.extensions.push(virtualMachineExtensionJsonInstance);
                  
                  var propertiesValue3 = resourcesValue['properties'];
                  if (propertiesValue3 !== null && propertiesValue3 !== undefined) {
                    var publisherValue3 = propertiesValue3['publisher'];
                    if (publisherValue3 !== null && publisherValue3 !== undefined) {
                      var publisherInstance3 = publisherValue3;
                      virtualMachineExtensionJsonInstance.publisher = publisherInstance3;
                    }
                    
                    var typeValue3 = propertiesValue3['type'];
                    if (typeValue3 !== null && typeValue3 !== undefined) {
                      var typeInstance3 = typeValue3;
                      virtualMachineExtensionJsonInstance.extensionType = typeInstance3;
                    }
                    
                    var typeHandlerVersionValue3 = propertiesValue3['typeHandlerVersion'];
                    if (typeHandlerVersionValue3 !== null && typeHandlerVersionValue3 !== undefined) {
                      var typeHandlerVersionInstance3 = typeHandlerVersionValue3;
                      virtualMachineExtensionJsonInstance.typeHandlerVersion = typeHandlerVersionInstance3;
                    }
                    
                    var autoUpgradeMinorVersionValue = propertiesValue3['autoUpgradeMinorVersion'];
                    if (autoUpgradeMinorVersionValue !== null && autoUpgradeMinorVersionValue !== undefined) {
                      var autoUpgradeMinorVersionInstance = autoUpgradeMinorVersionValue;
                      virtualMachineExtensionJsonInstance.autoUpgradeMinorVersion = autoUpgradeMinorVersionInstance;
                    }
                    
                    var settingsValue = propertiesValue3['settings'];
                    if (settingsValue !== null && settingsValue !== undefined) {
                      var settingsInstance = settingsValue;
                      virtualMachineExtensionJsonInstance.settings = settingsInstance;
                    }
                    
                    var protectedSettingsValue = propertiesValue3['protectedSettings'];
                    if (protectedSettingsValue !== null && protectedSettingsValue !== undefined) {
                      var protectedSettingsInstance = protectedSettingsValue;
                      virtualMachineExtensionJsonInstance.protectedSettings = protectedSettingsInstance;
                    }
                    
                    var provisioningStateValue2 = propertiesValue3['provisioningState'];
                    if (provisioningStateValue2 !== null && provisioningStateValue2 !== undefined) {
                      var provisioningStateInstance2 = provisioningStateValue2;
                      virtualMachineExtensionJsonInstance.provisioningState = provisioningStateInstance2;
                    }
                    
                    var instanceViewValue2 = propertiesValue3['instanceView'];
                    if (instanceViewValue2 !== null && instanceViewValue2 !== undefined) {
                      var instanceViewInstance2 = { statuses: [], subStatuses: [] };
                      virtualMachineExtensionJsonInstance.instanceView = instanceViewInstance2;
                      
                      var nameValue6 = instanceViewValue2['name'];
                      if (nameValue6 !== null && nameValue6 !== undefined) {
                        var nameInstance6 = nameValue6;
                        instanceViewInstance2.name = nameInstance6;
                      }
                      
                      var typeValue4 = instanceViewValue2['type'];
                      if (typeValue4 !== null && typeValue4 !== undefined) {
                        var typeInstance4 = typeValue4;
                        instanceViewInstance2.extensionType = typeInstance4;
                      }
                      
                      var typeHandlerVersionValue4 = instanceViewValue2['typeHandlerVersion'];
                      if (typeHandlerVersionValue4 !== null && typeHandlerVersionValue4 !== undefined) {
                        var typeHandlerVersionInstance4 = typeHandlerVersionValue4;
                        instanceViewInstance2.typeHandlerVersion = typeHandlerVersionInstance4;
                      }
                      
                      var substatusesArray2 = instanceViewValue2['substatuses'];
                      if (substatusesArray2 !== null && substatusesArray2 !== undefined) {
                        for (var loweredIndex18 = 0; loweredIndex18 < substatusesArray2.length; loweredIndex18 = loweredIndex18 + 1) {
                          var substatusesValue2 = substatusesArray2[loweredIndex18];
                          var instanceViewStatusInstance6 = {};
                          instanceViewInstance2.subStatuses.push(instanceViewStatusInstance6);
                          
                          var codeValue7 = substatusesValue2['code'];
                          if (codeValue7 !== null && codeValue7 !== undefined) {
                            var codeInstance7 = codeValue7;
                            instanceViewStatusInstance6.code = codeInstance7;
                          }
                          
                          var levelValue7 = substatusesValue2['level'];
                          if (levelValue7 !== null && levelValue7 !== undefined) {
                            var levelInstance7 = levelValue7;
                            instanceViewStatusInstance6.level = levelInstance7;
                          }
                          
                          var displayStatusValue7 = substatusesValue2['displayStatus'];
                          if (displayStatusValue7 !== null && displayStatusValue7 !== undefined) {
                            var displayStatusInstance7 = displayStatusValue7;
                            instanceViewStatusInstance6.displayStatus = displayStatusInstance7;
                          }
                          
                          var messageValue7 = substatusesValue2['message'];
                          if (messageValue7 !== null && messageValue7 !== undefined) {
                            var messageInstance7 = messageValue7;
                            instanceViewStatusInstance6.message = messageInstance7;
                          }
                          
                          var timeValue7 = substatusesValue2['time'];
                          if (timeValue7 !== null && timeValue7 !== undefined) {
                            var timeInstance7 = timeValue7;
                            instanceViewStatusInstance6.time = timeInstance7;
                          }
                        }
                      }
                      
                      var statusesArray5 = instanceViewValue2['statuses'];
                      if (statusesArray5 !== null && statusesArray5 !== undefined) {
                        for (var loweredIndex19 = 0; loweredIndex19 < statusesArray5.length; loweredIndex19 = loweredIndex19 + 1) {
                          var statusesValue5 = statusesArray5[loweredIndex19];
                          var instanceViewStatusInstance7 = {};
                          instanceViewInstance2.statuses.push(instanceViewStatusInstance7);
                          
                          var codeValue8 = statusesValue5['code'];
                          if (codeValue8 !== null && codeValue8 !== undefined) {
                            var codeInstance8 = codeValue8;
                            instanceViewStatusInstance7.code = codeInstance8;
                          }
                          
                          var levelValue8 = statusesValue5['level'];
                          if (levelValue8 !== null && levelValue8 !== undefined) {
                            var levelInstance8 = levelValue8;
                            instanceViewStatusInstance7.level = levelInstance8;
                          }
                          
                          var displayStatusValue8 = statusesValue5['displayStatus'];
                          if (displayStatusValue8 !== null && displayStatusValue8 !== undefined) {
                            var displayStatusInstance8 = displayStatusValue8;
                            instanceViewStatusInstance7.displayStatus = displayStatusInstance8;
                          }
                          
                          var messageValue8 = statusesValue5['message'];
                          if (messageValue8 !== null && messageValue8 !== undefined) {
                            var messageInstance8 = messageValue8;
                            instanceViewStatusInstance7.message = messageInstance8;
                          }
                          
                          var timeValue8 = statusesValue5['time'];
                          if (timeValue8 !== null && timeValue8 !== undefined) {
                            var timeInstance8 = timeValue8;
                            instanceViewStatusInstance7.time = timeInstance8;
                          }
                        }
                      }
                    }
                  }
                  
                  var idValue6 = resourcesValue['id'];
                  if (idValue6 !== null && idValue6 !== undefined) {
                    var idInstance6 = idValue6;
                    virtualMachineExtensionJsonInstance.id = idInstance6;
                  }
                  
                  var nameValue7 = resourcesValue['name'];
                  if (nameValue7 !== null && nameValue7 !== undefined) {
                    var nameInstance7 = nameValue7;
                    virtualMachineExtensionJsonInstance.name = nameInstance7;
                  }
                  
                  var typeValue5 = resourcesValue['type'];
                  if (typeValue5 !== null && typeValue5 !== undefined) {
                    var typeInstance5 = typeValue5;
                    virtualMachineExtensionJsonInstance.type = typeInstance5;
                  }
                  
                  var locationValue = resourcesValue['location'];
                  if (locationValue !== null && locationValue !== undefined) {
                    var locationInstance = locationValue;
                    virtualMachineExtensionJsonInstance.location = locationInstance;
                  }
                  
                  var tagsSequenceElement = resourcesValue['tags'];
                  if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
                    for (var property in tagsSequenceElement) {
                      var tagsKey = property;
                      var tagsValue = tagsSequenceElement[property];
                      virtualMachineExtensionJsonInstance.tags[tagsKey] = tagsValue;
                    }
                  }
                }
              }
              
              var idValue7 = valueValue['id'];
              if (idValue7 !== null && idValue7 !== undefined) {
                var idInstance7 = idValue7;
                virtualMachineJsonInstance.id = idInstance7;
              }
              
              var nameValue8 = valueValue['name'];
              if (nameValue8 !== null && nameValue8 !== undefined) {
                var nameInstance8 = nameValue8;
                virtualMachineJsonInstance.name = nameInstance8;
              }
              
              var typeValue6 = valueValue['type'];
              if (typeValue6 !== null && typeValue6 !== undefined) {
                var typeInstance6 = typeValue6;
                virtualMachineJsonInstance.type = typeInstance6;
              }
              
              var locationValue2 = valueValue['location'];
              if (locationValue2 !== null && locationValue2 !== undefined) {
                var locationInstance2 = locationValue2;
                virtualMachineJsonInstance.location = locationInstance2;
              }
              
              var tagsSequenceElement2 = valueValue['tags'];
              if (tagsSequenceElement2 !== null && tagsSequenceElement2 !== undefined) {
                for (var property2 in tagsSequenceElement2) {
                  var tagsKey2 = property2;
                  var tagsValue2 = tagsSequenceElement2[property2];
                  virtualMachineJsonInstance.tags[tagsKey2] = tagsValue2;
                }
              }
            }
          }
          
          var nextLinkValue = responseDoc['nextLink'];
          if (nextLinkValue !== null && nextLinkValue !== undefined) {
            var nextLinkInstance = nextLinkValue;
            result.nextLink = nextLinkInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Lists virtual-machine-sizes available to be used for a virtual machine.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} vmName The name of the virtual machine.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.listAvailableSizes = function(resourceGroupName, vmName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (vmName === null || vmName === undefined) {
      return callback(new Error('vmName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/';
    url2 = url2 + 'virtualMachines';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(vmName);
    url2 = url2 + '/vmSizes';
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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['Content-Type'] = 'application/json';
    
    // 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 = { virtualMachineSizes: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var valueArray = responseDoc['value'];
          if (valueArray !== null && valueArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var valueValue = valueArray[loweredIndex1];
              var virtualMachineSizeInstance = {};
              result.virtualMachineSizes.push(virtualMachineSizeInstance);
              
              var nameValue = valueValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                virtualMachineSizeInstance.name = nameInstance;
              }
              
              var numberOfCoresValue = valueValue['numberOfCores'];
              if (numberOfCoresValue !== null && numberOfCoresValue !== undefined) {
                var numberOfCoresInstance = numberOfCoresValue;
                virtualMachineSizeInstance.numberOfCores = numberOfCoresInstance;
              }
              
              var osDiskSizeInMBValue = valueValue['osDiskSizeInMB'];
              if (osDiskSizeInMBValue !== null && osDiskSizeInMBValue !== undefined) {
                var osDiskSizeInMBInstance = osDiskSizeInMBValue;
                virtualMachineSizeInstance.oSDiskSizeInMB = osDiskSizeInMBInstance;
              }
              
              var resourceDiskSizeInMBValue = valueValue['resourceDiskSizeInMB'];
              if (resourceDiskSizeInMBValue !== null && resourceDiskSizeInMBValue !== undefined) {
                var resourceDiskSizeInMBInstance = resourceDiskSizeInMBValue;
                virtualMachineSizeInstance.resourceDiskSizeInMB = resourceDiskSizeInMBInstance;
              }
              
              var memoryInMBValue = valueValue['memoryInMB'];
              if (memoryInMBValue !== null && memoryInMBValue !== undefined) {
                var memoryInMBInstance = memoryInMBValue;
                virtualMachineSizeInstance.memoryInMB = memoryInMBInstance;
              }
              
              var maxDataDiskCountValue = valueValue['maxDataDiskCount'];
              if (maxDataDiskCountValue !== null && maxDataDiskCountValue !== undefined) {
                var maxDataDiskCountInstance = maxDataDiskCountValue;
                virtualMachineSizeInstance.maxDataDiskCount = maxDataDiskCountInstance;
              }
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets the next page of Virtual Machines. NextLink is obtained by making a
   * ListAll() callwhich fetches the first page of Virtual Machines and a link
   * to fetch the next page.
   * 
   * @param {string} nextLink NextLink from the previous successful call to
   * ListVirtualMachines operation.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.listNext = function(nextLink, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (nextLink === null || nextLink === undefined) {
      return callback(new Error('nextLink cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + nextLink;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // 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 = { virtualMachines: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var valueArray = responseDoc['value'];
          if (valueArray !== null && valueArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var valueValue = valueArray[loweredIndex1];
              var virtualMachineJsonInstance = { extensions: [], tags: {} };
              result.virtualMachines.push(virtualMachineJsonInstance);
              
              var planValue = valueValue['plan'];
              if (planValue !== null && planValue !== undefined) {
                var planInstance = {};
                virtualMachineJsonInstance.plan = planInstance;
                
                var nameValue = planValue['name'];
                if (nameValue !== null && nameValue !== undefined) {
                  var nameInstance = nameValue;
                  planInstance.name = nameInstance;
                }
                
                var publisherValue = planValue['publisher'];
                if (publisherValue !== null && publisherValue !== undefined) {
                  var publisherInstance = publisherValue;
                  planInstance.publisher = publisherInstance;
                }
                
                var productValue = planValue['product'];
                if (productValue !== null && productValue !== undefined) {
                  var productInstance = productValue;
                  planInstance.product = productInstance;
                }
                
                var promotionCodeValue = planValue['promotionCode'];
                if (promotionCodeValue !== null && promotionCodeValue !== undefined) {
                  var promotionCodeInstance = promotionCodeValue;
                  planInstance.promotionCode = promotionCodeInstance;
                }
              }
              
              var propertiesValue = valueValue['properties'];
              if (propertiesValue !== null && propertiesValue !== undefined) {
                var hardwareProfileValue = propertiesValue['hardwareProfile'];
                if (hardwareProfileValue !== null && hardwareProfileValue !== undefined) {
                  var hardwareProfileInstance = {};
                  virtualMachineJsonInstance.hardwareProfile = hardwareProfileInstance;
                  
                  var vmSizeValue = hardwareProfileValue['vmSize'];
                  if (vmSizeValue !== null && vmSizeValue !== undefined) {
                    var vmSizeInstance = vmSizeValue;
                    hardwareProfileInstance.virtualMachineSize = vmSizeInstance;
                  }
                }
                
                var storageProfileValue = propertiesValue['storageProfile'];
                if (storageProfileValue !== null && storageProfileValue !== undefined) {
                  var storageProfileInstance = { dataDisks: [] };
                  virtualMachineJsonInstance.storageProfile = storageProfileInstance;
                  
                  var imageReferenceValue = storageProfileValue['imageReference'];
                  if (imageReferenceValue !== null && imageReferenceValue !== undefined) {
                    var imageReferenceInstance = {};
                    storageProfileInstance.imageReference = imageReferenceInstance;
                    
                    var publisherValue2 = imageReferenceValue['publisher'];
                    if (publisherValue2 !== null && publisherValue2 !== undefined) {
                      var publisherInstance2 = publisherValue2;
                      imageReferenceInstance.publisher = publisherInstance2;
                    }
                    
                    var offerValue = imageReferenceValue['offer'];
                    if (offerValue !== null && offerValue !== undefined) {
                      var offerInstance = offerValue;
                      imageReferenceInstance.offer = offerInstance;
                    }
                    
                    var skuValue = imageReferenceValue['sku'];
                    if (skuValue !== null && skuValue !== undefined) {
                      var skuInstance = skuValue;
                      imageReferenceInstance.sku = skuInstance;
                    }
                    
                    var versionValue = imageReferenceValue['version'];
                    if (versionValue !== null && versionValue !== undefined) {
                      var versionInstance = versionValue;
                      imageReferenceInstance.version = versionInstance;
                    }
                  }
                  
                  var osDiskValue = storageProfileValue['osDisk'];
                  if (osDiskValue !== null && osDiskValue !== undefined) {
                    var osDiskInstance = {};
                    storageProfileInstance.oSDisk = osDiskInstance;
                    
                    var osTypeValue = osDiskValue['osType'];
                    if (osTypeValue !== null && osTypeValue !== undefined) {
                      var osTypeInstance = osTypeValue;
                      osDiskInstance.operatingSystemType = osTypeInstance;
                    }
                    
                    var encryptionSettingsValue = osDiskValue['encryptionSettings'];
                    if (encryptionSettingsValue !== null && encryptionSettingsValue !== undefined) {
                      var encryptionSettingsInstance = {};
                      osDiskInstance.encryptionSettings = encryptionSettingsInstance;
                      
                      var diskEncryptionKeyValue = encryptionSettingsValue['diskEncryptionKey'];
                      if (diskEncryptionKeyValue !== null && diskEncryptionKeyValue !== undefined) {
                        var diskEncryptionKeyInstance = {};
                        encryptionSettingsInstance.diskEncryptionKey = diskEncryptionKeyInstance;
                        
                        var secretUrlValue = diskEncryptionKeyValue['secretUrl'];
                        if (secretUrlValue !== null && secretUrlValue !== undefined) {
                          var secretUrlInstance = secretUrlValue;
                          diskEncryptionKeyInstance.secretUrl = secretUrlInstance;
                        }
                        
                        var sourceVaultValue = diskEncryptionKeyValue['sourceVault'];
                        if (sourceVaultValue !== null && sourceVaultValue !== undefined) {
                          var sourceVaultInstance = {};
                          diskEncryptionKeyInstance.sourceVault = sourceVaultInstance;
                          
                          var idValue = sourceVaultValue['id'];
                          if (idValue !== null && idValue !== undefined) {
                            var idInstance = idValue;
                            sourceVaultInstance.referenceUri = idInstance;
                          }
                        }
                      }
                      
                      var keyEncryptionKeyValue = encryptionSettingsValue['keyEncryptionKey'];
                      if (keyEncryptionKeyValue !== null && keyEncryptionKeyValue !== undefined) {
                        var keyEncryptionKeyInstance = {};
                        encryptionSettingsInstance.keyEncryptionKey = keyEncryptionKeyInstance;
                        
                        var keyUrlValue = keyEncryptionKeyValue['keyUrl'];
                        if (keyUrlValue !== null && keyUrlValue !== undefined) {
                          var keyUrlInstance = keyUrlValue;
                          keyEncryptionKeyInstance.keyUrl = keyUrlInstance;
                        }
                        
                        var sourceVaultValue2 = keyEncryptionKeyValue['sourceVault'];
                        if (sourceVaultValue2 !== null && sourceVaultValue2 !== undefined) {
                          var sourceVaultInstance2 = {};
                          keyEncryptionKeyInstance.sourceVault = sourceVaultInstance2;
                          
                          var idValue2 = sourceVaultValue2['id'];
                          if (idValue2 !== null && idValue2 !== undefined) {
                            var idInstance2 = idValue2;
                            sourceVaultInstance2.referenceUri = idInstance2;
                          }
                        }
                      }
                    }
                    
                    var nameValue2 = osDiskValue['name'];
                    if (nameValue2 !== null && nameValue2 !== undefined) {
                      var nameInstance2 = nameValue2;
                      osDiskInstance.name = nameInstance2;
                    }
                    
                    var vhdValue = osDiskValue['vhd'];
                    if (vhdValue !== null && vhdValue !== undefined) {
                      var vhdInstance = {};
                      osDiskInstance.virtualHardDisk = vhdInstance;
                      
                      var uriValue = vhdValue['uri'];
                      if (uriValue !== null && uriValue !== undefined) {
                        var uriInstance = uriValue;
                        vhdInstance.uri = uriInstance;
                      }
                    }
                    
                    var imageValue = osDiskValue['image'];
                    if (imageValue !== null && imageValue !== undefined) {
                      var imageInstance = {};
                      osDiskInstance.sourceImage = imageInstance;
                      
                      var uriValue2 = imageValue['uri'];
                      if (uriValue2 !== null && uriValue2 !== undefined) {
                        var uriInstance2 = uriValue2;
                        imageInstance.uri = uriInstance2;
                      }
                    }
                    
                    var cachingValue = osDiskValue['caching'];
                    if (cachingValue !== null && cachingValue !== undefined) {
                      var cachingInstance = cachingValue;
                      osDiskInstance.caching = cachingInstance;
                    }
                    
                    var createOptionValue = osDiskValue['createOption'];
                    if (createOptionValue !== null && createOptionValue !== undefined) {
                      var createOptionInstance = createOptionValue;
                      osDiskInstance.createOption = createOptionInstance;
                    }
                    
                    var diskSizeGBValue = osDiskValue['diskSizeGB'];
                    if (diskSizeGBValue !== null && diskSizeGBValue !== undefined) {
                      var diskSizeGBInstance = diskSizeGBValue;
                      osDiskInstance.diskSizeGB = diskSizeGBInstance;
                    }
                  }
                  
                  var dataDisksArray = storageProfileValue['dataDisks'];
                  if (dataDisksArray !== null && dataDisksArray !== undefined) {
                    for (var loweredIndex2 = 0; loweredIndex2 < dataDisksArray.length; loweredIndex2 = loweredIndex2 + 1) {
                      var dataDisksValue = dataDisksArray[loweredIndex2];
                      var dataDiskInstance = {};
                      storageProfileInstance.dataDisks.push(dataDiskInstance);
                      
                      var lunValue = dataDisksValue['lun'];
                      if (lunValue !== null && lunValue !== undefined) {
                        var lunInstance = lunValue;
                        dataDiskInstance.lun = lunInstance;
                      }
                      
                      var nameValue3 = dataDisksValue['name'];
                      if (nameValue3 !== null && nameValue3 !== undefined) {
                        var nameInstance3 = nameValue3;
                        dataDiskInstance.name = nameInstance3;
                      }
                      
                      var vhdValue2 = dataDisksValue['vhd'];
                      if (vhdValue2 !== null && vhdValue2 !== undefined) {
                        var vhdInstance2 = {};
                        dataDiskInstance.virtualHardDisk = vhdInstance2;
                        
                        var uriValue3 = vhdValue2['uri'];
                        if (uriValue3 !== null && uriValue3 !== undefined) {
                          var uriInstance3 = uriValue3;
                          vhdInstance2.uri = uriInstance3;
                        }
                      }
                      
                      var imageValue2 = dataDisksValue['image'];
                      if (imageValue2 !== null && imageValue2 !== undefined) {
                        var imageInstance2 = {};
                        dataDiskInstance.sourceImage = imageInstance2;
                        
                        var uriValue4 = imageValue2['uri'];
                        if (uriValue4 !== null && uriValue4 !== undefined) {
                          var uriInstance4 = uriValue4;
                          imageInstance2.uri = uriInstance4;
                        }
                      }
                      
                      var cachingValue2 = dataDisksValue['caching'];
                      if (cachingValue2 !== null && cachingValue2 !== undefined) {
                        var cachingInstance2 = cachingValue2;
                        dataDiskInstance.caching = cachingInstance2;
                      }
                      
                      var createOptionValue2 = dataDisksValue['createOption'];
                      if (createOptionValue2 !== null && createOptionValue2 !== undefined) {
                        var createOptionInstance2 = createOptionValue2;
                        dataDiskInstance.createOption = createOptionInstance2;
                      }
                      
                      var diskSizeGBValue2 = dataDisksValue['diskSizeGB'];
                      if (diskSizeGBValue2 !== null && diskSizeGBValue2 !== undefined) {
                        var diskSizeGBInstance2 = diskSizeGBValue2;
                        dataDiskInstance.diskSizeGB = diskSizeGBInstance2;
                      }
                    }
                  }
                }
                
                var osProfileValue = propertiesValue['osProfile'];
                if (osProfileValue !== null && osProfileValue !== undefined) {
                  var osProfileInstance = { secrets: [] };
                  virtualMachineJsonInstance.oSProfile = osProfileInstance;
                  
                  var computerNameValue = osProfileValue['computerName'];
                  if (computerNameValue !== null && computerNameValue !== undefined) {
                    var computerNameInstance = computerNameValue;
                    osProfileInstance.computerName = computerNameInstance;
                  }
                  
                  var adminUsernameValue = osProfileValue['adminUsername'];
                  if (adminUsernameValue !== null && adminUsernameValue !== undefined) {
                    var adminUsernameInstance = adminUsernameValue;
                    osProfileInstance.adminUsername = adminUsernameInstance;
                  }
                  
                  var adminPasswordValue = osProfileValue['adminPassword'];
                  if (adminPasswordValue !== null && adminPasswordValue !== undefined) {
                    var adminPasswordInstance = adminPasswordValue;
                    osProfileInstance.adminPassword = adminPasswordInstance;
                  }
                  
                  var customDataValue = osProfileValue['customData'];
                  if (customDataValue !== null && customDataValue !== undefined) {
                    var customDataInstance = customDataValue;
                    osProfileInstance.customData = customDataInstance;
                  }
                  
                  var windowsConfigurationValue = osProfileValue['windowsConfiguration'];
                  if (windowsConfigurationValue !== null && windowsConfigurationValue !== undefined) {
                    var windowsConfigurationInstance = { additionalUnattendContents: [] };
                    osProfileInstance.windowsConfiguration = windowsConfigurationInstance;
                    
                    var provisionVMAgentValue = windowsConfigurationValue['provisionVMAgent'];
                    if (provisionVMAgentValue !== null && provisionVMAgentValue !== undefined) {
                      var provisionVMAgentInstance = provisionVMAgentValue;
                      windowsConfigurationInstance.provisionVMAgent = provisionVMAgentInstance;
                    }
                    
                    var enableAutomaticUpdatesValue = windowsConfigurationValue['enableAutomaticUpdates'];
                    if (enableAutomaticUpdatesValue !== null && enableAutomaticUpdatesValue !== undefined) {
                      var enableAutomaticUpdatesInstance = enableAutomaticUpdatesValue;
                      windowsConfigurationInstance.enableAutomaticUpdates = enableAutomaticUpdatesInstance;
                    }
                    
                    var timeZoneValue = windowsConfigurationValue['timeZone'];
                    if (timeZoneValue !== null && timeZoneValue !== undefined) {
                      var timeZoneInstance = timeZoneValue;
                      windowsConfigurationInstance.timeZone = timeZoneInstance;
                    }
                    
                    var additionalUnattendContentArray = windowsConfigurationValue['additionalUnattendContent'];
                    if (additionalUnattendContentArray !== null && additionalUnattendContentArray !== undefined) {
                      for (var loweredIndex3 = 0; loweredIndex3 < additionalUnattendContentArray.length; loweredIndex3 = loweredIndex3 + 1) {
                        var additionalUnattendContentValue = additionalUnattendContentArray[loweredIndex3];
                        var additionalUnattendContentInstance = {};
                        windowsConfigurationInstance.additionalUnattendContents.push(additionalUnattendContentInstance);
                        
                        var passNameValue = additionalUnattendContentValue['passName'];
                        if (passNameValue !== null && passNameValue !== undefined) {
                          var passNameInstance = passNameValue;
                          additionalUnattendContentInstance.passName = passNameInstance;
                        }
                        
                        var componentNameValue = additionalUnattendContentValue['componentName'];
                        if (componentNameValue !== null && componentNameValue !== undefined) {
                          var componentNameInstance = componentNameValue;
                          additionalUnattendContentInstance.componentName = componentNameInstance;
                        }
                        
                        var settingNameValue = additionalUnattendContentValue['settingName'];
                        if (settingNameValue !== null && settingNameValue !== undefined) {
                          var settingNameInstance = settingNameValue;
                          additionalUnattendContentInstance.settingName = settingNameInstance;
                        }
                        
                        var contentValue = additionalUnattendContentValue['content'];
                        if (contentValue !== null && contentValue !== undefined) {
                          var contentInstance = contentValue;
                          additionalUnattendContentInstance.content = contentInstance;
                        }
                      }
                    }
                    
                    var winRMValue = windowsConfigurationValue['winRM'];
                    if (winRMValue !== null && winRMValue !== undefined) {
                      var winRMInstance = { listeners: [] };
                      windowsConfigurationInstance.winRMConfiguration = winRMInstance;
                      
                      var listenersArray = winRMValue['listeners'];
                      if (listenersArray !== null && listenersArray !== undefined) {
                        for (var loweredIndex4 = 0; loweredIndex4 < listenersArray.length; loweredIndex4 = loweredIndex4 + 1) {
                          var listenersValue = listenersArray[loweredIndex4];
                          var winRMListenerInstance = {};
                          winRMInstance.listeners.push(winRMListenerInstance);
                          
                          var protocolValue = listenersValue['protocol'];
                          if (protocolValue !== null && protocolValue !== undefined) {
                            var protocolInstance = protocolValue;
                            winRMListenerInstance.protocol = protocolInstance;
                          }
                          
                          var certificateUrlValue = listenersValue['certificateUrl'];
                          if (certificateUrlValue !== null && certificateUrlValue !== undefined) {
                            var certificateUrlInstance = certificateUrlValue;
                            winRMListenerInstance.certificateUrl = certificateUrlInstance;
                          }
                        }
                      }
                    }
                  }
                  
                  var linuxConfigurationValue = osProfileValue['linuxConfiguration'];
                  if (linuxConfigurationValue !== null && linuxConfigurationValue !== undefined) {
                    var linuxConfigurationInstance = {};
                    osProfileInstance.linuxConfiguration = linuxConfigurationInstance;
                    
                    var disablePasswordAuthenticationValue = linuxConfigurationValue['disablePasswordAuthentication'];
                    if (disablePasswordAuthenticationValue !== null && disablePasswordAuthenticationValue !== undefined) {
                      var disablePasswordAuthenticationInstance = disablePasswordAuthenticationValue;
                      linuxConfigurationInstance.disablePasswordAuthentication = disablePasswordAuthenticationInstance;
                    }
                    
                    var sshValue = linuxConfigurationValue['ssh'];
                    if (sshValue !== null && sshValue !== undefined) {
                      var sshInstance = { publicKeys: [] };
                      linuxConfigurationInstance.sshConfiguration = sshInstance;
                      
                      var publicKeysArray = sshValue['publicKeys'];
                      if (publicKeysArray !== null && publicKeysArray !== undefined) {
                        for (var loweredIndex5 = 0; loweredIndex5 < publicKeysArray.length; loweredIndex5 = loweredIndex5 + 1) {
                          var publicKeysValue = publicKeysArray[loweredIndex5];
                          var sshPublicKeyInstance = {};
                          sshInstance.publicKeys.push(sshPublicKeyInstance);
                          
                          var pathValue = publicKeysValue['path'];
                          if (pathValue !== null && pathValue !== undefined) {
                            var pathInstance = pathValue;
                            sshPublicKeyInstance.path = pathInstance;
                          }
                          
                          var keyDataValue = publicKeysValue['keyData'];
                          if (keyDataValue !== null && keyDataValue !== undefined) {
                            var keyDataInstance = keyDataValue;
                            sshPublicKeyInstance.keyData = keyDataInstance;
                          }
                        }
                      }
                    }
                  }
                  
                  var secretsArray = osProfileValue['secrets'];
                  if (secretsArray !== null && secretsArray !== undefined) {
                    for (var loweredIndex6 = 0; loweredIndex6 < secretsArray.length; loweredIndex6 = loweredIndex6 + 1) {
                      var secretsValue = secretsArray[loweredIndex6];
                      var vaultSecretGroupInstance = { vaultCertificates: [] };
                      osProfileInstance.secrets.push(vaultSecretGroupInstance);
                      
                      var sourceVaultValue3 = secretsValue['sourceVault'];
                      if (sourceVaultValue3 !== null && sourceVaultValue3 !== undefined) {
                        var sourceVaultInstance3 = {};
                        vaultSecretGroupInstance.sourceVault = sourceVaultInstance3;
                        
                        var idValue3 = sourceVaultValue3['id'];
                        if (idValue3 !== null && idValue3 !== undefined) {
                          var idInstance3 = idValue3;
                          sourceVaultInstance3.referenceUri = idInstance3;
                        }
                      }
                      
                      var vaultCertificatesArray = secretsValue['vaultCertificates'];
                      if (vaultCertificatesArray !== null && vaultCertificatesArray !== undefined) {
                        for (var loweredIndex7 = 0; loweredIndex7 < vaultCertificatesArray.length; loweredIndex7 = loweredIndex7 + 1) {
                          var vaultCertificatesValue = vaultCertificatesArray[loweredIndex7];
                          var vaultCertificateInstance = {};
                          vaultSecretGroupInstance.vaultCertificates.push(vaultCertificateInstance);
                          
                          var certificateUrlValue2 = vaultCertificatesValue['certificateUrl'];
                          if (certificateUrlValue2 !== null && certificateUrlValue2 !== undefined) {
                            var certificateUrlInstance2 = certificateUrlValue2;
                            vaultCertificateInstance.certificateUrl = certificateUrlInstance2;
                          }
                          
                          var certificateStoreValue = vaultCertificatesValue['certificateStore'];
                          if (certificateStoreValue !== null && certificateStoreValue !== undefined) {
                            var certificateStoreInstance = certificateStoreValue;
                            vaultCertificateInstance.certificateStore = certificateStoreInstance;
                          }
                        }
                      }
                    }
                  }
                }
                
                var networkProfileValue = propertiesValue['networkProfile'];
                if (networkProfileValue !== null && networkProfileValue !== undefined) {
                  var networkProfileInstance = { networkInterfaces: [] };
                  virtualMachineJsonInstance.networkProfile = networkProfileInstance;
                  
                  var networkInterfacesArray = networkProfileValue['networkInterfaces'];
                  if (networkInterfacesArray !== null && networkInterfacesArray !== undefined) {
                    for (var loweredIndex8 = 0; loweredIndex8 < networkInterfacesArray.length; loweredIndex8 = loweredIndex8 + 1) {
                      var networkInterfacesValue = networkInterfacesArray[loweredIndex8];
                      var networkInterfaceReferenceJsonInstance = {};
                      networkProfileInstance.networkInterfaces.push(networkInterfaceReferenceJsonInstance);
                      
                      var propertiesValue2 = networkInterfacesValue['properties'];
                      if (propertiesValue2 !== null && propertiesValue2 !== undefined) {
                        var primaryValue = propertiesValue2['primary'];
                        if (primaryValue !== null && primaryValue !== undefined) {
                          var primaryInstance = primaryValue;
                          networkInterfaceReferenceJsonInstance.primary = primaryInstance;
                        }
                      }
                      
                      var idValue4 = networkInterfacesValue['id'];
                      if (idValue4 !== null && idValue4 !== undefined) {
                        var idInstance4 = idValue4;
                        networkInterfaceReferenceJsonInstance.referenceUri = idInstance4;
                      }
                    }
                  }
                }
                
                var diagnosticsProfileValue = propertiesValue['diagnosticsProfile'];
                if (diagnosticsProfileValue !== null && diagnosticsProfileValue !== undefined) {
                  var diagnosticsProfileInstance = {};
                  virtualMachineJsonInstance.diagnosticsProfile = diagnosticsProfileInstance;
                  
                  var bootDiagnosticsValue = diagnosticsProfileValue['bootDiagnostics'];
                  if (bootDiagnosticsValue !== null && bootDiagnosticsValue !== undefined) {
                    var bootDiagnosticsInstance = {};
                    diagnosticsProfileInstance.bootDiagnostics = bootDiagnosticsInstance;
                    
                    var enabledValue = bootDiagnosticsValue['enabled'];
                    if (enabledValue !== null && enabledValue !== undefined) {
                      var enabledInstance = enabledValue;
                      bootDiagnosticsInstance.enabled = enabledInstance;
                    }
                    
                    var storageUriValue = bootDiagnosticsValue['storageUri'];
                    if (storageUriValue !== null && storageUriValue !== undefined) {
                      var storageUriInstance = storageUriValue;
                      bootDiagnosticsInstance.storageUri = storageUriInstance;
                    }
                  }
                }
                
                var availabilitySetValue = propertiesValue['availabilitySet'];
                if (availabilitySetValue !== null && availabilitySetValue !== undefined) {
                  var availabilitySetInstance = {};
                  virtualMachineJsonInstance.availabilitySetReference = availabilitySetInstance;
                  
                  var idValue5 = availabilitySetValue['id'];
                  if (idValue5 !== null && idValue5 !== undefined) {
                    var idInstance5 = idValue5;
                    availabilitySetInstance.referenceUri = idInstance5;
                  }
                }
                
                var provisioningStateValue = propertiesValue['provisioningState'];
                if (provisioningStateValue !== null && provisioningStateValue !== undefined) {
                  var provisioningStateInstance = provisioningStateValue;
                  virtualMachineJsonInstance.provisioningState = provisioningStateInstance;
                }
                
                var instanceViewValue = propertiesValue['instanceView'];
                if (instanceViewValue !== null && instanceViewValue !== undefined) {
                  var instanceViewInstance = { disks: [], extensions: [], statuses: [] };
                  virtualMachineJsonInstance.instanceView = instanceViewInstance;
                  
                  var platformUpdateDomainValue = instanceViewValue['platformUpdateDomain'];
                  if (platformUpdateDomainValue !== null && platformUpdateDomainValue !== undefined) {
                    var platformUpdateDomainInstance = platformUpdateDomainValue;
                    instanceViewInstance.platformUpdateDomain = platformUpdateDomainInstance;
                  }
                  
                  var platformFaultDomainValue = instanceViewValue['platformFaultDomain'];
                  if (platformFaultDomainValue !== null && platformFaultDomainValue !== undefined) {
                    var platformFaultDomainInstance = platformFaultDomainValue;
                    instanceViewInstance.platformFaultDomain = platformFaultDomainInstance;
                  }
                  
                  var rdpThumbPrintValue = instanceViewValue['rdpThumbPrint'];
                  if (rdpThumbPrintValue !== null && rdpThumbPrintValue !== undefined) {
                    var rdpThumbPrintInstance = rdpThumbPrintValue;
                    instanceViewInstance.remoteDesktopThumbprint = rdpThumbPrintInstance;
                  }
                  
                  var vmAgentValue = instanceViewValue['vmAgent'];
                  if (vmAgentValue !== null && vmAgentValue !== undefined) {
                    var vmAgentInstance = { extensionHandlers: [], statuses: [] };
                    instanceViewInstance.vMAgent = vmAgentInstance;
                    
                    var vmAgentVersionValue = vmAgentValue['vmAgentVersion'];
                    if (vmAgentVersionValue !== null && vmAgentVersionValue !== undefined) {
                      var vmAgentVersionInstance = vmAgentVersionValue;
                      vmAgentInstance.vMAgentVersion = vmAgentVersionInstance;
                    }
                    
                    var extensionHandlersArray = vmAgentValue['extensionHandlers'];
                    if (extensionHandlersArray !== null && extensionHandlersArray !== undefined) {
                      for (var loweredIndex9 = 0; loweredIndex9 < extensionHandlersArray.length; loweredIndex9 = loweredIndex9 + 1) {
                        var extensionHandlersValue = extensionHandlersArray[loweredIndex9];
                        var virtualMachineExtensionHandlerInstanceViewInstance = {};
                        vmAgentInstance.extensionHandlers.push(virtualMachineExtensionHandlerInstanceViewInstance);
                        
                        var typeValue = extensionHandlersValue['type'];
                        if (typeValue !== null && typeValue !== undefined) {
                          var typeInstance = typeValue;
                          virtualMachineExtensionHandlerInstanceViewInstance.type = typeInstance;
                        }
                        
                        var typeHandlerVersionValue = extensionHandlersValue['typeHandlerVersion'];
                        if (typeHandlerVersionValue !== null && typeHandlerVersionValue !== undefined) {
                          var typeHandlerVersionInstance = typeHandlerVersionValue;
                          virtualMachineExtensionHandlerInstanceViewInstance.typeHandlerVersion = typeHandlerVersionInstance;
                        }
                        
                        var statusValue = extensionHandlersValue['status'];
                        if (statusValue !== null && statusValue !== undefined) {
                          var statusInstance = {};
                          virtualMachineExtensionHandlerInstanceViewInstance.status = statusInstance;
                          
                          var codeValue = statusValue['code'];
                          if (codeValue !== null && codeValue !== undefined) {
                            var codeInstance = codeValue;
                            statusInstance.code = codeInstance;
                          }
                          
                          var levelValue = statusValue['level'];
                          if (levelValue !== null && levelValue !== undefined) {
                            var levelInstance = levelValue;
                            statusInstance.level = levelInstance;
                          }
                          
                          var displayStatusValue = statusValue['displayStatus'];
                          if (displayStatusValue !== null && displayStatusValue !== undefined) {
                            var displayStatusInstance = displayStatusValue;
                            statusInstance.displayStatus = displayStatusInstance;
                          }
                          
                          var messageValue = statusValue['message'];
                          if (messageValue !== null && messageValue !== undefined) {
                            var messageInstance = messageValue;
                            statusInstance.message = messageInstance;
                          }
                          
                          var timeValue = statusValue['time'];
                          if (timeValue !== null && timeValue !== undefined) {
                            var timeInstance = timeValue;
                            statusInstance.time = timeInstance;
                          }
                        }
                      }
                    }
                    
                    var statusesArray = vmAgentValue['statuses'];
                    if (statusesArray !== null && statusesArray !== undefined) {
                      for (var loweredIndex10 = 0; loweredIndex10 < statusesArray.length; loweredIndex10 = loweredIndex10 + 1) {
                        var statusesValue = statusesArray[loweredIndex10];
                        var instanceViewStatusInstance = {};
                        vmAgentInstance.statuses.push(instanceViewStatusInstance);
                        
                        var codeValue2 = statusesValue['code'];
                        if (codeValue2 !== null && codeValue2 !== undefined) {
                          var codeInstance2 = codeValue2;
                          instanceViewStatusInstance.code = codeInstance2;
                        }
                        
                        var levelValue2 = statusesValue['level'];
                        if (levelValue2 !== null && levelValue2 !== undefined) {
                          var levelInstance2 = levelValue2;
                          instanceViewStatusInstance.level = levelInstance2;
                        }
                        
                        var displayStatusValue2 = statusesValue['displayStatus'];
                        if (displayStatusValue2 !== null && displayStatusValue2 !== undefined) {
                          var displayStatusInstance2 = displayStatusValue2;
                          instanceViewStatusInstance.displayStatus = displayStatusInstance2;
                        }
                        
                        var messageValue2 = statusesValue['message'];
                        if (messageValue2 !== null && messageValue2 !== undefined) {
                          var messageInstance2 = messageValue2;
                          instanceViewStatusInstance.message = messageInstance2;
                        }
                        
                        var timeValue2 = statusesValue['time'];
                        if (timeValue2 !== null && timeValue2 !== undefined) {
                          var timeInstance2 = timeValue2;
                          instanceViewStatusInstance.time = timeInstance2;
                        }
                      }
                    }
                  }
                  
                  var disksArray = instanceViewValue['disks'];
                  if (disksArray !== null && disksArray !== undefined) {
                    for (var loweredIndex11 = 0; loweredIndex11 < disksArray.length; loweredIndex11 = loweredIndex11 + 1) {
                      var disksValue = disksArray[loweredIndex11];
                      var diskInstanceViewInstance = { statuses: [] };
                      instanceViewInstance.disks.push(diskInstanceViewInstance);
                      
                      var nameValue4 = disksValue['name'];
                      if (nameValue4 !== null && nameValue4 !== undefined) {
                        var nameInstance4 = nameValue4;
                        diskInstanceViewInstance.name = nameInstance4;
                      }
                      
                      var statusesArray2 = disksValue['statuses'];
                      if (statusesArray2 !== null && statusesArray2 !== undefined) {
                        for (var loweredIndex12 = 0; loweredIndex12 < statusesArray2.length; loweredIndex12 = loweredIndex12 + 1) {
                          var statusesValue2 = statusesArray2[loweredIndex12];
                          var instanceViewStatusInstance2 = {};
                          diskInstanceViewInstance.statuses.push(instanceViewStatusInstance2);
                          
                          var codeValue3 = statusesValue2['code'];
                          if (codeValue3 !== null && codeValue3 !== undefined) {
                            var codeInstance3 = codeValue3;
                            instanceViewStatusInstance2.code = codeInstance3;
                          }
                          
                          var levelValue3 = statusesValue2['level'];
                          if (levelValue3 !== null && levelValue3 !== undefined) {
                            var levelInstance3 = levelValue3;
                            instanceViewStatusInstance2.level = levelInstance3;
                          }
                          
                          var displayStatusValue3 = statusesValue2['displayStatus'];
                          if (displayStatusValue3 !== null && displayStatusValue3 !== undefined) {
                            var displayStatusInstance3 = displayStatusValue3;
                            instanceViewStatusInstance2.displayStatus = displayStatusInstance3;
                          }
                          
                          var messageValue3 = statusesValue2['message'];
                          if (messageValue3 !== null && messageValue3 !== undefined) {
                            var messageInstance3 = messageValue3;
                            instanceViewStatusInstance2.message = messageInstance3;
                          }
                          
                          var timeValue3 = statusesValue2['time'];
                          if (timeValue3 !== null && timeValue3 !== undefined) {
                            var timeInstance3 = timeValue3;
                            instanceViewStatusInstance2.time = timeInstance3;
                          }
                        }
                      }
                    }
                  }
                  
                  var extensionsArray = instanceViewValue['extensions'];
                  if (extensionsArray !== null && extensionsArray !== undefined) {
                    for (var loweredIndex13 = 0; loweredIndex13 < extensionsArray.length; loweredIndex13 = loweredIndex13 + 1) {
                      var extensionsValue = extensionsArray[loweredIndex13];
                      var virtualMachineExtensionInstanceViewInstance = { statuses: [], subStatuses: [] };
                      instanceViewInstance.extensions.push(virtualMachineExtensionInstanceViewInstance);
                      
                      var nameValue5 = extensionsValue['name'];
                      if (nameValue5 !== null && nameValue5 !== undefined) {
                        var nameInstance5 = nameValue5;
                        virtualMachineExtensionInstanceViewInstance.name = nameInstance5;
                      }
                      
                      var typeValue2 = extensionsValue['type'];
                      if (typeValue2 !== null && typeValue2 !== undefined) {
                        var typeInstance2 = typeValue2;
                        virtualMachineExtensionInstanceViewInstance.extensionType = typeInstance2;
                      }
                      
                      var typeHandlerVersionValue2 = extensionsValue['typeHandlerVersion'];
                      if (typeHandlerVersionValue2 !== null && typeHandlerVersionValue2 !== undefined) {
                        var typeHandlerVersionInstance2 = typeHandlerVersionValue2;
                        virtualMachineExtensionInstanceViewInstance.typeHandlerVersion = typeHandlerVersionInstance2;
                      }
                      
                      var substatusesArray = extensionsValue['substatuses'];
                      if (substatusesArray !== null && substatusesArray !== undefined) {
                        for (var loweredIndex14 = 0; loweredIndex14 < substatusesArray.length; loweredIndex14 = loweredIndex14 + 1) {
                          var substatusesValue = substatusesArray[loweredIndex14];
                          var instanceViewStatusInstance3 = {};
                          virtualMachineExtensionInstanceViewInstance.subStatuses.push(instanceViewStatusInstance3);
                          
                          var codeValue4 = substatusesValue['code'];
                          if (codeValue4 !== null && codeValue4 !== undefined) {
                            var codeInstance4 = codeValue4;
                            instanceViewStatusInstance3.code = codeInstance4;
                          }
                          
                          var levelValue4 = substatusesValue['level'];
                          if (levelValue4 !== null && levelValue4 !== undefined) {
                            var levelInstance4 = levelValue4;
                            instanceViewStatusInstance3.level = levelInstance4;
                          }
                          
                          var displayStatusValue4 = substatusesValue['displayStatus'];
                          if (displayStatusValue4 !== null && displayStatusValue4 !== undefined) {
                            var displayStatusInstance4 = displayStatusValue4;
                            instanceViewStatusInstance3.displayStatus = displayStatusInstance4;
                          }
                          
                          var messageValue4 = substatusesValue['message'];
                          if (messageValue4 !== null && messageValue4 !== undefined) {
                            var messageInstance4 = messageValue4;
                            instanceViewStatusInstance3.message = messageInstance4;
                          }
                          
                          var timeValue4 = substatusesValue['time'];
                          if (timeValue4 !== null && timeValue4 !== undefined) {
                            var timeInstance4 = timeValue4;
                            instanceViewStatusInstance3.time = timeInstance4;
                          }
                        }
                      }
                      
                      var statusesArray3 = extensionsValue['statuses'];
                      if (statusesArray3 !== null && statusesArray3 !== undefined) {
                        for (var loweredIndex15 = 0; loweredIndex15 < statusesArray3.length; loweredIndex15 = loweredIndex15 + 1) {
                          var statusesValue3 = statusesArray3[loweredIndex15];
                          var instanceViewStatusInstance4 = {};
                          virtualMachineExtensionInstanceViewInstance.statuses.push(instanceViewStatusInstance4);
                          
                          var codeValue5 = statusesValue3['code'];
                          if (codeValue5 !== null && codeValue5 !== undefined) {
                            var codeInstance5 = codeValue5;
                            instanceViewStatusInstance4.code = codeInstance5;
                          }
                          
                          var levelValue5 = statusesValue3['level'];
                          if (levelValue5 !== null && levelValue5 !== undefined) {
                            var levelInstance5 = levelValue5;
                            instanceViewStatusInstance4.level = levelInstance5;
                          }
                          
                          var displayStatusValue5 = statusesValue3['displayStatus'];
                          if (displayStatusValue5 !== null && displayStatusValue5 !== undefined) {
                            var displayStatusInstance5 = displayStatusValue5;
                            instanceViewStatusInstance4.displayStatus = displayStatusInstance5;
                          }
                          
                          var messageValue5 = statusesValue3['message'];
                          if (messageValue5 !== null && messageValue5 !== undefined) {
                            var messageInstance5 = messageValue5;
                            instanceViewStatusInstance4.message = messageInstance5;
                          }
                          
                          var timeValue5 = statusesValue3['time'];
                          if (timeValue5 !== null && timeValue5 !== undefined) {
                            var timeInstance5 = timeValue5;
                            instanceViewStatusInstance4.time = timeInstance5;
                          }
                        }
                      }
                    }
                  }
                  
                  var bootDiagnosticsValue2 = instanceViewValue['bootDiagnostics'];
                  if (bootDiagnosticsValue2 !== null && bootDiagnosticsValue2 !== undefined) {
                    var bootDiagnosticsInstance2 = {};
                    instanceViewInstance.bootDiagnostics = bootDiagnosticsInstance2;
                    
                    var consoleScreenshotBlobUriValue = bootDiagnosticsValue2['consoleScreenshotBlobUri'];
                    if (consoleScreenshotBlobUriValue !== null && consoleScreenshotBlobUriValue !== undefined) {
                      var consoleScreenshotBlobUriInstance = consoleScreenshotBlobUriValue;
                      bootDiagnosticsInstance2.consoleScreenshotBlobUri = consoleScreenshotBlobUriInstance;
                    }
                    
                    var serialConsoleLogBlobUriValue = bootDiagnosticsValue2['serialConsoleLogBlobUri'];
                    if (serialConsoleLogBlobUriValue !== null && serialConsoleLogBlobUriValue !== undefined) {
                      var serialConsoleLogBlobUriInstance = serialConsoleLogBlobUriValue;
                      bootDiagnosticsInstance2.serialConsoleLogBlobUri = serialConsoleLogBlobUriInstance;
                    }
                  }
                  
                  var statusesArray4 = instanceViewValue['statuses'];
                  if (statusesArray4 !== null && statusesArray4 !== undefined) {
                    for (var loweredIndex16 = 0; loweredIndex16 < statusesArray4.length; loweredIndex16 = loweredIndex16 + 1) {
                      var statusesValue4 = statusesArray4[loweredIndex16];
                      var instanceViewStatusInstance5 = {};
                      instanceViewInstance.statuses.push(instanceViewStatusInstance5);
                      
                      var codeValue6 = statusesValue4['code'];
                      if (codeValue6 !== null && codeValue6 !== undefined) {
                        var codeInstance6 = codeValue6;
                        instanceViewStatusInstance5.code = codeInstance6;
                      }
                      
                      var levelValue6 = statusesValue4['level'];
                      if (levelValue6 !== null && levelValue6 !== undefined) {
                        var levelInstance6 = levelValue6;
                        instanceViewStatusInstance5.level = levelInstance6;
                      }
                      
                      var displayStatusValue6 = statusesValue4['displayStatus'];
                      if (displayStatusValue6 !== null && displayStatusValue6 !== undefined) {
                        var displayStatusInstance6 = displayStatusValue6;
                        instanceViewStatusInstance5.displayStatus = displayStatusInstance6;
                      }
                      
                      var messageValue6 = statusesValue4['message'];
                      if (messageValue6 !== null && messageValue6 !== undefined) {
                        var messageInstance6 = messageValue6;
                        instanceViewStatusInstance5.message = messageInstance6;
                      }
                      
                      var timeValue6 = statusesValue4['time'];
                      if (timeValue6 !== null && timeValue6 !== undefined) {
                        var timeInstance6 = timeValue6;
                        instanceViewStatusInstance5.time = timeInstance6;
                      }
                    }
                  }
                }
              }
              
              var resourcesArray = valueValue['resources'];
              if (resourcesArray !== null && resourcesArray !== undefined) {
                virtualMachineJsonInstance.extensions = [];
                for (var loweredIndex17 = 0; loweredIndex17 < resourcesArray.length; loweredIndex17 = loweredIndex17 + 1) {
                  var resourcesValue = resourcesArray[loweredIndex17];
                  var virtualMachineExtensionJsonInstance = { tags: {} };
                  virtualMachineJsonInstance.extensions.push(virtualMachineExtensionJsonInstance);
                  
                  var propertiesValue3 = resourcesValue['properties'];
                  if (propertiesValue3 !== null && propertiesValue3 !== undefined) {
                    var publisherValue3 = propertiesValue3['publisher'];
                    if (publisherValue3 !== null && publisherValue3 !== undefined) {
                      var publisherInstance3 = publisherValue3;
                      virtualMachineExtensionJsonInstance.publisher = publisherInstance3;
                    }
                    
                    var typeValue3 = propertiesValue3['type'];
                    if (typeValue3 !== null && typeValue3 !== undefined) {
                      var typeInstance3 = typeValue3;
                      virtualMachineExtensionJsonInstance.extensionType = typeInstance3;
                    }
                    
                    var typeHandlerVersionValue3 = propertiesValue3['typeHandlerVersion'];
                    if (typeHandlerVersionValue3 !== null && typeHandlerVersionValue3 !== undefined) {
                      var typeHandlerVersionInstance3 = typeHandlerVersionValue3;
                      virtualMachineExtensionJsonInstance.typeHandlerVersion = typeHandlerVersionInstance3;
                    }
                    
                    var autoUpgradeMinorVersionValue = propertiesValue3['autoUpgradeMinorVersion'];
                    if (autoUpgradeMinorVersionValue !== null && autoUpgradeMinorVersionValue !== undefined) {
                      var autoUpgradeMinorVersionInstance = autoUpgradeMinorVersionValue;
                      virtualMachineExtensionJsonInstance.autoUpgradeMinorVersion = autoUpgradeMinorVersionInstance;
                    }
                    
                    var settingsValue = propertiesValue3['settings'];
                    if (settingsValue !== null && settingsValue !== undefined) {
                      var settingsInstance = settingsValue;
                      virtualMachineExtensionJsonInstance.settings = settingsInstance;
                    }
                    
                    var protectedSettingsValue = propertiesValue3['protectedSettings'];
                    if (protectedSettingsValue !== null && protectedSettingsValue !== undefined) {
                      var protectedSettingsInstance = protectedSettingsValue;
                      virtualMachineExtensionJsonInstance.protectedSettings = protectedSettingsInstance;
                    }
                    
                    var provisioningStateValue2 = propertiesValue3['provisioningState'];
                    if (provisioningStateValue2 !== null && provisioningStateValue2 !== undefined) {
                      var provisioningStateInstance2 = provisioningStateValue2;
                      virtualMachineExtensionJsonInstance.provisioningState = provisioningStateInstance2;
                    }
                    
                    var instanceViewValue2 = propertiesValue3['instanceView'];
                    if (instanceViewValue2 !== null && instanceViewValue2 !== undefined) {
                      var instanceViewInstance2 = { statuses: [], subStatuses: [] };
                      virtualMachineExtensionJsonInstance.instanceView = instanceViewInstance2;
                      
                      var nameValue6 = instanceViewValue2['name'];
                      if (nameValue6 !== null && nameValue6 !== undefined) {
                        var nameInstance6 = nameValue6;
                        instanceViewInstance2.name = nameInstance6;
                      }
                      
                      var typeValue4 = instanceViewValue2['type'];
                      if (typeValue4 !== null && typeValue4 !== undefined) {
                        var typeInstance4 = typeValue4;
                        instanceViewInstance2.extensionType = typeInstance4;
                      }
                      
                      var typeHandlerVersionValue4 = instanceViewValue2['typeHandlerVersion'];
                      if (typeHandlerVersionValue4 !== null && typeHandlerVersionValue4 !== undefined) {
                        var typeHandlerVersionInstance4 = typeHandlerVersionValue4;
                        instanceViewInstance2.typeHandlerVersion = typeHandlerVersionInstance4;
                      }
                      
                      var substatusesArray2 = instanceViewValue2['substatuses'];
                      if (substatusesArray2 !== null && substatusesArray2 !== undefined) {
                        for (var loweredIndex18 = 0; loweredIndex18 < substatusesArray2.length; loweredIndex18 = loweredIndex18 + 1) {
                          var substatusesValue2 = substatusesArray2[loweredIndex18];
                          var instanceViewStatusInstance6 = {};
                          instanceViewInstance2.subStatuses.push(instanceViewStatusInstance6);
                          
                          var codeValue7 = substatusesValue2['code'];
                          if (codeValue7 !== null && codeValue7 !== undefined) {
                            var codeInstance7 = codeValue7;
                            instanceViewStatusInstance6.code = codeInstance7;
                          }
                          
                          var levelValue7 = substatusesValue2['level'];
                          if (levelValue7 !== null && levelValue7 !== undefined) {
                            var levelInstance7 = levelValue7;
                            instanceViewStatusInstance6.level = levelInstance7;
                          }
                          
                          var displayStatusValue7 = substatusesValue2['displayStatus'];
                          if (displayStatusValue7 !== null && displayStatusValue7 !== undefined) {
                            var displayStatusInstance7 = displayStatusValue7;
                            instanceViewStatusInstance6.displayStatus = displayStatusInstance7;
                          }
                          
                          var messageValue7 = substatusesValue2['message'];
                          if (messageValue7 !== null && messageValue7 !== undefined) {
                            var messageInstance7 = messageValue7;
                            instanceViewStatusInstance6.message = messageInstance7;
                          }
                          
                          var timeValue7 = substatusesValue2['time'];
                          if (timeValue7 !== null && timeValue7 !== undefined) {
                            var timeInstance7 = timeValue7;
                            instanceViewStatusInstance6.time = timeInstance7;
                          }
                        }
                      }
                      
                      var statusesArray5 = instanceViewValue2['statuses'];
                      if (statusesArray5 !== null && statusesArray5 !== undefined) {
                        for (var loweredIndex19 = 0; loweredIndex19 < statusesArray5.length; loweredIndex19 = loweredIndex19 + 1) {
                          var statusesValue5 = statusesArray5[loweredIndex19];
                          var instanceViewStatusInstance7 = {};
                          instanceViewInstance2.statuses.push(instanceViewStatusInstance7);
                          
                          var codeValue8 = statusesValue5['code'];
                          if (codeValue8 !== null && codeValue8 !== undefined) {
                            var codeInstance8 = codeValue8;
                            instanceViewStatusInstance7.code = codeInstance8;
                          }
                          
                          var levelValue8 = statusesValue5['level'];
                          if (levelValue8 !== null && levelValue8 !== undefined) {
                            var levelInstance8 = levelValue8;
                            instanceViewStatusInstance7.level = levelInstance8;
                          }
                          
                          var displayStatusValue8 = statusesValue5['displayStatus'];
                          if (displayStatusValue8 !== null && displayStatusValue8 !== undefined) {
                            var displayStatusInstance8 = displayStatusValue8;
                            instanceViewStatusInstance7.displayStatus = displayStatusInstance8;
                          }
                          
                          var messageValue8 = statusesValue5['message'];
                          if (messageValue8 !== null && messageValue8 !== undefined) {
                            var messageInstance8 = messageValue8;
                            instanceViewStatusInstance7.message = messageInstance8;
                          }
                          
                          var timeValue8 = statusesValue5['time'];
                          if (timeValue8 !== null && timeValue8 !== undefined) {
                            var timeInstance8 = timeValue8;
                            instanceViewStatusInstance7.time = timeInstance8;
                          }
                        }
                      }
                    }
                  }
                  
                  var idValue6 = resourcesValue['id'];
                  if (idValue6 !== null && idValue6 !== undefined) {
                    var idInstance6 = idValue6;
                    virtualMachineExtensionJsonInstance.id = idInstance6;
                  }
                  
                  var nameValue7 = resourcesValue['name'];
                  if (nameValue7 !== null && nameValue7 !== undefined) {
                    var nameInstance7 = nameValue7;
                    virtualMachineExtensionJsonInstance.name = nameInstance7;
                  }
                  
                  var typeValue5 = resourcesValue['type'];
                  if (typeValue5 !== null && typeValue5 !== undefined) {
                    var typeInstance5 = typeValue5;
                    virtualMachineExtensionJsonInstance.type = typeInstance5;
                  }
                  
                  var locationValue = resourcesValue['location'];
                  if (locationValue !== null && locationValue !== undefined) {
                    var locationInstance = locationValue;
                    virtualMachineExtensionJsonInstance.location = locationInstance;
                  }
                  
                  var tagsSequenceElement = resourcesValue['tags'];
                  if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
                    for (var property in tagsSequenceElement) {
                      var tagsKey = property;
                      var tagsValue = tagsSequenceElement[property];
                      virtualMachineExtensionJsonInstance.tags[tagsKey] = tagsValue;
                    }
                  }
                }
              }
              
              var idValue7 = valueValue['id'];
              if (idValue7 !== null && idValue7 !== undefined) {
                var idInstance7 = idValue7;
                virtualMachineJsonInstance.id = idInstance7;
              }
              
              var nameValue8 = valueValue['name'];
              if (nameValue8 !== null && nameValue8 !== undefined) {
                var nameInstance8 = nameValue8;
                virtualMachineJsonInstance.name = nameInstance8;
              }
              
              var typeValue6 = valueValue['type'];
              if (typeValue6 !== null && typeValue6 !== undefined) {
                var typeInstance6 = typeValue6;
                virtualMachineJsonInstance.type = typeInstance6;
              }
              
              var locationValue2 = valueValue['location'];
              if (locationValue2 !== null && locationValue2 !== undefined) {
                var locationInstance2 = locationValue2;
                virtualMachineJsonInstance.location = locationInstance2;
              }
              
              var tagsSequenceElement2 = valueValue['tags'];
              if (tagsSequenceElement2 !== null && tagsSequenceElement2 !== undefined) {
                for (var property2 in tagsSequenceElement2) {
                  var tagsKey2 = property2;
                  var tagsValue2 = tagsSequenceElement2[property2];
                  virtualMachineJsonInstance.tags[tagsKey2] = tagsValue2;
                }
              }
            }
          }
          
          var nextLinkValue = responseDoc['nextLink'];
          if (nextLinkValue !== null && nextLinkValue !== undefined) {
            var nextLinkInstance = nextLinkValue;
            result.nextLink = nextLinkInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The operation to power off (stop) a virtual machine.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} vmName The name of the virtual machine.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.powerOff = function(resourceGroupName, vmName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachines.beginPoweringOff(resourceGroupName, vmName, 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.getLongRunningOperationStatus(result.azureAsyncOperation, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The operation to restart a virtual machine.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} vmName The name of the virtual machine.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.restart = function(resourceGroupName, vmName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachines.beginRestarting(resourceGroupName, vmName, 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.getLongRunningOperationStatus(result.azureAsyncOperation, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * The operation to start a virtual machine.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} vmName The name of the virtual machine.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineOperations.prototype.start = function(resourceGroupName, vmName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.virtualMachines.beginStarting(resourceGroupName, vmName, 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.getLongRunningOperationStatus(result.azureAsyncOperation, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  return VirtualMachineOperations;
})();

var VirtualMachineSizeOperations = ( /** @lends VirtualMachineSizeOperations */ function() {
  /**
   * @class
   * Operations for listing virtual machine sizes available in a region.
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [ComputeManagementClient] {@link
   * ComputeManagementClient~ComputeManagementClient}.
   * See [virtualMachineSizes] {@link
   * ComputeManagementClient~ComputeManagementClient#virtualMachineSizes}.
   * Initializes a new instance of the VirtualMachineSizeOperations class.
   * @constructor
   * 
   * @param {ComputeManagementClient} client Reference to the service client.
   */
  function VirtualMachineSizeOperations(client) {
    this.client = client;
  }
  
  /**
   * Lists virtual-machine-sizes available in a location for a subscription.
   * 
   * @param {string} location The location upon which virtual-machine-sizes is
   * queried.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  VirtualMachineSizeOperations.prototype.list = function(location, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (location === null || location === undefined) {
      return callback(new Error('location cannot be null.'));
    }
    if (location !== null && location !== undefined && location.length > 1000) {
      return callback(new Error('location is outside the valid range.'));
    }
    if (/^[-\w\._]+$/.test(location) === false) {
      return callback(new Error('location is outside the valid range.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Compute';
    url2 = url2 + '/locations/';
    url2 = url2 + encodeURIComponent(location);
    url2 = url2 + '/vmSizes';
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-15');
    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['Content-Type'] = 'application/json';
    
    // 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 = { virtualMachineSizes: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var valueArray = responseDoc['value'];
          if (valueArray !== null && valueArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var valueValue = valueArray[loweredIndex1];
              var virtualMachineSizeInstance = {};
              result.virtualMachineSizes.push(virtualMachineSizeInstance);
              
              var nameValue = valueValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                virtualMachineSizeInstance.name = nameInstance;
              }
              
              var numberOfCoresValue = valueValue['numberOfCores'];
              if (numberOfCoresValue !== null && numberOfCoresValue !== undefined) {
                var numberOfCoresInstance = numberOfCoresValue;
                virtualMachineSizeInstance.numberOfCores = numberOfCoresInstance;
              }
              
              var osDiskSizeInMBValue = valueValue['osDiskSizeInMB'];
              if (osDiskSizeInMBValue !== null && osDiskSizeInMBValue !== undefined) {
                var osDiskSizeInMBInstance = osDiskSizeInMBValue;
                virtualMachineSizeInstance.oSDiskSizeInMB = osDiskSizeInMBInstance;
              }
              
              var resourceDiskSizeInMBValue = valueValue['resourceDiskSizeInMB'];
              if (resourceDiskSizeInMBValue !== null && resourceDiskSizeInMBValue !== undefined) {
                var resourceDiskSizeInMBInstance = resourceDiskSizeInMBValue;
                virtualMachineSizeInstance.resourceDiskSizeInMB = resourceDiskSizeInMBInstance;
              }
              
              var memoryInMBValue = valueValue['memoryInMB'];
              if (memoryInMBValue !== null && memoryInMBValue !== undefined) {
                var memoryInMBInstance = memoryInMBValue;
                virtualMachineSizeInstance.memoryInMB = memoryInMBInstance;
              }
              
              var maxDataDiskCountValue = valueValue['maxDataDiskCount'];
              if (maxDataDiskCountValue !== null && maxDataDiskCountValue !== undefined) {
                var maxDataDiskCountInstance = maxDataDiskCountValue;
                virtualMachineSizeInstance.maxDataDiskCount = maxDataDiskCountInstance;
              }
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return VirtualMachineSizeOperations;
})();
