Once I had my Azure Stack up and running I couldn’t wait to create a custom image as the only template available was Server 2012 R2.  Now typically I would always go for the latest and greatest (ie Server 2016) but I thought on this occasion I would go backwards and create a Server 2008 R2 so I could reminisce on the good old days.

First of all you need to create a VM and install the OS (Server 2008 R2 in my case).  It needs to be a Generation 1 VM using a VHD NOT a VHDX (I know, it will be supported eventually I’m sure…sighs Winking smile ).  Once done system prep it.

image

Copy the VHD to a temporary location on the AzureStackPOC machine.  In my case its C:\VMTemplates

image

Now you need to use the scripts on the DataImage VHD.  If its not already mounted then navigate to the location where you extracted the Azure Stack POC installer files and mount the MicrosoftAzureStackPOC.vhd file.

image

Its now mounted as my D: Drive:

image

Open PoweShell and navigate to

D:\CRP\VM\Microsoft.AzureStack.Compute.Installer\content\Scripts

You will see the following scripts if you run DIR:

image

The script you need to use is the CopyImageToPlatformImageRepository.ps1. I feel the name of the script gives it away a little.

This script is going to copy your custom image VHD to the Scale Out Files Server share share \\sofs\Share\CRP\PlatformImages and create a Manifest for this disk in question.

The script has the following parameters that we need to answer a value for:

  • PlatformImageRepositoryPath: Our image respositry is \\SOFS\Share\CRP\PlatformImages\
  • ImagePath: Where the VHD of the custom image is stored.  In our case its C:\VMTemplates
  • Publisher: Whoever you want.  I will use Microsoft
  • Offer: The offer is WindowsServer
  • Sku: I will use 2008-R2
  • Version: The version of the image you have created.  This is my first edition so I will use 1.0.0  (it has to be in the minor build format so 2 x decimal points not 1.0)
  • OSType: Windows or Linux

Now we can use the following command on the AzureStackPOC Server 2016 machine to import it based on the variables above:

.\CopyImageToPlatformImageRepository.ps1 -PlatformImageRespositoryPath \\SOFS\Share\CRP\PlatformImages\ -ImagePath ‘C:\VMTemplates\Server2008R2.vhd’ -Publisher "Microsoft" -Offer "WindowsServer" -Sku "2008-R2" -Version 1.0.0 -OsType Windows –Verbose

image

Once complete navigate to \\SOFS\Share\CRP\PlatformImages\ and you will see your image with a manifest.json file.

image

 

Open the manifest.json file and you will see how it has been created from the attributes populated in the PowerShell command:

image

Navigate back to the AzureStack ClientVM and refresh your browser or log on as your Azure Tennant account.  Navigate to New > Compute and you should now see your new template:

image

Go create a new VM based on your template.

image

Once created and running click Connect and enter your credentials.

image

There you have it a beautiful new fresh Virtual machine running Server 2008 R2 just like you would have in Azure.

You can use the exact same principals to deploy Sever 2016 as a template for Azure Stack.

If you want to add a Linux image take a look at Ben Gekens blog here: https://azurestack.eu/2016/02/adding-centos-7-to-azure-stack-tp1/