Azure Virtual Machines (VM) is on-demand, scalable, computing resources provided by Microsoft Azure as IAAS. Most of the cloud service providers like AWS and Google provide IAAS related to meet infrastructure demands. Virtual Machine is needed to have more control over the computing environment.
Azure VM gives you the flexibility of virtualization without maintaining a physical machine. Since these services are provided as infrastructure as service so it needs to be maintained after creation. Azure VM used in all environments like Development/Test/QA and Productions as well depending on your requirements.
As you are aware Virtual Machine is the core part of Azure Cloud IAAS offers. Various models of virtual machines provided in an ARM to fulfill all the requirements of different categories of application deployments. The size determines the number of computing resources such as CPU, GPU, and memory that are made available to the virtual machine. VM needs to be sized appropriately for the expected workload.
Of per main advantages of cloud services, it’s scalability. In either case like workload increases, wrong provisioning, or script based deployment in your organization you can resize your VM whenever required.
Obviously, there are many ways to do the same task but here we would like to go through the most common one GUI-based method via Azure Portal and CLI based. Let’s go through some basics first which will help to understand more about the targeted task.
Different Category of Virtual Machines in Azure
How to find available VM sizes in using Azure CLI
To find out available VM sizes in a specific location using CLI via command az vm list-sizes command. The sample truncated output is as below.
How to Start or Stop VM using Azure CLI
We can start or stop VM using az vm start/az vm stop . Please refer to the below snap.
How to get VM Power States using Azure CLI
Before resizing let us see in which state your VM should be. VM may be in various states. There are many ways how you can find the current status of VM. Windows SA will love to use Azure PowerShell while Unix SA will love using Azure CLI most of the time.
In case if you want from GUI Azure Web Portal is your best friend in most of the cases. It depends on which way you would like to achieve the same objective, you can use any and it is true for all the changes/modifications or setup. Below is the snap for various virtual machine status.
How to Correct VM Size in AZURE
As mentioned above let’s see how to resize virtual machines in AZURE using two methods via the web portal or CLI.
(A ) How to Correct or Resize Virtual Machine Size in AZURE using Web Portal
1. log in to Azure Web Console using https://portal.azure.com using your credentials. You will have a console like below.
2. Click on Virtual Machine from the left panel of the console. Please see below.
3. You will get a screen like below which will give you the option to search based on your subscription. You can type your VM name which you need to resize. Once you find your VM click on it. It will open VM.
4. On VM Screen like below. If new VM size in the same cluster or another cluster. VM is expected to be rebooted in either case so it is always better to place VM in a deallocated state. You can achieve by taking the Stop option on this screen.
Once Stop completed you can see VM status as deallocated. Please be careful and make sure VM is in a stopped/deallocated state before proceeding the next step.
5. Select Size Option here (it is from the same specific VM as step 4.)
6. You will have the below screen based on your subscription.If your target VM type is visible select VM and takes the below option. Else you can find from here if your machine type is not visible. Finally, take the Resize option and let the resize task completed. This resize option is visible down to machine type.
7. Go to VM Screen described in Step 4 and start the VM. Let the task completed. You can log in and validate and see the current VM type on the same screen. It may take a few minutes to reflect. You can refresh the screen as well to see the current VM type.
That’s all for this topic as of now.
Let’s see how we can achieve the same via CLI.
(B ) How to Correct or Resize Virtual Machine in AZURE using Azure CLI
1. log in to your Azure CLI using the procedure you have. Considering you have all your access intact and you have VM Contributor role to your profile.
3. If required VM size is available in the cluster, VM can be resized in the powered-on state of VM, anyhow VM will be rebooted during the operation. You can use az vm resize command to resize.
Note: When VM is powered back on, data on the temp disk may be removed. The public IP address also changes unless a static IP address is being used. If you are using static IP you need not worry.
How to Deallocate Virtual Machine in Azure
6. Start VM once resize completed and validate once available.
That’s all for this topic as of now. Hope this will be helpful…
Thanks for keep going through the above procedure.If you like you can subscribe to our newsletter to get the latest tips, tricks, and how-to steps to accomplish specific tasks. Please do not hesitate to share this with all possible social accounts where ever you have a presence.