Search code examples
azureazure-resource-managerazure-marketplace

How to reference a virtual machine image for a marketplace offer


I have created a vm image from a customized virtual machine running in azure environment. Now I want to use that image as the base operating system for my solution in azure market place. How can I reference this image in the mainTemplate for the market place. When i check the image resource, I dont see any source blob uri. There is a resource ID, but I dont think it will be accessible outside my subscription.

Thanks

I have gone through the documentation. There was mentioned that the image should be on the blob storage. But I cannot figure out how to move the image from my resource group to storage.


Solution

  • You first need to publish the image in the Azure Marketplace:

    https://learn.microsoft.com/en-us/azure/marketplace/cloud-partner-portal/virtual-machine/cpp-create-offer

    Once you do that you can reference the image in the template via the PublisherID, OfferId, SKU and Version

    For marketplace images you need to set the values on the plan object and the imageReference object and just for fun we've made the property names different in each.

    See: https://github.com/Azure/azure-quickstart-templates/blob/master/1-CONTRIBUTION-GUIDE/best-practices.md#vm-image-references--disks

    EDIT:

    Ok to use the base image cross tenant in the marketplace you need to publish a VM image - you will, through the process need to turn your disk into a blob (if using a managed disk for your base image) and that blob would be provided to the marketplace:

    https://learn.microsoft.com/en-us/azure/marketplace/cloud-partner-portal/virtual-machine/cpp-virtual-machine-offer

    When you create that VM offer, you can set it as public, private or hidden. The difference between private and hidden (public should be obvious ;)) is that private will make the image available only to subscriptions you whitelist. Hidden means that the image will not show up when users browse or search vm images but they can be used in an Azure Application offer (i.e. template) in the marketplace. To reference it there you'll need to add a plan object to your VM resource, this sample:

    https://github.com/Azure/azure-quickstart-templates/blob/master/201-vmss-datascience/azuredeploy-ubuntu.json#L41-L51

    Will give you an idea of how to do it.

    Final note on "hidden" - while a user can't go to the portal, browse/search, find your vm image, it is available to api callers - so still possible to deploy outside of your template for folks that want to find it (and that's intentional). If you really need more "security" than that you'd have to make it a private offer.

    That help?