Skip to content

Instantly share code, notes, and snippets.

@ivanbuzyka
Last active June 9, 2016 06:51
Show Gist options
  • Save ivanbuzyka/4dcf8d56b86b00d76bf23f183a393457 to your computer and use it in GitHub Desktop.
Save ivanbuzyka/4dcf8d56b86b00d76bf23f183a393457 to your computer and use it in GitHub Desktop.
# Used to copy VM disk image between Azure storage account, can be used as an alternative to AzCopy#
# VHD blob to copy #
$blobName = "3zlubhfb.m2s201603051726390086.vhd"
# Source Storage Account Information #
$sourceStorageAccountName = "wndscstor4"
$sourceKey = "<source-key>"
$sourceContext = New-AzureStorageContext -StorageAccountName $sourceStorageAccountName -StorageAccountKey $sourceKey
$sourceContainer = "vhds"
# Destination Storage Account Information #
$destinationStorageAccountName = "wndscstor5"
$destinationKey = "<dest-key>"
$destinationContext = New-AzureStorageContext -StorageAccountName $destinationStorageAccountName -StorageAccountKey $destinationKey
# Create the destination container #
$destinationContainerName = "vmvhds"
New-AzureStorageContainer -Name $destinationContainerName -Context $destinationContext
# Copy the blob #
$blobCopy = Start-AzureStorageBlobCopy -DestContainer $destinationContainerName -DestContext $destinationContext -SrcBlob $blobName -Context $sourceContext -SrcContainer $sourceContainer
while(($blobCopy | Get-AzureStorageBlobCopyState).Status -eq "Pending")
{
Start-Sleep -s 30
$blobCopy | Get-AzureStorageBlobCopyState
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment