Create your Azure Virtual Machine technical assets
This article describes how to create and configure technical assets for a virtual machine (VM) offer for Azure Marketplace. A VM contains two components: the operating system virtual hard disk (VHD) and optional associated data disks VHDs:
- Operating system VHD – Contains the operating system and solution that deploys with your offer. The process of preparing the VHD differs depending on whether it is a Linux-based, Windows-based, or custom-based VM.
- Data disks VHDs - Dedicated, persistent storage for a VM. Don't use the operating system VHD (for example, the C: drive) to store persistent information.
A VM image contains one operating system disk and up to 16 data disks. Use one VHD per data disk, even if the disk is blank.
Regardless of which operating system you use, add only the minimum number of data disks needed by the solution. Customers cannot remove disks that are part of an image at the time of deployment, but they can always add disks during or after deployment.
Every VM Image in a plan must have the same number of data disks.
Fundamental technical knowledge
Designing, building, and testing these assets takes time and requires technical knowledge of both the Azure platform and the technologies used to build the offer. In addition to your solution domain, your engineering team should have knowledge of the following Microsoft technologies:
- Basic understanding of Azure Services
- How to design and architect Azure applications
- Working knowledge of Azure Virtual Machines, Azure Storage and Azure Networking
- Working knowledge of Azure Resource Manager
- Working Knowledge of JSON
Suggested tools – optional
Consider using one of the following scripting environments to help manage VMs and VHDs:
Additionally, consider adding the following tools to your development environment:
- Azure Storage Explorer
- Visual Studio Code
Create a VM image using an approved base
To create your virtual machine technical assets using an image you built on your own premises, go to Create a VM using your own image.
This section describes various aspects of using an approved base, such as using the Remote Desktop Protocol (RDP), selecting a size for the VM, installing the latest Windows updates, and generalizing the VHD image.
The following sections focus mainly on windows-based VHDs. For more information about creating Linux-based VHDs, see Linux on distributions endorsed by Azure.
Follow the guidance in this topic to use Azure to create a VM containing a pre-configured, endorsed operating system. If this isn't compatible with your solution, it's possible to create and configure an on-premises VM using an approved operating system. You can then configure and prepare it for upload as described in Prepare a Windows VHD or VHDX to upload to Azure.
Select an approved base
Select either the Windows operation system or Linux as your base.
The operating system VHD for your Windows-based VM image must be based on an Azure-approved base image that contains Windows Server or SQL Server. To begin, create a VM from one of the following images from the Azure portal:
- Windows Server (2016, 2012 R2 Datacenter, 2012 Datacenter, 2008 R2 SP1)
- SQL Server 2014 (Enterprise, Standard, Web)
- SQL Server 2012 SP2 (Enterprise, Standard, Web)
If you're using the current Azure portal or Azure PowerShell, then Windows Server images published on September 8, 2014 and later are approved.
Azure offers a range of approved Linux distributions. For a current list, see Linux on distributions endorsed by Azure.
Create VM in the Azure portal
Follow these steps to create the base VM image in the Azure portal:
Sign in to the Azure portal with the Microsoft account associated with the Azure subscription you want to use to publish your VM offer.
Create a new resource group and provide your Resource group name, Subscription, and Resource group location. For details, see Manage resources.
Select Virtual machines on the left to display the Virtual machines details page.
Select + Add to open the Create a virtual machine experience.
Select the image from the drop-down list or click Browse all public and private images to search or browse all available virtual machine images.
Select the size of the VM to deploy using the following recommendations:
- If you plan to develop the VHD on-premises, the size doesn't matter. Consider using one of the smaller VMs.
- If you plan to develop the image in Azure, consider using one of the recommended VM sizes for the selected image.
In the Disks section, expand the Advanced section and set the Use managed disks option to No.
Provide the other required details to create the VM.
Select Review + create to review your choices. When you see the Validation passed message, select Create.
Azure begins provisioning the virtual machine you specified. You can track its progress by selecting the Virtual Machines tab on the left. After it's created, the status will change to Running.
If you encounter difficulty creating your new Azure-based VHD, see Common issues during VHD creation (FAQs).
Connect to your Azure VM
This section explains how to connect to and sign into the VM you created on Azure. After you've successfully connected, you can work with the VM as if you were locally logged in to its host server.
Connect to a Windows-based VM
Use the remote desktop client to connect to the Windows-based VM hosted on Azure. Most versions of Windows natively contain support for the remote desktop protocol (RDP). For other operating systems, you can find more information about clients in Remote Desktop clients.
This article details how to use the built-in Windows RDP support to connect to your VM: How to connect and log on to an Azure virtual machine running Windows.
You may get security warnings during the process. For example, warnings such as "The .rdp file is from an unknown publisher" or "Your user credentials cannot be verified." It is safe to ignore these warnings.
Connect to a Linux-based VM
To connect to a Linux-based VM, you need a secure shell protocol (SSH) client. The following steps use the free PuTTY SHH terminal.
Go to the Azure portal.
Search for and select Virtual machines.
Select the VM you want to connect to.
Start the VM if it isn't already running.
Select the name of the VM to open its Overview page.
Note the Public IP address and DNS name of your VM (if these values are not set, you must Create a network interface).
Open the PuTTY application.
In the PuTTY Configuration dialog, enter the IP address or DNS name of your VM.
Select Open to open a PuTTY terminal.
When prompted, enter the account name and password of your Linux VM account.
If you have connection problems, refer to the documentation for your SSH client. For example, Chapter 10: Common error messages.
For details, including how to add a desktop to a provisioned Linux VM, see Install and configure Remote Desktop to connect to a Linux VM in Azure.
Create a VM using your own image
This section describes how to create and deploy a user-provided virtual machine (VM) image. You can do this by providing operating system and data disk VHD images from an Azure-deployed virtual hard disk (VHD).
To optionally use an approved base image, follow the instructions in Create a VM image using an approved base.
- Upload your images to Azure Storage account.
- Deploy the VM image.
- Capture the VM image.
Upload your images to an Azure storage account
- Log on to the Azure portal.
- Upload your generalized operating system VHD and data disk VHDs to your Azure storage account.
Deploy your image
Create your image using either the Azure portal or Azure PowerShell.
Deploy using the Azure portal
On the home page, select Create a resource, search for "Template Deployment", and select Create.
Choose Build your own template in the editor.
Paste this JSON template into the editor and select Save.
Provide the parameter values for the displayed Custom deployment property pages.
Parameter Description User Storage Account Name Content from cell 2 User Storage Container Name Storage account name where the generalized VHD is located DNS Name for Public IP Public IP DNS name. Define the DNS name for the public IP address in the Azure portal after the offer is deployed. Admin User Name Administrator account's username for new VM Admin Password Administrator account's password for new VM OS Type VM operating system: Windows or Linux Subscription ID Identifier of the selected subscription Location Geographic location of the deployment VM Size Azure VM size, for example Standard_A2 Public IP Address Name Name of your public IP address VM Name Name of the new VM Virtual Network Name Name of the virtual network used by the VM NIC Name Name of the network interface card running the virtual network VHD URL Complete OS Disk VHD URL
After you supply these values, select Purchase.
Azure will begin deployment. It creates a new VM with the specified unmanaged VHD in the specified storage account path. You can track the progress in the Azure portal by selecting Virtual Machines on the left side of the portal. When the VM is created, the status will change from Starting to Running.
Deploy using Azure PowerShell
$img = Get-AzureVMImage -ImageName "myVMImage" $user = "user123" $pass = "adminPassword123" $myVM = New-AzureVMConfig -Name "VMImageVM" -InstanceSize "Large" -ImageName $img.ImageName | Add-AzureProvisioningConfig -Windows -AdminUsername $user -Password $pass New-AzureVM -ServiceName "VMImageCloudService" -VMs $myVM -Location "West US" -WaitForBoot
Capture the VM image
Use the following instructions that correspond to your approach:
- Azure PowerShell: How to create an unmanaged VM image from an Azure VM
- Azure CLI: How to create an image of a virtual machine or VHD
- API: Virtual Machines - Capture
Configure the virtual machine
This section describes how to size, update, and generalize an Azure VM. These steps are necessary to prepare your VM to be deployed on Azure Marketplace.
Sizing the VHDs
If you selected one of the VMs pre-configured with an operating system (and optionally additional services), you have already picked a standard Azure VM size. Starting your solution with a pre-configured OS is the recommended approach. However, if you are installing an OS manually, you must size your primary VHD in your VM image:
- For Windows, the operating system VHD should be created as a 127–128 GB fixed-format VHD.
- For Linux, this VHD should be created as a 30–50 GB fixed-format VHD.
If the physical size is less than 127–128 GB, the VHD should be Expandable (sparse/dynamic). The base Windows and SQL Server images that are provided already meet these requirements, so don't change the format or the size of the VHD.
Data disks can be as large as 1 TB. When deciding on size, remember that customers cannot resize VHDs within an image at the time of deployment. Data disk VHDs should be created as fixed-format VHDs. They should also be Expandable (sparse/dynamic). Data disks can initially be empty or contain data.
Install the most current updates
The base images of operating system VMs must contain the latest updates up to their published date. Before publishing the operating system VHD you created, ensure you update the OS and all installed services with all the latest security and maintenance patches.
For Windows Server, run the Check for Updates command.
For Linux distributions, updates are commonly downloaded and installed through a command-line tool or a graphical utility. For example, Ubuntu Linux provides the apt-get command and the Update Manager tool for updating the OS.
Perform additional security checks
Maintain a high level of security for your solution images in the Azure Marketplace. The following article provides a checklist of security configurations and procedures to assist you: Security Recommendations for Azure Marketplace Images. Some of these recommendations are specific to Linux-based images, but most apply to any VM image.
Perform custom configuration and scheduled tasks
If additional configuration is needed, use a scheduled task that runs at startup to make any final changes to the VM after it has been deployed. Also consider the following recommendations:
- If it is a run-once task, the task should delete itself after it successfully completes.
- Configurations should not rely on drives other than C or D, because only these two drives are always guaranteed to exist (drive C is the operating system disk and drive D is the temporary local disk).
For more information about Linux customizations, see Virtual machine extensions and features for Linux.
Generalize the image
All images in the Azure Marketplace must be reusable in a generic fashion. To achieve this, the operating system VHD must be generalized, an operation that removes all instance-specific identifiers and software drivers from a VM.
Windows OS disks are generalized with the sysprep tool. If you subsequently update or reconfigure the OS, you must rerun sysprep.
Because updates may run automatically, after you run sysprep, turn off the VM until its deployed. This shutdown will avoid subsequent updates from making instance-specific changes to the operating system or installed services. For more information about running sysprep, see Steps to generalize a VHD.
The following process generalizes a Linux VM and redeploys it as a separate VM. For details, see How to create an image of a virtual machine or VHD. You can stop when you reach the section "Create a VM from the captured image".
Remove the Azure Linux agent
- Connect to your Linux VM using an SSH client.
- In the SSH window, enter the following command:
sudo waagent -deprovision+user.
- Type Y to continue (you can add the -force parameter to the previous command to avoid the confirmation step). d. After the command completes, type Exit to close the SSH client.
Stop virtual machine
- In the Azure portal, select your resource group (RG) and de-allocate the VM.
- Your VHD is now generalized and you can create a new VM using this VHD.
If you encountered difficulty creating your new Azure-based VHD, see Common issues during VHD creation.
- Certify your VM image explains how to test and submit a VM image for Azure Marketplace certification, including where to get the Certification Test Tool for Azure Certified tool and how to use it to certify your VM image.