Over a million developers have joined DZone.

Moving Data In, Out, and Between Azure Storage Accounts Using AzCopy

A useful way to move your data around the Azure cloud.

· Cloud Zone

Build fast, scale big with MongoDB Atlas, a hosted service for the leading NoSQL database on AWS. Try it now! Brought to you in partnership with MongoDB.

The little script I demoed at IT Camp @Houston. Just:

  1. Install AzCopy.
  2. Copy the script as it is.
  3. Validate the source path, destination path, and associated Azure storage account access keys.
  4. Run it.

Here is the entire PowerShell script. The source and the destination storage accounts can be different subscriptions. Namely it can do cross-subscription copying.

$theSource      = @{path=’?’; accessKey=’?’; recursion=”; pattern=”}
$theDestination = @{path=’?’; accessKey=’?’}

<# Validate the data

$theSource.path      = ‘/Source:https://nothere.blob.core.windows.net/abcdefg’ 
$theSource.AccessKey = ‘/SourceKey:mySourceStorageAccessKey’                   

$theDestination.path      = ‘/Dest:https://mydest.blob.core.windows.net/ContainerTOBeCreated’
$theDestination.AccessKey = ‘/DestKey:myDESTStorageAccessKey’


$theSource.pattern         = ” 
$theSource.recursion       = ‘/S’
$supressConfirmationPrompt = ‘/Y’
$listingOnlyOption         = ”   # or /L

$verbose        = ‘on’
$verboseLogFile = “$env:USERPROFILE\documents\”+(get-date -format ‘mmss’)+’.azcopy.verbose.txt’
$verboseLog     =”/V:$verboseLogFile”

$responsefile = “$($theSource.path) “+
                “$($theDestination.path) “+ 
                “$($theSource.AccessKey) “+
                “$($theDestination.AccessKey) “+
                “$($theSource.pattern) $($theSource.recursion) $supressConfirmationPrompt “+
#                “$snapshot “+
                “$listingOnlyOption “+ 

start-process `
    -FilePath         ‘C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy\AzCopy.exe’ `
    -WorkingDirectory ‘C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy’ `
    -ArgumentList     “$responsefile” `

if ($verbose -eq ‘on’) { notepad $verboseLogfile }

Now it's easier than ever to get started with MongoDB, the database that allows startups and enterprises alike to rapidly build planet-scale apps. Introducing MongoDB Atlas, the official hosted service for the database on AWS. Try it now! Brought to you in partnership with MongoDB.

azure ,data ,acopy ,powershell ,cloud

Published at DZone with permission of Yung Chou, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}