Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Hosted-services / Azure

Creating Azure Virtual Machines

4.29/5 (6 votes)
1 Jun 2015CPOL4 min read 21.4K  
This tip will help you to get a basic understanding of Virtual Machines on Azure and guide you about how to create and run a Virtual Machine on Azure.

Introduction

Setting up and managing servers and infrastructure needed to power our development takes a lot of time. These obstacles could be removed if we developers could provision our own servers. It is also easier for enterprises of all sizes to benefit from the high performance and availability of the network without the cost of running your own hardware. Azure virtual Machine is an ideal solution in many ways. An Azure virtual machine gives you the flexibility of virtualization without spending the time and money to buy and maintain the hardware that hosts the virtual machine.

Azure Virtual Machines

Azure Virtual Machines are one of the central features of Azure's IaaS capabilities. It supports the deployment of Windows Server or Linux Virtual Machines (VMs) in a Microsoft Azure datacenter.

There are two tiers for Azure Virtual Machines, Basic and Standard. The differences are Standard tier is well suited for more consistent performance on the CPU and network, while it also offers load-balancing and auto-scaling whereas Basic does not offer these features. You can use both Basic and Standard tiers for production workloads, depending upon your needs. Azure offers many images, you can also use your own images.

You can create a VM in Azure by:

  • The Azure Portal or Azure Preview Portal- GUI based
  • Azure CLI or Azure PowerShell- Command Shell

Virtual Machine Status

Azure VMs have the following three possible states:

  • Running: The VM is on and running normally.
  • Stopped: The VM is stopped, but it is still consuming compute resources within Azure.
  • Stopped (Deallocated): The VM is stopped and it is not consuming computer resources within Azure.

Billing

Azure Virtual machines are billed on per-minute basis.

There is a direct relationship between the VM's status and billing, if the VM is in Running or in Stopped state, it is billable. You have to completely place the VM in dealllocated state to stop the billing.

Creating Virtual Machines

One of the easiest ways to get started creating Azure VMs is to use the Azure Management Portal or the Azure Preview Portal. This tip will guide you step by step to create a Virtual Machine on Azure. Windows Azure offers many images, we will be creating Windows Server 2012 R2 Datacenter image for the sake of this tutorial.

Image 1

  • Log into the Azure Preview Portal at http://portal.azure.com. At this point, you will need an Azure subscription. If you don’t have one, you can sign up for a free trial at http://azure.microsoft.com.
  • To get started, click +NEW in the upper-left corner of the screen.
  • In the New blade, click Compute, and then click Windows Server 2012 R2 Datacenter for the purposes of this example.

Image 2

  • On the Create VM blade, fill in the Host Name you want for the VM, the administrative User Name, and a strong password.
    • Host Name - The name of the VM
    • User Name - The administrative user name
    • Password - The password for the administrative user
    • Pricing Tier - Expand this lens to view all the different pricing

Image 3

Optional Configuration - Expand this lens to control several important settings, such as:

  • The cloud service name (the DNS name; for example, contoso.cloudapp.net). Whether operating system automatic updates (that is, Windows Update) is enabled (default is ON).
  • The storage account to store the operating system disk’s virtual hard drive (VHD).
  • Any Virtual Network options (the VM will be placed in its own Virtual Network unless otherwise specified).
  • Whether diagnostics should be enabled.
  • Resource Group-Provides a logical container for Azure resources (to help manage resources that are often used together).
  • Location - The Azure region where the VM should be placed.

Image 4

  • When finished, click the blue Create button to instruct Azure to start creating your VM. This process could take several minutes.
  • After Azure creates the VM, you'll see it on your Startboard.

Image 5

 

Connect to a Virtual Machine

When creating a VM using the Azure Preview Portal, Remote Desktop is enabled by default. To connect to the VM, select the Connect button from the top of the desired VM blade.

Image 6

Open the RDP file and connect to the VM.

You will need to provide the administrative user name and password set when initially provisioning the VM.

Image 7

You can now work with the virtual machine.

Image 8

Stopping VM

By default, stopping a VM in the Azure Management Portal puts the VM into the Stopped (Deallocated) state. If you want to stop the VM but keep it allocated, you will need to use the PowerShell.

cmdlet: Stop-AzureVM -Name "az-essential" -ServiceName "az-essential" -StayProvisioned.

Shutting down the VM from the operating system of the VM will also stop the VM but will not deallocate the VM.

If you are creating your Aure Virtual Machine for testing purposes, please make sure to place it in Stopped(Deallocated) state.

Points of Interest

Microsoft Azure provides massive amounts of infrastructure you can utilize to run your applications and systems. And, you always can scale up or out whenever you like. We can now set up an environment that closely resembles our production environment, and it won't cost much as Azure bills us by hour. By distributing load across virtualized machines, Azure VM are able to ensure high availability of applications and data. Even if one server fails, another virtual machine can be spun up with minimal downtime or data loss.

History

  • V1 of tip

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)