Windows Azure PowerShell Cmdlets Now Supports Storage!

The Windows Azure Storage team has delivered an outstanding set of PowerShell cmdlets for managing and using storage from PowerShell.

The new abilities include the ability to create and manage containers and blobs which includes the ability to asynchronously copy blobs (across storage accounts and across regions!).

A quick example of how to kick off async blob copies is below. The cmdlets were designed to allow multiple blob copies to start and then to monitor the results at a later time. This allows the end user to take advantage of the async nature of the APIs instead.


Import-Module Azure
Select-AzureSubscription mysubscription

$destContext = New-AzureStorageContext  –StorageAccountName $storageAccount `
                                        -StorageAccountKey $storageKey

New-AzureStorageContainer -Name $containerName

$blob1 = Start-CopyAzureStorageBlob -srcUri $srcUri1 `
                                 -DestContainer $containerName `
                                 -DestBlob $fileName1 `
                                 -DestContext $destContext 

$blob2 = Start-CopyAzureStorageBlob -srcUri $srcUri2 `
                                 -DestContainer $containerName `
                                 -DestBlob $fileName2 `
                                 -DestContext $destContext 

$blob3 = Start-CopyAzureStorageBlob -srcUri $srcUri3 `
                                 -DestContainer $containerName `
                                 -DestBlob $fileName3  `
                                 -DestContext $destContext 

$blob1 | Get-AzureStorageBlobCopyState 
$blob2 | Get-AzureStorageBlobCopyState
$blob3 | Get-AzureStorageBlobCopyState

The output of the Get-AzureStorageBlobCopyState cmdlet is below:

CopyId            : 60a3c559-14f4-4b37-ae2b-80755fc072c4
CompletionTime    : 3/27/2013 10:33:29 PM +00:00
Status            : Success
Source            : https://mwweststorage.blob.core.windows.net/source/testcopy1.vhd
BytesCopied       : 32212255232
TotalBytes        : 32212255232
StatusDescription : 

CopyId            : 0c665b44-aa33-47db-8367-b00aa450ed78
CompletionTime    : 3/27/2013 10:33:30 PM +00:00
Status            : Success
Source            : https://mwweststorage.blob.core.windows.net/source/testcopy2.vhd
BytesCopied       : 32212255232
TotalBytes        : 32212255232
StatusDescription : 

CopyId            : d425fae7-c9ba-4816-a81e-d0ded84baa75
CompletionTime    : 3/27/2013 10:33:31 PM +00:00
Status            : Success
Source            : https://mwweststorage.blob.core.windows.net/source/testcopy3.vhd
BytesCopied       : 32212255232
TotalBytes        : 32212255232
StatusDescription : 

The complete list of storage cmdlets are below:

  • Get-AzureStorageContainerAcl
  • Get-AzureStorageBlob
  • Get-AzureStorageBlobContent
  • Get-AzureStorageBlobCopyState
  • Get-AzureStorageContainer
  • New-AzureStorageContainer
  • New-AzureStorageContext
  • Remove-AzureStorageBlob
  • Remove-AzureStorageContainer
  • Set-AzureStorageBlobContent
  • Set-AzureStorageContainerAcl
  • Start-CopyAzureStorageBlob <- will likely be renamed to Start-AzureStorageBlobCopy
  • Stop-CopyAzureStorageBlob <- will likely be renamed to Stop-AzureStorageBlobCopy

4 thoughts on “Windows Azure PowerShell Cmdlets Now Supports Storage!

  1. Michael,
    It appears that the ability to asynchronously copy blobs is client side – i.e. the blob is downloaded to the client machine and re-uploaded to the destination machine. Is this correct or am I missing something? Does Windows Azure plan on supporting a web service that will do the copy more efficiently between data-centers and subscriptions.
    Also any plans to support copying across subscriptions? We have staging and production deployments in different subscriptions and would like to be able to move (copy) the staging deployment to the production subscription with an x-copy like mechanism.

  2. Turns out, I might have been wrong – http://blogs.msdn.com/b/windowsazurestorage/archive/2012/06/12/introducing-asynchronous-cross-account-copy-blob.aspx
    However we are still having issues getting it to work across accounts through the commandlets. We get the following error message
    “The remote server returned an error: (400) Bad Request. HTTP Status Code: 400 – HTTP Error Message: The copy source account and destination account must be the same.”

    Could you post a sample demonstrating cross account copying using the commandlets. That would help immensely.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s