Copy large files to an Azure VM – Engineerer
299
post-template-default,single,single-post,postid-299,single-format-standard,wp-custom-logo,bridge-core-3.1.2,qode-page-transition-enabled,ajax_fade,page_not_loaded,,footer_responsive_adv,hide_top_bar_on_mobile_header,qode-content-sidebar-responsive,qode-theme-ver-30.1,qode-theme-bridge,qode_header_in_grid,elementor-default,elementor-template-full-width,elementor-kit-641,elementor-page-1064
Shipping Containers

Copy large files to an Azure VM

Googling around led me to the simplest of all solutions: Create an Azure File Share and use it as a middle man/woman.

Here you find an Overview of Azure Storage Solutions.

Using an Azure File Share (3min of effort)

  1. Create a new storage account
  2. Create a File Share in the storage account
  3. Navigate to the File Share
  4. Click “Connect” and paste the commands to the PowerShell consoles on your client and on your Azure VM. Commands for Linux and MacOS are available as well.
  5. Transfer files to and from the File Share
The script is displayed to the right after clicking “Connect”.

Speed from my client to the Azure File Share: 8MB/s.

Speed from Azure File Share to the Azure VM: 90MB/s.

My speed test results from https://www.speedtest.net

Automated through the Azure CLI

The script works fine. Still, if you want an easy way to download the files on the target VM, navigate through the Azure Portal to the File Share and copy the script shown after clicking “Connect”.

$subscriptionId = "YOUR_SUBSCRIPTION_ID"
$location = "switzerlandnorth"
$resourceGroupName = "rg-fileshare-temp"
$ownerMail = "kai@engineerer.ch"
$storageAccountName = "filesharetemp"
$fileShareName = "transfer"

# Create the file share
az login
az account set --subscription $subscriptionId
az group create --location $location --name $resourceGroupName --tags "owner=$ownerMail"
az storage account create --name $storageAccountName `
    --resource-group $resourceGroupName `
    --sku "Standard_LRS" `
    --location $location `
    --quota 20
    
az storage share create --account-name $storageAccountName --name $fileShareName

az storage file upload `
	--account-name $storageAccountName `
	--share-name $fileShareName `
	--source $fileToUploadAbsolutePath

# You can create a SAS token from here to access the file programatically
az storage file generate-sas `
    -p fileToUploadAbsolutePath `
    -s $fileShareName `
    --account-name $storageAccountName `
    --permissions rcdw `
    --https-only

# If you have the AZ CLI on the target VM installed as well, you can download files with it
az login 
az account set --subscription "YOUR_SUBSCRIPTION_ID" 

az storage file download `
	--account-name $storageAccountName `
	--share-name $fileShareName `
	--path $fileName

Conclusion

Sure, sharing from my OneDrive could have been an option too. Only if our admin didn’t disable anonymous sharing links. And logging in was kind of a pain in the ass because of the locked-down Internet Explorer on the VM.

This method is the one to go for me. Maybe something similar is achievable through AzCopy (a hint from the MS Docs) as well. If you know how to copy files INSIDE a Managed Disk I’d be glad to hear about it.