2015-04-04_13-59-32This blogpost is part 3 in a series of posts regarding how to create a vm in Azure.
Part 1: What is “the planned way”?
Part 2: Set up the prerequisites
Part 3: Set up the VM
Part 4: Go Hybrid

More and more people realize that Microsoft Azure can be a huge benefit in their day to day business. The scalability of services and speed with which you can run your business on a global scale is unprescedented to anything you would be able to accomplish in your own datacenter.

The Azure web interface looks straight-forward enough, but after working with it for a few days, weeks,  months or after following one of my Azure classes, people soon realize that Azure really consists out of a lot of “moving parts”.  This blogpost I’ll focus on all moving parts surrounding a Virtual Machine in Azure. Lots of readers will surely think:”Come on, it’s not that different from an on-prem VM, is it?” I could just give you the answer right away, but that would make for a really short blog post, wouldn’t it?

Part 3: Set up the VM

Welcome back at part three of this four-part series. So far we’ve created a small plan (design) to create a Virtual Machine and looked at all dependencies we might need in the future. We also created a storage account for our VHD files to land in, and consulted with our networking department which subnets we can use for the workloads we’ll provision in Azure.

First thing we need to do, is to setup a network for our Virtual Machines in the Azure Cloud. Since our end-goal here is to provide hybrid services, we will provision a gateway in part 4 of this series. For now, a “normal” Virtual Network will suffice.

To create a Virtual Network, we will head over to http://manage.windowsazure.com (the “old” management portal) and after logging in to the portal, we’ll hit the big “+” mark at the bottom of the screen.

2015-04-04_13-59-32Navigate to Network Services -> Virtual Network -> Custom Create and choose an applicable name and region.
Click on the small arrow at the bottom of the screen to advance.

Create a Virtual Network

Since we will be using this network in a Hybrid Scenario, next we’ll provide the address of our local dns servers (on-prem that is).

create dns servers localNext up, the single most important thing you’ll do today, except for reading this blog…. Define the online address spaces. Spaces? Yes, spaceS! It’s a 2-step action… First you need to define the overall address space you’ll reserve for all services, after that you can define different subnets within that address space for, e.g. different of your customers or different service types…

In this example we’ve  created 2 subnets. One for our own infrastructure servers and one for our customers’ servers. Is this a “golden” rule? No! All implementations and use-cases for Azure are different. This only shows how you could use the different subnets in your Azure address space.

Define network adress space

After this step, Azure has all required information and the network can be created. It will be shown as below.

Created Virtual Network

With the creation of this network we’re again a step closer to our goal; creating a planned vm, usable in future scenario’s in Microsoft Azure…

Now we finally have all things in place for a basic VM, we can create the VM in 2 common ways.. With the user interface or with Powershell, and since I’m in a good mood, I’ll show both….

With the Preview WebUi:

Click on the big “+” on the bottom of the screen, and go to “Compute”  and create any VM of your liking through the gallery. For this demonstration, I’ve chosen my default weapon of choice, Server 2012 R2.

create vm 1

Here’s the part to start paying attention… Don’t do a Next-Next-Finish please. Again,pay close attention to your pre-defined design, including naming conventions and the dependancies we’ve created before. Step 1 is to fill in the requested fields…

create vm 3a

After this naming and local user choice, you’ll pick the T-Shirt size of the Virtual Machine. This can vary between an A0 basic and a G5 standard (which isn’t that standard) and is entirely up to you and your needs / budget. Then choose a local user account and password you can remember.
Next up: picking the right pre-defined services (cloud and storageaccounts) we created before.

create vm 4

This requires some self-control and discipline for the next-next-finish generation, Check the settings carefully. In this demo I haven’t selected any installable extensions (security or Deployment), and clicked on “Create VM”. The job will show up in the User Interface…

create vm 5

For all of you who have some knowledge of Powershell, here’s the how-to with Powershell.

First-off you’ll need the powershell module for Azure, then get the Azure Publish Settings file. With this file imported you gain access to your Azure subscription through the Powershell command-line interface. Next you’ll need to set the Azure Subscription and Storage Account you’ve created earlier as the default to use for the creation of the Virtual Machine.

Set-AzureSubscription -SubscriptionName “[subscription name]” -CurrentStorageAccountName “[storage account name]”

Once you’ve managed to create this connection, you can use the following script to create a Virtual Machine. Make sure you fill the variables with your own settings….

$user = “LocalAdmin”
$pwd = “Password”
$VMName = “NameOfVM”
$location = “West Europe”
$img = “a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-Datacenter-201503.01-en.us-127GB.vhd”
$size = “Basic_A0”
$cloudService = “CloudService”
$VirtualNet = “PutYourNetworkNameHere”
$vmConfig = New-AzureVMConfig -Name $VMName -ImageName $img -InstanceSize $size
$vmConfig | Add-AzureProvisioningConfig -Windows -AdminUsername $User -Password $pwd
$vmConfig | New-AzureVM -ServiceName $cloudService -Location $location -VNetName $VirtualNet


There you go… That’s how we create our planned VM, with the User Interface (WebUI) or with Powershell. In part 4 we will create cross-premise connectivity and check whether our cloud-vm can communicate with an on-premise Domain Controller.


Leave a Reply