Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

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

DZone's Guide to

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

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

· Cloud Zone ·
Free Resource

Site24x7 - Full stack It Infrastructure Monitoring from the cloud. Sign up for free trial.

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 “+ 
                “$verboseLog”

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

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


Site24x7 - Full stack It Infrastructure Monitoring from the cloud. Sign up for free trial.

Topics:
azure ,data ,acopy ,powershell ,cloud

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}