Reputation: 571
I have a windows VM on which I want to implement autoscaling.
Currently Azure Scaleset does not accepts VM which is already creted.
Has anyone implemented Autoscaling on Azure VM like its there on AWS based on CPU metrics ?
Upvotes: 0
Views: 2508
Reputation: 13974
Has anyone implemented Autoscaling on Azure VM like its there on AWS based on CPU metrics ?
As Rudi said, we can use Azure virtual machine scale set to achieve this. VMSS is scale in or scale out, create another VM to scale out, remove a VM to scale in.
In Azure, we can use runbook to scale up or scale down. Use resize VM size to achieve this.
We can set this via Azure portal: Metrics-->Add metric alert-->select runbook:
Note:
In this way, scale up or scale down will reboot your VM.
Update:
If you want to scale Azure VM horizontally. I think we can use Azure VMSS. Use auto scale rules to achieve it.
More information about Azure VMSS, please refer to this link.
Update2:
We can use Powershell to copy managed disk to Azure storage account, we can use this powershell script:
##create $SAS
$sas = Grant-AzureRmDiskAccess -ResourceGroupName shui -DiskName test -DurationInSecond 3600 -Access Read
$destContext = New-AzureStorageContext –StorageAccountName contosostorageav1 -StorageAccountKey 'YourStorageAccountKey'
Start-AzureStorageBlobCopy -AbsoluteUri $sas.AccessSAS -DestContainer 'vhds' -DestContext $destContext -DestBlob 'MyDestinationBlobName.vhd'
Update3:
We can use this script:
$rgname = "myrg"
$vmssname = "myvmss"
$newversion = "4.0.20160229"
$instanceid = "1"
# get the VMSS model
$vmss = Get-AzureRmVmss -ResourceGroupName $rgname -VMScaleSetName $vmssname
# set the new version in the model data
$vmss.virtualMachineProfile.storageProfile.imageReference.version = $newversion
# update the virtual machine scale set model
Update-AzureRmVmss -ResourceGroupName $rgname -Name $vmssname -VirtualMachineScaleSet $vmss
# now start updating instances
Update-AzureRmVmssInstance -ResourceGroupName $rgname -VMScaleSetName $vmssname -InstanceId $instanceId
More information about it, please refer to this link.
Upvotes: 1
Reputation: 516
I believe the only way you can "scale VMs" horizontally is by using VM Scale sets. Although scale sets do not support already running machines, I would recommend that you take a snapshot of your running machine, and use that as the image for VM Scale sets, and start with 2 images, then implementing your metrics to scale to more instances.
Upvotes: 0