How to Direct-Upload to Azure Managed Disks

Oct 08, 2019 · 2 mins read · Post a comment

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.

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 from the 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.


  • Azure subscription
  • Azure Storage account
  • AzCopy

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 an empty managed disk.

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

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 instance:

"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.

Clean up

Step 7. 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. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.