Azure CLI

Create a VM with the CLI

In this walk-through, we will configure the Cloud Shell, use Azure CLI to create a resource group and virtual machine, and review Azure Advisor recommendations.

Task 1: Configure the Cloud Shell

  1. Sign in to the Azure portal.
  2. From the Azure portal, open the Azure Cloud Shell by clicking on the icon in the top right of the Azure Portal.

3. If you have previously used the Cloud Shell, proceed to the next task.

4. When prompted to select either Bash or PowerShell, select Bash.

5. When prompted, click Create storage, and wait for the Azure Cloud Shell to initialize.

Task 2: Create a resource group and a virtual machine

In this task, we will use Azure CLI to create a resource group and a virtual machine.

1. Ensure Bash is selected in the upper-left drop-down menu of the Cloud Shell pane (and if not, select it).

2. In the Bash session, within the Cloud Shell pane, create a new resource group.

az group create –name myRGCLI –location EastUS

Verify the resource group was created.

az group list –output table

3. Create a new virtual machine. Make sure that each line except for the last one is followed by the backslash () character. If you type the whole command on the same line, do not use any backslash characters.

az vm create
–name myVMCLI
–resource-group myRGCLI
–image UbuntuLTS
–location EastUS
–admin-username azureuser
–admin-password Pa$$w0rd1234

Note: If you are using the command line on a Windows computer, replace the backslash () character with the caret (^) character.
Note: The command will take 2 to 3 minutes to complete. The command will create a virtual machine and various resources associated with it such as storage, networking and security resources. Do not continue to the next step until the virtual machine deployment is complete.

4. When the command finishes running, in the browser window, close the Cloud Shell pane.

5. In the Azure portal, search for Virtual machines and verify that myVMCLI is running.

Task 3: Execute commmands in the Cloud Shell

In this task, we will practice executing CLI commands from the Cloud Shell.

  1. From the Azure portal, open the Azure Cloud Shell by clicking on the icon in the top right of the Azure Portal.
  2. Ensure Bash is selected in the upper-left drop-down menu of the Cloud Shell pane.

3. Retrieve information about the virtual machine you provisioned, including name,

resource group, location, and status. Notice the PowerState is running.

az vm show –resource-group myRGCLI –name myVMCLI –show-details –output table

4. Stop the virtual machine. Notice the message that billing continues until the virtual machine is deallocated.

az vm stop –resource-group myRGCLI –name myVMCLI

5. Verify your virtual machine status. The PowerState should now be stopped.

az vm show –resource-group myRGCLI –name myVMCLI –show-details –output table

Task 4: Review Azure Advisor Recommendations

In this task, we will review Azure Advisor recommendations.

Note: If you have completed the previous lab (Create a VM with PowerShell), then you have already performed this task.

  1. From the All services blade, search for and select Advisor.
  2. On the Advisor blade, select Overview. Notice recommendations are grouped by High Availability, Security, Performance, and Cost.

3. Select All recommendations and take time to view each recommendation and suggested actions.

Note: Depending on your resources, your recommendations will be different.

  1. Notice that you can download the recommendations as a CSV or PDF file.
  2. Notice that you can create alerts.
  3. If you have time, continue to experiment with Azure CLI.

Congratulations! You have configured Cloud Shell, created a virtual machine using Azure CLI, practiced with Azure CLI commands, and viewed Advisor recommendations.

Note: To avoid additional costs, you can remove this resource group. Search for resource groups, click your resource group, and then click Delete resource group. Verify the name of the resource group and then click Delete. Monitor the Notifications to see how the delete is proceeding.

Leave A Comment

Certifs IT Library

Explore our comprehensive web library to Find a wealth of invaluable resources, including extensive documentation and hands-on labs.

Inscription ouverte pour la formation Vmware VCP-DCV 2024
Mai 2024