azure-cli
Version:
Microsoft Azure Cross Platform Command Line tool
1,141 lines (1,096 loc) • 456 kB
JavaScript
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is
* regenerated.
*/
'use strict';
const msRest = require('ms-rest');
const msRestAzure = require('ms-rest-azure');
const WebResource = msRest.WebResource;
/**
* Create or update a VM scale set.
*
* @param {string} resourceGroupName The name of the resource group.
*
* @param {string} vmScaleSetName The name of the VM scale set to create or
* update.
*
* @param {object} parameters The scale set object.
*
* @param {object} [parameters.sku] The virtual machine scale set sku.
*
* @param {string} [parameters.sku.name] The sku name.
*
* @param {string} [parameters.sku.tier] Specifies the tier of virtual machines
* in a scale set.<br /><br /> Possible Values:<br /><br /> **Standard**<br
* /><br /> **Basic**
*
* @param {number} [parameters.sku.capacity] Specifies the number of virtual
* machines in the scale set.
*
* @param {object} [parameters.plan] Specifies information about the
* marketplace image used to create the virtual machine. This element is only
* used for marketplace images. Before you can use a marketplace image from an
* API, you must enable the image for programmatic use. In the Azure portal,
* find the marketplace image that you want to use and then click **Want to
* deploy programmatically, Get Started ->**. Enter any required information
* and then click **Save**.
*
* @param {string} [parameters.plan.name] The plan ID.
*
* @param {string} [parameters.plan.publisher] The publisher ID.
*
* @param {string} [parameters.plan.product] Specifies the product of the image
* from the marketplace. This is the same value as Offer under the
* imageReference element.
*
* @param {string} [parameters.plan.promotionCode] The promotion code.
*
* @param {object} [parameters.upgradePolicy] The upgrade policy.
*
* @param {string} [parameters.upgradePolicy.mode] Specifies the mode of an
* upgrade to virtual machines in the scale set.<br /><br /> Possible values
* are:<br /><br /> **Manual** - You control the application of updates to
* virtual machines in the scale set. You do this by using the manualUpgrade
* action.<br /><br /> **Automatic** - All virtual machines in the scale set
* are automatically updated at the same time. Possible values include:
* 'Automatic', 'Manual', 'Rolling'
*
* @param {object} [parameters.upgradePolicy.rollingUpgradePolicy] The
* configuration parameters used while performing a rolling upgrade.
*
* @param {number}
* [parameters.upgradePolicy.rollingUpgradePolicy.maxBatchInstancePercent] The
* maximum percent of total virtual machine instances that will be upgraded
* simultaneously by the rolling upgrade in one batch. As this is a maximum,
* unhealthy instances in previous or future batches can cause the percentage
* of instances in a batch to decrease to ensure higher reliability. The
* default value for this parameter is 20%.
*
* @param {number}
* [parameters.upgradePolicy.rollingUpgradePolicy.maxUnhealthyInstancePercent]
* The maximum percentage of the total virtual machine instances in the scale
* set that can be simultaneously unhealthy, either as a result of being
* upgraded, or by being found in an unhealthy state by the virtual machine
* health checks before the rolling upgrade aborts. This constraint will be
* checked prior to starting any batch. The default value for this parameter is
* 20%.
*
* @param {number}
* [parameters.upgradePolicy.rollingUpgradePolicy.maxUnhealthyUpgradedInstancePercent]
* The maximum percentage of upgraded virtual machine instances that can be
* found to be in an unhealthy state. This check will happen after each batch
* is upgraded. If this percentage is ever exceeded, the rolling update aborts.
* The default value for this parameter is 20%.
*
* @param {string}
* [parameters.upgradePolicy.rollingUpgradePolicy.pauseTimeBetweenBatches] The
* wait time between completing the update for all virtual machines in one
* batch and starting the next batch. The time duration should be specified in
* ISO 8601 format. The default value is 0 seconds (PT0S).
*
* @param {boolean} [parameters.upgradePolicy.automaticOSUpgrade] Whether OS
* upgrades should automatically be applied to scale set instances in a rolling
* fashion when a newer version of the image becomes available.
*
* @param {object} [parameters.virtualMachineProfile] The virtual machine
* profile.
*
* @param {object} [parameters.virtualMachineProfile.osProfile] Specifies the
* operating system settings for the virtual machines in the scale set.
*
* @param {string}
* [parameters.virtualMachineProfile.osProfile.computerNamePrefix] Specifies
* the computer name prefix for all of the virtual machines in the scale set.
* Computer name prefixes must be 1 to 15 characters long.
*
* @param {string} [parameters.virtualMachineProfile.osProfile.adminUsername]
* Specifies the name of the administrator account. <br><br> **Windows-only
* restriction:** Cannot end in "." <br><br> **Disallowed values:**
* "administrator", "admin", "user", "user1", "test", "user2", "test1",
* "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet",
* "backup", "console", "david", "guest", "john", "owner", "root", "server",
* "sql", "support", "support_388945a0", "sys", "test2", "test3", "user4",
* "user5". <br><br> **Minimum-length (Linux):** 1 character <br><br>
* **Max-length (Linux):** 64 characters <br><br> **Max-length (Windows):** 20
* characters <br><br><li> For root access to the Linux VM, see [Using root
* privileges on Linux virtual machines in
* Azure](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-use-root-privileges?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json)<br><li>
* For a list of built-in system users on Linux that should not be used in this
* field, see [Selecting User Names for Linux on
* Azure](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-usernames?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json)
*
* @param {string} [parameters.virtualMachineProfile.osProfile.adminPassword]
* Specifies the password of the administrator account. <br><br>
* **Minimum-length (Windows):** 8 characters <br><br> **Minimum-length
* (Linux):** 6 characters <br><br> **Max-length (Windows):** 123 characters
* <br><br> **Max-length (Linux):** 72 characters <br><br> **Complexity
* requirements:** 3 out of 4 conditions below need to be fulfilled <br> Has
* lower characters <br>Has upper characters <br> Has a digit <br> Has a
* special character (Regex match [\W_]) <br><br> **Disallowed values:**
* "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", "pass@word1",
* "Password!", "Password1", "Password22", "iloveyou!" <br><br> For resetting
* the password, see [How to reset the Remote Desktop service or its login
* password in a Windows
* VM](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-windows-reset-rdp?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json)
* <br><br> For resetting root password, see [Manage users, SSH, and check or
* repair disks on Azure Linux VMs using the VMAccess
* Extension](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-using-vmaccess-extension?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json#reset-root-password)
*
* @param {string} [parameters.virtualMachineProfile.osProfile.customData]
* Specifies a base-64 encoded string of custom data. The base-64 encoded
* string is decoded to a binary array that is saved as a file on the Virtual
* Machine. The maximum length of the binary array is 65535 bytes. <br><br> For
* using cloud-init for your VM, see [Using cloud-init to customize a Linux VM
* during
* creation](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-using-cloud-init?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json)
*
* @param {object}
* [parameters.virtualMachineProfile.osProfile.windowsConfiguration] Specifies
* Windows operating system settings on the virtual machine.
*
* @param {boolean}
* [parameters.virtualMachineProfile.osProfile.windowsConfiguration.provisionVMAgent]
* Indicates whether virtual machine agent should be provisioned on the virtual
* machine. <br><br> When this property is not specified in the request body,
* default behavior is to set it to true. This will ensure that VM Agent is
* installed on the VM so that extensions can be added to the VM later.
*
* @param {boolean}
* [parameters.virtualMachineProfile.osProfile.windowsConfiguration.enableAutomaticUpdates]
* Indicates whether virtual machine is enabled for automatic updates.
*
* @param {string}
* [parameters.virtualMachineProfile.osProfile.windowsConfiguration.timeZone]
* Specifies the time zone of the virtual machine. e.g. "Pacific Standard Time"
*
* @param {array}
* [parameters.virtualMachineProfile.osProfile.windowsConfiguration.additionalUnattendContent]
* Specifies additional base-64 encoded XML formatted information that can be
* included in the Unattend.xml file, which is used by Windows Setup.
*
* @param {object}
* [parameters.virtualMachineProfile.osProfile.windowsConfiguration.winRM]
* Specifies the Windows Remote Management listeners. This enables remote
* Windows PowerShell.
*
* @param {array}
* [parameters.virtualMachineProfile.osProfile.windowsConfiguration.winRM.listeners]
* The list of Windows Remote Management listeners
*
* @param {object}
* [parameters.virtualMachineProfile.osProfile.linuxConfiguration] Specifies
* the Linux operating system settings on the virtual machine. <br><br>For a
* list of supported Linux distributions, see [Linux on Azure-Endorsed
* Distributions](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-endorsed-distros?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json)
* <br><br> For running non-endorsed distributions, see [Information for
* Non-Endorsed
* Distributions](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-create-upload-generic?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json).
*
* @param {boolean}
* [parameters.virtualMachineProfile.osProfile.linuxConfiguration.disablePasswordAuthentication]
* Specifies whether password authentication should be disabled.
*
* @param {object}
* [parameters.virtualMachineProfile.osProfile.linuxConfiguration.ssh]
* Specifies the ssh key configuration for a Linux OS.
*
* @param {array}
* [parameters.virtualMachineProfile.osProfile.linuxConfiguration.ssh.publicKeys]
* The list of SSH public keys used to authenticate with linux based VMs.
*
* @param {array} [parameters.virtualMachineProfile.osProfile.secrets]
* Specifies set of certificates that should be installed onto the virtual
* machines in the scale set.
*
* @param {object} [parameters.virtualMachineProfile.storageProfile] Specifies
* the storage settings for the virtual machine disks.
*
* @param {object}
* [parameters.virtualMachineProfile.storageProfile.imageReference] Specifies
* information about the image to use. You can specify information about
* platform images, marketplace images, or virtual machine images. This element
* is required when you want to use a platform image, marketplace image, or
* virtual machine image, but is not used in other creation operations.
*
* @param {string}
* [parameters.virtualMachineProfile.storageProfile.imageReference.publisher]
* The image publisher.
*
* @param {string}
* [parameters.virtualMachineProfile.storageProfile.imageReference.offer]
* Specifies the offer of the platform image or marketplace image used to
* create the virtual machine.
*
* @param {string}
* [parameters.virtualMachineProfile.storageProfile.imageReference.sku] The
* image SKU.
*
* @param {string}
* [parameters.virtualMachineProfile.storageProfile.imageReference.version]
* Specifies the version of the platform image or marketplace image used to
* create the virtual machine. The allowed formats are Major.Minor.Build or
* 'latest'. Major, Minor, and Build are decimal numbers. Specify 'latest' to
* use the latest version of an image available at deploy time. Even if you use
* 'latest', the VM image will not automatically update after deploy time even
* if a new version becomes available.
*
* @param {string}
* [parameters.virtualMachineProfile.storageProfile.imageReference.id] Resource
* Id
*
* @param {object} [parameters.virtualMachineProfile.storageProfile.osDisk]
* Specifies information about the operating system disk used by the virtual
* machines in the scale set. <br><br> For more information about disks, see
* [About disks and VHDs for Azure virtual
* machines](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-windows-about-disks-vhds?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json).
*
* @param {string}
* [parameters.virtualMachineProfile.storageProfile.osDisk.name] The disk name.
*
* @param {string}
* [parameters.virtualMachineProfile.storageProfile.osDisk.caching] Specifies
* the caching requirements. <br><br> Possible values are: <br><br> **None**
* <br><br> **ReadOnly** <br><br> **ReadWrite** <br><br> Default: **None for
* Standard storage. ReadOnly for Premium storage**. Possible values include:
* 'None', 'ReadOnly', 'ReadWrite'
*
* @param {string}
* parameters.virtualMachineProfile.storageProfile.osDisk.createOption
* Specifies how the virtual machines in the scale set should be
* created.<br><br> The only allowed value is: **FromImage** \u2013 This value
* is used when you are using an image to create the virtual machine. If you
* are using a platform image, you also use the imageReference element
* described above. If you are using a marketplace image, you also use the
* plan element previously described. Possible values include: 'fromImage',
* 'empty', 'attach'
*
* @param {string}
* [parameters.virtualMachineProfile.storageProfile.osDisk.osType] This
* property allows you to specify the type of the OS that is included in the
* disk if creating a VM from user-image or a specialized VHD. <br><br>
* Possible values are: <br><br> **Windows** <br><br> **Linux**. Possible
* values include: 'Windows', 'Linux'
*
* @param {object}
* [parameters.virtualMachineProfile.storageProfile.osDisk.image] Specifies
* information about the unmanaged user image to base the scale set on.
*
* @param {string}
* [parameters.virtualMachineProfile.storageProfile.osDisk.image.uri] Specifies
* the virtual hard disk's uri.
*
* @param {array}
* [parameters.virtualMachineProfile.storageProfile.osDisk.vhdContainers]
* Specifies the container urls that are used to store operating system disks
* for the scale set.
*
* @param {object}
* [parameters.virtualMachineProfile.storageProfile.osDisk.managedDisk] The
* managed disk parameters.
*
* @param {string}
* [parameters.virtualMachineProfile.storageProfile.osDisk.managedDisk.storageAccountType]
* Specifies the storage account type for the managed disk. Possible values
* are: Standard_LRS or Premium_LRS. Possible values include: 'Standard_LRS',
* 'Premium_LRS'
*
* @param {array} [parameters.virtualMachineProfile.storageProfile.dataDisks]
* Specifies the parameters that are used to add data disks to the virtual
* machines in the scale set. <br><br> For more information about disks, see
* [About disks and VHDs for Azure virtual
* machines](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-windows-about-disks-vhds?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json).
*
* @param {object} [parameters.virtualMachineProfile.networkProfile] Specifies
* properties of the network interfaces of the virtual machines in the scale
* set.
*
* @param {object}
* [parameters.virtualMachineProfile.networkProfile.healthProbe] A reference to
* a load balancer probe used to determine the health of an instance in the
* virtual machine scale set. The reference will be in the form:
* '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'.
*
* @param {string}
* [parameters.virtualMachineProfile.networkProfile.healthProbe.id] The ARM
* resource id in the form of
* /subscriptions/{SubcriptionId}/resourceGroups/{ResourceGroupName}/...
*
* @param {array}
* [parameters.virtualMachineProfile.networkProfile.networkInterfaceConfigurations]
* The list of network configurations.
*
* @param {object} [parameters.virtualMachineProfile.diagnosticsProfile]
* Specifies the boot diagnostic settings state. <br><br>Minimum api-version:
* 2015-06-15.
*
* @param {object}
* [parameters.virtualMachineProfile.diagnosticsProfile.bootDiagnostics] Boot
* Diagnostics is a debugging feature which allows you to view Console Output
* and Screenshot to diagnose VM status. <br><br> For Linux Virtual Machines,
* you can easily view the output of your console log. <br><br> For both
* Windows and Linux virtual machines, Azure also enables you to see a
* screenshot of the VM from the hypervisor.
*
* @param {boolean}
* [parameters.virtualMachineProfile.diagnosticsProfile.bootDiagnostics.enabled]
* Whether boot diagnostics should be enabled on the Virtual Machine.
*
* @param {string}
* [parameters.virtualMachineProfile.diagnosticsProfile.bootDiagnostics.storageUri]
* Uri of the storage account to use for placing the console output and
* screenshot.
*
* @param {object} [parameters.virtualMachineProfile.extensionProfile]
* Specifies a collection of settings for extensions installed on virtual
* machines in the scale set.
*
* @param {array}
* [parameters.virtualMachineProfile.extensionProfile.extensions] The virtual
* machine scale set child extension resources.
*
* @param {string} [parameters.virtualMachineProfile.licenseType] Specifies
* that the image or disk that is being used was licensed on-premises. This
* element is only used for images that contain the Windows Server operating
* system. <br><br> Possible values are: <br><br> Windows_Client <br><br>
* Windows_Server <br><br> If this element is included in a request for an
* update, the value must match the initial value. This value cannot be
* updated. <br><br> For more information, see [Azure Hybrid Use Benefit for
* Windows
* Server](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-windows-hybrid-use-benefit-licensing?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json)
* <br><br> Minimum api-version: 2015-06-15
*
* @param {boolean} [parameters.overprovision] Specifies whether the Virtual
* Machine Scale Set should be overprovisioned.
*
* @param {boolean} [parameters.singlePlacementGroup] When true this limits the
* scale set to a single placement group, of max size 100 virtual machines.
*
* @param {object} [parameters.identity] The identity of the virtual machine
* scale set, if configured.
*
* @param {string} [parameters.identity.type] The type of identity used for the
* virtual machine scale set. Currently, the only supported type is
* 'SystemAssigned', which implicitly creates an identity. Possible values
* include: 'SystemAssigned'
*
* @param {array} [parameters.zones] The virtual machine scale set zones.
*
* @param {string} parameters.location Resource location
*
* @param {object} [parameters.tags] Resource tags
*
* @param {object} [options] Optional Parameters.
*
* @param {object} [options.customHeaders] Headers that will be added to the
* request
*
* @param {function} callback - The callback.
*
* @returns {function} callback(err, result, request, response)
*
* {Error} err - The Error object if an error occurred, null otherwise.
*
* {object} [result] - The deserialized result object if an error did not occur.
* See {@link VirtualMachineScaleSet} for more
* information.
*
* {object} [request] - The HTTP Request object if an error did not occur.
*
* {stream} [response] - The HTTP Response stream if an error did not occur.
*/
function _createOrUpdate(resourceGroupName, vmScaleSetName, parameters, options, callback) {
/* jshint validthis: true */
let client = this.client;
if(!callback && typeof options === 'function') {
callback = options;
options = null;
}
if (!callback) {
throw new Error('callback cannot be null.');
}
// Send request
this.beginCreateOrUpdate(resourceGroupName, vmScaleSetName, parameters, options, (err, parsedResult, httpRequest, response) => {
if (err) return callback(err);
let initialResult = new msRest.HttpOperationResponse();
initialResult.request = httpRequest;
initialResult.response = response;
initialResult.body = response.body;
client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => {
if (err) return callback(err);
// Create Result
let result = null;
httpRequest = pollingResult.request;
response = pollingResult.response;
let responseBody = pollingResult.body;
if (responseBody === '') responseBody = null;
// Deserialize Response
let parsedResponse = null;
try {
parsedResponse = JSON.parse(responseBody);
result = JSON.parse(responseBody);
if (parsedResponse !== null && parsedResponse !== undefined) {
let resultMapper = new client.models['VirtualMachineScaleSet']().mapper();
result = client.deserialize(resultMapper, parsedResponse, 'result');
}
} catch (error) {
let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
deserializationError.request = msRest.stripRequest(httpRequest);
deserializationError.response = msRest.stripResponse(response);
return callback(deserializationError);
}
return callback(null, result, httpRequest, response);
});
});
}
/**
* Update a VM scale set.
*
* @param {string} resourceGroupName The name of the resource group.
*
* @param {string} vmScaleSetName The name of the VM scale set to create or
* update.
*
* @param {object} parameters The scale set object.
*
* @param {object} [parameters.sku] The virtual machine scale set sku.
*
* @param {string} [parameters.sku.name] The sku name.
*
* @param {string} [parameters.sku.tier] Specifies the tier of virtual machines
* in a scale set.<br /><br /> Possible Values:<br /><br /> **Standard**<br
* /><br /> **Basic**
*
* @param {number} [parameters.sku.capacity] Specifies the number of virtual
* machines in the scale set.
*
* @param {object} [parameters.plan] The purchase plan when deploying a virtual
* machine scale set from VM Marketplace images.
*
* @param {string} [parameters.plan.name] The plan ID.
*
* @param {string} [parameters.plan.publisher] The publisher ID.
*
* @param {string} [parameters.plan.product] Specifies the product of the image
* from the marketplace. This is the same value as Offer under the
* imageReference element.
*
* @param {string} [parameters.plan.promotionCode] The promotion code.
*
* @param {object} [parameters.upgradePolicy] The upgrade policy.
*
* @param {string} [parameters.upgradePolicy.mode] Specifies the mode of an
* upgrade to virtual machines in the scale set.<br /><br /> Possible values
* are:<br /><br /> **Manual** - You control the application of updates to
* virtual machines in the scale set. You do this by using the manualUpgrade
* action.<br /><br /> **Automatic** - All virtual machines in the scale set
* are automatically updated at the same time. Possible values include:
* 'Automatic', 'Manual', 'Rolling'
*
* @param {object} [parameters.upgradePolicy.rollingUpgradePolicy] The
* configuration parameters used while performing a rolling upgrade.
*
* @param {number}
* [parameters.upgradePolicy.rollingUpgradePolicy.maxBatchInstancePercent] The
* maximum percent of total virtual machine instances that will be upgraded
* simultaneously by the rolling upgrade in one batch. As this is a maximum,
* unhealthy instances in previous or future batches can cause the percentage
* of instances in a batch to decrease to ensure higher reliability. The
* default value for this parameter is 20%.
*
* @param {number}
* [parameters.upgradePolicy.rollingUpgradePolicy.maxUnhealthyInstancePercent]
* The maximum percentage of the total virtual machine instances in the scale
* set that can be simultaneously unhealthy, either as a result of being
* upgraded, or by being found in an unhealthy state by the virtual machine
* health checks before the rolling upgrade aborts. This constraint will be
* checked prior to starting any batch. The default value for this parameter is
* 20%.
*
* @param {number}
* [parameters.upgradePolicy.rollingUpgradePolicy.maxUnhealthyUpgradedInstancePercent]
* The maximum percentage of upgraded virtual machine instances that can be
* found to be in an unhealthy state. This check will happen after each batch
* is upgraded. If this percentage is ever exceeded, the rolling update aborts.
* The default value for this parameter is 20%.
*
* @param {string}
* [parameters.upgradePolicy.rollingUpgradePolicy.pauseTimeBetweenBatches] The
* wait time between completing the update for all virtual machines in one
* batch and starting the next batch. The time duration should be specified in
* ISO 8601 format. The default value is 0 seconds (PT0S).
*
* @param {boolean} [parameters.upgradePolicy.automaticOSUpgrade] Whether OS
* upgrades should automatically be applied to scale set instances in a rolling
* fashion when a newer version of the image becomes available.
*
* @param {object} [parameters.virtualMachineProfile] The virtual machine
* profile.
*
* @param {object} [parameters.virtualMachineProfile.osProfile] The virtual
* machine scale set OS profile.
*
* @param {string} [parameters.virtualMachineProfile.osProfile.customData] A
* base-64 encoded string of custom data.
*
* @param {object}
* [parameters.virtualMachineProfile.osProfile.windowsConfiguration] The
* Windows Configuration of the OS profile.
*
* @param {boolean}
* [parameters.virtualMachineProfile.osProfile.windowsConfiguration.provisionVMAgent]
* Indicates whether virtual machine agent should be provisioned on the virtual
* machine. <br><br> When this property is not specified in the request body,
* default behavior is to set it to true. This will ensure that VM Agent is
* installed on the VM so that extensions can be added to the VM later.
*
* @param {boolean}
* [parameters.virtualMachineProfile.osProfile.windowsConfiguration.enableAutomaticUpdates]
* Indicates whether virtual machine is enabled for automatic updates.
*
* @param {string}
* [parameters.virtualMachineProfile.osProfile.windowsConfiguration.timeZone]
* Specifies the time zone of the virtual machine. e.g. "Pacific Standard Time"
*
* @param {array}
* [parameters.virtualMachineProfile.osProfile.windowsConfiguration.additionalUnattendContent]
* Specifies additional base-64 encoded XML formatted information that can be
* included in the Unattend.xml file, which is used by Windows Setup.
*
* @param {object}
* [parameters.virtualMachineProfile.osProfile.windowsConfiguration.winRM]
* Specifies the Windows Remote Management listeners. This enables remote
* Windows PowerShell.
*
* @param {array}
* [parameters.virtualMachineProfile.osProfile.windowsConfiguration.winRM.listeners]
* The list of Windows Remote Management listeners
*
* @param {object}
* [parameters.virtualMachineProfile.osProfile.linuxConfiguration] The Linux
* Configuration of the OS profile.
*
* @param {boolean}
* [parameters.virtualMachineProfile.osProfile.linuxConfiguration.disablePasswordAuthentication]
* Specifies whether password authentication should be disabled.
*
* @param {object}
* [parameters.virtualMachineProfile.osProfile.linuxConfiguration.ssh]
* Specifies the ssh key configuration for a Linux OS.
*
* @param {array}
* [parameters.virtualMachineProfile.osProfile.linuxConfiguration.ssh.publicKeys]
* The list of SSH public keys used to authenticate with linux based VMs.
*
* @param {array} [parameters.virtualMachineProfile.osProfile.secrets] The List
* of certificates for addition to the VM.
*
* @param {object} [parameters.virtualMachineProfile.storageProfile] The
* virtual machine scale set storage profile.
*
* @param {object}
* [parameters.virtualMachineProfile.storageProfile.imageReference] The image
* reference.
*
* @param {string}
* [parameters.virtualMachineProfile.storageProfile.imageReference.publisher]
* The image publisher.
*
* @param {string}
* [parameters.virtualMachineProfile.storageProfile.imageReference.offer]
* Specifies the offer of the platform image or marketplace image used to
* create the virtual machine.
*
* @param {string}
* [parameters.virtualMachineProfile.storageProfile.imageReference.sku] The
* image SKU.
*
* @param {string}
* [parameters.virtualMachineProfile.storageProfile.imageReference.version]
* Specifies the version of the platform image or marketplace image used to
* create the virtual machine. The allowed formats are Major.Minor.Build or
* 'latest'. Major, Minor, and Build are decimal numbers. Specify 'latest' to
* use the latest version of an image available at deploy time. Even if you use
* 'latest', the VM image will not automatically update after deploy time even
* if a new version becomes available.
*
* @param {string}
* [parameters.virtualMachineProfile.storageProfile.imageReference.id] Resource
* Id
*
* @param {object} [parameters.virtualMachineProfile.storageProfile.osDisk] The
* OS disk.
*
* @param {string}
* [parameters.virtualMachineProfile.storageProfile.osDisk.caching] The caching
* type. Possible values include: 'None', 'ReadOnly', 'ReadWrite'
*
* @param {object}
* [parameters.virtualMachineProfile.storageProfile.osDisk.image] 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.virtualMachineProfile.storageProfile.osDisk.image.uri] Specifies
* the virtual hard disk's uri.
*
* @param {array}
* [parameters.virtualMachineProfile.storageProfile.osDisk.vhdContainers] The
* list of virtual hard disk container uris.
*
* @param {object}
* [parameters.virtualMachineProfile.storageProfile.osDisk.managedDisk] The
* managed disk parameters.
*
* @param {string}
* [parameters.virtualMachineProfile.storageProfile.osDisk.managedDisk.storageAccountType]
* Specifies the storage account type for the managed disk. Possible values
* are: Standard_LRS or Premium_LRS. Possible values include: 'Standard_LRS',
* 'Premium_LRS'
*
* @param {array} [parameters.virtualMachineProfile.storageProfile.dataDisks]
* The data disks.
*
* @param {object} [parameters.virtualMachineProfile.networkProfile] The
* virtual machine scale set network profile.
*
* @param {array}
* [parameters.virtualMachineProfile.networkProfile.networkInterfaceConfigurations]
* The list of network configurations.
*
* @param {object} [parameters.virtualMachineProfile.diagnosticsProfile] The
* virtual machine scale set diagnostics profile.
*
* @param {object}
* [parameters.virtualMachineProfile.diagnosticsProfile.bootDiagnostics] Boot
* Diagnostics is a debugging feature which allows you to view Console Output
* and Screenshot to diagnose VM status. <br><br> For Linux Virtual Machines,
* you can easily view the output of your console log. <br><br> For both
* Windows and Linux virtual machines, Azure also enables you to see a
* screenshot of the VM from the hypervisor.
*
* @param {boolean}
* [parameters.virtualMachineProfile.diagnosticsProfile.bootDiagnostics.enabled]
* Whether boot diagnostics should be enabled on the Virtual Machine.
*
* @param {string}
* [parameters.virtualMachineProfile.diagnosticsProfile.bootDiagnostics.storageUri]
* Uri of the storage account to use for placing the console output and
* screenshot.
*
* @param {object} [parameters.virtualMachineProfile.extensionProfile] The
* virtual machine scale set extension profile.
*
* @param {array}
* [parameters.virtualMachineProfile.extensionProfile.extensions] The virtual
* machine scale set child extension resources.
*
* @param {string} [parameters.virtualMachineProfile.licenseType] The license
* type, which is for bring your own license scenario.
*
* @param {boolean} [parameters.overprovision] Specifies whether the Virtual
* Machine Scale Set should be overprovisioned.
*
* @param {boolean} [parameters.singlePlacementGroup] When true this limits the
* scale set to a single placement group, of max size 100 virtual machines.
*
* @param {object} [parameters.identity] The identity of the virtual machine
* scale set, if configured.
*
* @param {string} [parameters.identity.type] The type of identity used for the
* virtual machine scale set. Currently, the only supported type is
* 'SystemAssigned', which implicitly creates an identity. Possible values
* include: 'SystemAssigned'
*
* @param {object} [parameters.tags] Resource tags
*
* @param {object} [options] Optional Parameters.
*
* @param {object} [options.customHeaders] Headers that will be added to the
* request
*
* @param {function} callback - The callback.
*
* @returns {function} callback(err, result, request, response)
*
* {Error} err - The Error object if an error occurred, null otherwise.
*
* {object} [result] - The deserialized result object if an error did not occur.
* See {@link VirtualMachineScaleSet} for more
* information.
*
* {object} [request] - The HTTP Request object if an error did not occur.
*
* {stream} [response] - The HTTP Response stream if an error did not occur.
*/
function _update(resourceGroupName, vmScaleSetName, parameters, options, callback) {
/* jshint validthis: true */
let client = this.client;
if(!callback && typeof options === 'function') {
callback = options;
options = null;
}
if (!callback) {
throw new Error('callback cannot be null.');
}
// Send request
this.beginUpdate(resourceGroupName, vmScaleSetName, parameters, options, (err, parsedResult, httpRequest, response) => {
if (err) return callback(err);
let initialResult = new msRest.HttpOperationResponse();
initialResult.request = httpRequest;
initialResult.response = response;
initialResult.body = response.body;
client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => {
if (err) return callback(err);
// Create Result
let result = null;
httpRequest = pollingResult.request;
response = pollingResult.response;
let responseBody = pollingResult.body;
if (responseBody === '') responseBody = null;
// Deserialize Response
let parsedResponse = null;
try {
parsedResponse = JSON.parse(responseBody);
result = JSON.parse(responseBody);
if (parsedResponse !== null && parsedResponse !== undefined) {
let resultMapper = new client.models['VirtualMachineScaleSet']().mapper();
result = client.deserialize(resultMapper, parsedResponse, 'result');
}
} catch (error) {
let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
deserializationError.request = msRest.stripRequest(httpRequest);
deserializationError.response = msRest.stripResponse(response);
return callback(deserializationError);
}
return callback(null, result, httpRequest, response);
});
});
}
/**
* Deletes a VM scale set.
*
* @param {string} resourceGroupName The name of the resource group.
*
* @param {string} vmScaleSetName The name of the VM scale set.
*
* @param {object} [options] Optional Parameters.
*
* @param {object} [options.customHeaders] Headers that will be added to the
* request
*
* @param {function} callback - The callback.
*
* @returns {function} callback(err, result, request, response)
*
* {Error} err - The Error object if an error occurred, null otherwise.
*
* {object} [result] - The deserialized result object if an error did not occur.
* See {@link OperationStatusResponse} for more
* information.
*
* {object} [request] - The HTTP Request object if an error did not occur.
*
* {stream} [response] - The HTTP Response stream if an error did not occur.
*/
function _deleteMethod(resourceGroupName, vmScaleSetName, options, callback) {
/* jshint validthis: true */
let client = this.client;
if(!callback && typeof options === 'function') {
callback = options;
options = null;
}
if (!callback) {
throw new Error('callback cannot be null.');
}
// Send request
this.beginDeleteMethod(resourceGroupName, vmScaleSetName, options, (err, parsedResult, httpRequest, response) => {
if (err) return callback(err);
let initialResult = new msRest.HttpOperationResponse();
initialResult.request = httpRequest;
initialResult.response = response;
initialResult.body = response.body;
client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => {
if (err) return callback(err);
// Create Result
let result = null;
httpRequest = pollingResult.request;
response = pollingResult.response;
let responseBody = pollingResult.body;
if (responseBody === '') responseBody = null;
// Deserialize Response
let parsedResponse = null;
try {
parsedResponse = JSON.parse(responseBody);
result = JSON.parse(responseBody);
if (parsedResponse !== null && parsedResponse !== undefined) {
let resultMapper = new client.models['OperationStatusResponse']().mapper();
result = client.deserialize(resultMapper, parsedResponse, 'result');
}
} catch (error) {
let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
deserializationError.request = msRest.stripRequest(httpRequest);
deserializationError.response = msRest.stripResponse(response);
return callback(deserializationError);
}
return callback(null, result, httpRequest, response);
});
});
}
/**
* Display information about a virtual machine scale set.
*
* @param {string} resourceGroupName The name of the resource group.
*
* @param {string} vmScaleSetName The name of the VM scale set.
*
* @param {object} [options] Optional Parameters.
*
* @param {object} [options.customHeaders] Headers that will be added to the
* request
*
* @param {function} callback - The callback.
*
* @returns {function} callback(err, result, request, response)
*
* {Error} err - The Error object if an error occurred, null otherwise.
*
* {object} [result] - The deserialized result object if an error did not occur.
* See {@link VirtualMachineScaleSet} for more
* information.
*
* {object} [request] - The HTTP Request object if an error did not occur.
*
* {stream} [response] - The HTTP Response stream if an error did not occur.
*/
function _get(resourceGroupName, vmScaleSetName, options, callback) {
/* jshint validthis: true */
let client = this.client;
if(!callback && typeof options === 'function') {
callback = options;
options = null;
}
if (!callback) {
throw new Error('callback cannot be null.');
}
let apiVersion = '2017-03-30';
// Validate
try {
if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
}
if (vmScaleSetName === null || vmScaleSetName === undefined || typeof vmScaleSetName.valueOf() !== 'string') {
throw new Error('vmScaleSetName cannot be null or undefined and it must be of type string.');
}
if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
}
if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
throw new Error('this.client.acceptLanguage must be of type string.');
}
} catch (error) {
return callback(error);
}
// Construct URL
let baseUrl = this.client.baseUri;
let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}';
requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
requestUrl = requestUrl.replace('{vmScaleSetName}', encodeURIComponent(vmScaleSetName));
requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
let queryParameters = [];
queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
if (queryParameters.length > 0) {
requestUrl += '?' + queryParameters.join('&');
}
// Create HTTP transport objects
let httpRequest = new WebResource();
httpRequest.method = 'GET';
httpRequest.url = requestUrl;
httpRequest.headers = {};
// Set Headers
httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
if (this.client.generateClientRequestId) {
httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
}
if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
httpRequest.headers['accept-language'] = this.client.acceptLanguage;
}
if(options) {
for(let headerName in options['customHeaders']) {
if (options['customHeaders'].hasOwnProperty(headerName)) {
httpRequest.headers[headerName] = options['customHeaders'][headerName];
}
}
}
httpRequest.body = null;
// Send Request
return client.pipeline(httpRequest, (err, response, responseBody) => {
if (err) {
return callback(err);
}
let statusCode = response.statusCode;
if (statusCode !== 200) {
let error = new Error(responseBody);
error.statusCode = response.statusCode;
error.request = msRest.stripRequest(httpRequest);
error.response = msRest.stripResponse(response);
if (responseBody === '') responseBody = null;
let parsedErrorResponse;
try {
parsedErrorResponse = JSON.parse(responseBody);
if (parsedErrorResponse) {
if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
}
if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
let resultMapper = new client.models['CloudError']().mapper();
error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
}
} catch (defaultError) {
error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
`- "${responseBody}" for the default response.`;
return callback(error);
}
return callback(error);
}
// Create Result
let result = null;
if (responseBody === '') responseBody = null;
// Deserialize Response
if (statusCode === 200) {
let parsedResponse = null;
try {
parsedResponse = JSON.parse(responseBody);
result = JSON.parse(responseBody);
if (parsedResponse !== null && parsedResponse !== undefined) {
let resultMapper = new client.models['VirtualMachineScaleSet']().mapper();
result = client.deserialize(resultMapper, parsedResponse, 'result');
}
} catch (error) {
let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
deserializationError.request = msRest.stripRequest(httpRequest);
deserializationError.response = msRest.stripResponse(response);
return callback(deserializationError);
}
}
return callback(null, result, httpRequest, response);
});
}
/**
* Deallocates specific virtual machines in a VM scale set. Shuts down the
* virtual machines and releases the compute resources. You are not billed for
* the compute resources that this virtual machine scale set deallocates.
*
* @param {string} resourceGroupName The name of the resource group.
*
* @param {string} vmScaleSetName The name of the VM scale set.
*
* @param {object} [options] Optional Parameters.
*
* @param {array} [options.instanceIds] The virtual machine scale set instance
* ids. Omitting the virtual machine scale set instance ids will result in the
* operation being performed on all virtual machines in the virtual machine
* scale set.
*
* @param {object} [options.customHeaders] Headers that will be added to the
* request
*
* @param {function} callback - The callback.
*
* @returns {function} callback(err, result, request, response)
*
* {Error} err - The Error object if an error occurred, null otherwise.
*
* {object} [result] - The deserialized result object if an error did not occur.
* See {@link OperationStatusResponse} for more
* information.
*
* {object} [request] - The HTTP Request object if an error did not occur.
*
* {stream} [response] - The HTTP Response stream if an error did not occur.
*/
function _deallocate(resourceGroupName, vmScaleSetName, options, callback) {
/* jshint validthis: true */
let client = this.client;
if(!callback && typeof options === 'function') {
callback = options;
options = null;
}
if (!callback) {
throw new Error('callback cannot be null.');
}
// Send request
this.beginDeallocate(resourceGroupName, vmScaleSetName, options, (err, parsedResult, httpRequest, response) => {
if (err) return callback(err);
let initialResult = new msRest.HttpOperationResponse();
initialResult.request = httpRequest;
initialResult.response = response;
initialResult.body = response.body;
client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => {
if (err) return callback(err);
// Create Result
let result = null;
httpRequest = pollingResult.request;
response = pollingResult.response;
let responseBody = pollingResult.body;
if (responseBody === '') responseBody = null;
// Deserialize Response
let parsedResponse = null;
try {
parsedResponse = JSON.parse(responseBody);
result = JSON.parse(responseBody);
if (parsedResponse !== null && parsedResponse !== undefined) {
let resultMapper = new client.models['OperationStatusResponse']().mapper();
result = client.deserialize(resultMapper, parsedResponse, 'result');
}
} catch (error) {
let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
deserializationError.request = msRest.stripRequest(httpRequest);
deserializationError.response = msRest.stripResponse(response);
return callback(deserializationError);
}
return callback(null, result, httpRequest, response);
});
});
}
/**
* Deletes virtual machines in a VM scale set.
*
* @param {string} resourceGroupName The name of the resource group.
*
* @param {string} vmScaleSetName The name of the VM scale set.
*
* @param {array} instanceIds The virtual machine scale set instance ids.
*
* @param {object} [options] Optional Parameters.
*
* @param {object} [options.customHeaders] Headers that will be added to the
* request
*
* @param {function} callback - The callback.
*
* @returns {function} callback(err, result, request, response)
*
* {Error} err - The Error object if an error occurred, null otherwise.
*
* {object} [result] - The deserialized result object if an error did not occur.
* See {@link OperationStatusResponse} for more
* information.
*
* {object} [request] - The HTTP Request object if an error did not occur.
*
* {stream} [response] - The HTTP Response stream if an error did not occur.
*/
function _deleteInstances(resourceGroupName, vmScaleSetName, instanceIds, options, callback) {
/* jshint validthis: true */
let client = this.client;
if(!callback && typeof options === 'function') {
callback = options;
options = null;
}