Add a custom image to Azure Stack

In this blog post I will explain how you can add multiple custom images to Azure Stack. At cubesys we have a brand new Azure Stack environment that we use as a demo and test environment for our consultants. Each consultant has his own subscription with pre-defined quotas that they can use to build, test and destroy whenever and whatever they want to test. One of our senior consultants asked me add the following custom images as he wanted to test and validate a System Center upgrade scenario:
  • Windows 7 SP1 x64 Enterprise
  • Windows 8.1 x64 Enterprise
  • Windows 10 (Build 1511) x64 Enterprise
  • Windows Server 2008 R2 SP1 Datacenter
  • Windows Server 2012 Datacenter
So let’s make our tenant happy shall we?

Sysprep the virtual machines

First of all you will have to sysprep the virtual machines.
  1. Create a new virtual machine in Hyper-V
    1. make sure it’s generation 1
    2. and the hard drive needs to be VHD and not VHDX
  2. Install the operating system
SNAGHTMLd020970.png  
  1. Once the operating system is installed you need to sysprep the machine using the following command
    1. For Windows 8 and after:
      1. open a Command Prompt window as an administrator, and then move to the %WINDIR%\system32\sysprep directory.
      2. Run the following command:
        Sysprep /generalize /shutdown  /oobe /mode:vm
    2. Anything before Windows 8
        1. open a Command Prompt window as an administrator, and then move to the %WINDIR%\system32\sysprep directory
        2. Run the following command:
           Sysprep /generalize /shutdown /oobe
sysprep.jpg Once complete the virtual machines will shutdown automatically. Copy the sysprepped virtual hard drives to another location. In my case E:\templates image11.png  

Add the image to the Platform Image Repository

Once we have all our virtual machines sysprepped and copied the virtual hard drives we can add them to Azure Stack. To add a new image to Azure stack it needs to be added to the Platform Image Repository or PIR. Microsoft has provided a PowerShell script (CopyImageToPlatformImageRepository.ps1) to do this. You can find this PowerShell script on the MicrosoftAzureStackPOC.vhd virtual hard drive.
  • Right click on the vhd file and mount the VHD
  • Get the Drive letter of the DATAIMAGE drive
azurestackpir.png  
  • Use PowerShell and Navigate to D:\CRP\VM\Microsoft.AzureStack.Compute.Installer\content\Scripts where you will find the CopyImageToPlatformImageRepository.ps1 PowerShell script
image12.png The script requires the following parameters:
  1. For PlatformImageRepositoryPath, type \\SOFS\Share\CRP\PlatformImages\
  2. For ImagePath, type the path to the PIR image. In my case ‘C:\templates\Sysprep2008R2.vhd’
  3. For Publisher, type a publisher name, like Microsoft.
  4. For Offer, type any value, like WindowsServer.
  5. For Sku, type a SKU for the image, like 2008-R2.
  6. For Version, type a version in #.#.# format, like 1.0.0.
  7. For OsType, type Windows or Linux.
We can now use the parameters above to launch the script:
.\CopyImageToPlatformImageRepository.ps1 -PlatformImageRespositoryPath \\SOFS\Share\CRP\PlatformImages\ -ImagePath ‘C:\templates\Sysprep2008R2.vhd’ -Publisher "Microsoft" -Offer "WindowsServer" -Sku "2008-R2" -Version 1.0.0 -OsType Windows –Verbose
sofs image13.png After the command completes, restart your browser to see the new item in the Marketplace. The image can now be referenced in your virtual machine deployment templates. In some cases it may take up to 5 minutes for this new image to appear in the Marketplace. stackimages   Thanks, Alex
Alexandre Verkinderen
Alexandre Verkinderen
Technology passionate, evangelist and subject matter expert in cloud, virtualization and management.

Get in touch

Your Name (required)

Your Email (required)

Subject

Your Message

Get in touch

Your Name (required)

Your Email (required)

Subject

Your Message

Get in touch

Your Name (required)

Your Email (required)

Subject

Your Message

Get in touch

Your Name (required)

Your Email (required)

Subject

Your Message

Get in touch

Your Name (required)

Your Email (required)

Subject

Your Message

Get in touch

Your Name (required)

Your Email (required)

Subject

Your Message

Get in touch

Your Name (required)

Your Email (required)

Subject

Your Message

Get in touch

Your Name (required)

Your Email (required)

Subject

Your Message

Get in touch

Your Name (required)

Your Email (required)

Subject

Your Message

Get in touch

Your Name (required)

Your Email (required)

Subject

Your Message

Get in touch

Your Name (required)

Your Email (required)

Subject

Your Message