
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Change the Size of Azure VM Using PowerShell
First, to retrieve the size of the Azure VM that is currently applied, we can use the below command.
PS C:\> $vm = Get-AzVM -VMName VMName PS C:\> $vm.HardwareProfile.VmSize
Output
Standard_B1ms
Now to get the size of the Azure VMs available in the particular location we can use the below command.
PS C:\> Get-AzVMSize -VMName $vm.Name -ResourceGroupName $vm.ResourceGroupName
You will get all the available sizes for Azure VM.
Now we need to set the VM size. Here we will first set the size of the VM and then we will update the virtual machine to take the updated size.
PS C:\> $vm.HardwareProfile.VmSize = 'Standard_B2ms' PS C:\> Update-AzVM -VM $vm -ResourceGroupName $vm.ResourceGroupName - Verbose
We are changing the size of the VM from the Standard_B1ms to Standard_B2ms.
Output
VERBOSE: Performing the operation "Update" on target "Win2k16VM1". RequestId IsSuccessStatusCode StatusCode ReasonPhrase --------- ------------------- ---------- ------------ True OK OK
Once we check the hardware size, it should be updated.
PS C:\> (Get-AzVM -VMName vmname).HardwareProfile.VmSize Standard_B2ms
Advertisements