Azure Citadel
  • Blogs

  • ARM
  • Azure Arc
    • Overview
    • Azure Arc-enabled Servers
      • Prereqs
      • Scenario
      • Hack Overview
      • Azure Landing Zone
      • Arc Pilot resource group
      • Azure Monitoring Agent
      • Additional policy assignments
      • Access your on prem VMs
      • Create onboarding scripts
      • Onboarding using scripts
      • Inventory
      • Monitoring
      • SSH
      • Windows Admin Center
      • Governance
      • Custom Script Extension
      • Key Vault Extension
      • Managed Identity
    • Azure Arc-enabled Kubernetes
      • Prereqs
      • Background
      • Deploy Cluster
      • Connect to Arc
      • Enable GitOps
      • Deploy Application
      • Enable Azure AD
      • Enforce Policy
      • Enable Monitoring
      • Enable Azure Defender
      • Enable Data Services
      • Enable Application Delivery
    • Useful Links
  • Azure CLI
    • Install
    • Get started
    • JMESPATH queries
    • Integrate with Bash
  • Azure Landing Zones
    • Prereqs
    • Day 1
      • Azure Baristas
      • Day 1 Challenge
    • Day 2
      • Example
      • Day 2 Challenge
    • Day 3
      • Day 3 Challenge
    • Useful Links
  • Azure Policy
    • Azure Policy Basics
      • Policy Basics in the Azure Portal
      • Creating Policy via the CLI
      • Deploy If Not Exists
      • Management Groups and Initiatives
    • Creating Custom Policies
      • Customer scenario
      • Policy Aliases
      • Determine the logic
      • Create the custom policy
      • Define, assign and test
  • Azure Stack HCI
    • Overview
    • Useful Links
    • Updates from Microsoft Ignite 2022
  • Marketplace
    • Introduction
      • Terminology
      • Offer Types
    • Partner Center
    • Offer Type
    • Publish a VM Offer HOL
      • Getting Started
      • Create VM Image
      • Test VM Image
      • VM Offer with SIG
      • VM Offer with SAS
      • Publish Offer
    • Other VM Resources
    • Publish a Solution Template HOL
      • Getting Started
      • Create ARM Template
      • Validate ARM Template
      • Create UI Definition
      • Package Assets
      • Publish Offer
    • Publish a Managed App HOL
      • Getting Started
      • Create ARM Template
      • Validate ARM Template
      • Create UI Definition
      • Package Assets
      • Publish Offer
    • Managed Apps with AKS HOL
    • Other Managed App Resources
    • SaaS Offer HOLs
    • SaaS Offer Video Series
      • Video 1 - SaaS Offer Overview
      • Video 2 - Purchasing a SaaS Offer
      • Video 3 - Purchasing a Private SaaS Plan
      • Video 4 - Publishing a SaaS Offer
      • Video 5 - Publishing a Private SaaS Plan
      • Video 6 - SaaS Offer Technical Overview
      • Video 7 - Azure AD Application Registrations
      • Video 8 - Using the SaaS Offer REST Fulfillment API
      • Video 9 - The SaaS Client Library for .NET
      • Video 10 - Building a Simple SaaS Landing Page in .NET
      • Video 11 - Building a Simple SaaS Publisher Portal in .NET
      • Video 12 - SaaS Webhook Overview
      • Video 13 - Implementing a Simple SaaS Webhook in .NET
      • Video 14 - Securing a Simple SaaS Webhook in .NET
      • Video 15 - SaaS Metered Billing Overview
      • Video 16 - The SaaS Metered Billing API with REST
  • Microsoft Fabric
    • Theory
    • Prereqs
    • Fabric Capacity
    • Set up a Remote State
    • Create a repo from a GitHub template
    • Configure an app reg for development
    • Initial Terraform workflow
    • Expanding your config
    • Configure a workload identity
    • GitHub Actions for Microsoft Fabric
    • GitLab pipeline for Microsoft Fabric
  • Packer & Ansible
    • Packer
    • Ansible
    • Dynamic Inventories
    • Playbooks & Roles
    • Custom Roles
    • Shared Image Gallery
  • Partner
    • Lighthouse and Partner Admin Link
      • Microsoft Cloud Partner Program
      • Combining Lighthouse and PAL
      • Minimal Lighthouse definition
      • Using service principals
      • Privileged Identity Management
    • Useful Links
  • REST API
    • REST API theory
    • Using az rest
  • Setup
  • Terraform
    • Fundamentals
      • Initialise
      • Format
      • Validate
      • Plan
      • Apply
      • Adding resources
      • Locals and outputs
      • Managing state
      • Importing resources
      • Destroy
    • Working Environments for Terraform
      • Cloud Shell
      • macOS
      • Windows with PowerShell
      • Windows with Ubuntu in WSL2
    • Using AzAPI
      • Using the REST API
      • azapi_resource
      • Removing azapi_resource
      • azapi_update_resource
      • Data sources and outputs
      • Removing azapi_update_resource
  • Virtual Machines
    • Azure Bastion with native tools & AAD
    • Managed Identities

  • About
  • Archive
  1. Home
  2. Marketplace
  3. Publish a VM Offer HOL
  4. Test VM Image

Table of Contents

  • Introduction
  • Test we can create a VM from the virtual machine image
    • Steps for Shared Image Gallery approach
    • Steps for SAS URI approach
    • Finalise the test
  • Run validations on the virtual machine
  • Resources

Test VM Image

Test the VM image before publishing.

Introduction

It is important that we test the image we’ve created before publishing. Otherwise the image may fail certification checks or simply not function as desired.

Test we can create a VM from the virtual machine image

The first and simplest test is to confirm that we can create a new VM instance based on the work we did in the last lab.

The steps are different depending on which approach you have chosen to follow. Follow the relevant steps and then continue from Finalise the test

Steps for Shared Image Gallery approach

  1. Do not follow these steps if you are using the SAS URI approach

  2. Make sure the VM is deallocated

    az vm deallocate \
       --resource-group 'marketplace-vm-offer' \
       --name 'marketplacevm'
    
  3. Set the status of the VM to “Generalized”

    az vm generalize \
       --resource-group 'marketplace-vm-offer' \
       --name 'marketplacevm'
    
  4. Create an image of the VM

    az image create \
       --resource-group 'marketplace-vm-offer' \
       --source 'marketplacevm' \
       --name 'marketplacevm-image'
    

    Example output

       {
          "extendedLocation": null,
          "hyperVGeneration": "V1",
          "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/marketplace-vm-offer/providers/Microsoft.Compute/images/marketplacevm-image",
          "location": "westeurope",
          "name": "marketplacevm-image1",
          "provisioningState": "Succeeded",
          "resourceGroup": "marketplace-vm-offer",
          "sourceVirtualMachine": {
             "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/marketplace-vm-offer/providers/Microsoft.Compute/virtualMachines/marketplacevm",
             "resourceGroup": "marketplace-vm-offer"
          },
          "storageProfile": {
             "dataDisks": [],
             "osDisk": {
                ...
                ...
                ...
          }
    
  5. Take a note of the “id” from the output. You will use it in the next step.

  6. Now create a new resource group and create a new VM from the image we just created

    az group create --name 'marketplace-vm-offer-test' --location 'westeurope'
    

    Use the “id” as the --image parameter

    az vm create \
       --resource-group 'marketplace-vm-offer-test' \
       --name 'marketplacevm-test-vm' \
       --image '/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/marketplace-vm-offer/providers/Microsoft.Compute/images/marketplacevm-image' \
       --admin-username azureuser \
       --ssh-key-value ~/.ssh/id_rsa.pub
    
    

Skip to finalise the test

Steps for SAS URI approach

  1. Do not follow these steps if you’re using the Shared Image Gallery approach

The following is based on the instructions Test a virtual machine image but with some modifications as I have found the provided script not to work for Linux images.

  1. Sign in to the Azure portal.

  2. On the home page, select Create a resource, search for “Template Deployment”, and select Create.

  3. Choose “Build your own template in the editor”.

    Create VM from ARM Template

  4. Replace the contents of the editor with the JSON from this file and hit Save

  5. You will need to provide parameter values for the following

    Parameter Comment
    User Storage Account Name Name of the storage account where the VHD image is stored
    User Storage Container Name Most likely the default vhds
    Dns Name For Public IP Provide a DNS name for the public IP; must be lowercase
    Admin User Name Set a username the administrator account for the new VM
    Admin Password Set an administrator password for the new VM
    OS Type Leave as Linux
    VM Size Size of the virtual machine instance (defaults to Standard_B1s)
    VM Name Provide a name for the VM resource
    VHD URL URL of the VHD Image we created above. This can be found on the blob details page. Navigate to: storage account -> containers -> vhds -> VHD image blob name

    It is a good idea to create a new resource group for the test VM. However the deployment will fail if the target storage account for the new VHD is not the same account hosting the source VHD image. Either:

    • use the storage account that was created in the previous steps of the lab (resulting in the new VM and its VHD being in different resource groups) or
    • create a resource group and storage account and copy the VHD image to the new storage account before creating the VM in the same resource group

    The first approach is simpler and adequate for the purposes of a test. Once finished testing you can delete the resource group and the new (specialised) VHD from the original storage account. Be careful not to delete the generalised VHD image.

Finalise the test

  1. Confirm that browsing to the IP address of the new VM displays the NGINX welcome page - NOTE you may need to add a rule on the NSG to allow incoming traffic on Port 80.
  2. SSH into the new VM and confirm the presence of a /tmp/users.txt file with a creation time matching the last reboot

Run validations on the virtual machine

  1. Prior to submitting a VM Offer for certification (publishing), you should run a set of validation tests against a specialised VM created from the generalised VM image. This can identity early issues that would otherwise result in a certification failure.

    We can use the VM we created in the previous step.

  2. There are two ways to do this:

    1. Use the Certification Test Tool for Azure Certified

      This is a Windows application that walks through the process of connecting to the VM, running a series of tests and producing a report. You can create a small Windows VM in Azure and install it on that to test. We will use this approach for the lab.

    2. Use the Self-Test API

      This is an API hosted in Azure. You send a POST request to the API with details of the machine to test and it returns a test report. You need to create an AAD app registration to authenticate with the API. You can find more details here. There is an excellent walkthrough video here which also bridges some of the gaps in the documentation.

  3. Install the Certification Test Tool for Azure Certified on a Windows Machine. Download Link

  4. Run the Certification Test Tool and enter the required information (test name, platform, auth type, DNS name for the VM to be tested etc)

  5. On completion you will be presented with a set of test results. Review the results and ensure you take any necessary action before submitting a final image for certification.

    The VM test tool results

  6. In these labs we will be submitting a VM offer to the marketplace but only to the preview stage for testing purposes. We will not submit for final certification.

    While attention should be paid to the results of the report, it is not necessarily required to fix every issue for the purposes of completing the lab.

Resources

  • Test a virtual machine image
  • Create a managed image of a generalized VM in Azure
  • Create an image from a VM

Create VM Image Test VM Image VM Offer with SIG VM Offer with SAS