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

MongoDB Atlas is a database as a service that makes it easy to deploy, manage, and scale MongoDB. So you can focus on innovation, not operations. 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 “+ 
                “$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 }


MongoDB Atlas is the best way to run MongoDB on AWS — highly secure by default, highly available, and fully elastic. Get started free. Brought to you in partnership with MongoDB.

Topics:
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 DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

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

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}