Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A script to copy Blobs between Azure Storage Accounts
$ErrorActionPreference = 'stop';
# Setup source storage account and container
$SourceStorageAccount = Get-AzureRmStorageAccount -ResourceGroupName $SourceStorageAccountResourcegroupName -Name $SourceStorageAccountName;
$SourceStorageAccountContainer = Get-AzureStorageContainer -Name $SourceStorageAccountContainerName -Context $SourceStorageAccount.Context;
# Setup destination context and container
$DestContext = New-AzureStorageContext -StorageAccountName $DestStorageAccountContainerName -StorageAccountKey $DestStorageAccountKey;
$DestStorageAccountContainer = Get-AzureStorageContainer -Name $DestStorageAccountContainerName -Context $DestContext;
# Get a list of blobs to copy
Get-AzureStorageBlob -Container $SourceStorageAccountContainer.Name -Context $SourceStorageAccount.Context |
ForEach-Object {
# copy each blob
$DestBlob = $_.Name;
$SrcURI = $_.ICloudBlob.StorageUri.PrimaryUri.AbsoluteUri;
Start-AzureStorageBlobCopy -Context $SourceStorageAccount.Context -SrcUri $SrcURI -DestContext $DestContext -DestContainer $DestStorageAccountContainerName -DestBlob $DestBlob -Force;
throw $_;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.