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

Arsen Vladimirskiy
2 min readSep 9, 2020

--

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

Tip: Play the video full screen.

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

AAD Token Request

curl --location --request POST 'https://login.microsoftonline.com/{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=https://management.core.windows.net'

AAD Token Response

{
"token_type": "Bearer",
"expires_in": "86399",
"ext_expires_in": "86399",
"expires_on": "1599663998",
"not_before": "1599577298",
"resource": "https://management.core.windows.net",
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJS…"
}

Self-Test API

Self-Test VM Request — using SSH Password

curl --location --request POST 'https://isvapp.azurewebsites.net/selftest-vm' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGci...' \
--data-raw '{
"DNSName": "your_running_vm_dns_or_ip_address",
"UserName": "YOUR_VM_USERNAME",
"Password": "SECURE_PASSWORD_FOR_THE_SSH_INTO_VM",
"OS": "Linux",
"PortNo": "22",
"CompanyName": "COMPANY_NAME",
"AppId": "CLIENT_ID_SAME_AS_USED_FOR_AAD_TOKEN ",
"TenantId": "TENANT_ID_SAME_AS_USED_FOR_AAD_TOKEN"
}'

Self-Test VM Request — using SSH Key

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 https://twitter.com/ArsenVlad

--

--

Arsen Vladimirskiy

Principal Engineer / Architect, FastTrack for Azure at Microsoft