Azure has two different deployment models for creating and working with resources: Resource Manager and classic. This article covers using the classic deployment model. Microsoft recommends that most new deployments use the Resource Manager model.
This article shows you how to upload a virtual hard disk (VHD) with an operating system so you can use it as an image to create virtual machines based on that image. For more details about disks and VHDs in Microsoft Azure, see About Disks and VHDs for Virtual Machines.
This article assumes you have:
An Azure subscription - If you don't have one, you can open an Azure account for free: You get credits you can use to try out paid Azure services, and even after they're used up you can keep the account and use free Azure services, such as Websites. Your credit card won't be charged, unless you explicitly change your settings and ask to be charged. You also can activate MSDN subscriber benefits: Your MSDN subscription gives you credits every month that you can use for paid Azure services.
Microsoft Azure PowerShell - You have the Microsoft Azure PowerShell module installed and configured to use your subscription. To download the module, see Microsoft Azure Downloads. A tutorial to install and configure the module is available here. You'll use the Add-AzureVHD cmdlet to upload the VHD.
A supported Windows operating system stored in a .vhd file and attached to a virtual machine - Multiple tools exist to create .vhd files. For example, you can use Hyper-V to create a virtual machine and install the operating system. For instructions, see Install the Hyper-V Role and configure a virtual machine. For details about operating systems, see Microsoft server software support for Microsoft Azure virtual machines.
Before you upload the VHD to Azure, it needs to be generalized by using the Sysprep tool. This prepares the VHD to be used as an image. For details about Sysprep, see How to Use Sysprep: An Introduction.
From the virtual machine that the operating system was installed to, complete the following procedure:
Sign in to the operating system.
Open a command prompt window as an administrator. Change the directory to %windir%\system32\sysprep, and then run
The System Preparation Tool dialog box appears.
In the System Preparation Tool, select Enter System Out of Box Experience (OOBE) and make sure that Generalize is checked.
In Shutdown Options, select Shutdown.
You need a storage account in Azure so you have a place to upload the .vhd file. This step shows you how to create an account, or get the info you need from an existing account.
Sign in to the Azure portal.
On the command bar, click New.
Click Data Services > Storage > Quick Create.
Fill out the fields as follows:
Click Create Storage Account. The account now appears under Storage.
Next, create a container for your uploaded VHDs. Click the storage account name and then click Containers.
Click Create a Container.
Type a Name for your container and select the Access policy.
By default, the container is private and can be accessed only by the account owner. To allow public read access to the blobs in the container, but not the container properties and metadata, use the Public Blob option. To allow full public read access for the container and blobs, use the Public Container option.
Sign in to the Azure portal.
From the navigation pane, click Storage.
Click the name of the storage account, and then click Dashboard.
From the dashboard, under Services, hover over the Blobs URL, click the clipboard icon to copy the URL, then paste and save it. You'll use it when you build the command to upload the VHD.
Before you can upload a .vhd file, you need to establish a secure connection between your computer and your subscription in Azure. You can use the Microsoft Azure Active Directory method or the certificate method to do this.
To get started with Azure PowerShell, see How to install and configure Microsoft Azure PowerShell. For general information, see Get Started with Microsoft Azure Cmdlets.
Open the Azure PowerShell console.
In the sign-in windows, type the user name and password of your work or school account.
Azure authenticates and saves the credential information, and then closes the window.
Open the Azure PowerShell console.
A browser window opens and prompts you to download a .publishsettings file. It contains information and a certificate for your Microsoft Azure subscription.
Save the .publishsettings file.
<PathToFile> is the full path to the .publishsettings file.
When you upload the .vhd file, you can place the .vhd file anywhere within your blob storage.
From the Azure PowerShell window you used in the previous step, type a command similar to this:
Add-AzureVhd -Destination "<BlobStorageURL>/<YourImagesFolder>/<VHDName>.vhd" -LocalFilePath <PathToVHDFile>
For more information about the Add-AzureVhd cmdlet, see Add-AzureVhd.
To use Azure PowerShell instead of the Azure portal to add the image, use the Add-AzureVMImage cmdlet. For example:
Add-AzureVMImage -ImageName <ImageName> -MediaLocation <VHDLocation> -OS <OSType>
From the Azure portal, under All Items, click Virtual Machines.
Under Virtual Machines, click Images.
Click Create an Image.
In the Create an image from a VHD window:
In the Create an image from a VHD window, under Operating System Family, select your operating system. Check I have run Sysprep on the virtual machine associated with this VHD to verify that you generalized the operating system, and then click OK.
After you complete the previous steps, the new image is listed when you choose the Images tab.
This new image is now available under My Images when you create a virtual machine. For instructions, see How to create a custom virtual machine running Windows.
If you get an error when you try to create a VM, with this error message, "The VHD https://XXXXX... has an unsupported virtual size of YYYY bytes. The size must be a whole number (in MBs)," it means your VHD is not a whole number of MBs and needs to be a fixed size VHD. Try using the Add-AzureVMImage PowerShell cmdlet instead of the Azure portal to add the image (see step 5, above). The Azure cmdlets ensure that the VHD meets the Azure requirements.
After creating a virtual machine, try to create a SQL Server virtual machine. For instructions, see Provisioning a SQL Server virtual machine on Microsoft Azure.