Installing Azure Stack Development Kit on a Hyper-V VM

Want to try Azure Stack with the Azure Stack Development Kit? But maybe you don’t have the hardware to spare? But you do have the room to spin it up on your Hyper-V environment as a VM?

This post will go over what you need, my experience getting it installed, and a script I created that creates the VM with all the requirements needed.

The Development Kit is only meant as a proof of concept, not production loads. Its not going to be the fastest, especially if you’re not on solid state storage.

Setup the VM

First download the Azure Stack Development Kit here https://azure.microsoft.com/en-us/overview/azure-stack/development-kit/

Once downloaded, launch it and specify your settings and download the ~10GB file.

azure stack dev kit

Now extract the cloudbuilder.vhdx by running the Azurestackdevelopmentkit.exe and extracting it to a specified location.

Once extracted move it to your Hyper-V server and put it in a path for the VM and remember that path, we’ll use it in the script.

You’ll need a VM with:

  • 96GB is the recommended minimum, you could probably get it working with less but wouldn’t be able to do much with it. I tried 65GB but it got stuck, once deployed the infrastructure VMs and OS are using 61GB
  • 12 CPU
  • NAT Switch (do not connect any other vNICs the install will fail)
  • MAC Address Spoofing Enabled
  • Expose the VM processor virtualization extensions
  • Time synchronization Integration Services disabled
  • Resize the Cloudbuilder.vhdx to 200GB
  • 4 VHDX’s at 140GB each

My script below will create a VM with those requirements.

Credit Hyper-V-server.de for the NAT Switch Powershell
Credit Anil Erduran for the VHDX Powershell

Enter your path for the cloud builder VHDX and

#enter Azure Stack VM Name. Example azurestack
$vmname = "azurestack"
#enter cloudbuilder.vhd path. F:VMsazurestackcloudbuilder.vhdx
$cloudbuilder = your path here'
#enter vmpath for VHD files. Example f:vmsazurestack note: do not add the trailing to the end.
$vmpath = 'your path here'
#enter memory. exmample 75
[int64]$mem = 96
$vmmem = 1gb*$mem

#create NAT switch for VM
$natswitch = Get-VMSwitch -Name "NATSwitch" -ErrorAction SilentlyContinue

if($natswitch -eq $null) {
    New-VMSwitch -Name "NATSwitch" -SwitchType Internal -Verbose

    $NIC = Get-NetAdapter  | where Name -like "vEthernet*(NATSwitch)"

    New-NetIPAddress -IPAddress 172.16.0.1 -PrefixLength 24 -InterfaceIndex $NIC.ifIndex

    New-NetNat -Name "NatSwitch" -InternalIPInterfaceAddressPrefix "172.16.0.0/24" -Verbose
}

#create new azure stack as generation 2 VM

$vm = New-VM -Name $vmname -MemoryStartupBytes $vmmem -SwitchName $natswitch.name -BootDevice VHD -VHDPath $cloudbuilder -Generation 2 -Path $vmpath

#give VM 12 processors and specify the automatic stop action and set static memory
set-vm -VM $vm -ProcessorCount 12 -AutomaticStopAction ShutDown -StaticMemory

#expose Processor enabling nested virtualization
set-vmprocessor -vmname $vm.name -ExposeVirtualizationExtensions $true

#enable MAC address spoofing
get-vmnetworkadapter -VMName $vm.name | set-vmnetworkadapter -MacAddressSpoofing on

#disable time synchronization
Disable-VMIntegrationService -Name 'time synchronization' -VM $vm

#resize Cloudbuilder.vhdx to 200gb
Resize-VHD -Path $cloudbuilder -SizeBytes 200gb

#create VHDX drives for S2D cluster in Azure Stack
$vmpath = $vm.Path
$DiskCount = 1..4
foreach ($disk in $DiskCount)
{
 $vhd = New-VHD -Path "$vmpath$vmname$disk.vhdx" -Dynamic -SizeBytes 140GB
 Add-VMHardDiskDrive -VMName $vm.name -Path $vhd.path
}

Run this on your HyperV Server and it will create the VM for you with all the settings you need. Otherwise, you can do it manually, if you’re into that kind of thing.

azure stack dev kit hyperv

azure stack dev kit hyperv

azure stack dev kit hyperv

Prepare Windows for Azure Stack

Tip: before starting the VM copy the cloudbuilder.vhdx to another location, in case your install fails. I found it easier to blow the whole thing away and try again. Using the -rerun didnt work for me several times, it just quickly ran through and said Azure Stack is already installed, when it had hung previously. This is probably related to something I did or related to my environment.

Start your VM, since we don’t have the unattend.xml you’ll have to do the windows setup giving the machine a password etc.

Once in Windows there are a few things we need to do.

First in Server Manager turn off IE Enhanced Security. If you do not do this you will not be able to enter a Microsoft account during install and it will fail. I used my personal @outlook.com email just fine.

azure stack dev kit

Go into Computer Management and Extend the C drive and initialize and bring online the Azure Stack Disks, do not format them, just make sure they are online and that there are four of them.

azure stack dev kit

azure stack dev kit

azure stack dev kit

If you see anything other than this, unless you did more than 4 drives, stop and make sure you have the minimum requirements. One time I extended the Cloudbuilder.vhdx file in Hyper-V, but forgot to extend it in Windows and the install failed the hardware requirements.

azure stack dev kit

Give your Azure Stack an IP based upon the IP Subnet you gave the NAT Switch. In this case I just used 172.1.6.0.2. Give it your prefered DNS servers. Select OK then verify that you have internet access. If you don’t have internet, stop and figure out the problem, as you’ll need internet to get the install started with your Microsoft login.

Prepare Azure Stack settings for VM

First navigate to c:clouddeploymentsetup and run the BootStrapAzureStackDeployment.ps1 Powershell script. This gets all the configuration items needed to deploy.

azure stack dev kit

If for some reason your Hyper-V server doesn’t have the processing power to do 12 vCPUs, you can change the requirements by navigating to c:clouddeploymentconfigurationrolesinfrastructurebaremetal  and opening the OneNodeRule and finding the ValidationRequirements change the CPU to what you need it to. You can change the RAM to pass, but 65GB wasn’t enough to get it installed successfully

azure stack dev kit

azure stack dev kit

and finally, navigate to c:clouddeploymentrolesphysicalmachinestests and open the BareMetal.Tests

azure stack dev kit

Do a find on “isvirtual” and on lines 522, 602, 614 change

powershell

to

powershell

Start the Azure Stack Install

Now navigate to c:clouddeploymentsetup and run the InstallAzureStackPOC.ps1 script

azure stack powershell

.InstallAzureStackPOC.ps1 -NATIPv4Subnet 172.16.0.0/24 -NATIPv4Address 172.16.0.3 -NATIPv4DefaultGateway 172.16.0.1 -TimeServer 129.6.15.28

Note: I used 172.16.0.3 for the IP address, because 172.16.0.2 is already taken by the Azure Stack VM, in some of the pre-checks it will try to ping the IP you give the InstallAzureStackPOC script and fail because its taken.

I used a time server from here: https://tf.nist.gov/tf-cgi/servers.cgi  you can probably use an internal one as well, I didn’t try that.

Hit enter, and the install will prompt you for a password. Remember that password, because its the password for every login.

It will then ask you for a Microsoft account to login with. After that prepare for 4 to 5 hours of Powershell goodness.

azure stack development kit hyper-v powershell

Don’t fear if any one step stays the same for a few minutes. Unless it stays on the same step for hours on end, then the install might be hung. Several times it hung on me and I left it for 24 hours and nothing happened. I killed it with ctrl+c then tried re-run and it would go through and then say it was complete very quickly. This is why I ending up opting to blow away the VM and try again after each failure, also why I ended up creating a script to do almost everything, because there are quite a few steps that if you miss any one of them the install will fail.

If all goes well you will see this:

azure stack development kit hyper-v powershell

On the Azure Stack VM you can go to https://adminportal.local.azurestack.external to get to the admin portal.

azure stack development kit hyper-v

azure stack development kit hyper-v

I had two alerts, one for registration and one for low memory capacity.

azure stack development kit hyper-v

The VM is currently using 62GB with nothing else installed.

There are more steps you need to do like registering Azure Stack, installing Azure Stack Powershell, Resetting the password expiration policy.