Using Self-Test API to validate VM images for publishing in Azure Marketplace

In this brief video, we look at how to use Self-Test API to validate VM images for publishing in Azure Marketplace.

Azure virtual machine image validation” document describes two approaches for running the validation or so-called “certification” tests:

  • Windows-only GUI certification tool that can be used to validate both Linux and Windows VM images
  • Self-Test REST API that can be invoked from either Linux or Windows without using the GUI tool

This walkthrough demonstrates both options, but focuses more on the Self-Test API approach (while, as of September 2020, the official doc for Self-Test API is undergoing updates).

Video Walkthrough

If you want to learn more about how to certify your Virtual Machine and Azure Application offers, you may want to take a look at the video recording of the Developing for Commercial Marketplace Office Hours from September 3, 2020.

Azure Active Directory Token

curl --location --request POST '{TENANT_ID}/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id={CLIENT_ID} ' \
--data-urlencode 'client_secret={CLIENT_SECRET}' \
--data-urlencode 'resource='

AAD Token Response

"token_type": "Bearer",
"expires_in": "86399",
"ext_expires_in": "86399",
"expires_on": "1599663998",
"not_before": "1599577298",
"resource": "",
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJS…"

Self-Test API

curl --location --request POST '' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGci...' \
--data-raw '{
"DNSName": "your_running_vm_dns_or_ip_address",
"OS": "Linux",
"PortNo": "22",
"CompanyName": "COMPANY_NAME",

Self-Test VM Request — using SSH Key

Image for post
Image for post

Self-Test VM Response

{"TrackingId": "9bffc887-dd1d-40dd-a8a2-34cee4f4c4c3",
"Response": "{\"SchemaVersion\":1,\"AppCertificationCategory\":\"Microsoft Single VM Certification\",\"ProviderID\":\"050DE427-2A99-46D4-817C-5354D3BF2AE8\",\"OSName\":\"Ubuntu 18.04\",\"OSDistro\":\"Ubuntu 18.04.5 LTS\",\"KernelVersion\":\"5.4.0-1023-azure\",\"KernelFullVersion\":\"Linux version 5.4.0-1023-azure (buildd@lgw01-amd64-053) (gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)) #23~18.04.1-Ubuntu SMP Thu Aug 20 14:46:48 UTC 2020\\n\",\"OSVersion\":\"18.04\",\"CreatedDate\":\"09/08/2020 01:13:47\",\"TestResult\":\"Pass\",\"APIVersion\":\"1.5\",\"Tests\":[{\"TestID\":\"48\",\"TestCaseName\":\"Bash History\",\"Description\":\"Bash history files should be cleared before creating the VM image.\",\"Result\":\"Passed\",\"ActualValue\":\"No file Exist\",\"RequiredValue\":\"1024\"},...removed for brevity...}]}"}

JSON-formatted Self-Test VM Response

My other posts and videos about Azure VM offers

Thank you!

Please leave feedback and questions below or on Twitter

Principal Engineer / Architect, FastTrack for Azure at Microsoft

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store