Attach a data disk to a Windows virtual machine created with the classic deployment model
Important
Classic VMs will be retired on March 1, 2023.
If you use IaaS resources from ASM, please complete your migration by March 1, 2023. We encourage you to make the switch sooner to take advantage of the many feature enhancements in Azure Resource Manager.
For more information, see Migrate your IaaS resources to Azure Resource Manager by March 1, 2023.
This article shows you how to attach new and existing disks created with the Classic deployment model to a Windows virtual machine using the Azure portal.
You can also attach a data disk to a Linux VM in the Azure portal.
Before you attach a disk, review these tips:
The size of the virtual machine controls how many data disks you can attach. For details, see Sizes for virtual machines.
To use Premium storage, you need a DS-series or GS-series virtual machine. You can use disks from both Premium and Standard storage accounts with these virtual machines. Premium storage is available in certain regions. For details, see Premium Storage: High-Performance Storage for Azure Virtual Machine Workloads.
For a new disk, you don't need to create it first because Azure creates it when you attach it.
You can also attach a data disk using Powershell.
Important
Azure has two different deployment models for creating and working with resources: Resource Manager and Classic.
Starting November 15, 2017, virtual machines will be available only in the Azure portal.
Find the virtual machine
Sign in to the Azure portal.
Select the virtual machine from the resource listed on the dashboard.
In the left pane under Settings, click Disks.
Continue by following instructions for attaching either a new disk or an existing disk.
Option 1: Attach and initialize a new disk
On the Disks blade, click Attach new.
Review the default settings, update as necessary, and then click OK.
After Azure creates the disk and attaches it to the virtual machine, the new disk is listed in the virtual machine's disk settings under Data Disks.
Initialize a new data disk
Connect to the virtual machine. For instructions, see How to connect and log on to an Azure virtual machine running Windows.
After you log on to the virtual machine, open Server Manager. In the left pane, select File and Storage Services.
Select Disks.
The Disks section lists the disks. Most often, a virtual machine has disk 0, disk 1, and disk 2. Disk 0 is the operating system disk, disk 1 is the temporary disk, and disk 2 is the data disk newly attached to the virtual machine. The data disk lists the Partition as Unknown.
Right-click the disk and select Initialize.
You're notified that all data will be erased when the disk is initialized. Click Yes to acknowledge the warning and initialize the disk. Once complete, the partition will be listed as GPT. Right-click the disk again and select New Volume.
Complete the wizard using the default values. When the wizard is done, the Volumes section lists the new volume. The disk is now online and ready to store data.
Option 2: Attach an existing disk
On the Disks blade, click Attach existing.
Under Attach existing disk, click Location.
Under Storage accounts, select the account and container that holds the .vhd file.
Select the .vhd file.
Under Attach existing disk, the file you just selected is listed under VHD File. Click OK.
After Azure attaches the disk to the virtual machine, it's listed in the virtual machine's disk settings under Data Disks.
Use TRIM with standard storage
If you use standard storage (HDD), you should enable TRIM. TRIM discards unused blocks on the disk so you are only billed for storage that you are actually using. Using TRIM can save costs, including unused blocks that result from deleting large files.
You can run this command to check the TRIM setting. Open a command prompt on your Windows VM and type:
fsutil behavior query DisableDeleteNotify
If the command returns 0, TRIM is enabled correctly. If it returns 1, run the following command to enable TRIM:
fsutil behavior set DisableDeleteNotify 0
Next steps
If your application needs to use the D: drive to store data, you can change the drive letter of the Windows temporary disk.