Vous êtes sur la page 1sur 6

Azura Documents

As a technology professional, you likely have expertise in a specific area. Perhaps you're
a storage admin or virtualization expert, or maybe you focus on the latest security
practices. If you're a student, you may still be exploring what interests you most.

No matter your role, most people get started with the cloud by creating a virtual
machine. Here you'll deploy a virtual machine running Windows Server 2016.

There are many ways to create a virtual machine on Azure. Here, you'll create a Windows
or Linux virtual machine using an interactive terminal called Cloud Shell. If you work
from the terminal on a daily basis, you know this is often the fastest way to get the job
done.
Tip

Prefer Linux or want to try something new? Select Linux from the top of this page to
run a Linux virtual machine.

Let's review some basic terms and get your first virtual machine up and running.

What is a virtual machine?


A virtual machine, or VM, is a software emulation of a physical computer. Because VMs
exist as software, dozens, hundreds, or even thousands of Azure VMs can be generated
in minutes, then deleted when you don't need them. With low-cost, per-minute billing,
you pay only for the compute resources you use, for as long as you are using them. Plus,
there are many ways to configure the VMs to fit your needs.

A snapshot of a running VM is called an image. Azure provides images for Windows and
several flavors of Linux. You can also create your own preconfigured images to make
deployments go faster. Here you'll bring up a Windows Server 2016 VM, provided by
Microsoft.

What defines a virtual machine on Azure?


A virtual machine is defined by a number of factors, including its size and location.
Before you bring up your VM, let's briefly cover what's involved.
Size

A VM's size defines its processor speed, amount of memory, initial amount of storage, and
expected network bandwidth. Some sizes even include specialized hardware such as GPUs for
heavy graphics rendering and video editing.

Region

Azure is made up of data centers distributed throughout the world. A region is a set of Azure data
centers in a named geographic location. Every Azure resource, including virtual machines, is
assigned a region. East US and North Europe are examples of regions.

Network

A virtual network is a logically isolated network on Azure. Each virtual machine on Azure is
associated with a virtual network. Azure provides cloud-level firewalls for your virtual networks
called network security groups.

Resource groups

Virtual machines and other cloud resources are grouped into logical containers called resource
groups. Groups are typically used to organize sets of resources that are deployed together as part
of an application or service. You refer to a resource group by its name.

What is Azure Cloud Shell?


Azure Cloud Shell is a browser-based command-line experience for managing and
developing Azure resources. Think of Cloud Shell as an interactive console that you run
in the cloud.

Cloud Shell provides two experiences to choose from: Bash and PowerShell. Both
include access to the Azure CLI, the command-line interface for Azure.

You can use any Azure management interface, including the Azure portal, Azure CLI, and
Azure PowerShell, to manage any kind of VM. For learning purposes, here you'll use the
Azure CLI to create and manage either a Windows or Linux VM.
Note

Make sure you have activated the sandbox before proceeding with these instructions.

Creating resources in Azure


Normally, the first thing we'd do is to create a resource group to hold all the things that
we need to create. This allows us to administer all the VMs, disks, network interfaces,
and other elements that make up our solution as a unit. We can use the Azure CLI to
create a resource group with the az group create command. It takes a --name to give it
a unique name in our subscription, and a --location to tell Azure what area of the
world we want the resources to be located by default.

Since we are in the free Azure sandbox environment, you don't need to do this step,
instead, you will use the pre-created resource group [Resource Group Name].

Choosing a location
The free sandbox allows you to create resources in a subset of Azure's global regions.
Select a region from the following list when creating any resources:

 westus2

 southcentralus

 centralus

 eastus

 westeurope

 southeastasia

 japaneast

 brazilsouth

 australiasoutheast

 centralindia

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.
bashCopy

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 CLICopy

az vm create \
--name myVM \
--resource-group [sandbox resource group name] \
--image Win2016Datacenter \
--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 [sandbox resource
group name].

 Win2016Datacenter specifies the Windows Server 2016 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.
JSONCopy
{
"fqdns": "",
"id": "/subscriptions/00000000-0000-0000-0000-
000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtua
lMachines/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 CLICopy

az vm get-instance-view \
--name myVM \
--resource-group [sandbox resource group name] \
--output table

The output you see resembles this.

Azure CLICopy

Name ResourceGroup Location


ProvisioningState PowerState
------ ------------------------------------ ----------
------------------- ------------
myVM [sandbox resource group name] 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.

Vous aimerez peut-être aussi