• Improve this Doc

    Show / Hide Table of Contents

    How to create a custom image from a VM on Azure Stack Hub using the UKCloud Azure Stack Hub portal

    Overview

    You can create an image resource from a generalised virtual machine (VM) that is stored as either a managed disk or an unmanaged disk in a storage account. You can then use the image to create multiple VMs.

    This article explains how to create a custom image from a VM on Azure Stack Hub, which you can then use to deploy other VMs.

    Prerequisites

    To complete the steps in this article, you must have appropriate access to a subscription in the Azure Stack Hub portal.

    Generalise your VM

    Warning

    Once you've generalised a VM, you cannot log back into it.

    • Windows
    • Linux
    1. Log in to your Windows VM using Remote Desktop Protocol (RDP).

    2. Open a PowerShell console or command prompt as administrator and run the following command: C:\Windows\System32\Sysprep\sysprep.exe

    3. In the System Preparation Tool, from the System Cleanup Action list, select Enter System Out-of-Box Experience (OOBE).

    4. Ensure the Generalise check box is selected.

    5. From the Shutdown Options list, select Shutdown.

      See the image below for an example:

      Windows sysprep example

    6. Click OK and wait for the VM to shutdown. Your RDP session will be closed.

      Tip

      The generalisation process is complete once your VM is in a stopped state.

    1. Log in to your Linux VM using Secure Shell (SSH).

    2. Run the following command: sudo su and enter your user password if prompted.

    3. Run the following command: waagent -deprovision+user -force

    4. Wait a minute for the generalisation process to complete before continuing.

    Creating the image

    • Managed Disk
    • Unmanaged Disk
    Warning

    Capturing a VM image will make the VM unusable and cannot be undone.

    1. Log in to the Azure Stack Hub portal.

      For more detailed instructions, see Getting Started Guide for UKCloud for Microsoft Azure.

    2. In the favourites panel, select Virtual machines.

    3. In the Virtual machines blade, select the VM that you want to capture.

    4. In the top menu, click Capture.

      Capture VM image

    5. In the Create image blade, provide a Name for the new image.

    6. From the Resource group list, select an existing resource group, or create a new one by clicking the Create new link and then typing a name for your new resource group in the pop out window.

    7. Select Automatically delete this virtual machine after creating the image.

    8. In the Type the virtual machine name field, enter the VM name.

    9. Click Create.

      Create VM image

    10. Wait for the image creation process to finish.

    11. Once complete, your VM image will appear in the resource group you selected in step 6.

      Custom image resource group

    12. Click the VM image.

    13. In the new page, click Create VM.

      Create VM from image

    14. Enter a Name, Username, Authentication type, Password and Resource group for the new VM, then click OK.

    15. Select a VM size then click Select.

    16. In Configure optional features, under Select public inbound ports, select the ports you want to open.

    17. Click OK.

    18. Review the Summary blade and click OK. The new VM will now begin deployment.

      Custom image VM summary

    Caution

    It is not possible to capture a VM image from the portal for a unmanaged disk VM. However, it is possible using PowerShell.

    Feedback

    If you find a problem with this article, click Improve this Doc to make the change yourself or raise an issue in GitHub. If you have an idea for how we could improve any of our services, send an email to feedback@ukcloud.com.

    ☀
    ☾
    Generated by DocFX
    Back to top
    © UKCloud Ltd, 2022. All Rights Reserved.
    Privacy Policy. Terms of Use. Contribute.

    The UKCloud Knowledge Centre uses cookies to ensure that we give you the best experience on our website. If you continue we assume that you consent to receive all cookies on this website.