How to Direct-Upload to Azure Managed Disks

Oct 08, 2019 · 3 mins read · Post a comment
How to Direct-Upload to Azure Managed Disks

A few days ago, Microsoft announced the preview of direct-upload to Azure Managed Disks. So, there are two ways you could move a VHD to the Azure cloud as a managed disk:

  1. Upload the VHD in a storage account, and then convert it into a managed disk.
  2. Create and attach empty managed disk to a VM, and then do the copy.

As stated by Raman Kumar, a Principal Project Manager at Azure, these two ways have disadvantages. The first scenario requires extra storage account management, while the second scenario has extra cost because of a running virtual machine. Direct-upload allows copying an on-premise VHD directly to the Azure cloud as a managed disk, which reduces the cost and the management issues mentioned earlier.
Currently, you can direct-upload to standard HDD, standard SSD, and premium SSD managed disks of all supported sizes.

Direct-Upload can be approached using Azure Storage Explorer via GUI, which is basically a standalone app, or if you are more of a developer, or DevOps guy, you could use a Rest API or Azure CLI with AzCopy command-line utility. I have already covered AWS to Azure migration topic on this post. Today, we are going to use Azure CLI in combination with AzCopy.

Check the official blog Introducing the preview of direct-upload to Azure managed disks.


  • Azure account
  • Azure Storage account

Create an Azure Managed Disk

Step 1. Open Terminal and login to the Azure Portal:

az login

It will open a new window using the default browser where you will be prompted for email and password.

Step 2. Create a resource group:

az group create --name "managed-disks-rg" --location westeurope

Step 3. Create a empty managed disk:

az disk create --name "myfirstmanageddisk" --resource-group "managed-disks-rg" --location westeurope --for-upload --upload-size-bytes 34359738880 --sku "standard_lrs"


  • --name: name of the managed disk.
  • --resource-group: name of the managed disk’s resource group.
  • --location: location of the managed disk.
  • --for-upload: creates a disk for uploading purposes.
  • --upload-size-bytes: the file size (in bytes) of the VHD you want to upload.
  • --sku: storage SKU.

Step 4. Next, create a writable shared access signature (SAS) of your empty managed disk:

az disk grant-access --name "myfirstmanageddisk" --resource-group "managed-disks-rg" --access-level Write --duration-in-seconds 86400

The parameters are self-explanatory. Output will be in json format. For example:

"accessSas": ""

Step 5. Now that you have writable SAS, you can upload a VHD using AzCopy tool:

azcopy copy "VHDs/managedDisk1.vhd" "<insert_the_sas_token_output_here>" --blob-type PageBlob

Step 6. Once the upload completed, you can revoke the SAS, so it allows you to attach a managed disk to a VM:

az disk revoke-access --name "myfirstmanageddisk" --resource-group "managed-disks-rg"

Now, you can attach the managed disk to a virtual machine.

Cleaning up

Step 7. Delete the managed disk:

az disk delete --name "myfirstmanageddisk" --resource-group "managed-disks-rg"

Step 8. Delete the resource group:

az group delete --name "managed-disks-rg"


If you are working with IaaS Virtual Machines, using Direct-Upload is a recommended way to do it, because it will save you a lot of time in a backup and restore, disaster and recovery scenarios.