Managing Azure Compute Gallery Virtual Machine Images
    • 06 Sep 2024
    • 14 Minutes to read

    Managing Azure Compute Gallery Virtual Machine Images


    Article summary

    Azure Compute Gallery (formerly known as Shared Image Gallery) is a service that allows you to create and share custom Virtual Machine (VM) images in Azure and then deploy virtual machines based on those images this is the recommended path for utilizing virtual machines in Azure as it enables you to have completely custom images rather than always starting from a default Marketplace image.

    When using Azure for virtualization in Skillable Studio, VMs presented to learners or candidates are deployed into an Azure region based on VM images that live within an Azure Compute Gallery. VM images utilized in this way can be replicated to multiple regions so that Skillable can geolocate the lab user and launch the VM in the supported Azure region that is physically closest to the lab user - improving overall user connectivity & experience.

    Overview of Steps Required to Create an Azure Compute Gallery Virtual Machine

    Once an Azure Subscription & Skillable Subscription Pool have been configured for Azure Compute Gallery, you are ready to start building custom images and labs based on those images! To do so, there are several required steps across the combination of Microsoft Azure and Skillable Studio

    Pre-requisites

    Ensure the Setup Azure Compute Gallery for deploying custom VMs process has been completed. If any steps were missed or skipped, VMs created using this guide may not function as expected.

    Azure Tasks

    Prior to using Azure Compute Gallery for virtual machines within Skillable Studio, there are a number of steps that must be prepared and completed.

    Migrate Images from Another Subscription/Tenant

    If you have a Compute Gallery with images in another subscription/tenant that you would like to migrate to your current one, follow the Copy Azure Compute Gallery Image Versions between Azure Clouds, Tenants, and Subscriptions process from Microsoft’s Tech Community hub.

    Create Image Definition

    Specialized Image Definition

    Skillable currently requires Compute Gallery images to have a Specialized state. Generalized images will need to be recreated as specialized.

    If you already have a Specialized image definition, skip this step. If you have a Generalized image definition, complete this step. This can be identified on the Overview tab of the Image Definition.

    image(88)

    Create an image definition to define specifications for virtual machines that are created and deployed from your Compute Gallery.

    1. Go to the Compute Gallery you just created.

    2. Click +Add new image definition in the upper-left of the page.

      1. Region: Select a region where the image definition will be created.

      2. Image definition name: Name the image definition. This name will be used in Skillable Studio in the Machine Image fields on the VM profile.

      3. Operating system: select the operating system that your VM will use.

    3. Security Type: Select Standard.

      Other options may/may not work depending upon the source image.

    4. VM Generation: Select the VM generation that your VM will use.

    5. Operating system state: Specialized

    6. Define Unique Metadata:

      1. Publisher: Enter a publisher name for the Image Definition.

      2. Offer: Enter the name of the Image Definition offer.

      3. SKU: Enter the name of the Image Definition SKU.

        There are no official requirements as-to what these values need to be, but your Organization may have their own requirements. The combination of these 3 values must be unique from any other image definition in the Compute Gallery.

    7. Select Next: Publishing options in the Azure portal to add Publishing options.

      1. Recommended VM vCPUs: Select the minimum and maximum number of vCPUs that can be used in any VMs that are deployed using this image definition.

      2. Recommended VM memory: Select the minimum and maximum amount of memory that can be used in any VMs that are deployed using this image definition.

      3. Excluded disk types: select any disk types that should be excluded.

    8. Click Next: Review + Create.

    9. Click Create.

    Create Image Version

    After the image definition is created, an image version must be specified. As updates to the VM Image are made, it is new versions that will be created - the definition will remain unchanged.

    Migrate Local VMs

    Best Practice: Use Azure Native VMs

    Unless your local VMs are already heavily customized, it is recommended to deploy native Azure VMs from the Azure Marketplace and tailor from there instead of migrating existing local VMs.

    If you are using Azure VMs, and not migrating Local VMs, skip this step.

    If you have a virtual machine image from a local hypervisor (such as Hyper-V) that you would like to build an Azure VM out of follow the Upload a VHD File process outlined below.

    Upload a VHD File

    Local Migrations Only

    This process is only for migrating VMs from a local hypervisor into Azure. If you are creating a Specialized image from an existing Azure VM or Generalized image, skip this section.

    Uploading a VM to Azure is comprised of a number of steps this guide will walk you through:

    • Validate the VHD is prepared for Azure.

    • Create a storage account inside of your resource group where template VHDs will be stored in a storage container.

    • Create a container inside your storage account.

    • Upload each template VHD.

    Prepare the VHD for Upload to Azure
    1. Follow Microsoft’s Documentation for preparing your VHD.

    Do not Sysprep

    As Skillable currently only supports Specialized images, do not sysprep or otherwise prepare your image for a Generalized state.

    Create a Storage Account Inside the Resource Group
    1. Navigate to the resource group created at the beginning of this document.

    2. Click + Add to add a resource to the resource group.

      1. Search for Storage and select the Storage Accounts service.

      2. Select the Resource group drop-down and select the resource group you created in a previous task.

      3. Enter a name for your storage account in the Storage account name field. This name must be globally unique, so it is a good idea to choose a name that is meaningful to you and that will be unique.

      4. Choose the region where you want to store your storage account from the list of regions available in the Location drop-down.

      5. Click Review + create to create the storage account.

      6. Click Create.

    Create Containers Inside of the Blob Service in Your Storage Account

    Once you have created a resource group and a storage account within it, you need to create containers inside of the blob service in your storage account to store VHD files and host running virtual machine instances. This can be done from within the Microsoft Azure Portal, by following these steps:

    1. Navigate to the storage account that you created in the previous task. This will open the storage account blade.

    2. Click on the Containers service in the storage account blade. This will open the container service blade.

    3. Click on the +container button to create a new storage container.

      1. In the Name field, enter the name that you would like to use for your storage container (e.g. template-vhds for the container for template virtual hard disks, or instance-vhds for the container for running virtual machine instances). Save the name in a document because you will need it later on.

      2. Select Blob for the Public access level.

      3. Click on OK to create the container.

      4. Repeat these steps to create a second storage container, this time for running virtual machine instances.

    Uploading a VHD To Azure
    1. Navigate to the storage account you are going to use to store VHD files and host running virtual machine instances.

    2. In the storage account, go to the container where the VHD files will uploaded (template VHD storage).

    3. Click the upload button near the top of the page.

    4. Click the blue folder icon and select the VHD file that you want to upload.

    5. Click Advanced.

    6. Select the drop-down menu for Blob type and change the blob type to Page blob.

      If the VHD is uploaded as a Block Blob (default upload setting), the VHD will not be able to be used for a VM in a lab. The VHD must be uploaded as a page blob.

    7. Click the Upload button to upload the VHD to the container.

    8. After the VHD uploads, copy the VHD file name and save the name in a document because you will need it later on.

    Create Managed Disk

    Go back to the Azure admin dashboard and in the upper search bar, search for Managed Disks and select the Managed Disks service.

    On the Create a managed disk page, enter the following:

    1. Subscription: select the same subscription as previous selections.

    2. Resource Group: Select the resource group where the Managed Disk will be deployed to. This should be the resource group selected in previous steps.

    3. Disk Name: Name the shared disk.

    4. Region: select the same region selected in previous steps.

      1. Click Review + Create.

      2. Click Create.

    Enable Skillable Integration Services

    To enable scoring, Life Cycle Actions (LCAs) and Activity-based Assessment (ABA), the Skillable integration service must be installed, by executing a PowerShell script in the VM, on all virtual machines that will use these features. Select Install Integration Services below for installation instructions.

    You can verify the service is running by following the steps below:

    1. Open a web browser in the VM.

    2. Navigate to the following URL: localhost:2724

    3. If a page is displayed with Skillable Integration Service on the page, the service is running. Skip this step.

    4. If nothing or a failure to connect is displayed, complete the Install Inegration Services process below.

    Install Integration Services

    Before installing the integration service, there must not be any previous version of the service installed on the VM.

    1. Ensure there are no previous versions of the integration service installed on the VM:

      1. Navigate to Programs and Features in the Control Panel and ensure there is no integration service listed in the installed list.

    2. Navigate to Skillable Integration Service GitHub page and download the contents of the repository. This repository contains a PowerShell script and a folder that contains the integration service.

      You can download the repository contents by selecting the green Code button and then selecting Download ZIP.

    3. Copy the downloaded files to the Virtual Machine, using your preferred method to transfer files into the VM.

      The simplest method to get these files into the VM is to access this repository from the VM and download the files.

    4. In the VM, move the downloaded VmIntegrationService folder to the root of the VM's C drive.

    5. Navigate back to the downloaded files, and run the install.ps1 PowerShell script, as an administrator by right-clicking and selecting the option to run as administrator.

    6. After the script is executed, reboot the VM.

    7. Once the VM is rebooted, the integration service may take a few minutes to start. Scoring, LCA and ABA will not function correctly until the integration service is running.

      Subsequent launches of this VM will have the same delayed start with the integration service. It is recommended to configure a delay to any Life Cycle Actions that are configured on lab profiles that use this VM.

    8. Open a web browser in the VM.

    9. Navigate to the following URL: localhost:2724

      If a page is displayed with Skillable Integration Service on the page, the service is running. Scoring, LCA and ABA will now function correctly.

    Capture Running VM

    1. Launch a VM within Azure.

      Local VHD Upload

      Existing Azure VM

      Marketplace Image

      Compute Gallery Image

      From the managed disk, select + Create VM

      Start the VM

      Create a new VM

      From the Image Definition, select + Create VM

    2. Ensure the VM is in a Running state.

    3. If this is your first time saving this image for use with Skillable, enable Skillable Integration Services.

    4. Follow Microsoft’s Documentation for capturing an image and saving it to your custom Compute Gallery.

      Do not Sysprep

      As Skillable currently only supports Specialized images, do not sysprep or otherwise prepare your image for a Generalized state.

    Update Region Availability/Replication

    By default Azure Compute Gallery images are available only in a single region. To provide a better experience to a global audience, Skillable Studio supports Geo-location that deploys the virtual machine into the supported region closest to the lab user. Currently supported regions are:

    North America

    Europe

    Asia/Pacific

    Central US

    East US

    South Central US

    West US

    West Europe

    Southeast Asia

    If your current image version is not available in one of these regions, or if you would like to replicate it into multiple of these regions, complete the following:

    1. Go to the Image Version that was created in the previous steps.

    2. Click Update replication on the left side of the page.

    3. Target regions: select all regions that you want the VM to launch from. Geolocating labs and launching VMs in the region closest to the lab user, is dependent on the regions that the image version is replicated to.

    4. Target region replica count: select the number of replicas that will be needed in each region.

    5. Storage account type: select the type of storage that will be used; Standard HDD, Premium SSD or Zone-redundant.

    6. Click Save to begin replicating to the chosen regions.

    7. If you wish to replicate more images, or replicate to different regions, you can do so after the current replication job is completed by completing these steps again.

    Azure Check List

    At this point, you should have the following created in your resource group in Azure:

    • Specialized Image Definition

    • Image Version

    • Image Replicas in desired regions

    If you are missing any of these items in your resource group, please go back to previous steps and complete any sections that were missed.

    Skillable Studio Tasks

    Associate Image with Virtual Machine Profile

    Create a virtual machine profile that can be assigned to a Lab Profile.

    1. Select Azure as the Virtualization Platform.

    2. Select Use Image Library.

    3. Enter the Machine Name. This will be the Image Definition name that was created during previous steps.

    4. Enter the version number if you want the VM profile to use a specific version of your image. You can alternatively specify latest, which will always use whatever image version is marked latest in Azure.

    5. Specify the VM username.

    6. Specify the VM password.

    Associate VM Profile with Lab profile

    Create or edit a lab profile that to deploy the virtual machine in Azure.

    1. Configure the lab for cloud slice as normal, setting Azure as the virtualization platform on the Basic Information tab.

    2. Add the VM profile to your lab profile.

    3. Configure the Network tab

    4. Configure the Cloud tab

    5. On the Virtual Machines tab, select the Network and Resource Group that the VM will use.

    Persist Changes in the Virtual Machine for Future Launches

    Persisting changes to a virtual machine allows you to configure virtual machine settings and/or software, then capture those changes so that they are present in the VM for all users that launch the lab in the future. For Azure Compute Gallery images, this can be initiated in Skillable Studio but must be completed in the Azure Portal.

    Persist Changes

    To permanently save any modifications to the image in the Azure Compute Gallery:

    1. Launch a lab and modify the VM in any way you desire.

      1. Alternatively, you could deploy a VM directly from the compute gallery in Azure - the rest of the steps will remain the same.

    2. Navigate to the VM in the Azure portal.

    3. On Overview tab, select Capture at the top of the page.

    4. Select the resource group where the image library is stored.

    5. Select the target Azure Compute Gallery.

    6. Select Specialized Operating System State.

    7. Select the Target VM image definition where your image definition is stored.

    8. Enter a version number. This version number will be used to configure the VM profile in Skillable Studio.

    9. Select replication settings if you would like to replicate this VM for availability in other Azure regions.

      1. Select Review + Create.

      2. Click Create.

    Edit VM Profile to Use New Version

    If the VM Profile in Skillable Studio is configured to use a specified version number, rather than latest, updating to the last version requires the following steps:

    1. Login to Skillable Studio.

    2. Navigate to the VM profile.

    3. Select Edit on the profile.

    4. Change the version number to the new version number that was set in Azure during previous steps.

    5. Launch lab and confirm changes are present.


    Was this article helpful?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.