Skip to content

Instantly share code, notes, and snippets.

@stlk
Created August 17, 2014 19:46
Show Gist options
  • Save stlk/24827871eb13d5778fee to your computer and use it in GitHub Desktop.
Save stlk/24827871eb13d5778fee to your computer and use it in GitHub Desktop.
copy file from one azure container to another
$srcUri = "http://something.blob.core.windows.net/vhds/something.vhd"
### Source Storage Account ###
$srcStorageAccount = "NAME"
$srcStorageKey = "KEY"
### Target Storage Account ###
$destStorageAccount = "NAME"
$destStorageKey = "KEY"
### Target Container Name
$containerName = "vhds"
### Create the source storage account context ###
$srcContext = New-AzureStorageContext –StorageAccountName $srcStorageAccount `
-StorageAccountKey $srcStorageKey
### Create the destination storage account context ###
$destContext = New-AzureStorageContext –StorageAccountName $destStorageAccount `
-StorageAccountKey $destStorageKey
### Create the container on the destination ###
New-AzureStorageContainer -Name $containerName -Context $destContext
### Start the asynchronous copy - specify the source authentication with -SrcContext ###
$blob1 = Start-AzureStorageBlobCopy -srcUri $srcUri `
-SrcContext $srcContext `
-DestContainer $containerName `
-DestBlob "something.vhd" `
-DestContext $destContext
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment