Assignment 01 - Installing Azure CLI 2.0 and resizing VM

Week 1 Homework


Installing Azure CLI 2.0 and resizing VM


Now that we have more experience working with Azure VMs, I’d like people to become familiar with the command line interface (CLI) to Azure.  Every possible operation is made available through the CLI, in contrast to the web portal where many things are difficult and sometimes not even possible to do.
  • Install CLI for your environment
You generally will want to have the CLI available on your local machine/laptop since you are really only interacting with the VMs at this point.


  • Login to CLI (Link to your NetId account)
  • az login
  • This will open browser, login with same UW netId credentials you usually use to log into the portal, and you will get a code to link your CLI install to your account.


    • Resize VM
    While you can resize the VMin the portal, the size we are going to use for this class may not be available via the portal and to get experience we will use the CLI.

    • For reference, can see the available sizes with the list-vm-resize-options cmd
      • az vm list-vm-resize-options --resource-group Big_Data_Technologies --output table --name <VMNAME>
      • Ex: az vm list-vm-resize-options --resource-group Big_Data_Technologies --output table --name jkolter01
    • Resize VM with the vm resize command
      • az vm resize --resource-group Big_Data_Technologies --name <VMNAME> --size Standard_A4m_v2

    • Start/Stop(Deallocate) using CLI
      • Additionally, you can use the CLI to start and shutdown your VM.  There is a subtle difference between “stop” and “deallocate” in Azure and the behavior in the portal.  For this class lets always use the “deallocate” option
        • You do NOT need to use the CLI if you prefer the portal for start/stop of VM
      • az vm start --resource-group Big_Data_Technologies --name <VMNAME>
      • az vm deallocate --resource-group Big_Data_Technologies --name <VMNAME>

If you encounter an error when resizing:


If you encounter and error after resizing, it means that your disk storage type was not switched over when you did the resize, so you have to manually do it.  First stop your VM in the portal (or az deallocate it from the command line).


Then go to your VM in the portal, and go to the “disks page”.  Then for each of your disks associated with your VM
(OS and Data) click on each of them and it should look something like in the following image:

Click “save”


After you save the new disk state, the save button should be grayed out, and you’ll get a notification in the portal that says something about “successfully updated disk”.  

Do that for each of the two disks, and then you should be able to restart your VM

Comments

Popular posts from this blog