Monday 1 July 2019

Create Your VM

Create a Windows VM

Let's get your Windows VM up and running.
  1. In the Cloud Shell on the side of this page, run the following commands to create a username and generate a random password.
    bash
    USERNAME=azureuser
    PASSWORD=$(openssl rand -base64 32)
    
    The username and password here are stored as Bash variables. If you're a PowerShell user, just know that Bash variables are similar. You'll use these variables in the next step to set the Windows admin name and password.
    This example uses azureuser as the username. But the name can be whatever you'd like.
    There are many ways to generate passwords. The command shown here is just one of them.
  2. Run the following az vm create command to create your VM. The command creates the VM in the "East US" location, but you can change that to any of the locations listed above.
    Azure CLI
    az vm create \
      --name myVM \
      --resource-group Learn-8eb73ca3-d5f2-4ee1-89c5-cdcd999a132a \
      --image Win2019Datacenter \
      --size Standard_DS2_v2 \
      --location eastus \
      --admin-username $USERNAME \
      --admin-password $PASSWORD
    
     Tip
    You can use the Copy button to copy commands to the clipboard. To paste, right click on a new line in the Cloud Shell window and select Paste or use the Shift+Insert keyboard shortcut (⌘+V on macOS).
    Your VM will take four to five minutes to come up. Compare that to the time it takes to purchase, rack, and configure a system in your data center. Quite a difference!
While you're waiting, let's review the command you just ran.
  • The VM is named myVM. This name identifies the VM in Azure. It also becomes the VM's internal hostname, or computer name.
  • The resource group, or the VM's logical container, is named Learn-8eb73ca3-d5f2-4ee1-89c5-cdcd999a132a.
  • Win2019Datacenter specifies the Windows Server 2019 VM image.
  • Standard_DS2_v2 refers to the size of the VM. This size has two virtual CPUs and 7 GB of memory.
  • The username and password enable you to connect to your VM later. For example, you can connect over Remote Desktop or WinRM to work with and configure the system.
 Note
Although you have everything you need to connect directly to your VM, don't do so quite yet. In the next unit, you'll see one way to connect to the VM to make changes to its configuration.
By default, Azure assigns a public IP address to your VM. You can configure a VM to be accessible from the Internet or only from the internal network.
You can also check out this short video about some of the options you have to create and manage VMs.

Options to create and manage VMs

When the VM is ready, you see information about it. Here's an example.
JSON
{
  "fqdns": "",
  "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM",
  "location": "eastus",
  "macAddress": "00-0D-3A-1E-1B-3B",
  "powerState": "VM running",
  "privateIpAddress": "10.0.0.5",
  "publicIpAddress": "104.211.9.245",
  "resourceGroup": "myResourceGroup",
  "zones": ""
}
 Note
On Microsoft Learn, you'll often see sample output, like the output shown above. We show you these examples so you can compare them to the output you see. However, it's just an example, so don't enter it into the Cloud Shell session.

Verify your VM is running

The az vm create command succeeded, but let's verify that your VM is up and running.
  1. Run the following az vm get-instance-view command to verify that the VM was successfully created and is running.
    Azure CLI
    az vm get-instance-view \
      --name myVM \
      --resource-group Learn-8eb73ca3-d5f2-4ee1-89c5-cdcd999a132a \
      --output table
    
    The output you see resembles this.
    Azure CLI
    Name    ResourceGroup                         Location    ProvisioningState    PowerState
    ------  ------------------------------------  ----------  -------------------  ------------
    myVM    Learn-8eb73ca3-d5f2-4ee1-89c5-cdcd999a132a  eastus      Succeeded            VM running
    
    You see the VM's name, its resource group, and its location. You also see that the VM was provisioned, or created, successfully and that it's running.

Next unit: Exercise - Add a web server

No comments:

Post a Comment